Exemple #1
0
    inventory_path = os.path.join(HOSTS_DIR, 'target')
    with open(inventory_path, 'w') as fp:
        fp.write('[test-targets]\n')
        fp.writelines(
            "%(name)s "
            "ansible_host=%(hostname)s "
            "ansible_port=%(port)s "
            "ansible_python_interpreter=%(python_path)s "
            "ansible_user=mitogen__has_sudo_nopw "
            "ansible_password=has_sudo_nopw_password"
            "\n"
            % container
            for container in containers
        )

    ci_lib.dump_file(inventory_path)

    if not ci_lib.exists_in_path('sshpass'):
        run("sudo apt-get update")
        run("sudo apt-get install -y sshpass")


with ci_lib.Fold('ansible'):
    playbook = os.environ.get('PLAYBOOK', 'all.yml')
    try:
        run('./run_ansible_playbook.py %s -i "%s" %s',
            playbook, HOSTS_DIR, ' '.join(sys.argv[1:]))
    except:
        pause_if_interactive()
        raise
Exemple #2
0
                 "\n"
                 "ansible_user: mitogen__has_sudo_pubkey\n"
                 "ansible_become_pass: has_sudo_pubkey_password\n"
                 "ansible_ssh_private_key_file: %s\n"
                 "\n"
                 # Speed up slow DH generation.
                 "dhparam__bits: ['128', '64']\n" % (ci_lib.key_file, ))

    with open(inventory_path, 'a') as fp:
        fp.writelines('%(name)s '
                      'ansible_host=%(hostname)s '
                      'ansible_port=%(port)d '
                      'ansible_python_interpreter=%(python_path)s '
                      '\n' % container for container in containers)

    ci_lib.dump_file('ansible/inventory/hosts')

    # Now we have real host key checking, we need to turn it off
    os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False'

interesting = ci_lib.get_interesting_procs()

with ci_lib.Fold('first_run'):
    ci_lib.run('debops common %s', ' '.join(sys.argv[1:]))

ci_lib.check_stray_processes(interesting, containers)

with ci_lib.Fold('second_run'):
    ci_lib.run('debops common %s', ' '.join(sys.argv[1:]))

ci_lib.check_stray_processes(interesting, containers)