I'm really new to Ansible but I have a situation with replace module.
I tried my regex online https://regex101.com/ and it worked.
Then I tried the regex in my Ansible but it's not working. I also tried to use lineInFile module. Guess I'm somehow still thinking old way and not the right Ansible way. Therefore I'm not able to put this together.
- name: Update the CMakeLists, add -latomic
replace:
path: /home/{{ device_user }}/ros2_{{ ros2_distro }}/src/ros2/rcutils/CMakeLists.txt
regexp: '^\s+target_link_libraries\(test_atomics_executable\s+\${PROJECT_NAME}'
replace: '^\s+target_link_libraries\(test_atomics_executable\s+\${PROJECT_NAME} -latomic\)'
Those lines produces:
The error was: re.error: bad escape \s at position 1
I don't know why is that since the regex is ok, isn't it? I'm trying to find exact match I know that there is only one line such as this.
The CMakeLists.txt where I'm trying to do my changes:
...
target_link_libraries(test_atomics_executable ${PROJECT_NAME})
if(HAVE_LIBATOMICS)
target_link_libraries(test_atomics_executable atomic)
endif()
add_test(NAME test_atomics COMMAND test_atomics_executable)
...
Could you please tell me what I doing wrong? (Please don't bother to just link the docs I have been already there and I tried to read it.)