Trying to find a solution for this task: I have a role with default values. For example - here are them:
some_hash:
name1:
some_attr: some_val
some_extra_args: ''
limits:
max: 1
min: 2
name2:
some_attr: some_val
some_extra_args: ''
limits:
max: 10
min: 5
...
This role is working as expected and it is enough for 99% of usage cases. But sometimes I need to run this role with the same values except min
and max
. In these rare cases I need to have min
and max
to equal 0 for all cases in this hash.
First of all I thought about adding an additional task (with tag never
and some additional tag to execute this part) which will have include_vars
and additional file where I will set all min
and max
to 0.
But in this case in the future I will need to keep updated at least 2 files: default vars and my custom vars which is not good.
Does Ansible has some filter to update values in hash dynamically? Example of what I need in rare cases:
some_hash:
name1:
some_attr: some_val
some_extra_args: ''
limits:
max: 0
min: 0
name2:
some_attr: some_val
some_extra_args: ''
limits:
max: 0
min: 0
...
And this conversation should be applied before tasks:
- name: Assemble config
assemble:
src: "some_path"
dest: "some_path.j2"
- name: Templating
template:
src: "path_from_asseble_above.j2"
dest: ...
...
Maybe it is possible with set_fact
task and some ansible filters/convertations?
