Got it, thanks!

On Wed, May 4, 2022 at 3:13 PM Vladimir Botka <[email protected]> wrote:

> See the complete example below
>
> shell> cat docker-compose
> image: graylog/graylog4.2.5
>
>
> shell> cat pb.yml
> ---
> - hosts: localhost
>   vars:
>     versions:
>       4.2.5: false
>       4.2.8: true
>   tasks:
>     - lineinfile:
>         path: docker-compose
>         regex: '^\s*#*\s*image: graylog/graylog{{ item.key }}\s*$'
>         line: '{{ hash }}image: graylog/graylog{{ item.key }}'
>       loop: "{{ versions|dict2items }}"
>       vars:
>         hash: "{{ item.value|ternary('', '#') }}"
>
>
> shell> ansible-playbook pb.yml
>
> PLAY [localhost]
> ***************************************************************
>
> TASK [lineinfile]
> ***************************************************************
> changed: [localhost] => (item={'key': '4.2.5', 'value': False})
> changed: [localhost] => (item={'key': '4.2.8', 'value': True})
>
> PLAY RECAP
> ***************************************************************
> localhost: ok=1    changed=1    unreachable=0
> failed=0    skipped=0    rescued=0    ignored=0
>
>
> shell> cat docker-compose
> #image: graylog/graylog4.2.5
> image: graylog/graylog4.2.8
>
>
> --
> 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/CALmkhkpbF-HnvHLaOVE_fnF6JkwngdX2vKjSWLCou9YEArEGxA%40mail.gmail.com.

Reply via email to