-
Notifications
You must be signed in to change notification settings - Fork 0
/
linux_srv.yml
69 lines (60 loc) · 1.67 KB
/
linux_srv.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
62
63
64
65
66
67
68
69
- name: Health check notifications
hosts: linux_srv, linux_virtualbox
become: true
vars:
ansible_ssh_user: "{{ user }}"
ansible_become_password: "{{ password }}"
tasks:
- name: Ensuring that required packages are installed
apt:
name:
- cowsay
- mailutils
- sendmail
state: present
- name: Enshuring sendmail service in enabled and running
service:
name: sendmail
state: started
enabled: true
- name: Copying health check script content
template:
src: health_check.sh.j2
dest: /usr/local/bin/health_check.sh
mode: 0744
owner: "{{ user }}"
group: "{{ user }}"
- name: Adding cron entry
template:
src: cron.j2
dest: /etc/cron.d/health_check
mode: 0644
- name: NTP client configuration
hosts: linux_srv, linux_virtualbox
become: true
vars:
ansible_ssh_user: "{{ user }}"
ansible_become_password: "{{ password }}"
tasks:
- name: Ensuring that ntpsec package is installed
apt:
name:
- ntpsec
state: present
- name: Comment out pool configuration lines
replace:
path: /etc/ntpsec/ntp.conf
regexp: '^(pool .*)$'
replace: '# \1'
register: ntp_conf_comment
- name: Insert server configuration line
lineinfile:
path: /etc/ntpsec/ntp.conf
line: server {{ ntp_server_address }}
state: present
register: ntp_conf_server
- name: Restart ntpsec.service
service:
name: ntpsec
state: restarted
when: ntp_conf_comment.changed or ntp_conf_server.changed