From 9f3d91bd1c1eb2f7eb85268654c92d047cdf1cb0 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Sat, 23 Jul 2022 22:03:41 +0200 Subject: [PATCH 1/3] readme: Remove host list This list has proven to be hard to maintain (not because it is especially difficult, but people simply tend to forget it). So we give some hints instead now and avoid duplicate information. Suggested-by: Stefan Haun References: !55 --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ddb7317..2b3758a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,10 @@ # Ansible configuration for the Netz39 infrastructure -Currently including the following hosts: +This call lists all hosts defined in the inventory: -* tau.netz39.de -* pottwal.n39.eu -* unicorn.n39.eu -* platon.n39.eu -* radon.n39.eu -* krypton.n39.eu -* oganesson.n39.eu +```bash +ansible -i inventory.yml all --list-hosts +``` ## Setup ```bash From e29311c4ed3cc2f03507c3bc7f3bcf5c0ac92a70 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Sat, 23 Jul 2022 22:15:39 +0200 Subject: [PATCH 2/3] Move tasks for all hosts to separate file When working on !54 it became obvious playbooks could be structured better in this project. Therefor we move the tasks supposed to be run for _all_ hosts to a separate file. The *main.yml* file should only import other playbooks from now on, should not define tasks anymore. --- all.yml | 38 ++++++++++++++++++++++++++++++++++++++ main.yml | 37 +++---------------------------------- 2 files changed, 41 insertions(+), 34 deletions(-) create mode 100644 all.yml diff --git a/all.yml b/all.yml new file mode 100644 index 0000000..3d14478 --- /dev/null +++ b/all.yml @@ -0,0 +1,38 @@ +--- +# tasks for all hosts + +- hosts: all + become: true + + vars: + ansible_python_interpreter: /usr/bin/python3 + + roles: + - role: ansible.timezone + + tasks: + - name: Update and clean package cache + apt: + update_cache: true + cache_valid_time: 3600 + autoclean: true + changed_when: false + + - name: Ensure unattended-upgrades is installed and up to date + apt: + name: unattended-upgrades + state: present + + - name: Setup unattended-upgrades + include_role: + name: ansible-role-unattended-upgrades + vars: + unattended_origins_patterns: + - "origin=Debian,archive=buster-security" + - "o=Debian,a=buster-updates" + unattended_package_blacklist: [cowsay] + unattended_mail: "root" + + - name: Setup users + include_role: + name: users diff --git a/main.yml b/main.yml index 88c86ef..797b943 100644 --- a/main.yml +++ b/main.yml @@ -1,39 +1,8 @@ --- -- hosts: all - become: true +# main playbook aggregating all the other playbooks - vars: - ansible_python_interpreter: /usr/bin/python3 - - roles: - - role: ansible.timezone - - tasks: - - name: Update and clean package cache - apt: - update_cache: true - cache_valid_time: 3600 - autoclean: true - changed_when: false - - - name: Ensure unattended-upgrades is installed and up to date - apt: - name: unattended-upgrades - state: present - - - name: Setup unattended-upgrades - include_role: - name: ansible-role-unattended-upgrades - vars: - unattended_origins_patterns: - - "origin=Debian,archive=buster-security" - - "o=Debian,a=buster-updates" - unattended_package_blacklist: [cowsay] - unattended_mail: "root" - - - name: Setup users - include_role: - name: users +- name: Setup for all hosts + import_playbook: all.yml - name: Specific setup for all proxmox hosts import_playbook: proxmox.yml From 6b4cf977b617086796d11295b75c417105bb50a5 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Sat, 23 Jul 2022 23:13:00 +0200 Subject: [PATCH 3/3] Add ansible.cfg with inventory path Link: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-host-list References: !53 --- ansible.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 ansible.cfg diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..fa52dca --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory=inventory.yml