Lately I’ve been working on automatically provisioning servers while trying to
remain sane as well as getting simple automatic deployments
running. I’ve been bit by it before, but it wasn’t until I was trying to set up
loadbalancers and DNS in Rackspace, that I took some time to look into the
problem: with_subelements
doesn’t work properly. At least not the
way I thought it should work.
With this object…
… with_subelements
can access the list in object.subobject
as well as the
list in sublist
with the following:
But if sublist
is placed deeper in the object, like the virtual IPs are, when
creating multiple Rackspace load balancers:
… and you try to access it with
… Ansible just complains that the key balancer.virtual_ips
wasn’t found or
didn’t contain a list.
So I fixed that, making with_subelements
properly descend the levels
of an object. You can place the updated version of subelements.py
in your
Ansible project in the filter_plugins
folder until my pull request
hopefully is accepted.