Skip to content

Commit

Permalink
Fix problem with private-key execution via API.
Browse files Browse the repository at this point in the history
SSH wants that private-key has new line always in file.

Closes vstconsulting/polemarch#87
  • Loading branch information
onegreyonewhite committed Aug 22, 2019
1 parent 60429af commit 9373700
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion polemarch/main/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import tempfile
import traceback
from pathlib import Path
from collections import namedtuple, OrderedDict
from subprocess import Popen
from functools import reduce
Expand Down Expand Up @@ -227,8 +228,12 @@ 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 re.match(r"[-]+BEGIN .+ KEY[-]+", value):
# Add new line if not exists and generate tmpfile for private key value
value = value + '/n' if value[-1] != '/n' else value
return self.__generate_arg_file(value)
return "{}/{}".format(self.workdir, value), []
# Return path in project if it's path
path = (Path(self.workdir)/Path(value).expanduser()).resolve()
return str(path), []

def __convert_arg(self, ansible_extra: AnsibleExtra, item: Tuple[Text, Any]) -> Tuple[List, List]:
extra_args, files = ansible_extra
Expand Down

0 comments on commit 9373700

Please sign in to comment.