示例#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')
示例#2
0
def deploy(filter='*', upload=1, sync=1, debug=0):
    """Tells master to send pillars and execute salt state files on clients.

    If debug is set to 'yes', runs locally with more debugging information output.
    If upload is set to 'yes', then uploads current salt configurations to the master before deploying.
    """
    runner.action('Deploying salt files')
    output = ''
    with runner.with_prefix('  '):
        # if has('/opt/saltstack/', 'test -e %(app)s'):
        #     lowlevel.upgrade_bleeding()
        if boolean(upload):
            lowlevel.upload()
        if boolean(sync):
            if boolean(debug):
                cmd = "salt-call state.highstate -l debug"
            else:    
                cmd = "salt '{0}' state.highstate".format(filter)
            runner.action('Ensuring minion state')
            with show('stdout', 'stderr'):
                out = runner.sudo(cmd, combine_stderr=True)
            with open('sync.log', 'w+') as handle:
                handle.write(out)
            runner.action('Wrote output to sync.log')