On Tue, 3 May 2022 10:10:06 -0700 (PDT)
Tony Wong <[email protected]> wrote:

> comment out a line in a docker-compose 
> file and add a line
> 
> #image: gralog/graylog:4.2.5
> image: graylog/graylog4.2.8

I assume, the expected result is below. If not confirm your example
and ignore the rest here

#image: graylog/graylog4.2.5
image: graylog/graylog4.2.8

For example, create a dictionary of the disabled and enabled versions

    versions:
      4.2.5: false
      4.2.8: true

Then the *lineinfile* task below should comment out disabled versions
and add enabled versions

    - 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('', '#') }}"

-- 
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/20220503205202.09a18e56%40gmail.com.

Attachment: pgpfzHTAxIdA9.pgp
Description: OpenPGP digital signature

Reply via email to