Exemple #1
0
def setup_master(and_minion=1, upgrade=0):
    """Bootstraps and sets up a master.

    Sets up a minion pointing to itself unless otherwise said.

    Options:
        and_minion: Set to 'no' to not install salt-minion.
        upgrade:    Set to 'yes' to upgrade all system packages before
                    installing salt.
    """
    lowlevel.bootstrap(upgrade)
    lowlevel.master()
    lowlevel.upload(sync=False)
    if boolean(and_minion):
        name = hostname()
        roles = ['salt-master'] + list(env.salt_roles)
        lowlevel.create_minion_key(name)
        lowlevel.minion(master='127.0.0.1', hostname=name, roles=roles)
    
    
    if env.salt_bleeding:
        lowlevel.convert_to_bleeding()
        time.sleep(1)
        if boolean(and_minion):
            service('salt-minion', 'start')
        service('salt-master', 'start')
Exemple #2
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')
Exemple #3
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')
Exemple #4
0
def upgrade_bleeding():
    "Upgrades the bleeding edge and reinstall it."
    runner.action('Upgrade bleeding edge salt installation')
    with runner.with_prefix(' ~> '):
        service('salt-master', 'stop')
        service('salt-minion', 'stop')
        time.sleep(1)
        with cd('/opt/saltstack/'):
            sudo('git pull origin master')
            sudo('python setup.py install')
            service('salt-master', 'start')
            service('salt-minion', 'start')
Exemple #5
0
def setup_minion(fab_master, master, upgrade=0):
    """Bootstraps and sets up a minion. Requires the ip address of the master.
    
    Options:
        fab_master: The method for this machine (running fabric) to connect to the
                    master. This can be specified as "-H <IPADDRESS>" or fabric
                    task name
        master:     The address for the minion to connect to the master.
        upgrade:    Set to 'yes' to upgrade all the minion's packages before
                    installing salt-minion
    """
    name = hostname()
    local('fab {0} create_minion_key:{1}'.format(fab_master, repr(name)))
    lowlevel.bootstrap(upgrade)
    lowlevel.minion(master, name, env.salt_roles)

    if env.salt_bleeding:
        lowlevel.convert_to_bleeding()
        time.sleep(1)
        service('salt-minion', 'start')