-
Notifications
You must be signed in to change notification settings - Fork 1
/
RHEL7x_Install-NTP-Services-playbook.yml
75 lines (58 loc) · 2.21 KB
/
RHEL7x_Install-NTP-Services-playbook.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
70
71
72
73
74
75
---
################################################################################
# description: Installs NTP Services on RHEL7x
# usage: ansible-playbook RHEL7x_Install-NTP-Services-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# author: Ernest G. Wilson II <ErnestGWilsonII@gmail.com> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Install NTP Services on RHEL7x
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Install yum packages
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
- name: Install ntp (ntpd) package
yum:
name=ntp
state=present
# Restart firewalld to make sure it is running OK before changing any rules
# REF: http://docs.ansible.com/ansible/service_module.html
###########################################################################
- name: Ensure the firewalld service is enabled and re-started before changing any rules
service:
name=firewalld
enabled=yes
state=restarted
# Update the firewalld configuration
# REF: http://docs.ansible.com/ansible/firewalld_module.html
############################################################
- name: Update firewall to allow port TCP 123 ntpd connections
firewalld:
port=123/tcp
permanent=true
immediate=yes
state=enabled
zone=public
- name: Update firewall to allow port UDP 123 ntpd connections
firewalld:
port=123/udp
permanent=true
immediate=yes
state=enabled
zone=public
# Enable and start services
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Enable and start the ntpd service
service:
name=ntpd
enabled=yes
state=restarted
# Command line verification:
# systemctl status ntpd
# ntpq -p