Allow user-defined extra distro packages

This change allows the deployer to specify lists of distro packages
which will be installed in addition to those specified by this role.

Change-Id: I35ac3be4ec61c432492871de80f6d7f29cca828d
This commit is contained in:
Jonathan Rosser 2018-08-13 19:55:49 +01:00
parent 78a4291ace
commit e84dfc7ec8
7 changed files with 46 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
cache_timeout: 600
# Required apt packages.
lxc_hosts_distro_packages:
_lxc_hosts_distro_packages:
- apparmor
- apparmor-profiles
- apparmor-utils

View File

@ -17,7 +17,7 @@
cache_timeout: 600
# Required apt packages.
lxc_hosts_distro_packages:
_lxc_hosts_distro_packages:
- apparmor
- apparmor-profiles
- apparmor-utils