Я использую Ansible 2.9.4 и как-то при запуске следующего задания выдает ошибку escape:
sre_constants.error: bad escape \m at position 1
Любопытно, что это только сбой при итерации по \ m другие значения работают должным образом.
role / defaults / main.yml:
motd_deleted_options:
- "\\r"
- "\\s"
- "\\v"
- "\\m"
role / tasks / main.yml:
- name: task - 1.8.1.1 Ensure message of the day is configured properly (Scored)
lineinfile:
path: /etc/motd
regexp: "{{ item }}"
state: absent
loop: "{{ motd_deleted_options }}"
Задача состоит в том, чтобы делать то, что мне нужно, пока не достигнет "\ m", где в режиме отладки у меня есть:
[WARNING]: The loop variable 'item' is already in use. You should set the `loop_var` value in the `loop_control` option for the task to something else
to avoid variable collisions and unexpected behavior.
The full traceback is:
Traceback (most recent call last):
File "<stdin>", line 102, in <module>
File "<stdin>", line 94, in _ansiballz_main
File "<stdin>", line 40, in invoke_module
File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_lineinfile_payload_8kdh8sul/ansible_lineinfile_payload.zip/ansible/modules/files/lineinfile.py", line 573, in <module>
File "/tmp/ansible_lineinfile_payload_8kdh8sul/ansible_lineinfile_payload.zip/ansible/modules/files/lineinfile.py", line 569, in main
File "/tmp/ansible_lineinfile_payload_8kdh8sul/ansible_lineinfile_payload.zip/ansible/modules/files/lineinfile.py", line 471, in absent
File "/usr/lib64/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/usr/lib64/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib64/python3.6/sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/usr/lib64/python3.6/sre_parse.py", line 502, in _parse
code = _escape(source, this, state)
File "/usr/lib64/python3.6/sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \m at position 1
failed: [centos8] (item='\m') => changed=false
ansible_loop_var: item
item: '''\m'''
module_stderr: |-
Traceback (most recent call last):
File "<stdin>", line 102, in <module>
File "<stdin>", line 94, in _ansiballz_main
File "<stdin>", line 40, in invoke_module
File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_lineinfile_payload_8kdh8sul/ansible_lineinfile_payload.zip/ansible/modules/files/lineinfile.py", line 573, in <module>
File "/tmp/ansible_lineinfile_payload_8kdh8sul/ansible_lineinfile_payload.zip/ansible/modules/files/lineinfile.py", line 569, in main
File "/tmp/ansible_lineinfile_payload_8kdh8sul/ansible_lineinfile_payload.zip/ansible/modules/files/lineinfile.py", line 471, in absent
File "/usr/lib64/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/usr/lib64/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib64/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib64/python3.6/sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib64/python3.6/sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "/usr/lib64/python3.6/sre_parse.py", line 502, in _parse
code = _escape(source, this, state)
File "/usr/lib64/python3.6/sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \m at position 1
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
Любой совет будет оценен.