Skip to content

Commit

Permalink
1.4.1
Browse files Browse the repository at this point in the history
Fix key searching pattern for SSH-keys in ansible run.
Allow to use any private keys.
  • Loading branch information
onegreyonewhite committed Aug 15, 2019
2 parents bf9b1eb + 49c2dcd commit d31d616
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion polemarch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"VST_ROOT_URLCONF": os.getenv("VST_ROOT_URLCONF", 'vstutils.urls'),
}

__version__ = "1.4.0"
__version__ = "1.4.1"

prepare_environment(**default_settings)
2 changes: 1 addition & 1 deletion polemarch/main/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def __generate_arg_file(self, value: Text) -> Tuple[Text, List[tmp_file]]:

def __parse_key(self, key: Text, value: Text) -> Tuple[Text, List]:
# pylint: disable=unused-argument,
if "BEGIN RSA PRIVATE KEY" in value:
if re.match(r"[-]+BEGIN .+ KEY[-]+", value):
return self.__generate_arg_file(value)
return "{}/{}".format(self.workdir, value), []

Expand Down
16 changes: 13 additions & 3 deletions polemarch/main/tests/executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@

logger = logging.getLogger('polemarch')
pm_mod = settings.VST_PROJECT_LIB_NAME
ssh_key_pattern = '''-----BEGIN OPENSSH PRIVATE KEY-----
our_private_key_string
-----END OPENSSH PRIVATE KEY-----
'''

ssh_rsa_pattern = '''-----BEGIN RSA PRIVATE KEY-----
our_private_key_string
-----END RSA PRIVATE KEY-----
'''

test_ansible_cfg = '''
[defaults]
library = lib:lib2
Expand Down Expand Up @@ -600,7 +610,7 @@ def playbook_tests(self, prj, playbook_count=1, execute=None, inventory="localho
_exec = dict(
connection="local", limit="docker",
playbook="<1[data][results][0][playbook]>", inventory=inventory,
private_key='BEGIN RSA PRIVATE KEY'
private_key=ssh_key_pattern
)
bulk_data = self.project_bulk_sync_and_playbooks(prj['id'])
bulk_data += [
Expand Down Expand Up @@ -658,7 +668,7 @@ def wip_manual(self, project_data):
self.sync_project(**project_data)
# Create test ssh-key
with open(self.get_file_path('key.pem', path), 'w') as key:
key.write('BEGIN RSA PRIVATE KEY')
key.write(ssh_key_pattern)
self.make_test_templates(project_data)
self.make_test_periodic_task(project_data)
self.make_test_readme(project_data)
Expand Down Expand Up @@ -1148,7 +1158,7 @@ def over_download(*args, **kwargs):
)
_ex_playbook = dict(
playbook='unknown.yml', inventory='192.168.254.255',
private_key='BEGIN RSA PRIVATE KEY'
private_key=ssh_rsa_pattern
)
unsync = dict(key='repo_sync_on_run', value=False)
pk = project_data['id']
Expand Down

0 comments on commit d31d616

Please sign in to comment.