From 9b3fc2e05b80008b67419d1881ec20a53fd7ed1f Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 09:05:27 +0100 Subject: [PATCH 01/15] Create localhost.yml --- host_vars/localhost.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 host_vars/localhost.yml diff --git a/host_vars/localhost.yml b/host_vars/localhost.yml new file mode 100644 index 0000000..919bfbc --- /dev/null +++ b/host_vars/localhost.yml @@ -0,0 +1,9 @@ +all: + hosts: + localhost: + hostname: hostname1 + fqdn: hostname1.domain.tld + username: user001 + dns1: 10.0.0.1 + dns2: 10.0.0.2 + From e96135e7f712d130d44df635604185d99ff88bcc Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 09:08:21 +0100 Subject: [PATCH 02/15] Update localhost.yml --- host_vars/localhost.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/host_vars/localhost.yml b/host_vars/localhost.yml index 919bfbc..c7a02ee 100644 --- a/host_vars/localhost.yml +++ b/host_vars/localhost.yml @@ -5,5 +5,3 @@ all: fqdn: hostname1.domain.tld username: user001 dns1: 10.0.0.1 - dns2: 10.0.0.2 - From 21c2d431a5463dc96d63869c5f371ff1cc397bfc Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:29:12 +0100 Subject: [PATCH 03/15] Update main.yml --- tasks/configuration/main.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tasks/configuration/main.yml b/tasks/configuration/main.yml index 5472c2a..e7ba9ca 100644 --- a/tasks/configuration/main.yml +++ b/tasks/configuration/main.yml @@ -1,10 +1,27 @@ --- - -- name: Set the machine FQDN - when: ansible_fqdn is defined and ansible_fqdn | length <= 32 +- name: Set the machine hostname + when: hostname is defined and hostname | length <= 32 become: true ansible.builtin.hostname: - name: "{{ ansible_facts['fqdn'] }}" + name: "{{ hostname }}" + +- name: Set the machine hostname and fqdn + ansible.builtin.lineinfile: + path: /etc/hosts + regexp: '^127\.0\.1\.1' + line: "127.0.1.1 {{ fqdn }} {{ hostname }}" + create: true + +- name: Create new user + ansible.builtin.user: + name: "{{ username }}" + shell: /bin/bash + create_home: true + state: present + +- name: Configure DNS via systemd-resolved + ansible.builtin.command: + cmd: "resolvectl dns {{ ansible_facts['default_ipv4']['alias'] }} {{ dns1 }}" - name: Set timezone to Europe/Amsterdam become: true @@ -35,7 +52,7 @@ - name: Check if SSH private key already exists ansible.builtin.find: - paths: "/home/{{ ansible_facts.user_id }}/.ssh" + paths: "/home/{{ ansible_facts['user_id'] }}/.ssh" file_type: file patterns: - "id_*" From 776328dfc9d1c9d6fa7b02245d25bedf4c440107 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:36:32 +0100 Subject: [PATCH 04/15] Update main.yml --- tasks/configuration/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/configuration/main.yml b/tasks/configuration/main.yml index e7ba9ca..20c43ab 100644 --- a/tasks/configuration/main.yml +++ b/tasks/configuration/main.yml @@ -6,13 +6,16 @@ name: "{{ hostname }}" - name: Set the machine hostname and fqdn + become: true ansible.builtin.lineinfile: path: /etc/hosts regexp: '^127\.0\.1\.1' line: "127.0.1.1 {{ fqdn }} {{ hostname }}" create: true + mode: 0644 - name: Create new user + become: true ansible.builtin.user: name: "{{ username }}" shell: /bin/bash @@ -20,6 +23,7 @@ state: present - name: Configure DNS via systemd-resolved + become: true ansible.builtin.command: cmd: "resolvectl dns {{ ansible_facts['default_ipv4']['alias'] }} {{ dns1 }}" From 553f27bc9ee4383183d5c6de64c9ead3bb59f8e1 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:38:21 +0100 Subject: [PATCH 05/15] Update main.yml --- tasks/configuration/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/configuration/main.yml b/tasks/configuration/main.yml index 20c43ab..c00de24 100644 --- a/tasks/configuration/main.yml +++ b/tasks/configuration/main.yml @@ -12,7 +12,7 @@ regexp: '^127\.0\.1\.1' line: "127.0.1.1 {{ fqdn }} {{ hostname }}" create: true - mode: 0644 + mode: "0644" - name: Create new user become: true From 7defe8176cefb43ce3ec46a6408dfbfa5cf5c9f5 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:39:40 +0100 Subject: [PATCH 06/15] Update main.yml --- tasks/configuration/main.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks/configuration/main.yml b/tasks/configuration/main.yml index c00de24..976471e 100644 --- a/tasks/configuration/main.yml +++ b/tasks/configuration/main.yml @@ -22,10 +22,16 @@ create_home: true state: present -- name: Configure DNS via systemd-resolved +- name: Get current DNS configuration + ansible.builtin.command: resolvectl dns + register: resolvectl_dns + changed_when: false + +- name: Configure DNS become: true ansible.builtin.command: - cmd: "resolvectl dns {{ ansible_facts['default_ipv4']['alias'] }} {{ dns1 }}" + cmd: "resolvectl dns {{ ansible_facts['default_ipv4']['interface'] }} {{ dns1 }}" + when: dns1 not in resolvectl_dns.stdout - name: Set timezone to Europe/Amsterdam become: true From d95cd11ce589957d44b3e417b007c99b34d61427 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:55:23 +0100 Subject: [PATCH 07/15] Update main.yml --- tasks/configuration/main.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tasks/configuration/main.yml b/tasks/configuration/main.yml index 976471e..b0726fd 100644 --- a/tasks/configuration/main.yml +++ b/tasks/configuration/main.yml @@ -22,16 +22,11 @@ create_home: true state: present -- name: Get current DNS configuration - ansible.builtin.command: resolvectl dns - register: resolvectl_dns - changed_when: false - - name: Configure DNS become: true - ansible.builtin.command: - cmd: "resolvectl dns {{ ansible_facts['default_ipv4']['interface'] }} {{ dns1 }}" - when: dns1 not in resolvectl_dns.stdout + community.general.resolved: + interface: "{{ ansible_facts['default_ipv4']['interface'] }}" + dns: "{{ dns1 }}" - name: Set timezone to Europe/Amsterdam become: true From 1d189deb723cd48bf1fbf7ebab647537cd3da7e9 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:45:03 +0100 Subject: [PATCH 08/15] Update main.yml --- tasks/configuration/main.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tasks/configuration/main.yml b/tasks/configuration/main.yml index b0726fd..1c4c1eb 100644 --- a/tasks/configuration/main.yml +++ b/tasks/configuration/main.yml @@ -22,11 +22,18 @@ create_home: true state: present -- name: Configure DNS +- name: Read current DNS servers + ansible.builtin.command: + cmd: resolvectl dns {{ ansible_facts['default_ipv4']['interface'] }} + register: current_dns + changed_when: false + +- name: Configure DNS via systemd-resolved become: true - community.general.resolved: - interface: "{{ ansible_facts['default_ipv4']['interface'] }}" - dns: "{{ dns1 }}" + ansible.builtin.command: + cmd: resolvectl dns {{ ansible_facts['default_ipv4']['interface'] }} {{ dns1 }} + when: dns1 not in current_dns.stdout + changed_when: true - name: Set timezone to Europe/Amsterdam become: true From 81dd7e9e8afc43d16066e87821891da0c7f99b1c Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 08:12:33 +0100 Subject: [PATCH 09/15] Update ansible.yml --- .github/workflows/ansible.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index 78f413b..e572958 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -99,7 +99,11 @@ jobs: - name: Run Ansible Playbook if: ${{ inputs.ansible_verbose == false }} run: ansible-playbook -i inventory site.yml - + + - name: Show ansible facte + if: ${{ inputs.ansible_verbose == true }} + run: ansible -i inventory site.yml -m ansible.builtin.setup + - name: Run Ansible Playbook (verbose) if: ${{ inputs.ansible_verbose == true }} run: ansible-playbook -i inventory -vvvv site.yml From 613e72577e54d5d562779ec8d3fcec384c06aa1f Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 08:37:46 +0100 Subject: [PATCH 10/15] Update ansible.yml --- .github/workflows/ansible.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml index e572958..cfa6e47 100644 --- a/.github/workflows/ansible.yml +++ b/.github/workflows/ansible.yml @@ -102,7 +102,7 @@ jobs: - name: Show ansible facte if: ${{ inputs.ansible_verbose == true }} - run: ansible -i inventory site.yml -m ansible.builtin.setup + run: ansible all -i inventory -m ansible.builtin.setup - name: Run Ansible Playbook (verbose) if: ${{ inputs.ansible_verbose == true }} From 6ff2ce27a348c335b5c09cb191ee37d1b65b37e3 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 09:03:07 +0100 Subject: [PATCH 11/15] Update main.yml --- tasks/disk/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks/disk/main.yml b/tasks/disk/main.yml index 556eeb9..db13f60 100644 --- a/tasks/disk/main.yml +++ b/tasks/disk/main.yml @@ -1,4 +1,9 @@ --- +- name: Skip disk if in pipeline + ansible.builtin.meta: end_play + when: + - in_pipeline | bool + - name: Detect candidate block devices ansible.builtin.set_fact: candidate_disks: >- @@ -42,8 +47,7 @@ - name: Skip disk partitioning ansible.builtin.meta: end_play when: - - in_pipeline | bool - or single_root_disk + - single_root_disk - name: Ensure all packages are up to date become: true From 774535fbcca14dc7db4e8fec81fc190237dc678c Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 09:15:52 +0100 Subject: [PATCH 12/15] Update main.yml --- tasks/disk/main.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tasks/disk/main.yml b/tasks/disk/main.yml index db13f60..edf841c 100644 --- a/tasks/disk/main.yml +++ b/tasks/disk/main.yml @@ -1,9 +1,4 @@ --- -- name: Skip disk if in pipeline - ansible.builtin.meta: end_play - when: - - in_pipeline | bool - - name: Detect candidate block devices ansible.builtin.set_fact: candidate_disks: >- From f7a2f8c3deb66c960e4ffc643d8fc235d0ee92a5 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 09:17:24 +0100 Subject: [PATCH 13/15] Update ubuntu2404.yml --- tasks/ubuntu2404.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/ubuntu2404.yml b/tasks/ubuntu2404.yml index de56d68..454cb17 100644 --- a/tasks/ubuntu2404.yml +++ b/tasks/ubuntu2404.yml @@ -4,8 +4,8 @@ msg: "Running tasks for Ubuntu 24.04" - name: Disk Configuration - when: ubtu24_run_task_disk - ansible.builtin.import_tasks: disk/main.yml + when: ubtu24_run_task_disk and not in_pipeline | bool + ansible.builtin.import_tasks: disk/main.yml tags: - disk From ec5685be32523d3100b5390060aad2dfd5c8c9fa Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 12:27:25 +0100 Subject: [PATCH 14/15] Update main.yml --- tasks/docker/main.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tasks/docker/main.yml b/tasks/docker/main.yml index 61a28e8..4daeaa8 100644 --- a/tasks/docker/main.yml +++ b/tasks/docker/main.yml @@ -189,7 +189,9 @@ path: "/home/{{ ansible_facts['user_id'] }}/.bashrc" line: "export DOCKER_HOST=unix:///run/user/{{ ansible_facts['user_uid'] }}/docker.sock" state: present - register: bashrc_docker_host_check + mode: "0644" + create: true +# register: bashrc_docker_host_check ignore_errors: true changed_when: false @@ -201,14 +203,14 @@ # ignore_errors: true # changed_when: false - - name: Ensure DOCKER_HOST is set in .bashrc - ansible.builtin.lineinfile: - path: /home/{{ ansible_facts['user_id'] }}/.bashrc - line: "export DOCKER_HOST=unix:///run/user/{{ ansible_facts['user_uid'] }}/docker.sock" - state: present - create: true - mode: "0644" - when: bashrc_docker_host_check.rc != 0 +# - name: Ensure DOCKER_HOST is set in .bashrc +# ansible.builtin.lineinfile: +# path: /home/{{ ansible_facts['user_id'] }}/.bashrc +# line: "export DOCKER_HOST=unix:///run/user/{{ ansible_facts['user_uid'] }}/docker.sock" +# state: present +# create: true +# mode: "0644" +# when: bashrc_docker_host_check.rc != 0 - name: Check if lingering is enabled for the user ansible.builtin.command: loginctl show-user {{ ansible_facts['user_id'] }} --property=Linger From b33624ff3bd7bdab1721794c9f631ee8453d51e3 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 19 Mar 2026 13:52:22 +0100 Subject: [PATCH 15/15] Update ubuntu2404.yml --- tasks/ubuntu2404.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/ubuntu2404.yml b/tasks/ubuntu2404.yml index 454cb17..1cb55a4 100644 --- a/tasks/ubuntu2404.yml +++ b/tasks/ubuntu2404.yml @@ -5,7 +5,7 @@ - name: Disk Configuration when: ubtu24_run_task_disk and not in_pipeline | bool - ansible.builtin.import_tasks: disk/main.yml + ansible.builtin.import_tasks: disk/main.yml tags: - disk