Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Vladimir Botka
Quoting from *lineinfile* parameter *regexp* https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html#parameter-regexp For state=present, the pattern to replace if found. Only the last line found will be replaced. Thank you! On Fri, 6 May 2022 13:54:20 -0700

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Nico Kadel-Garcia
On Fri, May 6, 2022 at 4:36 PM Tony Wong wrote: > > does this mean I cannot keep the old commented line? > > #image: graylog/graylog4.2.5 It's tricky. You can write scripting to do anything you want to do, but it's not necessarily built-in precisely the way you want it to behave. It's why many c

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Todd Lewis
Assuming you only have one line for each version, it will assure that the line for any version that's marked false will be commented, and any line for a version marked true will be uncommented. Where it gets hairy is when you have more than one line for any version. In that case, the second tas

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Tony Wong
does this mean I cannot keep the old commented line? #image: graylog/graylog4.2.5 requirement is I need to have this line commented On Thu, May 5, 2022 at 9:50 PM Vladimir Botka wrote: > > shell> cat pb.yml > > - hosts: localhost > > vars: > > versions: > > 4.2.5: false > > 4

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread dulhaver via Ansible Project
On 06.05.22 14:52, Tony Wong wrote: is there docker module or I should just use shell module? I believe it's always better to use designated Modules over shell or command that said ... you may want to get familiar (or at least be aware of this list

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Tony Wong
I have another requirement to down the container on node01 first docker-compose down then run the pb, then docker-compose up -d wait 30secs or so repeat with node02 repeat with node03 is there docker module or I should just use shell module? On Fri, May 6, 2022 at 5:48 AM Tony Wong wrote: >

Re: [ansible-project] playbook to comment out one line and add another line in a file

2022-05-06 Thread Tony Wong
i got it to work the simple way with multiple tasks --- - name: test hosts: k8s tasks: - name: comment line lineinfile: line: "#image: graylog/graylog4.2.5" regexp: '^image:\sgraylog/graylog4.2.5' path: /tmp/temp2.txt - name: add line lineinfile: