Hi!
I am automating some DNS stuff and decided to implement some of the logic inside a module. I need to:
- load a file in YAML format (just like include_vars module does)
- merge the contents of the loaded files with host variables from dynamic inventory
- filter out data that does not belong to host defined using module’s parameters
- make resulting hash available to Ansible just like include_vars does
- each host will have different data, depending on the module parameters
So basically I need to modify the include_vars module. I did some research and I cannot do it using plain module - only ActionModule, because:
- in needs to modify ansible vars
- it uses host vars
- in needs to be executed locally
I have few questions though - is there a way to call it like every other module (== splitting arguments into multiple lines) ? Plain module has some boilerplate that parses arguments for me, but ActionModue seams to miss such functionality. So, instead of calling it like this:
- name: Some description goes here
local_action: data_merge input_file=/path/to/file zone_host={{ inventory hostname }}
I would like to be able to call it like this:
- name: Some description goes here
data_merge
args:
input_file=/path/to/file
zone_host={{ inventory hostname }}
How do I parse keyword arguments in a way that permits both form (single line and “args”) ? The include_vars module assumes that everything will be on single line, not sure how I can get rid of “local_action” keyword either.
Thanks in advance
Paweł Rozlach