Add docker_container_copy_into module (#545)

* Move copying functionality to module_utils.

* Add docker_container_copy_into module.

* Use new module in other tests.

* Fix copyright and attributes.

* Improve idempotency, improve stat code.

* Document and test when a stopped container works.

* Improve owner/group detection error handling when container is stopped.

* Fix formulation.

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Improve file comparison.

* Avoid reading whole file at once.

* Stream when fetching files from daemon.

* Fix comment.

* Use read() instead of read1().

* Stream files when copying into container.

* Linting.

* Add force parameter.

* Simplify library code.

* Linting.

* Add content and content_is_b64 options.

* Make force=false work as for copy module: only copy if the destination does not exist.

* Improve docs.

* content should be no_log.

* Implement diff mode.

* Improve error handling.

* Lint and improve.

* Set owner/group ID to avoid ID lookup (which fails in paused containers).

* Apply suggestions from code review

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
This commit is contained in:
Felix Fontein
2023-01-09 11:52:29 +01:00
committed by GitHub
parent 134d32cae6
commit e198e4ab43
26 changed files with 3920 additions and 101 deletions
@@ -43,7 +43,12 @@
- nginx.conf
- name: Copy static files into volume
command: docker cp {{ remote_tmp_dir }}/{{ item }} {{ daemon_nginx_frontend }}:/etc/nginx/{{ item }}
docker_container_copy_into:
container: '{{ daemon_nginx_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
container_path: '/etc/nginx/{{ item }}'
owner_id: 0
group_id: 0
loop:
- nginx.conf
register: can_copy_files
@@ -94,7 +99,12 @@
provider: ownca
- name: Copy dynamic files into volume
command: docker cp {{ remote_tmp_dir }}/{{ item }} {{ daemon_nginx_frontend }}:/etc/nginx/{{ item }}
docker_container_copy_into:
container: '{{ daemon_nginx_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
container_path: '/etc/nginx/{{ item }}'
owner_id: 0
group_id: 0
loop:
- ca.pem
- cert.pem