|
| 1 | +#!/usr/bin/env python |
| 2 | +# Run tests/ansible/all.yml under Ansible and Ansible-Mitogen |
| 3 | + |
| 4 | +import glob |
| 5 | +import os |
| 6 | +import sys |
| 7 | + |
| 8 | +import ci_lib |
| 9 | +from ci_lib import run |
| 10 | + |
| 11 | + |
| 12 | +TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') |
| 13 | +IMAGE_PREP_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/image_prep') |
| 14 | +HOSTS_DIR = os.path.join(TESTS_DIR, 'hosts') |
| 15 | + |
| 16 | + |
| 17 | +with ci_lib.Fold('unit_tests'): |
| 18 | + os.environ['SKIP_MITOGEN'] = '1' |
| 19 | + ci_lib.run('./run_tests -v') |
| 20 | + |
| 21 | + |
| 22 | +with ci_lib.Fold('job_setup'): |
| 23 | + # Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version. |
| 24 | + run("pip install -q ansible==%s", ci_lib.ANSIBLE_VERSION) |
| 25 | + |
| 26 | + os.chdir(TESTS_DIR) |
| 27 | + os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7)) |
| 28 | + |
| 29 | + if not ci_lib.exists_in_path('sshpass'): |
| 30 | + run("brew install sshpass") |
| 31 | + |
| 32 | + |
| 33 | +with ci_lib.Fold('machine_prep'): |
| 34 | + if os.path.expanduser('~mitogen__user1') == '~mitogen_user1': |
| 35 | + os.chdir(IMAGE_PREP_DIR) |
| 36 | + run("ansible-playbook -i localhost, _user_accounts.yml") |
| 37 | + |
| 38 | + |
| 39 | +with ci_lib.Fold('ansible'): |
| 40 | + os.chdir(TESTS_DIR) |
| 41 | + playbook = os.environ.get('PLAYBOOK', 'all.yml') |
| 42 | + run('./run_ansible_playbook.py %s -l target %s', |
| 43 | + playbook, HOSTS_DIR, ' '.join(sys.argv[1:])) |
0 commit comments