mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Migrate Linux CI roles to test targets. (#17997)
This commit is contained in:
58
test/integration/targets/docker/tasks/docker-tests.yml
Normal file
58
test/integration/targets/docker/tasks/docker-tests.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
- name: Start docker daemon
|
||||
service:
|
||||
name: docker
|
||||
state: started
|
||||
|
||||
- name: Download busybox image
|
||||
docker:
|
||||
image: busybox
|
||||
state: present
|
||||
pull: missing
|
||||
|
||||
- name: Run a small script in busybox
|
||||
docker:
|
||||
image: busybox
|
||||
state: reloaded
|
||||
pull: always
|
||||
command: "nc -l -p 2000 -e xargs -n1 echo hello"
|
||||
detach: True
|
||||
|
||||
- name: Get the docker container ip
|
||||
set_fact: container_ip="{{docker_containers[0].NetworkSettings.IPAddress}}"
|
||||
|
||||
- name: Try to access the server
|
||||
shell: "echo 'world' | nc {{ container_ip }} 2000"
|
||||
register: docker_output
|
||||
|
||||
- name: check that the script ran
|
||||
assert:
|
||||
that:
|
||||
- "'hello world' in docker_output.stdout_lines"
|
||||
|
||||
- name: Run a script that sets environment in busybox
|
||||
docker:
|
||||
image: busybox
|
||||
state: reloaded
|
||||
pull: always
|
||||
env:
|
||||
TEST: hello
|
||||
command: '/bin/sh -c "nc -l -p 2000 -e xargs -n1 echo $TEST"'
|
||||
detach: True
|
||||
|
||||
- name: Get the docker container ip
|
||||
set_fact: container_ip="{{docker_containers[0].NetworkSettings.IPAddress}}"
|
||||
|
||||
- name: Try to access the server
|
||||
shell: "echo 'world' | nc {{ container_ip }} 2000"
|
||||
register: docker_output
|
||||
|
||||
- name: check that the script ran
|
||||
assert:
|
||||
that:
|
||||
- "'hello world' in docker_output.stdout_lines"
|
||||
|
||||
- name: Remove containers
|
||||
shell: "docker rm -f $(docker ps -aq)"
|
||||
|
||||
- name: Remove all images from the local docker
|
||||
shell: "docker rmi -f $(docker images -q)"
|
||||
Reference in New Issue
Block a user