Can ansible parse and act based on information in an input xml / yaml / json file?

Is there a way ansible can use an input file like xml / yaml / json to control its actions?

I know “lookup” works on “flat” file types, but I cannot find reference to a feature that can walk a tree-like hierarchical input file type (e.g., xml / yaml / json ).

The right answer to this probably depends on where this “input file” is located (on Ansible server or on hosts being modified) and what you’re wanting to do with the information. But in general, if you are talking about reading a YAML or JSON file into variables for use within a playbook you can take a look at include_vars. Hosts can also provide local JSON or INI information via *.fact files in /etc/ansible/facts.d. Or you can read YAML information specific to hosts, groups, etc via all the variable directory conventions (group_vars, host_vars, etc)

If you can give some further details, someone may have a better plan.

The right answer to this probably depends on where this “input file” is located (on Ansible server or on hosts being modified) and what you’re wanting to do with the information. But in general, if you are talking about reading a YAML or JSON file into variables for use within a playbook you can take a look at include_vars. Hosts can also provide local JSON or INI information via *.fact files in /etc/ansible/facts.d. Or you can read YAML information specific to hosts, groups, etc via all the variable directory conventions (group_vars, host_vars, etc)

If you can give some further details, someone may have a better plan.

Thanks for response.
I mean, I want to configure something based on an xml file, but the number of various sections is not known before handle. And the existence or non-existence of various sections (i.e., XML nodes) is also not known before hand. Same with attributes.

I think i need to suck into an XML Dom and then trigger actions while walking the DOM.

As an example,

I have a 3 level tree structure that defines a config.

top level list: A , B , C, D, … ← note the ellipses

Then under A: x, y, z, … ← note the ellipses

Then under x: i, j, k, … <— note the ellipses

And the pattern can continue.

Moreover, there can be absent configs too.