示例#1
0
def upload_minion_config(master, roles=()):
    "Uploads the minion config to the remote server and restarts the salt-minion."
    runner.state('Upload minion configuration')
    config_template_upload('minion', '/etc/salt/minion', context=salt_config_context(roles, master=master))
    runner.state("Reboot minion")
    service('salt-minion', 'stop; true')
    runner.silent('pkill salt-minion', use_sudo=True)
    time.sleep(1)
    service('salt-minion', 'start')
示例#2
0
def upload_master_config():
    "Uploads master config to the remote server and restarts the salt-master."
    runner.state('Upload master configuration')
    config_template_upload('master', '/etc/salt/master', context=salt_config_context())
    runner.state("Reboot master")
    service('salt-master', 'stop')
    runner.silent('pkill salt-master', use_sudo=True) # to ensure it gets killed
    time.sleep(1)
    service('salt-master', 'start')
示例#3
0
def convert_to_bleeding():
    "Converts the master installation to bleeding edge."
    runner.action('Convert Salt to bleeding edge')
    if runner.silent('test -d /opt/saltstack', use_sudo=True):
        runner.state('Already installed.')
        return
    with runner.with_prefix(' ~> '):
        pkgmgr = find_pkgmgr()
        pkgmgr.install('python')
        pkgmgr.install('python-dev')
        pkgmgr.install('python-pip')
        sudo('yes | pip install pyzmq PyYAML pycrypto msgpack-python jinja2 psutil')
        pkgmgr.install('salt-common')
        runner.silent('pkill salt-master', use_sudo=True)
        runner.silent('pkill salt-minion', use_sudo=True)
        time.sleep(1)
        pkgmgr.remove('salt-master')
        pkgmgr.remove('salt-minion')
        pkgmgr.install('git-core')
        runner.silent('rm -rf /opt/saltstack', use_sudo=True)
        runner.silent('mkdir /opt', use_sudo=True)
        with cd('/opt'):
            sudo('git clone {0} {1}'.format(env.salt_bleeding, 'saltstack'))
        with cd('/opt/saltstack/'):
            sudo('python setup.py install')
示例#4
0
def bootstrap(upgrade=False):
    "Performs a bootstrap depending on the operating system."
    runner.action('Bootstrapping salt')
    with runner.with_prefix(' ~> '):
        pkgmgr = find_pkgmgr()
        bootstrappers = {
            'apt': bootstrap_with_aptget,
        }
        runner.silent('rm -rf /etc/salt/')
        runner.silent('rm -rf /opt/salt/')
        bootstrappers[pkgmgr.name](boolean(upgrade))
示例#5
0
def reboot_if_required():
    """Reboots the machine only if the system indicates a restart is required for updates.
    """
    out = runner.silent('[ -f /var/run/reboot-required ]')
    if not out.return_code:
        runner.state("System requires reboot => Rebooting NOW")
        reboot()