From c3dd45ed821f16f41d0d121607220a6db6df780b Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Sat, 27 May 2017 21:44:37 +0200 Subject: [PATCH] Add common Ansible role --- operations/common/tasks/apt.yml | 36 ++++++++++++++++++++++++++++++++ operations/common/tasks/main.yml | 13 ++++++++++++ operations/common/tasks/time.yml | 26 +++++++++++++++++++++++ operations/common/tasks/util.yml | 15 +++++++++++++ operations/tracker.yml | 9 ++++++++ 5 files changed, 99 insertions(+) create mode 100644 operations/common/tasks/apt.yml create mode 100644 operations/common/tasks/main.yml create mode 100644 operations/common/tasks/time.yml create mode 100644 operations/common/tasks/util.yml create mode 100644 operations/tracker.yml diff --git a/operations/common/tasks/apt.yml b/operations/common/tasks/apt.yml new file mode 100644 index 0000000..4eabd63 --- /dev/null +++ b/operations/common/tasks/apt.yml @@ -0,0 +1,36 @@ +--- +# +# Installs upgrades and configures package manager. +# + +- name: Upgrade packages + apt: + update_cache: yes + upgrade: dist + register: result + +- name: Update GRUB + command: update-grub + environment: + UCF_FORCE_CONFFNEW: YES + when: result | changed + +- name: Install Debian utilities + apt: + name: "{{ item }}" + state: present + with_items: + - debconf-utils + - unattended-upgrades + +- name: Enable unattended upgrades + debconf: + name: unattended-upgrades + question: unattended-upgrades/enable_auto_updates + vtype: boolean + value: "true" + register: result + +- name: Reconfigure unattended upgrades + command: dpkg-reconfigure -f noninteractive unattended-upgrades + when: result | changed diff --git a/operations/common/tasks/main.yml b/operations/common/tasks/main.yml new file mode 100644 index 0000000..aa40069 --- /dev/null +++ b/operations/common/tasks/main.yml @@ -0,0 +1,13 @@ +--- +# +# Common tasks. +# + +- name: Configure packages + include: apt.yml + +- name: Configure time + include: time.yml + +- name: Configure utilities + include: util.yml diff --git a/operations/common/tasks/time.yml b/operations/common/tasks/time.yml new file mode 100644 index 0000000..d948524 --- /dev/null +++ b/operations/common/tasks/time.yml @@ -0,0 +1,26 @@ +--- +# +# Configures time and synchronization. +# + +- name: Set timezone to Etc/UTC + file: + src: /usr/share/zoneinfo/Etc/UTC + dest: /etc/timezone + force: yes + state: link + register: result + +- name: Reconfigure tzdata + command: dpkg-reconfigure -f noninterractive tzdata + when: result | changed + +- name: Install NTP daemon + apt: + name: ntp + state: present + +- name: Start NTP daemon + service: + name: ntp + state: started diff --git a/operations/common/tasks/util.yml b/operations/common/tasks/util.yml new file mode 100644 index 0000000..72e06b0 --- /dev/null +++ b/operations/common/tasks/util.yml @@ -0,0 +1,15 @@ +--- +# +# Installs common utilities. +# + +- name: Install utilities + apt: + name: "{{ item }}" + state: present + with_items: + - bmon + - htop + - iotop + - screen + - vim diff --git a/operations/tracker.yml b/operations/tracker.yml new file mode 100644 index 0000000..b979773 --- /dev/null +++ b/operations/tracker.yml @@ -0,0 +1,9 @@ +--- +# +# Configures trackers. +# + +- name: Tracker + hosts: trackers + roles: + - common