diff --git a/roles/bootstrap/tasks/almalinux.yml b/roles/bootstrap/tasks/almalinux.yml index 973067a..98b3072 100644 --- a/roles/bootstrap/tasks/almalinux.yml +++ b/roles/bootstrap/tasks/almalinux.yml @@ -16,12 +16,6 @@ register: bootstrap_almalinux_base_result changed_when: bootstrap_almalinux_base_result.rc == 0 - - name: Ensure chroot has resolv.conf - ansible.builtin.file: - src: /run/NetworkManager/resolv.conf - dest: /mnt/etc/resolv.conf - state: link - - name: Install extra packages ansible.builtin.command: >- {{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False diff --git a/roles/bootstrap/tasks/alpine.yml b/roles/bootstrap/tasks/alpine.yml index 41d7ede..2e417bc 100644 --- a/roles/bootstrap/tasks/alpine.yml +++ b/roles/bootstrap/tasks/alpine.yml @@ -6,13 +6,6 @@ lookup('vars', bootstrap_var_key) | reject('equalto', '') | join(' ') }} block: - - name: Ensure chroot has resolv.conf - ansible.builtin.file: - src: /run/NetworkManager/resolv.conf - dest: /mnt/etc/resolv.conf - state: link - force: true - - name: Install Alpine Linux packages ansible.builtin.command: > apk --root /mnt --no-cache add alpine-base diff --git a/roles/bootstrap/tasks/debian.yml b/roles/bootstrap/tasks/debian.yml index 7ef4638..d6eaf2c 100644 --- a/roles/bootstrap/tasks/debian.yml +++ b/roles/bootstrap/tasks/debian.yml @@ -55,18 +55,6 @@ register: bootstrap_debian_base_result changed_when: bootstrap_debian_base_result.rc == 0 - - name: Generate resolv.conf for chroot - ansible.builtin.copy: - content: | - {% for ns in system_cfg.network.dns.servers | default(['1.1.1.1', '8.8.8.8']) %} - nameserver {{ ns }} - {% endfor %} - {% if system_cfg.network.dns.search | default([]) | length > 0 %} - search {{ system_cfg.network.dns.search | join(' ') }} - {% endif %} - dest: /mnt/etc/resolv.conf - mode: "0644" - - name: Install extra packages when: bootstrap_debian_extra_packages | length > 0 ansible.builtin.command: "{{ chroot_command }} apt install -y {{ bootstrap_debian_extra_args }}" diff --git a/roles/bootstrap/tasks/fedora.yml b/roles/bootstrap/tasks/fedora.yml index 9f353de..be93676 100644 --- a/roles/bootstrap/tasks/fedora.yml +++ b/roles/bootstrap/tasks/fedora.yml @@ -16,12 +16,6 @@ register: bootstrap_fedora_base_result changed_when: bootstrap_fedora_base_result.rc == 0 - - name: Ensure chroot has resolv.conf - ansible.builtin.file: - src: /run/NetworkManager/resolv.conf - dest: /mnt/etc/resolv.conf - state: link - - name: Install extra packages ansible.builtin.command: >- {{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False diff --git a/roles/bootstrap/tasks/main.yml b/roles/bootstrap/tasks/main.yml index d389abe..3a01640 100644 --- a/roles/bootstrap/tasks/main.yml +++ b/roles/bootstrap/tasks/main.yml @@ -39,3 +39,10 @@ void: void.yml bootstrap_var_key: "{{ 'bootstrap_' + (os | replace('-lts', '') | replace('-', '_')) }}" ansible.builtin.include_tasks: "{{ bootstrap_os_task_map[os] }}" + +- name: Ensure chroot uses live environment DNS + ansible.builtin.file: + src: /run/NetworkManager/resolv.conf + dest: /mnt/etc/resolv.conf + state: link + force: true diff --git a/roles/bootstrap/tasks/opensuse.yml b/roles/bootstrap/tasks/opensuse.yml index dfbeeff..1717b3f 100644 --- a/roles/bootstrap/tasks/opensuse.yml +++ b/roles/bootstrap/tasks/opensuse.yml @@ -6,13 +6,6 @@ lookup('vars', bootstrap_var_key) | reject('equalto', '') | join(' ') }} block: - - name: Ensure chroot has resolv.conf - ansible.builtin.file: - src: /run/NetworkManager/resolv.conf - dest: /mnt/etc/resolv.conf - state: link - force: true - - name: Install openSUSE base packages ansible.builtin.command: > zypper --root /mnt --non-interactive install -t pattern patterns-base-base diff --git a/roles/bootstrap/tasks/rhel.yml b/roles/bootstrap/tasks/rhel.yml index 15afded..adad061 100644 --- a/roles/bootstrap/tasks/rhel.yml +++ b/roles/bootstrap/tasks/rhel.yml @@ -13,18 +13,6 @@ - bootstrap_result.rc != 0 - "'grub2-common' not in (bootstrap_result.stderr | default(''))" - - name: Write resolv.conf into chroot - ansible.builtin.copy: - dest: /mnt/etc/resolv.conf - mode: "0644" - content: | - {% for dns in system_cfg.network.dns.servers %} - nameserver {{ dns }} - {% endfor %} - {% if system_cfg.network.dns.search | default([]) | length > 0 %} - search {{ system_cfg.network.dns.search | join(' ') }} - {% endif %} - - name: Ensure chroot RHEL DVD directory exists ansible.builtin.file: path: /mnt/usr/local/install/redhat/dvd diff --git a/roles/bootstrap/tasks/rocky.yml b/roles/bootstrap/tasks/rocky.yml index 9a801a1..856e56c 100644 --- a/roles/bootstrap/tasks/rocky.yml +++ b/roles/bootstrap/tasks/rocky.yml @@ -16,12 +16,6 @@ register: bootstrap_rocky_base_result changed_when: bootstrap_rocky_base_result.rc == 0 - - name: Ensure chroot has resolv.conf - ansible.builtin.file: - src: /run/NetworkManager/resolv.conf - dest: /mnt/etc/resolv.conf - state: link - - name: Install extra packages ansible.builtin.command: >- {{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False diff --git a/roles/bootstrap/tasks/ubuntu.yml b/roles/bootstrap/tasks/ubuntu.yml index 39e6bcb..0395da2 100644 --- a/roles/bootstrap/tasks/ubuntu.yml +++ b/roles/bootstrap/tasks/ubuntu.yml @@ -47,18 +47,6 @@ register: bootstrap_ubuntu_base_result changed_when: bootstrap_ubuntu_base_result.rc == 0 - - name: Generate resolv.conf for chroot - ansible.builtin.copy: - content: | - {% for ns in system_cfg.network.dns.servers | default(['1.1.1.1', '8.8.8.8']) %} - nameserver {{ ns }} - {% endfor %} - {% if system_cfg.network.dns.search | default([]) | length > 0 %} - search {{ system_cfg.network.dns.search | join(' ') }} - {% endif %} - dest: /mnt/etc/resolv.conf - mode: "0644" - - name: Enable universe repository ansible.builtin.command: "{{ chroot_command }} sed -i '1s|$| universe|' /etc/apt/sources.list" register: bootstrap_ubuntu_repo_result diff --git a/roles/bootstrap/tasks/void.yml b/roles/bootstrap/tasks/void.yml index a761312..f276e3c 100644 --- a/roles/bootstrap/tasks/void.yml +++ b/roles/bootstrap/tasks/void.yml @@ -6,13 +6,6 @@ lookup('vars', bootstrap_var_key) | reject('equalto', '') | join(' ') }} block: - - name: Ensure chroot has resolv.conf - ansible.builtin.file: - src: /run/NetworkManager/resolv.conf - dest: /mnt/etc/resolv.conf - state: link - force: true - - name: Install Void Linux base packages ansible.builtin.command: > xbps-install -Sy -r /mnt -R https://repo-default.voidlinux.org/current void-repo-nonfree base-system