Remove lxc_cache_map variable

This has not had any practical use for several releases and mostly
carries copies of ansible facts. Remove the variable and use the
facts directly.

Change-Id: I1d2be9d07b38eaf2b737819c451a0d2339f723d0
This commit is contained in:
Jonathan Rosser 2023-10-10 17:50:54 +01:00
parent a22ec2150f
commit d57f9a8f47
9 changed files with 51 additions and 59 deletions

View File

@ -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 }}

View File

@ -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.

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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.

View File

@ -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"

View File

@ -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"

View File

@ -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"