import logging
import os
import shutil
+import stat
import textwrap
from pathlib import Path
from ..xlate import XLATOR
-__version__ = '0.4.0'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
str(self.script_dir), str(self.project_dir)))
LOG.debug(_("Script-Dir relative to project dir: {!r}.").format(str(self.script_dir_rel)))
+ filemode = stat.S_IMODE(self.private_key.stat().st_mode)
+ LOG.debug(_("Permissions of {k!r} are {m:04o}.").format(
+ k=str(self.private_key), m=filemode))
+ if filemode not in [0o400, 0o600]:
+ LOG.info(_("Setting permissions of {k!r} from {o:04o} to {m:04o}.").format(
+ k=str(self.private_key), o=filemode, m=0o600))
+ self.private_key.chmod(0o600)
+
self.keys_dir_rel = Path(os.path.relpath(
str(self.keys_dir), str(self.project_dir)))
LOG.debug(_("Directory for SSH deploy keys relative to project dir: {!r}.").format(
type = "ssh"
host = "{h}"
user = "root"
- private_key = "{k}"
+ private_key = file("{k}")
agent = "false"
}}
}}
type = "ssh"
host = "{h}"
user = "root"
- private_key = "{k}"
+ private_key = file("{k}")
agent = "false"
}}
}}
content += ' type = "ssh"\n'
content += ' host = "{}"\n'.format(vm.fqdn)
content += ' user = "root"\n'
- content += ' private_key = "{}"\n'.format(self.private_key_rel)
+ content += ' private_key = file("{}")\n'.format(self.private_key_rel)
content += ' agent = "false"\n'
content += ' }\n'
content += ' }\n\n'
content += ' ]\n'
content += ' when = destroy\n'
content += ' connection {\n'
- content += ' type = "ssh"\n'
- content += ' host = "{}"\n'.format(vm.fqdn)
- content += ' user = "root"\n'
- content += ' private_key = "{}"\n'.format(self.private_key_rel)
- content += ' agent = "false"\n'
+ content += ' type = "ssh"\n'
+ content += ' host = "{}"\n'.format(vm.fqdn)
+ content += ' user = "root"\n'
content += ' }\n'
content += ' }\n\n'
type = "ssh"
host = "{h}"
user = "root"
- private_key = "{k}"
+ private_key = file("{k}")
agent = "false"
}}
}}
]
when = destroy
connection {{
- type = "ssh"
- host = "{h}"
- user = "root"
- private_key = "{k}"
- agent = "false"
+ type = "ssh"
+ host = "{h}"
+ user = "root"
}}
}}