Skip to content

Commit 4ced885

Browse files
committed
issue #543: localhost_ansible scripts.
1 parent c7e2b03 commit 4ced885

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.ci/localhost_ansible_install.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
3+
import ci_lib
4+
5+
batches = [
6+
[
7+
# Must be installed separately, as PyNACL indirect requirement causes
8+
# newer version to be installed if done in a single pip run.
9+
'pip install "pycparser<2.19" "idna<2.7"',
10+
'pip install '
11+
'-r tests/requirements.txt '
12+
'-r tests/ansible/requirements.txt',
13+
]
14+
]
15+
16+
ci_lib.run_batches(batches)

.ci/localhost_ansible_tests.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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

Comments
 (0)