Browse Source

Merge "Allow user-defined extra distro packages"

Zuul 7 months ago
parent
commit
af91693ce0
2 changed files with 36 additions and 2 deletions
  1. 8
    2
      defaults/main.yml
  2. 28
    0
      tests/test.yml

+ 8
- 2
defaults/main.yml View File

@@ -199,17 +199,23 @@ nspawn_container_cache_files_from_host: []
199 199
 #    - gnupg
200 200
 nspawn_container_distro_required_packages: "{{ _nspawn_container_distro_required_packages | default([]) }}"
201 201
 
202
+# Define a list of extra distribution packages to install into the container cache
203
+nspawn_container_extra_distro_packages: []
204
+
202 205
 # Default list of packages to install within the build container cache.
203 206
 #  nspawn_container_distro_packages:
204 207
 #    - curl
205 208
 #    - tcpdump
206
-nspawn_container_distro_packages: "{{ _nspawn_container_distro_packages | default([]) }}"
209
+nspawn_container_distro_packages: "{{ _nspawn_container_distro_packages | default([]) + nspawn_container_extra_distro_packages }}"
210
+
211
+# Define a list of extra distribution packages to install onto the host
212
+nspawn_hosts_extra_distro_packages: []
207 213
 
208 214
 # Default list of packages to install on the physical host machine.
209 215
 #  nspawn_hosts_distro_packages:
210 216
 #    - bridge-utils
211 217
 #    - btrfs-tools
212
-nspawn_hosts_distro_packages: "{{ _nspawn_hosts_distro_packages | default([]) }}"
218
+nspawn_hosts_distro_packages: "{{ _nspawn_hosts_distro_packages | default([]) + nspawn_hosts_extra_distro_packages }}"
213 219
 
214 220
 
215 221
 # === General container defaults ===============================================

+ 28
- 0
tests/test.yml View File

@@ -18,6 +18,8 @@
18 18
   connection: local
19 19
   become: true
20 20
   vars:
21
+    extra_host_package: iotop
22
+    extra_cache_package: lshw
21 23
     bridges: []
22 24
     nspawn_networks:
23 25
       nspawn_address:
@@ -56,12 +58,21 @@
56 58
       set_fact:
57 59
         nspawn_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}"
58 60
 
61
+    - name: Ensure extra host package is not installed
62
+      package:
63
+        name: "{{ extra_host_package }}"
64
+        state: absent
65
+
59 66
   roles:
60 67
     - role: "nspawn_hosts"
61 68
       nspawn_container_base_name: "test-container"
62 69
       nspawn_container_cache_files:
63 70
         - src: files/container-file-copy-test.txt
64 71
           dest: /tmp/file-copied-from-deployment-host.txt
72
+      nspawn_hosts_extra_distro_packages:
73
+        - "{{ extra_host_package }}"
74
+      nspawn_container_extra_distro_packages:
75
+        - "{{ extra_cache_package }}"
65 76
 
66 77
   post_tasks:
67 78
     - name: Check for nspawn bridge
@@ -113,6 +124,23 @@
113 124
       command: "machinectl read-only test-container yes"
114 125
       changed_when: false
115 126
 
127
+    - name: Get installation state of extra host package
128
+      package:
129
+        name: "{{ extra_host_package }}"
130
+        state: present
131
+      failed_when:
132
+        - extra_host_package_state.changed == true
133
+      register: extra_host_package_state
134
+
135
+    - name: Check for extra package installed in lxc cache
136
+      find:
137
+        paths: "/var/lib/machines"
138
+        patterns: "{{ extra_cache_package }}"
139
+        recurse: yes
140
+      failed_when:
141
+        extra_cache_package_find.matched == 0
142
+      register: extra_cache_package_find
143
+
116 144
     - name: Ensure a read-only image is read-only
117 145
       file:
118 146
         path: /var/lib/machines/test-container/test-file

Loading…
Cancel
Save