|
3 | 3 |
|
4 | 4 | import glob |
5 | 5 | import os |
| 6 | +import shutil |
6 | 7 | import sys |
7 | 8 |
|
8 | 9 | import ci_lib |
|
12 | 13 | TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') |
13 | 14 | IMAGE_PREP_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/image_prep') |
14 | 15 | HOSTS_DIR = os.path.join(TESTS_DIR, 'hosts') |
| 16 | +KEY_PATH = os.path.join(TESTS_DIR, '../data/docker/mitogen__has_sudo_pubkey.key') |
15 | 17 |
|
16 | 18 |
|
17 | 19 | with ci_lib.Fold('unit_tests'): |
|
23 | 25 | # Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version. |
24 | 26 | run("pip install -q ansible==%s", ci_lib.ANSIBLE_VERSION) |
25 | 27 |
|
26 | | - os.chdir(TESTS_DIR) |
27 | | - os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7)) |
28 | | - |
| 28 | + os.chmod(KEY_PATH, int('0600', 8)) |
29 | 29 | if not ci_lib.exists_in_path('sshpass'): |
30 | 30 | run("brew install http://git.io/sshpass.rb") |
31 | 31 |
|
32 | 32 |
|
33 | 33 | with ci_lib.Fold('machine_prep'): |
34 | 34 | key_path = os.path.expanduser('~/.ssh/id_rsa') |
35 | | - if not os.path.exists(key_path): |
36 | | - run("ssh-keygen -N '' -f %s", key_path) |
| 35 | + shutil.copy(KEY_PATH, key_path) |
37 | 36 |
|
38 | 37 | auth_path = os.path.expanduser('~/.ssh/authorized_keys') |
39 | | - with open(auth_path, 'a') as fp: |
40 | | - fp.write(open(key_path + '.pub').read()) |
| 38 | + os.system('ssh-keygen -y -f %s >> %s' % (key_path, auth_path)) |
41 | 39 | os.chmod(auth_path, int('0600', 8)) |
42 | 40 |
|
43 | 41 | if os.path.expanduser('~mitogen__user1') == '~mitogen__user1': |
|
0 commit comments