Ejemplo n.º 1
0
def create_and_play(playbook_text, hosts):
    """
    Utility method that creates and runs
    a playbook
    """
    playbook_file = create_playbook(playbook_text)
    results = playbook(playbook_file, hosts)
    remove_file(playbook_file)
    return results
Ejemplo n.º 2
0
def init(config_file):
    copy_config(config_file)
    ansible.galaxy_install(install_path)
    ansible.playbook(install_path, 'playbook', True, False)
Ejemplo 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)
Ejemplo n.º 4
0
def init(config_file):
    copy_config(config_file)
    ansible.galaxy_install(install_path)
    ansible.playbook(install_path, 'playbook', True, False)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    Parameters:
        playbook- (str) path to playbook
        hosts- list of hosts, or path to a hosts file
    """
    inventory = ansible.inventory.Inventory(hosts)

    #create these objects- required by playbook
    stats = callbacks.AggregateStats()
    playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
    runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)

    pb = PlayBook(playbook=playbook,
                    inventory=inventory,
                    stats = stats,
                    callbacks = playbook_cb,
                    runner_callbacks = runner_cb,
                    #check=True, #sandboxes execution
                    forks=10)
    #results is a dict
    results = pb.run()
    return results

def print_results(pr):
    print json.dumps(pr, sort_keys=True, indent=4, separators=(',', ': '))

if __name__ == "__main__":
    hosts = ["10.12.0.14"]
    playbook('./setup_ovs.yaml', hosts)
    print json.dumps(pr, sort_keys=True, indent=4, separators=(',', ': '))