atomic-host-tests icon indicating copy to clipboard operation
atomic-host-tests copied to clipboard

provide metadata/dummy data for roles to allow for easier use/testing

Open miabbott opened this issue 7 years ago • 2 comments

Over in #324, I muse about improving the CI tests to do better checking of changed roles in PRs.

Unfortunately, before we can do that effectively, we need to have some sane metadata/dummy data about the arguments that a role requires. Some of the roles have some snippets about required variables, but we really need a standard, so that tests can determine how to run the roles.

This is just a spitball idea, but something like this:

---
#
# name:  docker_run
# args:
#    - docker_image (required)
#    - run_options (optional)
#
# dummy_data:
#    - docker_image: registry.fedoraproject.org/fedora:27
#

So maybe we need to define a sane standard for providing dummy data and then work on updating all the roles to have said data.

miabbott avatar Jan 29 '18 20:01 miabbott

Here's a spitball idea:

Maybe have a roles/role_name/vars/test.yml with dummy data in it? For example

roles/ansible_version_check/vars/test.yml

---
avc_major: 2
avc_minor: 2

Then we can have a generic playbook like this: test.yml

---
- name: Test Role
  hosts: all                                                                                               
  become: true

  vars_files:
    - "roles/{{ role }}/vars/test.yml"

  roles:
    - role: "{{ role }}"

To test, we run `ansible-playbook test.yml -e role="ansible_version_check"

This might need some work on the vars_files section if the role does not require any vars.

mike-nguyen avatar Feb 16 '18 15:02 mike-nguyen

@mike-nguyen I like it! We could still require vars/test.yml and just have it be a blank file.

miabbott avatar Feb 16 '18 15:02 miabbott