Ejemplo n.º 1
0
def ansible_playbook_file(playbooks, inventorys, **kwargs):
    """ Runs a playbook as part of a Cloudify lifecycle operation """

    for inventory in inventorys:
        inventory_path = utils.get_file(inventory)
        ctx.logger.info('Inventory path: {0}.'.format(inventory_path))

        for playbook in playbooks:
            playbook_path = utils.get_file(playbook)
            ctx.logger.info('Playbook path: {0}.'.format(playbook_path))
            command = ['ansible-playbook', '-i', inventory_path, playbook_path]
            ctx.logger.info('Running command: {0}.'.format(command))
            output = utils.run_command(command)
            ctx.logger.info('Command Output: {0}.'.format(output))
            ctx.logger.info('Finished running the Ansible Playbook.')
Ejemplo n.º 2
0
def ansible_playbook_module(module, playbook, inventorys,  **kwargs):
    """
    Runs a anisble module
    :param module:
    :param kwargs:
    :return:
    """
    path = utils.get_file(module)
    ctx.logger.info('Playbook module: {0}.'.format(path))
    command = ["tar", "zxvf", path, '-C', '/opt']
    output = utils.run_command(command)
    ctx.logger.info('Command Output: {0}.'.format(output))
    inventory = utils.get_inventory_1(playbook, inventorys, **kwargs)
    command = ['ansible-playbook', '-i', inventory, playbook]
    ctx.logger.info('Running command: {0}.'.format(command))
    output = utils.run_command(command)
    ctx.logger.info('Command Output: {0}.'.format(output))
    ctx.logger.info('Finished running the Ansible Playbook.')