self.inventory = self._write_hosts_file(hosts_str)
self.generated_inventory = True
- def _write_hosts_file(self, content):
+ def _write_hosts_file(self, content, suffix=''):
"""
Actually write the hosts file
"""
- hosts_file = NamedTemporaryFile(prefix="teuth_ansible_hosts_",
- delete=False)
+ hosts_file = NamedTemporaryFile(
+ prefix="teuth_ansible_hosts_",
+ suffix=suffix,
+ delete=False,
+ )
hosts_file.write(content)
hosts_file.flush()
return hosts_file.name
with patch.object(ansible, 'NamedTemporaryFile') as m_NTF:
m_NTF.return_value = hosts_file_obj
task.generate_hosts_file()
- m_NTF.assert_called_once_with(prefix="teuth_ansible_hosts_",
- delete=False)
+ m_NTF.assert_called_once_with(
+ prefix="teuth_ansible_hosts_",
+ delete=False,
+ suffix='',
+ )
assert task.generated_inventory is True
assert task.inventory == hosts_file_path
hosts_file_obj.seek(0)
task.find_repo()
task.get_playbook()
task.generate_playbook()
- m_NTF.assert_called_once_with(prefix="teuth_ansible_playbook_",
- dir=task.repo_path,
- delete=False)
+ m_NTF.assert_called_once_with(
+ prefix="teuth_ansible_playbook_",
+ dir=task.repo_path,
+ delete=False,
+ )
assert task.generated_playbook is True
assert task.playbook_file == playbook_file_obj
playbook_file_obj.seek(0)
with patch.object(ansible, 'NamedTemporaryFile') as m_NTF:
m_NTF.return_value = hosts_file_obj
task.generate_hosts_file()
- m_NTF.assert_called_once_with(prefix="teuth_ansible_hosts_",
- delete=False)
+ m_NTF.assert_called_once_with(
+ prefix="teuth_ansible_hosts_",
+ delete=False,
+ suffix='',
+ )
assert task.generated_inventory is True
assert task.inventory == hosts_file_path
hosts_file_obj.seek(0)