I have the following task, which appears to execute successfully, but I end 
up with only one block (the last), while I actually want to have a block 
for each item entered into my file. How do I do that?

task:

  - name: configure dns zone SRV records
    delegate_to: 127.0.0.1
    blockinfile:
      dest: /home/ansible/env/playbooks/vars/bind.yml
      state: present
      backup: yes
      insertafter: '^bind_zone_services:.*'
      marker: "# {mark} ANSIBLE MANAGED SRV BLOCK"
      block: |
             - name: "{{ item.name }}"
               weight: 100
               port: "{{ item.port }}"
               target: "{{ ansible_hostname }}"
    with_items:
      - { name: _ldap._tcp, port: 389 }
      - { name: _kerberos._tcp, port: 88 }
      - { name: _kerberos._udp, port: 88 }
      - { name: _kerberos-master._tcp, port: 88 }
      - { name: _kerberos-master._udp, port: 88 }
      - { name: _kpasswd._tcp, port: 464 }
      - { name: _kpasswd._udp, port: 464 }
      - { name: _ntp._udp, port: 123 }
 


Result
  - name: _ntp._udp
    weight: 100
    port: 123
    target: hostname

-- 
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/46faa4a1-cb8d-45f9-bd84-8c42a6a85bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to