Selaa lähdekoodia

Use common_timezone and fix idempotence

Thanks-to: 8e693b3db3
Laurent Arnoud 9 vuotta sitten
vanhempi
commit
dfb1b764d7
No account linked to committer's email address
4 muutettua tiedostoa jossa 16 lisäystä ja 6 poistoa
  1. 13
    6
      roles/common/tasks/main.yml
  2. 1
    0
      vars/defaults.yml
  3. 1
    0
      vars/testing.yml
  4. 1
    0
      vars/user.yml

+ 13
- 6
roles/common/tasks/main.yml Näytä tiedosto

@@ -41,15 +41,22 @@
41 41
   tags:
42 42
     - dependencies
43 43
 
44
-- name: Set timezone to UTC
45
-  action: shell echo Etc/UTC > /etc/timezone
44
+- name: timezone - configure /etc/timezone
45
+  copy:
46
+    content: "{{ common_timezone | regex_replace('$', '\n') }}"
47
+    dest: /etc/timezone
48
+    owner: root
49
+    group: root
50
+    mode: 0644
51
+  register: common_timezone_config
46 52
 
47
-- name: Set localtime to UTC
53
+- name: timezone - Set localtime to UTC
48 54
   file: src=/usr/share/zoneinfo/Etc/UTC dest=/etc/localtime
55
+  when: common_timezone_config.changed
49 56
 
50
-- name: Reconfigure tzdata
51
-  action: command dpkg-reconfigure -f noninteractive tzdata
52
-  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
57
+- name: timezone - reconfigure tzdata
58
+  command: dpkg-reconfigure --frontend noninteractive tzdata
59
+  when: common_timezone_config.changed
53 60
 
54 61
 - name: Apticron email configuration
55 62
   template: src=apticron.conf.j2 dest=/etc/apticron/apticron.conf

+ 1
- 0
vars/defaults.yml Näytä tiedosto

@@ -5,6 +5,7 @@
5 5
 ###############################################################################
6 6
 
7 7
 # # common
8
+# common_timezone: 'Etc/UTC' (required)
8 9
 # domain: (required)
9 10
 # main_user_name: (required)
10 11
 admin_email: "{{ main_user_name }}@{{ domain }}"

+ 1
- 0
vars/testing.yml Näytä tiedosto

@@ -5,6 +5,7 @@
5 5
 ###############################################################################
6 6
 
7 7
 # common
8
+common_timezone: 'Etc/UTC'
8 9
 domain: sovereign.local
9 10
 main_user_name: sovereign
10 11
 encfs_password: testPassword

+ 1
- 0
vars/user.yml Näytä tiedosto

@@ -5,6 +5,7 @@
5 5
 ###############################################################################
6 6
 
7 7
 # common
8
+common_timezone: 'Etc/UTC'
8 9
 domain: TODO.com
9 10
 main_user_name: TODO
10 11
 encfs_password: TODO    # NOTE: must not contain dollar sign characters '$'

Loading…
Peruuta
Tallenna