forked from ntheanh201/kodekloud-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution-sed.yaml
33 lines (31 loc) · 890 Bytes
/
solution-sed.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
- hosts: nautilus_app3
gather_facts: false
become: true
vars:
src_file: /home/BSD.txt
del_file: /home/BSD_DELETE.txt
del_word: software
rep_file: /home/BSD_REPLACE.txt
rep_src_word: the
rep_dest_word: for
tasks:
- name: Copy {{ src_file }} to {{ del_file }}
copy:
remote_src: true
src: "{{ src_file }}"
dest: "{{ del_file }}"
- name: Delete all lines contain {{ del_word }}
lineinfile:
path: "{{ del_file }}"
state: absent
regexp: "{{ del_word }}"
- name: Copy {{ src_file }} to {{ rep_file }}
copy:
remote_src: true
src: "{{ src_file }}"
dest: "{{ rep_file }}"
- name: Replace all {{ rep_src_word }} to {{ rep_dest_word }}
replace:
path: "{{ rep_file }}"
regexp: '\b{{ rep_src_word }}\b'
replace: "{{ rep_dest_word }}"