Esempio n. 1
0
def playbook(install_path,
             playbook='playbook',
             ask_sudo_pass=False,
             ask_vault_pass=False,
             extras=None):
    common.get_dotenv()
    check_roles_dir(install_path)
    os.environ["ANSIBLE_CONFIG"] = os.path.join(install_path, 'ansible.cfg')
    command_string = 'ansible-playbook'
    command_string += ' -i "%s"' % os.path.join(install_path, 'inventory')

    if ask_sudo_pass or os.environ.get("OSXSTRAP_ASK_SUDO_PASS") == '1':
        command_string += ' --ask-sudo-pass'
    if ask_vault_pass or os.environ.get("OSXSTRAP_ASK_VAULT_PASS") == '1':
        command_string += ' --ask-vault-pass'
    if extras:
        command_string += ' ' + extras

    default_playbook_path = os.path.join(install_path, playbook) + '.yml'
    if os.path.exists(default_playbook_path):
        command_string += ' "%s"' % default_playbook_path
    else:
        custom_playbook_path = os.path.join(custom_playbooks_path,
                                            playbook) + '.yml'
        if os.path.exists(custom_playbook_path):
            command_string += ' "%s"' % custom_playbook_path
        else:
            output.abort(
                "Cannot find playbook %s.yml, looked for it at\n%s\n%s" %
                (playbook, default_playbook_path, custom_playbook_path))
    common.run(command_string)
Esempio n. 2
0
def playbook(install_path, playbook='playbook', ask_sudo_pass=False, ask_vault_pass=False, extras=None):
	common.get_dotenv()
	check_roles_dir(install_path)
	os.environ["ANSIBLE_CONFIG"] = os.path.join(install_path, 'ansible.cfg')
	command_string = 'ansible-playbook'
	command_string += ' -i "%s"' % os.path.join(install_path, 'inventory')
	
	if ask_sudo_pass or os.environ.get("OSXSTRAP_ASK_SUDO_PASS") == '1':
		command_string += ' --ask-sudo-pass'
	if ask_vault_pass or os.environ.get("OSXSTRAP_ASK_VAULT_PASS") == '1':
		command_string += ' --ask-vault-pass'
	if extras:
		command_string += ' ' + extras

	default_playbook_path = os.path.join(install_path, playbook) + '.yml'
	if os.path.exists(default_playbook_path):
		command_string += ' "%s"' % default_playbook_path
	else:
		custom_playbook_path = os.path.join(custom_playbooks_path, playbook) + '.yml'
		if os.path.exists(custom_playbook_path):
			command_string += ' "%s"' % custom_playbook_path
		else:
			output.abort("Cannot find playbook %s.yml, looked for it at\n%s\n%s" % (playbook, default_playbook_path, custom_playbook_path))
	common.run(command_string)
Esempio n. 3
0
def cli(ctx, playbook, ask_sudo_pass, ask_vault_pass):
    common.get_dotenv()
    if ctx.invoked_subcommand is None:
        ansible.playbook(install_path, playbook, ask_sudo_pass, ask_vault_pass)
Esempio n. 4
0
def cli(ctx, playbook, ask_sudo_pass, ask_vault_pass):
    common.get_dotenv()
    if ctx.invoked_subcommand is None:  
        ansible.playbook(install_path, playbook, ask_sudo_pass, ask_vault_pass)