From bd6c3d307ae1d257ffff0ad8101cccb1306a0f39 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sat, 16 Mar 2019 20:35:27 +0000 Subject: [PATCH] Add the rest of the common role --- roles/common/defaults/main.yaml | 8 ++++++++ roles/common/handlers/main.yaml | 12 ++++++++++++ roles/common/tasks/main.yaml | 18 ++++++++++++++++++ roles/common/templates/resolv.conf.j2 | 8 ++++++++ roles/common/vars/Ubuntu-18.yaml | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 roles/common/defaults/main.yaml create mode 100644 roles/common/handlers/main.yaml create mode 100644 roles/common/templates/resolv.conf.j2 create mode 100644 roles/common/vars/Ubuntu-18.yaml diff --git a/roles/common/defaults/main.yaml b/roles/common/defaults/main.yaml new file mode 100644 index 0000000..04999fb --- /dev/null +++ b/roles/common/defaults/main.yaml @@ -0,0 +1,8 @@ +--- +cron_service_name: cron + +resolv_nameserver: [] +resolv_options: + - edns0 + +timezone: UTC diff --git a/roles/common/handlers/main.yaml b/roles/common/handlers/main.yaml new file mode 100644 index 0000000..e65a3d2 --- /dev/null +++ b/roles/common/handlers/main.yaml @@ -0,0 +1,12 @@ +--- +- name: "restart resolv" + service: + name: "{{ resolv_service_name }}" + state: restarted + when: resolv_service_name is defined + +- name: restart cron + service: + name: "{{ cron_service_name }}" + state: restarted + when: cron_service_name is defined diff --git a/roles/common/tasks/main.yaml b/roles/common/tasks/main.yaml index 7ce8944..823c1b4 100644 --- a/roles/common/tasks/main.yaml +++ b/roles/common/tasks/main.yaml @@ -1,6 +1,24 @@ --- +- name: gather OS specific variables + include_vars: "{{ item }} " + with_first_found: + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml" + - "{{ ansible_distribution }}.yaml" + - "{{ ansible_os_family }}.yaml" + - name: install system utilities package: name: "{{ item }}" state: present with_items: "{{ sys_utils }}" + +- name: configure resolv.conf + template: + src: resolv.conf.j2 + dest: /etc/resolv.conf + notify: "restart resolv" + +- name: configure system timezone + timezone: + name: "{{ timezone }}" + notify: restart cron diff --git a/roles/common/templates/resolv.conf.j2 b/roles/common/templates/resolv.conf.j2 new file mode 100644 index 0000000..f737c25 --- /dev/null +++ b/roles/common/templates/resolv.conf.j2 @@ -0,0 +1,8 @@ +# {{ ansible_managed }} + +{% for ns in resolv_nameserver %} +nameserver {{ ns }} +{% endfor %} +{% if resolv_options is defined %} +options {{ resolv_options | join(' ') }} +{% endif %} diff --git a/roles/common/vars/Ubuntu-18.yaml b/roles/common/vars/Ubuntu-18.yaml new file mode 100644 index 0000000..294ca73 --- /dev/null +++ b/roles/common/vars/Ubuntu-18.yaml @@ -0,0 +1,2 @@ +--- +resolv_service_name: systemd-resolved.service