Browse Source

Merge pull request #138 from tilsammans/ntp

Make the ntp pool configurable
Luke Cyca 10 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,20 +32,9 @@
32 32
   apt: pkg=unattended-upgrades state=installed
33 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 35
 - name: Apticron email configuration
44 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 38
 - name: Disable default Apache site
50 39
   command: a2dissite 000-default removes=/etc/apache2/sites-enabled/000-default
51 40
   notify: restart apache
@@ -59,3 +48,4 @@
59 48
 - include: ssl.yml tags=ssl
60 49
 - include: ufw.yml tags=ufw
61 50
 - include: security.yml tags=security
51
+- include: ntp.yml tags=ntp

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

@@ -0,0 +1,14 @@
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,11 +10,10 @@ filegen loopstats file loopstats type day enable
10 10
 filegen peerstats file peerstats type day enable
11 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 18
 # fallback
20 19
 server tick.usno.navy.mil

+ 14
- 0
vars/defaults.yml View File

@@ -12,6 +12,20 @@ admin_email: "{{ main_user_name }}@{{ domain }}"
12 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 29
 # database
16 30
 db_admin_username: 'postgres'
17 31
 # db_admin_password: (required)

Loading…
Cancel
Save