Jelajahi Sumber

Merge pull request #21 from lhuard1A/fix_ansible_libvirt_metadata

Fix libvirt metadata used to store ansible tags
Jason DeTiberus 10 tahun lalu
induk
melakukan
e85ad297c1

+ 1 - 1
inventory/libvirt/hosts/libvirt_generic.py

@@ -131,7 +131,7 @@ class LibvirtInventory(object):
 
             root = ET.fromstring(domain.XMLDesc())
             ns = {'ansible': 'https://github.com/ansible/ansible'}
-            for tag_elem in root.findall('./metadata/ansible:tag', ns):
+            for tag_elem in root.findall('./metadata/ansible:tags/ansible:tag', ns):
                 tag = tag_elem.text
                 self.push(inventory, "tag_%s" % tag, domain_name)
                 self.push(hostvars, 'libvirt_tags', tag)

+ 6 - 4
playbooks/libvirt/openshift-cluster/templates/domain.xml

@@ -2,10 +2,12 @@
   <name>{{ item }}</name>
   <memory unit='GiB'>1</memory>
   <metadata xmlns:ansible="https://github.com/ansible/ansible">
-    <ansible:tag>deployment-type-{{ deployment_type }}</ansible:tag>
-    <ansible:tag>env-{{ cluster }}</ansible:tag>
-    <ansible:tag>env-host-type-{{ cluster }}-openshift-{{ type }}</ansible:tag>
-    <ansible:tag>host-type-{{ type }}</ansible:tag>
+    <ansible:tags>
+      <ansible:tag>deployment-type-{{ deployment_type }}</ansible:tag>
+      <ansible:tag>env-{{ cluster }}</ansible:tag>
+      <ansible:tag>env-host-type-{{ cluster }}-openshift-{{ type }}</ansible:tag>
+      <ansible:tag>host-type-{{ type }}</ansible:tag>
+    </ansible:tags>
   </metadata>
   <currentMemory unit='GiB'>1</currentMemory>
   <vcpu placement='static'>2</vcpu>