diff --git a/defaults/main.yml b/defaults/main.yml index c20fca0f..cb0e55dd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -78,19 +78,12 @@ lxc_container_backing_store: dir # 'lvm'. # lxc_container_backing_method: copy-on-write -# The cache map is used as a basic instruction set when prep'ing the base -# container image. If the cache map is overridden, the following fields are -# required: -# lxc_cache_map: -# distro: name of the distro -# arch: "CPU architecture" -# release: version of the release -# copy_from_host: [] # List of files to copy into the container -lxc_cache_map: "{{ _lxc_cache_map }}" - # When using a base container to snapshot from for the overlayfs or LVM # copy-on-write backing stored, the base container can be set. -lxc_container_base_name: "{{ lxc_cache_map.distro }}-{{ lxc_cache_map.release }}-{{ lxc_cache_map.arch }}" +lxc_container_base_name: >- + {{ ansible_facts['distribution'] | lower ~ '-' ~ + ansible_facts['distribution_major_version'] ~ '-' ~ + lxc_architecture_mapping.get(ansible_facts['architecture']) }} # Set the default zfs root name lxc_container_zfs_root_name: "pool/lxc" @@ -219,9 +212,9 @@ lxc_image_cache_refresh: false lxc_cache_default_variant: default lxc_cache_download_template_extra_options: "" lxc_cache_download_template_options: >- - --dist {{ lxc_cache_map.distro }} - --release {{ lxc_cache_map.release }} - --arch {{ lxc_cache_map.arch }} + --dist {{ ansible_facts['distribution'] | lower }} + --release {{ ansible_facts['distribution_major_version'] }} + --arch {{ lxc_architecture_mapping.get(ansible_facts['architecture']) }} --force-cache --server localhost --variant {{ lxc_cache_default_variant }} diff --git a/releasenotes/notes/remove-cache-map-8552368f6d7c604c.yaml b/releasenotes/notes/remove-cache-map-8552368f6d7c604c.yaml new file mode 100644 index 00000000..93ed1119 --- /dev/null +++ b/releasenotes/notes/remove-cache-map-8552368f6d7c604c.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The variable lxc_cache_map is removed as the lxc_hosts ansible role + has only been able to create containers matching the host architecture + and OS for several releases, and lxc_cache_map simply carried copies + of data from ansible_facts. diff --git a/tasks/lxc_cache.yml b/tasks/lxc_cache.yml index f1951f53..71426c67 100644 --- a/tasks/lxc_cache.yml +++ b/tasks/lxc_cache.yml @@ -16,7 +16,11 @@ - name: Set LXC cache fact(s) set_fact: cache_path_fact: >- - {{ lxc_container_cache_path }}/{{ lxc_cache_map.distro }}/{{ lxc_cache_map.release }}/{{ lxc_cache_map.arch }}/{{ lxc_cache_default_variant }} + {{ lxc_container_cache_path ~ '/' ~ + ansible_facts['distribution'] | lower ~ '/' ~ + ansible_facts['distribution_major_version'] ~ '/' ~ + lxc_architecture_mapping.get(ansible_facts['architecture']) ~ '/' ~ + lxc_cache_default_variant }} cache_time: "{{ now().timestamp() }}" - name: Retrieve the expiry object diff --git a/tasks/lxc_cache_preparation.yml b/tasks/lxc_cache_preparation.yml index cf165a38..b6ddb214 100644 --- a/tasks/lxc_cache_preparation.yml +++ b/tasks/lxc_cache_preparation.yml @@ -28,7 +28,7 @@ register: _rsync_container_cache args: executable: "/bin/bash" - with_items: "{{ (lxc_cache_map.copy_from_host | union(lxc_container_cache_files_from_host)) | list }}" + with_items: "{{ (_lxc_copy_from_host | union(lxc_container_cache_files_from_host)) | list }}" - name: Ensure directories exist for lxc_container_cache_files file: diff --git a/templates/meta-data/config b/templates/meta-data/config index aa8f1f4d..e3122736 100644 --- a/templates/meta-data/config +++ b/templates/meta-data/config @@ -1,2 +1,2 @@ -lxc.include = LXC_TEMPLATE_CONFIG/{{ lxc_cache_map.distro }}.common.conf +lxc.include = LXC_TEMPLATE_CONFIG/{{ ansible_facts['distribution'] | lower }}.common.conf lxc.arch = x86_64 diff --git a/templates/meta-data/create-message b/templates/meta-data/create-message index 85d21eec..b783833d 100644 --- a/templates/meta-data/create-message +++ b/templates/meta-data/create-message @@ -1,4 +1,4 @@ -Created a {{ lxc_cache_map.distro }} container (release={{ lxc_cache_map.release }}, arch={{ lxc_cache_map.arch }}, variant={{ lxc_cache_default_variant }}) +Created a {{ ansible_facts['distribution'] | lower }} container (release={{ ansible_facts['distribution_major_version'] }}, arch={{ lxc_architecture_mapping.get(ansible_facts['architecture']) }}, variant={{ lxc_cache_default_variant }}) Use lxc-attach or chroot directly into the rootfs to set a root password or create user accounts. diff --git a/vars/debian-12.yml b/vars/debian-12.yml index 23d9df2a..a4e33299 100644 --- a/vars/debian-12.yml +++ b/vars/debian-12.yml @@ -20,21 +20,17 @@ _lxc_hosts_container_build_command: >- /var/lib/machines/{{ lxc_container_base_name }} {{ lxc_apt_mirror }} -_lxc_cache_map: - distro: "{{ ansible_facts['distribution'] | lower }}" - arch: "{{ lxc_architecture_mapping.get(ansible_facts['architecture']) }}" - release: "{{ ansible_facts['distribution_major_version'] }}" - copy_from_host: - - /etc/apt/sources.list - - /etc/apt/sources.list.d/ - - /etc/apt/apt.conf.d/ - - /etc/apt/trusted.gpg.d/ - - /etc/apt/trusted.gpg - - /etc/apt/preferences.d/ - - /etc/apt/mirrors/ - - /etc/environment - - /etc/localtime - - /etc/protocols +_lxc_copy_from_host: + - /etc/apt/sources.list + - /etc/apt/sources.list.d/ + - /etc/apt/apt.conf.d/ + - /etc/apt/trusted.gpg.d/ + - /etc/apt/trusted.gpg + - /etc/apt/preferences.d/ + - /etc/apt/mirrors/ + - /etc/environment + - /etc/localtime + - /etc/protocols _lxc_cache_prep_template: "prep-scripts/debian_prep.sh.j2" diff --git a/vars/debian.yml b/vars/debian.yml index 673ab2fc..bbff28e6 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -20,19 +20,15 @@ _lxc_hosts_container_build_command: >- /var/lib/machines/{{ lxc_container_base_name }} {{ lxc_apt_mirror }} -_lxc_cache_map: - distro: "{{ ansible_facts['distribution'] | lower }}" - arch: "{{ lxc_architecture_mapping.get(ansible_facts['architecture']) }}" - release: "{{ ansible_facts['distribution_major_version'] }}" - copy_from_host: - - /etc/apt/sources.list - - /etc/apt/apt.conf.d/ - - /etc/apt/trusted.gpg.d/ - - /etc/apt/trusted.gpg - - /etc/apt/preferences.d/ - - /etc/environment - - /etc/localtime - - /etc/protocols +_lxc_copy_from_host: + - /etc/apt/sources.list + - /etc/apt/apt.conf.d/ + - /etc/apt/trusted.gpg.d/ + - /etc/apt/trusted.gpg + - /etc/apt/preferences.d/ + - /etc/environment + - /etc/localtime + - /etc/protocols _lxc_cache_prep_template: "prep-scripts/debian_prep.sh.j2" diff --git a/vars/redhat.yml b/vars/redhat.yml index aab795e9..4e99183e 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -24,19 +24,15 @@ _lxc_hosts_container_build_command: >- --setopt=install_weak_deps=False --nodocs rootfiles coreutils dnf {{ _lxc_cache_core_repos }} --releasever={{ ansible_facts['distribution_major_version'] }} -_lxc_cache_map: - distro: "{{ ansible_facts['distribution'] | lower }}" - arch: "{{ lxc_architecture_mapping.get(ansible_facts['architecture']) }}" - release: "{{ ansible_facts['distribution_major_version'] }}" - copy_from_host: - - /etc/default/locale - - /etc/environment - - /etc/localtime - - /etc/locale.conf - - /etc/protocols - - /etc/pki/rpm-gpg/ - - /etc/yum/pluginconf.d/fastestmirror.conf - - /etc/yum.repos.d/ +_lxc_copy_from_host: + - /etc/default/locale + - /etc/environment + - /etc/localtime + - /etc/locale.conf + - /etc/protocols + - /etc/pki/rpm-gpg/ + - /etc/yum/pluginconf.d/fastestmirror.conf + - /etc/yum.repos.d/ _lxc_cache_prep_template: "prep-scripts/redhat_prep.sh.j2"