fabric password

前端 未结 7 1093
刺人心
刺人心 2020-11-29 23:42

Every time fabric runs, it asks for root password, can it be sent along same for automated proposes.

fab staging test
7条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 00:22

    It is possible to store the password securely in the operating system keyring service with the keyring module, the password can then be automatically retrieved and used in fabfile.py.

    You first need to store the password in the keyring, for example using the Python shell:

    >>> import keyring
    >>> keyring.set_password('some-host', 'some-user', 'passwd')
    

    Then you can use it in fabfile.py, for example with Fabric 2:

    from fabric import task
    import keyring
    
    @task
    def restart_apache(connection):
        connection.config.sudo.password = keyring.get_password(connection.host, 'some-user')
        connection.sudo('service apache2 restart')
    

提交回复
热议问题