diff --git a/defaults/main.yml b/defaults/main.yml index 9595486b..ba0a9bc7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -20,6 +20,14 @@ lxc_hosts_validate_certs: yes # Options are 'present' and 'latest' lxc_hosts_package_state: "latest" +# Define a list of extra distribuition packages to install onto the host +# at the discretion of the deployer +lxc_hosts_extra_distro_packages: [] + +# Define the total list of packages which to install onto the host combining +# distibution specific and deployers extra package lists +lxc_hosts_distro_packages: "{{ _lxc_hosts_distro_packages + lxc_hosts_extra_distro_packages }}" + # Mappings from Ansible reported architecture to distro release architecture lxc_architecture_mapping: x86_64: amd64 @@ -169,8 +177,13 @@ lxc_user_defined_container: null # which will be templated onto the deployment targets. lxc_cache_prep_template: "{{ _lxc_cache_prep_template }}" +## Define a list of extra distribuition packages to install in the container +# cache at the discretion of the deployer +lxc_cache_extra_distro_packages: [] + # List of packages to be installed into the base container cache -lxc_cache_distro_packages: "{{ _lxc_cache_distro_packages }}" +# Combines the distribution specific list with deployers extra list +lxc_cache_distro_packages: "{{ _lxc_cache_distro_packages + lxc_cache_extra_distro_packages }}" # The maximum amount of time (in seconds) to wait until failing the cache # preparation process. This is necessary to mitigate the issue that can diff --git a/tests/test.yml b/tests/test.yml index 3b3872e3..6c01ffcc 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -17,6 +17,9 @@ hosts: localhost connection: local become: true + vars: + extra_host_package: iotop + extra_cache_package: lshw pre_tasks: - name: Show host facts debug: @@ -44,6 +47,11 @@ set_fact: lxc_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}" + - name: Ensure extra host package is not installed + package: + name: "{{ extra_host_package }}" + state: absent + - include_tasks: "common/common-tasks/test-set-nodepool-vars.yml" roles: @@ -55,6 +63,10 @@ lxc_container_cache_files: - src: files/container-file-copy-test.txt dest: /tmp/file-copied-from-deployment-host.txt + lxc_hosts_extra_distro_packages: + - "{{ extra_host_package }}" + lxc_cache_extra_distro_packages: + - "{{ extra_cache_package }}" post_tasks: - name: Get sysctl content @@ -90,6 +102,19 @@ filter: ansible_lxcbr0 register: lxcbr0_facts + - name: Get installation state of extra host package + package: + name: "{{ extra_host_package }}" + state: present + register: extra_host_package_state + + - name: Check for extra package installed in lxc cache + find: + paths: "{{ lxc_image_cache_path }}" + patterns: "{{ extra_cache_package }}" + recurse: yes + register: extra_cache_package_find + - name: Check role functions assert: that: @@ -99,3 +124,5 @@ - sysctl_conf | search('fs.inotify.max_user_instances.*') - "lxc_bridge_file.stat.exists" - "lxcbr0_facts.ansible_facts.ansible_lxcbr0.ipv4.address | match('10.100.100.1')" + - extra_host_package_state.changed == false + - extra_cache_package_find.matched > 0 diff --git a/vars/redhat-7-host.yml b/vars/redhat-7-host.yml index 20f67cb8..c9d073a6 100644 --- a/vars/redhat-7-host.yml +++ b/vars/redhat-7-host.yml @@ -17,7 +17,7 @@ system_config_dir: "/etc/sysconfig" systemd_utils_prefix: "/lib/systemd" # Required rpm packages. -lxc_hosts_distro_packages: +_lxc_hosts_distro_packages: - aria2 - bridge-utils - btrfs-progs diff --git a/vars/suse-42-host.yml b/vars/suse-42-host.yml index 39d5049e..7282ac59 100644 --- a/vars/suse-42-host.yml +++ b/vars/suse-42-host.yml @@ -22,7 +22,7 @@ system_config_dir: "/etc/sysconfig" systemd_utils_prefix: "/usr/lib/systemd" # Required rpm packages. -lxc_hosts_distro_packages: +_lxc_hosts_distro_packages: - apparmor-parser - apparmor-profiles - apparmor-utils diff --git a/vars/suse-host.yml b/vars/suse-host.yml index 2d10939e..411e4024 100644 --- a/vars/suse-host.yml +++ b/vars/suse-host.yml @@ -26,7 +26,7 @@ system_config_dir: "/etc/sysconfig" systemd_utils_prefix: "/usr/lib/systemd" # Required rpm packages. -lxc_hosts_distro_packages: +_lxc_hosts_distro_packages: - apparmor-parser - apparmor-profiles - apparmor-utils diff --git a/vars/ubuntu-16.04-host.yml b/vars/ubuntu-16.04-host.yml index ed38ab40..6a2dfe31 100644 --- a/vars/ubuntu-16.04-host.yml +++ b/vars/ubuntu-16.04-host.yml @@ -17,7 +17,7 @@ cache_timeout: 600 # Required apt packages. -lxc_hosts_distro_packages: +_lxc_hosts_distro_packages: - apparmor - apparmor-profiles - apparmor-utils diff --git a/vars/ubuntu-18.04-host.yml b/vars/ubuntu-18.04-host.yml index 64e030f3..6cb8dda4 100644 --- a/vars/ubuntu-18.04-host.yml +++ b/vars/ubuntu-18.04-host.yml @@ -17,7 +17,7 @@ cache_timeout: 600 # Required apt packages. -lxc_hosts_distro_packages: +_lxc_hosts_distro_packages: - apparmor - apparmor-profiles - apparmor-utils