-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace_text.yml
61 lines (50 loc) · 2.32 KB
/
replace_text.yml
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
# Purpose: Replace ALL of the 3 different scenarios of incorrect text written to the /etc/issue, /etc/issue.net, and /etc/motd as well as fixing /etc/hosts and the /etc/sysconfig/network-scripts/ifcfg-ens192 configuration.
# Note: The copy module worked best here because it overwrites the file outright with the content you want. It doesn't care what text was in the file originally. This solved the scenario of having 3 differents sets of text in 3 different files.
- name: Replace text
hosts: all
gather_facts: no
tasks:
- name: replace the text of the file
copy:
content: "{{ agency }}'s systems must only be used for conducting {{ agency }}'s business or for purposes authorized by management."
dest: /etc/issue
- name: replace the text of the file
copy:
content: "{{ agency }}'s systems must only be used for conducting {{ agency }}'s business or for purposes authorized by management."
dest: /etc/issue.net
- name: replace the text of the file
copy:
content: "{{ agency }}'s systems must only be used for conducting {{ agency }}'s business or for purposes authorized by management."
dest: /etc/motd
# Match characters below in each line of file
- name: replace the text ABCDE with the agency acronynm
replace:
path: /etc/hosts
regexp: ABCDE.NA.NAV
replace: "{{ domain }}"
- name: replace the text Peer_DNS=yes to Peer_DNS=no
replace:
path: /etc/sysconfig/network-scripts/ifcfg-ens192
regexp: '^PEERDNS=yes'
replace: 'PEERDNS=no'
- name: delete Domain= line if found in /etc/sysconfig/network-scripts/ifcfg-ens192
lineinfile:
path: /etc/sysconfig/network-scripts/ifcfg-ens192
regexp: '^DOMAIN='
state: absent
- name: delete DNS1 line if found in /etc/sysconfig/network-scripts/ifcfg-ens192
lineinfile:
path: /etc/sysconfig/network-scripts/ifcfg-ens192
regexp: '^DNS1='
state: absent
- name: delete DNS2= line if found in /etc/sysconfig/network-scripts/ifcfg-ens192
lineinfile:
path: /etc/sysconfig/network-scripts/ifcfg-ens192
regexp: '^DNS2='
state: absent
- name: delete DNS3= line if found in /etc/sysconfig/network-scripts/ifcfg-ens192
lineinfile:
path: /etc/sysconfig/network-scripts/ifcfg-ens192
regexp: '^DNS3='
state: absent