Merge "SSH improvements for Ansible"
authormadavi <jm00553988@techmahindra.com>
Tue, 5 Nov 2019 04:51:32 +0000 (05:51 +0100)
committerGerrit Code Review <root@osm.etsi.org>
Tue, 5 Nov 2019 04:51:32 +0000 (05:51 +0100)
descriptor-packages/tools/charm-generator/generator/ansible-charm/templates/ansible_lib.py.j2

index 7492c6d..1d6165e 100644 (file)
@@ -49,7 +49,8 @@ def create_hosts(cfg, hosts):
     with open(inventory_path, 'w') as f:
         f.write('[{}]\n'.format(hosts))
         h1 = '{0} ansible_connection=ssh ansible_ssh_user={1} ansible_ssh_pass={2} ' \
-             'ansible_python_interpreter=/usr/bin/python3\n'.format(cfg['ssh-hostname'], cfg['ssh-username'],
+             'ansible_ssh_private_key_file=~/.ssh/id_juju_sshproxy ' \
+             'ansible_python_interpreter=/usr/bin/python\n'.format(cfg['ssh-hostname'], cfg['ssh-username'],
                                                                     cfg['ssh-password'])
         f.write(h1)
 
@@ -63,6 +64,11 @@ def create_ansible_cfg():
         # logs playbook execution attempts to the specified path
         f.write('log_path = /var/log/ansible.log\n')
 
+        f.write('[ssh_connection]\n')
+        f.write('control_path=%(directory)s/%%h-%%r\n')
+        f.write('control_path_dir=~/.ansible/cp\n')
+
+
 # Function to find the playbook path
 def find(pattern, path):
     result = ''