|
2 | 2 | # Run tests/ansible/all.yml under Ansible and Ansible-Mitogen |
3 | 3 |
|
4 | 4 | import os |
| 5 | +import subprocess |
5 | 6 | import sys |
6 | 7 |
|
7 | 8 | import ci_lib |
8 | | -from ci_lib import run |
9 | 9 |
|
10 | 10 |
|
11 | 11 | TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') |
|
24 | 24 | # NOTE: sshpass v1.06 causes errors so pegging to 1.05 -> "msg": "Error when changing password","out": "passwd: DS error: eDSAuthFailed\n", |
25 | 25 | # there's a checksum error with "brew install http://git.io/sshpass.rb" though, so installing manually |
26 | 26 | if not ci_lib.exists_in_path('sshpass'): |
27 | | - os.system("curl -O -L https://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz && \ |
| 27 | + subprocess.check_call( |
| 28 | + "curl -O -L https://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz && \ |
28 | 29 | tar xvf sshpass-1.05.tar.gz && \ |
29 | 30 | cd sshpass-1.05 && \ |
30 | 31 | ./configure && \ |
31 | | - sudo make install") |
| 32 | + sudo make install", |
| 33 | + shell=True, |
| 34 | + ) |
32 | 35 |
|
33 | 36 |
|
34 | 37 | with ci_lib.Fold('machine_prep'): |
35 | 38 | # generate a new ssh key for localhost ssh |
36 | 39 | if not os.path.exists(os.path.expanduser("~/.ssh/id_rsa")): |
37 | | - os.system("ssh-keygen -P '' -m pem -f ~/.ssh/id_rsa") |
38 | | - os.system("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") |
| 40 | + subprocess.check_call("ssh-keygen -P '' -m pem -f ~/.ssh/id_rsa", shell=True) |
| 41 | + subprocess.check_call("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys", shell=True) |
| 42 | + os.chmod(os.path.expanduser('~/.ssh'), int('0700', 8)) |
| 43 | + os.chmod(os.path.expanduser('~/.ssh/authorized_keys'), int('0600', 8)) |
39 | 44 |
|
40 | 45 | # also generate it for the sudo user |
41 | | - if os.system("sudo [ -f /var/root/.ssh/id_rsa ]") != 0: |
42 | | - os.system("sudo ssh-keygen -P '' -m pem -f /var/root/.ssh/id_rsa") |
43 | | - os.system("sudo cat /var/root/.ssh/id_rsa.pub | sudo tee -a /var/root/.ssh/authorized_keys") |
44 | | - |
45 | | - os.chmod(os.path.expanduser('~/.ssh'), int('0700', 8)) |
46 | | - os.chmod(os.path.expanduser('~/.ssh/authorized_keys'), int('0600', 8)) |
47 | | - # run chmod through sudo since it's owned by root |
48 | | - os.system('sudo chmod 700 /var/root/.ssh') |
49 | | - os.system('sudo chmod 600 /var/root/.ssh/authorized_keys') |
| 46 | + if os.system("sudo [ -f ~root/.ssh/id_rsa ]") != 0: |
| 47 | + subprocess.check_call("sudo ssh-keygen -P '' -m pem -f ~root/.ssh/id_rsa", shell=True) |
| 48 | + subprocess.check_call("sudo cat ~root/.ssh/id_rsa.pub | sudo tee -a ~root/.ssh/authorized_keys", shell=True) |
| 49 | + subprocess.check_call('sudo chmod 700 ~root/.ssh', shell=True) |
| 50 | + subprocess.check_call('sudo chmod 600 ~root/.ssh/authorized_keys', shell=True) |
50 | 51 |
|
51 | 52 | if os.path.expanduser('~mitogen__user1') == '~mitogen__user1': |
52 | 53 | os.chdir(IMAGE_PREP_DIR) |
53 | | - run("ansible-playbook -c local -i localhost, _user_accounts.yml") |
| 54 | + ci_lib.run("ansible-playbook -c local -i localhost, _user_accounts.yml") |
54 | 55 |
|
55 | 56 |
|
56 | 57 | with ci_lib.Fold('ansible'): |
57 | 58 | os.chdir(TESTS_DIR) |
58 | 59 | playbook = os.environ.get('PLAYBOOK', 'all.yml') |
59 | | - run('./run_ansible_playbook.py %s -l target %s', |
| 60 | + ci_lib.run('./run_ansible_playbook.py %s -l target %s', |
60 | 61 | playbook, ' '.join(sys.argv[1:])) |
0 commit comments