From 8f6aab955c35c86348993177c8183308082e2b32 Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Thu, 17 Apr 2025 20:20:43 +0200 Subject: [PATCH] first ansible structure with dhcp and resolv-dns hosts --- deploy.yaml | 5 +++++ inventories/eh22/hosts.yaml | 8 ++++++++ roles/base_config/meta/main.yaml | 3 +++ .../files/10-ccchh.conf | 3 +++ .../handlers/main.yaml | 5 +++++ .../tasks/main.yaml | 18 ++++++++++++++++++ 6 files changed, 42 insertions(+) create mode 100644 deploy.yaml create mode 100644 inventories/eh22/hosts.yaml create mode 100644 roles/base_config/meta/main.yaml create mode 100644 roles/deploy_systemd_journal_config/files/10-ccchh.conf create mode 100644 roles/deploy_systemd_journal_config/handlers/main.yaml create mode 100644 roles/deploy_systemd_journal_config/tasks/main.yaml diff --git a/deploy.yaml b/deploy.yaml new file mode 100644 index 0000000..67f3518 --- /dev/null +++ b/deploy.yaml @@ -0,0 +1,5 @@ +--- +- name: Ensure base config is deployment on all hosts + hosts: all + roles: + - base_config diff --git a/inventories/eh22/hosts.yaml b/inventories/eh22/hosts.yaml new file mode 100644 index 0000000..985309e --- /dev/null +++ b/inventories/eh22/hosts.yaml @@ -0,0 +1,8 @@ +all: + hosts: + dhcp: + ansible_host: 94.45.255.70 + ansible_user: noc + resolv-dns: + ansible_host: 94.45.254.2 + ansible_user: noc diff --git a/roles/base_config/meta/main.yaml b/roles/base_config/meta/main.yaml new file mode 100644 index 0000000..487a783 --- /dev/null +++ b/roles/base_config/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: deploy_systemd_journal_config diff --git a/roles/deploy_systemd_journal_config/files/10-ccchh.conf b/roles/deploy_systemd_journal_config/files/10-ccchh.conf new file mode 100644 index 0000000..3419fd9 --- /dev/null +++ b/roles/deploy_systemd_journal_config/files/10-ccchh.conf @@ -0,0 +1,3 @@ +[Journal] +MaxFileSec=2day +MaxRetentionSec=2week diff --git a/roles/deploy_systemd_journal_config/handlers/main.yaml b/roles/deploy_systemd_journal_config/handlers/main.yaml new file mode 100644 index 0000000..685f2ce --- /dev/null +++ b/roles/deploy_systemd_journal_config/handlers/main.yaml @@ -0,0 +1,5 @@ +- name: Restart `systemd-journald.service` + ansible.builtin.systemd: + name: systemd-journald.service + state: restarted + become: true diff --git a/roles/deploy_systemd_journal_config/tasks/main.yaml b/roles/deploy_systemd_journal_config/tasks/main.yaml new file mode 100644 index 0000000..1161a33 --- /dev/null +++ b/roles/deploy_systemd_journal_config/tasks/main.yaml @@ -0,0 +1,18 @@ +- name: Create 'journald.conf.d' directory if it does not exist + ansible.builtin.file: + path: "/etc/systemd/journald.conf.d" + state: directory + mode: '0644' + owner: root + group: root + become: true + +- name: make sure the custom configuration file is deployed + ansible.builtin.copy: + src: "10-ccchh.conf" + dest: "/etc/systemd/journald.conf.d/10-ccchh.conf" + mode: "0644" + owner: root + group: root + become: true + notify: Restart `systemd-journald.service`