Hi
Does anyone knows how it is possible to include all sub elements of a value to modules as attributes?
vars
extra_vars:
function: "server"
anotherkey: "anothervalue"
ansible_ssh_private_key_file: "/home/someuser/.ssh/id_rsa"
static task i have:
- name: "Create a group"
add_host:
name: "{{
item.name }}"
groups: "servergroup"
ansible_connection: ssh
ansible_host: "{{ item }}"
ansible_port: 22
function: "server"
anotherkey: "anothervalue"
ansible_ssh_private_key_file: "/home/someuser/.ssh/id_rsa"
with_items:
- "
host1.com"
- "
host2.com"
- "
host4.com"
dynamic task i want in a comination with "extra_vars" :
- name: "Create a group"
add_host:
name: "{{
item.name }}"
groups: "servergroup"
ansible_connection: ssh
ansible_host: "{{ item }}"
ansible_port: 22
{% for element in extra_vars %}
{{ "element.key": "element.value" }}
{% endfor %}
with_items:
- "
host1.com"
- "
host2.com"
- "
host4.com"
I hope you could understand my intention.
With nested loops I wasn’t successful. Maybe there is a possibility with a combine filter?
Thank you.