summaryrefslogtreecommitdiffstats
path: root/inventory/libvirt
diff options
context:
space:
mode:
authorLénaïc Huard <lenaic@lhuard.fr>2015-04-16 00:26:45 +0200
committerLénaïc Huard <lenaic@lhuard.fr>2015-04-16 00:30:04 +0200
commitaaee17b0fc8feddf31d4e5b46a1bfe2f8dabf16b (patch)
tree5afdd45cb977081ec407b34036d607d0cdda18f1 /inventory/libvirt
parent34326ef782bcba8632738a40d3948bb23a3915dc (diff)
downloadopenshift-aaee17b0fc8feddf31d4e5b46a1bfe2f8dabf16b.tar.gz
openshift-aaee17b0fc8feddf31d4e5b46a1bfe2f8dabf16b.tar.bz2
openshift-aaee17b0fc8feddf31d4e5b46a1bfe2f8dabf16b.tar.xz
openshift-aaee17b0fc8feddf31d4e5b46a1bfe2f8dabf16b.zip
Fix libvirt metadata used to store ansible tags
According to https://libvirt.org/formatdomain.html#elementsMetadata , the `metadata` tag can contain only one top-level element per namespace. Because of that, libvirt stored only the `deployment-type-{{ deployment_type }}` tag. As a consequence, the dynamic inventory reported no `env-{{ cluster }}` group. This is problematic for the `terminate.yml` playbook which iterates over `groups['tag-env-{{ cluster-id }}]` The symptom is that `oo_hosts_to_terminate` was not defined. In the end, as Ansible couldn’t iterate on the value of `groups['oo_hosts_to_terminate']`, it iterated on its letters: ``` TASK: [Destroy VMs] *********************************************************** failed: [localhost] => (item=['g', 'destroy']) => {"failed": true, "item": ["g", "destroy"]} msg: virtual machine g not found failed: [localhost] => (item=['g', 'undefine']) => {"failed": true, "item": ["g", "undefine"]} msg: virtual machine g not found failed: [localhost] => (item=['r', 'destroy']) => {"failed": true, "item": ["r", "destroy"]} msg: virtual machine r not found failed: [localhost] => (item=['r', 'undefine']) => {"failed": true, "item": ["r", "undefine"]} msg: virtual machine r not found failed: [localhost] => (item=['o', 'destroy']) => {"failed": true, "item": ["o", "destroy"]} msg: virtual machine o not found failed: [localhost] => (item=['o', 'undefine']) => {"failed": true, "item": ["o", "undefine"]} msg: virtual machine o not found failed: [localhost] => (item=['u', 'destroy']) => {"failed": true, "item": ["u", "destroy"]} msg: virtual machine u not found failed: [localhost] => (item=['u', 'undefine']) => {"failed": true, "item": ["u", "undefine"]} msg: virtual machine u not found failed: [localhost] => (item=['p', 'destroy']) => {"failed": true, "item": ["p", "destroy"]} msg: virtual machine p not found failed: [localhost] => (item=['p', 'undefine']) => {"failed": true, "item": ["p", "undefine"]} msg: virtual machine p not found failed: [localhost] => (item=['s', 'destroy']) => {"failed": true, "item": ["s", "destroy"]} msg: virtual machine s not found failed: [localhost] => (item=['s', 'undefine']) => {"failed": true, "item": ["s", "undefine"]} msg: virtual machine s not found failed: [localhost] => (item=['[', 'destroy']) => {"failed": true, "item": ["[", "destroy"]} msg: virtual machine [ not found failed: [localhost] => (item=['[', 'undefine']) => {"failed": true, "item": ["[", "undefine"]} msg: virtual machine [ not found failed: [localhost] => (item=["'", 'destroy']) => {"failed": true, "item": ["'", "destroy"]} msg: virtual machine ' not found failed: [localhost] => (item=["'", 'undefine']) => {"failed": true, "item": ["'", "undefine"]} msg: virtual machine ' not found failed: [localhost] => (item=['o', 'destroy']) => {"failed": true, "item": ["o", "destroy"]} msg: virtual machine o not found failed: [localhost] => (item=['o', 'undefine']) => {"failed": true, "item": ["o", "undefine"]} msg: virtual machine o not found etc… ```
Diffstat (limited to 'inventory/libvirt')
-rwxr-xr-xinventory/libvirt/hosts/libvirt_generic.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/inventory/libvirt/hosts/libvirt_generic.py b/inventory/libvirt/hosts/libvirt_generic.py
index 0a98e2af3..4652f112e 100755
--- a/inventory/libvirt/hosts/libvirt_generic.py
+++ b/inventory/libvirt/hosts/libvirt_generic.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
"""
libvirt external inventory script
@@ -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)