mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
synchronize: add support for buildah (#33823)
Fixes #33533 Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
This commit is contained in:
parent
c9e9422133
commit
0587aedc01
7 changed files with 114 additions and 13 deletions
2
test/integration/targets/synchronize-buildah/aliases
Normal file
2
test/integration/targets/synchronize-buildah/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
non_local
|
||||
needs/root
|
1
test/integration/targets/synchronize-buildah/inventory
Normal file
1
test/integration/targets/synchronize-buildah/inventory
Normal file
|
@ -0,0 +1 @@
|
|||
buildah-container ansible_host=buildah-container ansible_connection=buildah
|
|
@ -0,0 +1 @@
|
|||
abnormal content
|
|
@ -0,0 +1,66 @@
|
|||
# test code for the synchronize module
|
||||
# (c) 2014, James Tanner <tanner.jc@gmail.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: cleanup old files
|
||||
file:
|
||||
path: '{{ output_dir }}'
|
||||
state: absent
|
||||
|
||||
- name: ensure the target directory exists
|
||||
file:
|
||||
path: '{{ output_dir }}'
|
||||
state: directory
|
||||
|
||||
- name: synchronize file to new filename
|
||||
synchronize:
|
||||
src: normal_file.txt
|
||||
dest: '{{ output_dir }}/remote_file.txt'
|
||||
register: sync_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'changed' in sync_result"
|
||||
- "sync_result.changed == true"
|
||||
- "'cmd' in sync_result"
|
||||
- "'rsync' in sync_result.cmd"
|
||||
- "'msg' in sync_result"
|
||||
- "sync_result.msg.startswith('<f+')"
|
||||
- "sync_result.msg.endswith('+ normal_file.txt\n')"
|
||||
|
||||
- name: test that the file was really copied over
|
||||
stat:
|
||||
path: "{{ output_dir }}/remote_file.txt"
|
||||
register: stat_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "stat_result.stat.exists == True"
|
||||
- "stat_result.stat.checksum == '4f11fb5cd9fe0171ea6fab02ae33f65138f3e44e'"
|
||||
|
||||
- name: test that the file is not copied a second time
|
||||
synchronize: src=normal_file.txt dest={{output_dir}}/remote_file.txt
|
||||
register: sync_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "sync_result.changed == False"
|
||||
|
||||
- name: cleanup old files
|
||||
file:
|
||||
path: '{{ output_dir }}'
|
||||
state: absent
|
15
test/integration/targets/synchronize-buildah/runme.sh
Executable file
15
test/integration/targets/synchronize-buildah/runme.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ux
|
||||
|
||||
CONTAINER_NAME=buildah-container
|
||||
|
||||
buildah rm $CONTAINER_NAME >/dev/null 2>/dev/null
|
||||
|
||||
set -e
|
||||
|
||||
buildah from --name $CONTAINER_NAME docker.io/library/centos:7
|
||||
trap '{ buildah rm $CONTAINER_NAME; }' EXIT
|
||||
buildah run $CONTAINER_NAME -- yum install -y rsync
|
||||
|
||||
ansible-playbook test_synchronize_buildah.yml -c buildah -i inventory -vv
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- hosts: buildah-container
|
||||
connection: buildah
|
||||
gather_facts: no
|
||||
vars:
|
||||
output_dir: /tmp/ansible_test_synchronize_buildah
|
||||
roles:
|
||||
- test_buildah_synchronize
|
Loading…
Add table
Add a link
Reference in a new issue