From e47ae78cfe17371ce240e134fd66f01ed120ffee Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Mon, 11 Aug 2025 00:33:32 +0200 Subject: Remove configure dependency on other roles and add ubuntu support --- molecule/default/prepare.yml | 1 + roles/configure/README.md | 4 ++-- roles/configure/meta/argument_specs.yml | 10 ++++++---- roles/configure/meta/main.yml | 6 ++++-- roles/configure/tasks/install-debian.yml | 7 +++++++ roles/configure/tasks/main.yml | 15 ++++++++++----- 6 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 roles/configure/tasks/install-debian.yml diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index e62ccab..5f33e7f 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -7,6 +7,7 @@ ansible.builtin.set_fact: distro_hostname_mapping: archlinux: "archlinux.local" + ubuntu: "ubuntu.local" - name: "Create virtual disk image" become: true diff --git a/roles/configure/README.md b/roles/configure/README.md index dfab439..0430791 100644 --- a/roles/configure/README.md +++ b/roles/configure/README.md @@ -9,12 +9,12 @@ This role configures the bootstrapped distro installation basic networking funct ## Role Variables - `configure_playbooks_path` the root directory of the distro-configure playbooks +- `partiton_root` dictionary with the required `mount_path` - `hostname` the hostname variable defined in bootstrap role -- `mnt_root_path` the mount root path fact defined in bootstrap role ## Internals - Install ansible on live environment - Copy `ansible-distro-configure` playbook (via archive because it's waaaay faster) -- Update the `ansible-distro-configure` inventory to configure chroot (`mnt_root_path`) +- Update the `ansible-distro-configure` inventory to configure chroot (`partition_root.mount_path`) - Run the `ansible-distro-configure` playbook for desired `hostname` diff --git a/roles/configure/meta/argument_specs.yml b/roles/configure/meta/argument_specs.yml index cd10572..3fcde79 100644 --- a/roles/configure/meta/argument_specs.yml +++ b/roles/configure/meta/argument_specs.yml @@ -7,7 +7,9 @@ argument_specs: description: "The path to the configure playbook directory to run when provided" hostname: type: "str" - description: "Check hostname variable in role: bootstrap" - mnt_root_path: - type: "str" - description: "Check mnt_root_path fact in role: bootstrap" + required: true + description: "The distro linux hostname to be configured (will configure if availabe in inventory)" + partition_root: + type: "dict" + required: true + description: "Check partition_root argument in role: partition, required options: mount_path" diff --git a/roles/configure/meta/main.yml b/roles/configure/meta/main.yml index 1599ace..97ee720 100644 --- a/roles/configure/meta/main.yml +++ b/roles/configure/meta/main.yml @@ -1,6 +1,5 @@ --- -dependencies: - - bootstrap +dependencies: [] galaxy_info: role_name: configure author: a14m @@ -12,3 +11,6 @@ galaxy_info: - name: ArchLinux versions: - all + - name: Ubuntu + versions: + - noble diff --git a/roles/configure/tasks/install-debian.yml b/roles/configure/tasks/install-debian.yml new file mode 100644 index 0000000..d9dc732 --- /dev/null +++ b/roles/configure/tasks/install-debian.yml @@ -0,0 +1,7 @@ +--- +- name: "Ensure ansible dependencies are installed on live environment" + ansible.builtin.apt: + state: "present" + pkg: + - "python3" + - "python3-pip" diff --git a/roles/configure/tasks/main.yml b/roles/configure/tasks/main.yml index e4ff6b9..6a1e58c 100644 --- a/roles/configure/tasks/main.yml +++ b/roles/configure/tasks/main.yml @@ -1,8 +1,16 @@ --- +- name: "Set root partition paths" + ansible.builtin.set_fact: + configure_chroot_path: "{{ partition_root.mount_path }}" + - name: "Install archlinux" ansible.builtin.include_tasks: "install-archlinux.yml" when: ansible_os_family == "Archlinux" +- name: "Install debian" + ansible.builtin.include_tasks: "install-debian.yml" + when: ansible_os_family == "Debian" + - name: "Install ansible-core on live environment" # Can't install ansible-core using package manager # This resolve the "ERROR! ansible-galaxy requires resolvelib<1.1.1,>=0.5.3" @@ -13,10 +21,7 @@ break_system_packages: true - name: "Run distro-configure playbooks on bootstrapped distro" - when: - - configure_playbook_dir is defined - - mnt_root_path is defined - - hostname is defined + when: configure_playbook_dir is defined block: - name: "Archive playbook on controller" become: false @@ -55,7 +60,7 @@ ansible_connection: "chroot" ansible_chroot_exe: "arch-chroot" hosts: - {{ mnt_root_path }}: + {{ configure_chroot_path }}: - name: "Download playbook dependencies on live environment" ansible.builtin.command: -- cgit v1.2.3