I have used replace model in ansible play book to replace string from “/var/app/test/abc/80526” to “/var/app/test/abc/80528” in directory, searching inside the directory /var/app/test
Directory name:- /var/app/test
In above directory we have multiple folders which contain different file need to search for all the files and replace “/var/app/test/abc/80526” to “/var/app/test/abc/80528” in all the files.
Error which I am facing: – When I have tried the below code getting error as /var/app/test is a directory.
below values we are passing through parm `your text`
/var/app=inst_path
test=inst_name
oldver=80526
new_version=80528
- name: Replace the 80526 configuration path with 80528 Configuration path
ansible.builtin.replace:
path: "{{ inst_path }}/{{ inst_name }}"
regexp: "{{ inst_path }}/{{ inst_name }}/abc/{{ old_version }}"
replace: "{{ inst_path }}/{{ inst_name }}/abc/{{ new_version }}"
getting error as /var/app/test is directory.
need to replace /var/app/test/abc/80526 to /var/app/test/abc/80528 in all the files inside directory
Sachin B M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.