Skip to content

Commit 92de2ab

Browse files
committed
issue #543: use key from Git, newer ssh-keygen unsupported by Paramiko
1 parent 0e55bb3 commit 92de2ab

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

.ci/localhost_ansible_tests.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import glob
55
import os
6+
import shutil
67
import sys
78

89
import ci_lib
@@ -12,6 +13,7 @@
1213
TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible')
1314
IMAGE_PREP_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/image_prep')
1415
HOSTS_DIR = os.path.join(TESTS_DIR, 'hosts')
16+
KEY_PATH = os.path.join(TESTS_DIR, '../data/docker/mitogen__has_sudo_pubkey.key')
1517

1618

1719
with ci_lib.Fold('unit_tests'):
@@ -23,21 +25,17 @@
2325
# Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version.
2426
run("pip install -q ansible==%s", ci_lib.ANSIBLE_VERSION)
2527

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))
2929
if not ci_lib.exists_in_path('sshpass'):
3030
run("brew install http://git.io/sshpass.rb")
3131

3232

3333
with ci_lib.Fold('machine_prep'):
3434
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)
3736

3837
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))
4139
os.chmod(auth_path, int('0600', 8))
4240

4341
if os.path.expanduser('~mitogen__user1') == '~mitogen__user1':

0 commit comments

Comments
 (0)