]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
ansible: write hosts file in _write_hosts_file()
authorZack Cerza <zack@redhat.com>
Tue, 9 Feb 2016 22:30:45 +0000 (15:30 -0700)
committerZack Cerza <zack@redhat.com>
Thu, 18 Feb 2016 19:39:36 +0000 (12:39 -0700)
This is to make implementing the CephAnsible task cleaner.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/ansible.py

index 07dc50b5fa63d7b366fd0c3686b5d08e226328e6..d37a5a9e24661526f12a5d1bedc1e18a9c670d47 100644 (file)
@@ -199,12 +199,18 @@ class Ansible(Task):
             inventory.append('[{0}]'.format(self.inventory_group))
         inventory.extend(hostnames + [''])
         hosts_str = '\n'.join(inventory)
+        self.inventory = self._write_hosts_file(hosts_str)
+        self.generated_inventory = True
+
+    def _write_hosts_file(self, content):
+        """
+        Actually write the hosts file
+        """
         hosts_file = NamedTemporaryFile(prefix="teuth_ansible_hosts_",
                                         delete=False)
-        hosts_file.write(hosts_str)
+        hosts_file.write(content)
         hosts_file.flush()
-        self.generated_inventory = True
-        self.inventory = hosts_file.name
+        return hosts_file.name
 
     def generate_playbook(self):
         """