Allow a list of files to be copied into the container cache
In order to better make use of OpenStack-CI's resources (apt mirrors, etc) we need to be able to copy configuration files which have been implemented on the host image into the containers. This patch provides a facility to do this in a way that provides a new facility for deployers to use, doesn't affect existing production environments and is easy for us to consume in gate testing. A new variable called 'lxc_container_cache_files' is implemented, which is a list of dictionaries specifying the location of the file on the deployment system, where to put it in the container cache, and what attributes to assign the file. An example of how to use it is included in the role's defaults as a comment. Change-Id: Ia76b3a791239a07db1cb93636b7d1e23a6a6851c
This commit is contained in:
parent
ad8908a153
commit
587f4e85a0
@ -116,3 +116,10 @@ lxc_cache_validate_certs: "yes"
|
||||
# name: "trusty.tgz"
|
||||
# sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c"
|
||||
# chroot_path: trusty/rootfs-amd64
|
||||
|
||||
# A list of files may be copied into the container image cache during its preparation.
|
||||
# Example:
|
||||
# lxc_container_cache_files:
|
||||
# - src: "/etc/openstack_deploy/files/etc/issue"
|
||||
# dest: "/etc/issue"
|
||||
lxc_container_cache_files: []
|
||||
|
@ -13,6 +13,20 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Copy files from deployment host to the container cache
|
||||
copy:
|
||||
src: "{{ item[1].src }}"
|
||||
dest: "{{ lxc_container_cache_path }}/{{ item[0].chroot_path }}/{{ item[1].dest }}"
|
||||
owner: "{{ item[1].owner | default('root') }}"
|
||||
group: "{{ item[1].group | default('root') }}"
|
||||
mode: "{{ item[1].mode | default('644') }}"
|
||||
with_nested:
|
||||
- lxc_container_caches
|
||||
- lxc_container_cache_files
|
||||
tags:
|
||||
- lxc-cache
|
||||
- lxc-cache-copy-files
|
||||
|
||||
- name: Create apt repos in the cached container
|
||||
template:
|
||||
src: sources.list.j2
|
||||
|
1
tests/files/container-file-copy-test.txt
Normal file
1
tests/files/container-file-copy-test.txt
Normal file
@ -0,0 +1 @@
|
||||
This is a test file to verify that the container cache file copy worked.
|
@ -42,6 +42,9 @@
|
||||
name: "trusty.tgz"
|
||||
sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c"
|
||||
chroot_path: trusty/rootfs-amd64
|
||||
lxc_container_cache_files:
|
||||
- src: files/container-file-copy-test.txt
|
||||
dest: /tmp/file-copied-from-deployment-host.txt
|
||||
post_tasks:
|
||||
- name: Open sysctl file
|
||||
slurp:
|
||||
@ -72,6 +75,14 @@
|
||||
shell: |
|
||||
cat files/expected-lxc-net-bridge.cfg
|
||||
register: expected_interface_file
|
||||
- name: Get the deployed test file from the container cache
|
||||
slurp:
|
||||
src: /var/cache/lxc/trusty/rootfs-amd64/tmp/file-copied-from-deployment-host.txt
|
||||
register: copied_file
|
||||
- name: Get the expected test file which should have been copied
|
||||
slurp:
|
||||
src: files/container-file-copy-test.txt
|
||||
register: expected_copied_file
|
||||
- name: Get bridge interface facts
|
||||
setup:
|
||||
filter: ansible_lxcbr0
|
||||
@ -84,4 +95,5 @@
|
||||
- "container_cache_dir.stat.isdir"
|
||||
- "container_tar_file.stat.exists"
|
||||
- "interface_file.stdout | match(expected_interface_file.stdout)"
|
||||
- "copied_file.content | match(expected_copied_file.content)"
|
||||
- "lxcbr0_facts.ansible_facts.ansible_lxcbr0.ipv4.address | match('10.100.100.1')"
|
||||
|
Loading…
x
Reference in New Issue
Block a user