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.


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c0fb0baf-fce0-4d2d-8054-afc65fe98cdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to