Ansible replace module

@player001 Getting this error while running the playbook. Plz let me know what i am doing wrong while writing replace module.

Hello, @pratikshag
You have defined “when” condition is wrong place. It’s not a part of replace module. It should be like

- name: replace
  replace:
     path: ...
     ....
  when: <condition>

Hope it will help,

1 Like

Getting different error now.

Hello, @pratikshag
I thought you will catch that error that’s why not commented in the previous post. First thing is you are running this playbook in the targeted server as a normal user so you should have to mention become: yes condition.
Second thing is, In your when condition, after double equals (==) double quotes has an issue, that’s not as per playbook standard.
Please apply both changes and try again.

1 Like

@player001… Corrected all the errors and got the desired output. But instaead of replacing “xfusioncorp industries” , i replaced only “xfusioncorp” . Task failed . Thanks for the support.

1 Like

@player001
Hi Tej, Pratiksha,





let me know what’s wrong with my script?
thanks
Swaroop

fixed it!






thank you Pratiksha and Tej!!

Hello People


I don’t under stand why it got failed all was right I had created the playbook yet it says that playbook was not found on that specified path . Please help @Inderpreet @kodekloud-support3

@akshayyw It seems that you have mispelled the playbook.yml as playboook.yml

2 Likes