Last active
May 31, 2022 21:46
-
-
Save cvoltz/ddc14eddb55e59dcdc196092ec67f52d to your computer and use it in GitHub Desktop.
Running Ansible module tests in a container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# © Copyright 2022 Hewlett Packard Enterprise Development LP | |
# All rights reserved. | |
# | |
# Used to run the tests for the Ansible modules included as part of the | |
# installer. To use, run: | |
# cd ~/ece-installer/ansible/library | |
# docker-compose up --build | |
services: | |
test-mmmount: | |
build: ./ | |
command: | |
bash -c ' | |
source venv/bin/activate && | |
source hacking/env-setup && | |
python3.9 -m unittest test/units/modules/test_mmmount.py | |
' | |
volumes: | |
- type: bind | |
source: $PWD/tests/test_mmmount.py | |
target: /test/ansible/test/units/modules/test_mmmount.py | |
- type: bind | |
source: $PWD/tests/mmmount_stub.py | |
target: /test/ansible/test/units/modules/mmmount_stub.py | |
- type: bind | |
source: $PWD/mmmount.py | |
target: /test/ansible/lib/ansible/modules/mmmount.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# © Copyright 2022 Hewlett Packard Enterprise Development LP | |
# All rights reserved. | |
# | |
# Creates the Docker image used for testing Ansible modules. | |
FROM rockylinux:8.5 | |
RUN \ | |
dnf module reset -y python36 && \ | |
dnf module enable -y python39 && \ | |
dnf install -y \ | |
findutils \ | |
git \ | |
man-db \ | |
python3-virtualenv \ | |
python39 | |
WORKDIR /test | |
RUN \ | |
git clone https://github.com/ansible/ansible.git && \ | |
cd ansible && \ | |
virtualenv venv --python=/usr/bin/python3.9 && \ | |
source venv/bin/activate && \ | |
pip3 install -r requirements.txt && \ | |
source hacking/env-setup | |
WORKDIR /test/ansible |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put both files into
ansible/library
and rundocker-compose up --build
from that directory to run the tests.