Ejemplo n.º 1
0
)

# Create a virtualenv
server.shell(
    'virtualenv {{ host.data.env_dir }}',
    sudo=True,
    sudo_user='******',
)
# and manage pip within it
pip.packages(
    ['ElasticQuery', 'JsonTest'],
    virtualenv=host.data.env_dir,
    sudo=True,
    sudo_user='******',
)

# Wait for services
server.wait(
    port=22,
    timeout=5,
)


# Execute Python locally, mid-deploy
def some_python(state, host, *args, **kwargs):
    print('connecting host name: {0}, actual: {1}'.format(host.name, host.fact.hostname))
    local.shell('echo "local stuff!"')


python.call(some_python, 'arg1', 'arg2', kwarg='hello world')
Ejemplo n.º 2
0
        '/web/index.htm',
        '/web/index.html',
    )

    # Note: Allowing sudo to python is not a very secure.
    files.line(
        {'Ensure myweb can run /usr/bin/python3 without password'},
        '/etc/sudoers',
        r'myweb .*',
        replace='myweb ALL=(ALL) NOPASSWD: /usr/bin/python3',
    )

    server.shell(
        {'Check that sudoers file is ok'},
        'visudo -c',
    )

    init.systemd(
        {'Restart and enable myweb'},
        'myweb',
        running=True,
        restarted=True,
        enabled=True,
        daemon_reload=True,
    )

    server.wait(
        {'Wait until myweb starts'},
        port=80,
    )