#4 PLEASE REVIEW - add docker and rhts roles
Merged by merlinm. Opened by merlinm.
Unknown source master

Download 4.patch

This PR is for work I've done to implement two new Standard Test Interface ansible roles for docker and RHTS.

Since this is my first foray into using ansible and my docker experience is still limited, I would appreciate a thorough review and constructive feedback from some ansible experts before this PR gets merged!

The standard-test-docker role is for invoking tests against a docker image test subject in a similar manner to that described for other test subjects as described at https://fedoraproject.org/wiki/Changes/InvokingTestsAnsible#Invocation.

The standard-test-rhts role is for running RHTS (Red Hat Test System) style tests. (For those unfamiliar with RHTS, it is basically an enhanced version of beakerlib. Many of the tests being open sourced as part of the "upstream first" effort are based on RHTS.) The role uses restraint to run the tests as tasks, since the restraint-rhts package specifically includes support for running RHTS tests.

You can do a trial run that uses both of these new roles by running the following commands on a Fedora development machine:

Note: the standard-test-roles package in merlinm's COPR repo contains the latest copy of the roles referenced by this PR.

sudo dnf install ansible python2-dnf libselinux-python
sudo dnf copr enable merlinm/standard-test-roles
sudo dnf install standard-test-roles
mkdir scratch
cd scratch
git clone https://upstreamfirst.fedorainfracloud.org/diffutils.git
cd diffutils
sudo ansible-playbook test_docker.yml -e artifacts=$PWD/artifacts -e subjects=docker.io/fedora:latest
ls -l $PWD/artifacts
cat $PWD/artifacts/test.log

The playbook will take a while to run--especially the first time, if the fedora image needs to be downloaded. If you wish to examine the docker container that is used to run the tests before it gets cleaned up, set the environment variable FEDORA_TEST_DIAGNOSE=1.

You can also choose to run the tests directly on a local system by running the test_local.yml playbook, but you would be wise to do so on a disposable VM:

sudo systemctl start sshd
sudo ansible-playbook test_local.yml -e artifacts=$PWD/artifacts

Numerous additional examples of RHTS tests with test_local.yml and test_docker.yml playbooks can be found in many of the repos available at https://upstreamfirst.fedorainfracloud.org/browse/projects/.

Additional background information regarding the above commands for the quick trail run can be found in the "How to manually run migrated tests" section of the following document: https://docs.google.com/document/d/1nP_p1MwzCdMkcfz7Esl6A7ADFHnaCNkWq9lHxWqd2ig/edit#heading=h.z8o7qmgjtqpt

Yes. Try "including" the playbook?

http://docs.ansible.com/ansible/playbooks_roles.html#task-versus-play-includes

It may be that you cannot include a playbook from a role -- and that you can only include a playbook from another playbook.

If this is the case, this may need to be refactored to bring this "outside" of the current role.

Instead of all this file redirection, it might be better/simpler to use ansible copy or template modules.

No ability to use the service ansible module here? May be worth an inline comment explaining why.

Option 1: You can have one call to run the first role then another
Option 2: Use meta to have dependencies of other roles
http://docs.ansible.com/ansible/playbooks_roles.html#role-dependencies

Templates! Templates! Templates! are perfect for this in ansible

Thanks for the suggestions, @ralph and @alivigni. Perhaps I'm still misunderstanding something, but they don't seem to apply. This is the point where the designated playbook needs to be run inside the docker container that was just spun up by the previous tasks in this role.

This role could be running inside a docker container, so no service functionality AFAIK. I also want to capture the output from restraintd as an artifact. Thanks for the suggestion, @ralph.

1 new commit added

  • Use template module to generate restraint job.xml file.

Pull-Request has been merged by merlinm

I pushed ahead and merged this PR so I can get an updated package into the pipeline.

However, additional feedback and comments are still welcome!

Metadata