From 42ba49c8651083f25bf074e401cf5e33f64d8470 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Thu, 1 Sep 2022 17:12:52 -0500 Subject: [PATCH] common: refactor --- roles/common/defaults/main.yaml | 10 +++++----- roles/common/handlers/main.yaml | 7 ++----- roles/common/tasks/Debian.yaml | 6 +++--- roles/common/tasks/main.yaml | 13 +++++++++---- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/roles/common/defaults/main.yaml b/roles/common/defaults/main.yaml index 0174e31..782f43c 100644 --- a/roles/common/defaults/main.yaml +++ b/roles/common/defaults/main.yaml @@ -1,6 +1,6 @@ --- -cron_service_name: cron - -timezone: UTC - -# vim:ft=yaml.ansible: +# common_cron_service_name: cron.service +# common_timezone: Etc/UTC +# common_locale: C.UTF-8 +# common_apt_update_cache: true +# common_apt_cache_valid_time: 3600 diff --git a/roles/common/handlers/main.yaml b/roles/common/handlers/main.yaml index 3f2d994..ee41b27 100644 --- a/roles/common/handlers/main.yaml +++ b/roles/common/handlers/main.yaml @@ -1,8 +1,5 @@ --- - name: restart cron - service: - name: "{{ cron_service_name }}" + ansible.builtin.service: + name: "{{ common_cron_service_name | default('cron.service') }}" state: restarted - when: cron_service_name is defined - -# vim:ft=yaml.ansible: diff --git a/roles/common/tasks/Debian.yaml b/roles/common/tasks/Debian.yaml index e84f83a..c23596a 100644 --- a/roles/common/tasks/Debian.yaml +++ b/roles/common/tasks/Debian.yaml @@ -1,6 +1,6 @@ --- - name: run apt-get update - apt: - update_cache: yes - cache_valid_time: 3600 + ansible.builtin.apt: + update_cache: "{{ common_apt_update_cache | default(true) }}" + cache_valid_time: "{{ common_apt_cache_valid_time | default(3600) }}" changed_when: false diff --git a/roles/common/tasks/main.yaml b/roles/common/tasks/main.yaml index 0132525..f85a457 100644 --- a/roles/common/tasks/main.yaml +++ b/roles/common/tasks/main.yaml @@ -24,12 +24,17 @@ - tasks - name: set hostname - hostname: - name: "{{ hostname | default(inventory_hostname) }}" + ansible.builtin.hostname: + name: "{{ common_hostname | default(inventory_hostname) }}" - name: configure system timezone - timezone: - name: "{{ timezone }}" + ansible.builtin.timezone: + name: "{{ common_timezone | default('Etc/UTC') }}" notify: restart cron +- name: configure system locale + ansible.builtin.command: + cmd: "localectl set-locale {{ common_locale | default('C.UTF-8') }}" + when: ansible_facts.env.LANG != (common_locale | default('C.UTF-8')) + # vim:ft=yaml.ansible: