Browse Source

Merge pull request #138 from tilsammans/ntp

Make the ntp pool configurable
Luke Cyca 11 years ago
parent
commit
6c3cee70f2
4 changed files with 33 additions and 16 deletions
  1. 1
    11
      roles/common/tasks/main.yml
  2. 14
    0
      roles/common/tasks/ntp.yml
  3. 4
    5
      roles/common/templates/ntp.conf.j2
  4. 14
    0
      vars/defaults.yml

+ 1
- 11
roles/common/tasks/main.yml View File

32
   apt: pkg=unattended-upgrades state=installed
32
   apt: pkg=unattended-upgrades state=installed
33
   when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
33
   when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
34
 
34
 
35
-- name: Install ntp
36
-  apt: pkg=ntp state=installed
37
-
38
-- name: Configure ntp
39
-  template: src=ntp.conf.j2 dest=/etc/ntp.conf
40
-  notify:
41
-    - restart ntp
42
-
43
 - name: Apticron email configuration
35
 - name: Apticron email configuration
44
   template: src=apticron.conf.j2 dest=/etc/apticron/apticron.conf
36
   template: src=apticron.conf.j2 dest=/etc/apticron/apticron.conf
45
 
37
 
46
-- name: Ensure ntpd is running and enabled
47
-  service: name=ntp state=started enabled=yes
48
-
49
 - name: Disable default Apache site
38
 - name: Disable default Apache site
50
   command: a2dissite 000-default removes=/etc/apache2/sites-enabled/000-default
39
   command: a2dissite 000-default removes=/etc/apache2/sites-enabled/000-default
51
   notify: restart apache
40
   notify: restart apache
59
 - include: ssl.yml tags=ssl
48
 - include: ssl.yml tags=ssl
60
 - include: ufw.yml tags=ufw
49
 - include: ufw.yml tags=ufw
61
 - include: security.yml tags=security
50
 - include: security.yml tags=security
51
+- include: ntp.yml tags=ntp

+ 14
- 0
roles/common/tasks/ntp.yml View File

1
+---
2
+# Defines tasks applicable for NTP (Network Time Protocol)
3
+
4
+- name: Install ntp
5
+  apt: pkg=ntp state=installed
6
+
7
+- name: Configure ntp
8
+  template: src=ntp.conf.j2 dest=/etc/ntp.conf
9
+  notify:
10
+    - restart ntp
11
+
12
+- name: Ensure ntpd is running and enabled
13
+  service: name=ntp state=started enabled=yes
14
+

+ 4
- 5
roles/common/templates/ntp.conf.j2 View File

10
 filegen peerstats file peerstats type day enable
10
 filegen peerstats file peerstats type day enable
11
 filegen clockstats file clockstats type day enable
11
 filegen clockstats file clockstats type day enable
12
 
12
 
13
-# Use servers from the NTP Pool Project
14
-server 0.north-america.pool.ntp.org
15
-server 1.north-america.pool.ntp.org
16
-server 2.north-america.pool.ntp.org
17
-server 3.north-america.pool.ntp.org
13
+# Use servers configured via Ansible
14
+{% for server in ntp_servers %}
15
+server {{ server }}
16
+{% endfor %}
18
 
17
 
19
 # fallback
18
 # fallback
20
 server tick.usno.navy.mil
19
 server tick.usno.navy.mil

+ 14
- 0
vars/defaults.yml View File

12
 friendly_networks:
12
 friendly_networks:
13
   - ""
13
   - ""
14
 
14
 
15
+# ntp
16
+ntp_servers:
17
+  # use nearby ntp servers by default
18
+  - 0.pool.ntp.org
19
+  - 1.pool.ntp.org
20
+  - 2.pool.ntp.org
21
+  - 3.pool.ntp.org
22
+  # use servers tailored to the server location
23
+  # See http://www.pool.ntp.org/en/use.html
24
+  # - 0.north-america.pool.ntp.org
25
+  # - 1.north-america.pool.ntp.org
26
+  # - 2.north-america.pool.ntp.org
27
+  # - 3.north-america.pool.ntp.org
28
+
15
 # database
29
 # database
16
 db_admin_username: 'postgres'
30
 db_admin_username: 'postgres'
17
 # db_admin_password: (required)
31
 # db_admin_password: (required)

Loading…
Cancel
Save