Yup, that worked. However, the blocks don't apply/respect indentation,
which is another problem.
On Tuesday, May 31, 2016 at 12:54:59 PM UTC-5, Joanna Delaporte wrote:
>
> I just realized the last example on the blockinfile page will probably
> help me. Each "ANSIBLE MANAGED BLOCK" statement needs a unique name,
> apparently.
>
> On Tuesday, May 31, 2016 at 12:50:29 PM UTC-5, Joanna Delaporte wrote:
>>
>> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/db936d5e-5ad6-45ae-8cba-6770abe40516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.