however this worked though
- name: comment line
lineinfile:
backup: no
backrefs: yes
state: present
path: "{{ file_path }}"
regexp: '^(\s*)[#]?{{ item.search }}(: )*'
line: '\1{{ item.replace }}'
with_items:
- { search: "{{ line.line_to_replace }}", replace: "{{ line.replace_with
}}" }
On Thursday, July 14, 2022 at 1:36:06 PM UTC-7 Tony Wong wrote:
> failed: [xxxxxxxx] (item={'search': '#image: graylog/graylog:4.3.2',
> 'add': 'image: graylog/graylog:4.3.3'}) => {
> "ansible_loop_var": "item",
> "changed": false,
> "item": {
> "add": "image: graylog/graylog:4.3.3",
> "search": "#image: graylog/graylog:4.3.2"
> },
> "module_stderr": "Shared connection to xxxxx closed.\r\n",
> "module_stdout": "\r\nTraceback (most recent call last):\r\n File
> \"/home/twong/.ansible/tmp/ansible-tmp-1657826370.868146-3737-103625139036728/AnsiballZ_lineinfile.py\",
>
> line 102, in <module>\r\n _ansiballz_main()\r\n File
> \"/home/twong/.ansible/tmp/ansible-tmp-1657826370.868146-3737-103625139036728/AnsiballZ_lineinfile.py\",
>
> line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path,
> ANSIBALLZ_PARAMS)\r\n File
> \"/home/twong/.ansible/tmp/ansible-tmp-1657826370.868146-3737-103625139036728/AnsiballZ_lineinfile.py\",
>
> line 40, in invoke_module\r\n
> runpy.run_module(mod_name='ansible.modules.lineinfile', init_globals=None,
> run_name='__main__', alter_sys=True)\r\n File
> \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n fname,
> loader, pkg_name)\r\n File \"/usr/lib64/python2.7/runpy.py\", line 82, in
> _run_module_code\r\n mod_name, mod_fname, mod_loader, pkg_name)\r\n
> File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n exec
> code in run_globals\r\n File
> \"/tmp/ansible_lineinfile_payload_oqguHr/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py\",
>
> line 577, in <module>\r\n File
> \"/tmp/ansible_lineinfile_payload_oqguHr/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py\",
>
> line 568, in main\r\n File
> \"/tmp/ansible_lineinfile_payload_oqguHr/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py\",
>
> line 342, in present\r\n File \"/usr/lib64/python2.7/re.py\", line 266, in
> _expand\r\n return sre_parse.expand_template(template, match)\r\n File
> \"/usr/lib64/python2.7/sre_parse.py\", line 800, in expand_template\r\n
> raise error, \"unmatched group\"\r\nsre_constants.error: unmatched
> group\r\n",
> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
>
>
>
> -----------
>
> playbook task
>
> - name: add line
> lineinfile:
> backup: no
> backrefs: yes
> state: present
> path: "{{ file_path }}"
> regexp: '^(\s*)[#]?{{ item.search }}(: )*'
> line: '\1{{ item.search }}\2\n\1{{ item.add }}'
> with_items:
> - { search: "{{ line.replace_with }}", add: "{{ line.line_to_add }}" }
>
> On Thursday, July 14, 2022 at 12:58:22 PM UTC-7 Antony Stone wrote:
>
>> On Thursday 14 July 2022 at 21:27:43, Tony Wong wrote:
>>
>> > any idea why?
>>
>> No.
>>
>> Give us more context, and we might have a clue.
>>
>> Antony.
>>
>> --
>> "Once you have a panic, things tend to become rather undefined."
>>
>> - murble
>>
>> Please reply to the list;
>> please *don't* CC me.
>>
>
--
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/0a83ed84-4db1-439f-9eb8-adf70e47ef75n%40googlegroups.com.