diff --git a/tripleo_common/actions/ansible.py b/tripleo_common/actions/ansible.py index 55111c2d2..78534a97b 100644 --- a/tripleo_common/actions/ansible.py +++ b/tripleo_common/actions/ansible.py @@ -34,7 +34,8 @@ LOG = logging.getLogger(__name__) def write_default_ansible_cfg(work_dir, remote_user, - ssh_private_key, + ssh_private_key=None, + transport=None, base_ansible_cfg='/etc/ansible/ansible.cfg'): ansible_config_path = os.path.join(work_dir, 'ansible.cfg') shutil.copy(base_ansible_cfg, ansible_config_path) @@ -64,6 +65,8 @@ def write_default_ansible_cfg(work_dir, config.set('defaults', 'remote_user', remote_user) if ssh_private_key: config.set('defaults', 'private_key_file', ssh_private_key) + if transport: + config.set('defaults', 'transport', transport) with open(ansible_config_path, 'w') as configfile: config.write(configfile) @@ -218,7 +221,7 @@ class AnsibleAction(actions.Action): ansible_config_path = write_default_ansible_cfg( self.work_dir, self.remote_user, - self.ssh_private_key) + ssh_private_key=self.ssh_private_key) env_variables = { 'HOME': self.work_dir, 'ANSIBLE_LOCAL_TEMP': self.work_dir, @@ -480,7 +483,7 @@ class AnsiblePlaybookAction(base.TripleOAction): ansible_config_path = write_default_ansible_cfg( self.work_dir, self.remote_user, - self.ssh_private_key) + ssh_private_key=self.ssh_private_key) env_variables = { 'HOME': self.work_dir, 'ANSIBLE_LOCAL_TEMP': self.work_dir, diff --git a/tripleo_common/tests/actions/test_ansible.py b/tripleo_common/tests/actions/test_ansible.py index c5b0fe81e..57a82ba5c 100644 --- a/tripleo_common/tests/actions/test_ansible.py +++ b/tripleo_common/tests/actions/test_ansible.py @@ -60,7 +60,8 @@ class AnsibleActionTest(base.TestCase): } mock_write_cfg.assert_called_once_with(action.work_dir, - self.remote_user, None) + self.remote_user, + ssh_private_key=None) mock_execute.assert_called_once_with( 'ansible', self.hosts, '-vvvvv', '--module-name', self.module, @@ -101,7 +102,8 @@ class AnsiblePlaybookActionTest(base.TestCase): action.run(self.ctx) mock_write_cfg.assert_called_once_with(action.work_dir, - self.remote_user, None) + self.remote_user, + ssh_private_key=None) pb = os.path.join(action.work_dir, 'playbook.yaml') env = { @@ -191,7 +193,7 @@ class CopyConfigFileTest(base.TestCase): ansible_cfg_file.flush() resulting_ansible_config = ansible.write_default_ansible_cfg( - work_dir, None, None, base_ansible_cfg=ansible_cfg_path) + work_dir, None, None, None, base_ansible_cfg=ansible_cfg_path) self.assertEqual(resulting_ansible_config, os.path.join(work_dir, 'ansible.cfg'))