Merge "Allow user-defined extra distro packages"

This commit is contained in:
Zuul 2018-09-07 02:04:53 +00:00 committed by Gerrit Code Review
commit af91693ce0
2 changed files with 36 additions and 2 deletions

View File

@ -199,17 +199,23 @@ nspawn_container_cache_files_from_host: []
# - gnupg # - gnupg
nspawn_container_distro_required_packages: "{{ _nspawn_container_distro_required_packages | default([]) }}" nspawn_container_distro_required_packages: "{{ _nspawn_container_distro_required_packages | default([]) }}"
# Define a list of extra distribution packages to install into the container cache
nspawn_container_extra_distro_packages: []
# Default list of packages to install within the build container cache. # Default list of packages to install within the build container cache.
# nspawn_container_distro_packages: # nspawn_container_distro_packages:
# - curl # - curl
# - tcpdump # - tcpdump
nspawn_container_distro_packages: "{{ _nspawn_container_distro_packages | default([]) }}" nspawn_container_distro_packages: "{{ _nspawn_container_distro_packages | default([]) + nspawn_container_extra_distro_packages }}"
# Define a list of extra distribution packages to install onto the host
nspawn_hosts_extra_distro_packages: []
# Default list of packages to install on the physical host machine. # Default list of packages to install on the physical host machine.
# nspawn_hosts_distro_packages: # nspawn_hosts_distro_packages:
# - bridge-utils # - bridge-utils
# - btrfs-tools # - btrfs-tools
nspawn_hosts_distro_packages: "{{ _nspawn_hosts_distro_packages | default([]) }}" nspawn_hosts_distro_packages: "{{ _nspawn_hosts_distro_packages | default([]) + nspawn_hosts_extra_distro_packages }}"
# === General container defaults =============================================== # === General container defaults ===============================================

View File

@ -18,6 +18,8 @@
connection: local connection: local
become: true become: true
vars: vars:
extra_host_package: iotop
extra_cache_package: lshw
bridges: [] bridges: []
nspawn_networks: nspawn_networks:
nspawn_address: nspawn_address:
@ -56,12 +58,21 @@
set_fact: set_fact:
nspawn_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}" nspawn_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}"
- name: Ensure extra host package is not installed
package:
name: "{{ extra_host_package }}"
state: absent
roles: roles:
- role: "nspawn_hosts" - role: "nspawn_hosts"
nspawn_container_base_name: "test-container" nspawn_container_base_name: "test-container"
nspawn_container_cache_files: nspawn_container_cache_files:
- src: files/container-file-copy-test.txt - src: files/container-file-copy-test.txt
dest: /tmp/file-copied-from-deployment-host.txt dest: /tmp/file-copied-from-deployment-host.txt
nspawn_hosts_extra_distro_packages:
- "{{ extra_host_package }}"
nspawn_container_extra_distro_packages:
- "{{ extra_cache_package }}"
post_tasks: post_tasks:
- name: Check for nspawn bridge - name: Check for nspawn bridge
@ -113,6 +124,23 @@
command: "machinectl read-only test-container yes" command: "machinectl read-only test-container yes"
changed_when: false changed_when: false
- name: Get installation state of extra host package
package:
name: "{{ extra_host_package }}"
state: present
failed_when:
- extra_host_package_state.changed == true
register: extra_host_package_state
- name: Check for extra package installed in lxc cache
find:
paths: "/var/lib/machines"
patterns: "{{ extra_cache_package }}"
recurse: yes
failed_when:
extra_cache_package_find.matched == 0
register: extra_cache_package_find
- name: Ensure a read-only image is read-only - name: Ensure a read-only image is read-only
file: file:
path: /var/lib/machines/test-container/test-file path: /var/lib/machines/test-container/test-file