this is the playbook

---
- name: test
  hosts: k8s
  vars:
    versions:
      4.2.5: false
      4.2.8: true
  tasks:
    - name: test
      lineinfile:
        path: /tmp/temp.txt
        regex: '^\s*#*\s*image: graylog/graylog{{ item.key }}\s*$'
        line: '{{ hash }}image: graylog/graylog{{ item.key }}'
      loop: "{{ versions|dict2items }}"
      vars:
        hash: "{{ item.value|ternary('', '#') }}"

On Thu, May 5, 2022 at 7:21 PM Tony Wong <[email protected]> wrote:

> it only works for first node. When i run the playbook against 3 nodes the
> 2nd and 3rd node have this
>
> image: graylog/graylog:4.2.5
> #image: graylog/graylog4.2.5
> image: graylog/graylog4.2.8
>
> On Thu, May 5, 2022 at 3:51 PM Vladimir Botka <[email protected]> wrote:
>
>> On Thu, 5 May 2022 10:03:02 -0700
>> Tony Wong <[email protected]> wrote:
>>
>> > I was abl to get my first node changed but the other 2 had this added
>> >
>> > image: gralog/graylog:4.2.5
>> > #image: graylog/graylog4.2.5
>> > image: graylog/graylog4.2.8
>>
>> 'y' is missing in 'gralog/graylog:4.2.5' in the first line. This is
>> the reason why the first line wasn't replaced. Instead, the second
>> line was added.
>>
>> --
>> Vladimir Botka
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALmkhkox-h9i3Z2u2EW9CHCfcsQC7xSSq-LRLa4t5zsz_PGRdg%40mail.gmail.com.

Reply via email to