Question:
Solution
In jump_host go to ansible folder and create a playbook.yml
cd ~/ansible/
vi playbook.yml
Change path and replace text according to question
---
- name: ansible-replace-module
hosts: all
become: true
tasks:
- name: Replace a String
replace:
path: /opt/itadmin/blog.txt
regexp: 'xFusionCorp'
replace: "Nautilus"
when: (ansible_user == "tony")
- name: Replace a String
replace:
path: /opt/itadmin/story.txt
regexp: 'Nautilus'
replace: "KodeKloud"
when: (ansible_user == "steve")
- name: Replace a String
replace:
path: /opt/itadmin/media.txt
regexp: 'KodeKloud'
replace: "xFusionCorp Industries"
when: (ansible_user == "banner")
Then run this command to execute
ansible-playbook -i inventory playbook.yml
0 comments:
Post a Comment