Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 all -i inventory -m ansible.builtin.setup

- name: Run Ansible Playbook (verbose)
if: ${{ inputs.ansible_verbose == true }}
run: ansible-playbook -i inventory -vvvv site.yml
7 changes: 7 additions & 0 deletions host_vars/localhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all:
hosts:
localhost:
hostname: hostname1
fqdn: hostname1.domain.tld
username: user001
dns1: 10.0.0.1
39 changes: 34 additions & 5 deletions tasks/configuration/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
---

- 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
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
create_home: true
state: present

- 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
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
Expand Down Expand Up @@ -35,7 +64,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_*"
Expand Down
3 changes: 1 addition & 2 deletions tasks/disk/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,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
Expand Down
20 changes: 11 additions & 9 deletions tasks/docker/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tasks/ubuntu2404.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
msg: "Running tasks for Ubuntu 24.04"

- name: Disk Configuration
when: ubtu24_run_task_disk
when: ubtu24_run_task_disk and not in_pipeline | bool
ansible.builtin.import_tasks: disk/main.yml
tags:
- disk
Expand Down