Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Test include roles dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Jan 28, 2020
1 parent d7828b8 commit c16fdb0
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 0 deletions.
1 change: 1 addition & 0 deletions molecule/dynamic/.ansible-lint
1 change: 1 addition & 0 deletions molecule/dynamic/Dockerfile.j2
1 change: 1 addition & 0 deletions molecule/dynamic/debian-redis-server.service
13 changes: 13 additions & 0 deletions molecule/dynamic/group_vars/all
@@ -0,0 +1,13 @@
---
pulp_default_admin_password: password
pulp_roles:
- pulp-database
- pulp-workers
- pulp-resource-manager
- pulp-webserver
- pulp-content
pulp_install_plugins:
pulp-file: {}
pulp_settings:
secret_key: secret
content_origin: "http://{{ ansible_fqdn }}"
48 changes: 48 additions & 0 deletions molecule/dynamic/molecule.yml
@@ -0,0 +1,48 @@
---
dependency:
name: galaxy
role-file: requirements.yml
driver:
name: docker
lint:
name: yamllint
# This is ignored by molecule, but can be reused in yaml
.platform_base: &platform_base
privileged: False
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /tmp
- /run
- /run/lock
capabilities:
- NET_ADMIN
- NET_RAW
platforms:
- <<: *platform_base
name: centos-7
image: centos:7
command: /sbin/init
- <<: *platform_base
name: debian-10
image: debian:buster
command: /sbin/init
- <<: *platform_base
name: fedora-31
image: fedora:31
command: /usr/sbin/init
provisioner:
name: ansible
inventory:
links:
host_vars: ../scenario_resources/host_vars/
group_vars: ../scenario_resources/group_vars/
lint:
name: ansible-lint
scenario:
name: dynamic
verifier:
name: inspec
lint:
name: rubocop
enabled: false
20 changes: 20 additions & 0 deletions molecule/dynamic/playbook.yml
@@ -0,0 +1,20 @@
---
- hosts: all
pre_tasks:
# The version string below is the highest of all those in roles' metadata:
# "min_ansible_version". It needs to be kept manually up-to-date.
- name: Verify Ansible meets min required version
assert:
that: "ansible_version.full is version_compare('2.8', '>=')"
msg: >
"You must update Ansible to at least 2.8 to use this version of Pulp 3 Installer."
- name: Dynamically include prereq roles
include_role:
public: yes
name: "{{ roleinputvar }}"
loop: "{{ pulp_roles }}"
loop_control:
loop_var: roleinputvar
environment:
DJANGO_SETTINGS_MODULE: pulpcore.app.settings
8 changes: 8 additions & 0 deletions molecule/dynamic/prepare.yml
@@ -0,0 +1,8 @@
---
- hosts: all
tasks:
- name: Hot patch redis-server service for docker operation (Debian)
copy:
src: debian-redis-server.service
dest: /etc/systemd/system/redis-server.service
when: ansible_distribution == "Debian"
1 change: 1 addition & 0 deletions molecule/dynamic/requirements.yml
1 change: 1 addition & 0 deletions molecule/dynamic/roles
10 changes: 10 additions & 0 deletions tox.ini
Expand Up @@ -32,6 +32,16 @@ commands =
{env:TRAVIS_WAIT:} molecule idempotence -s source
molecule side-effect -s source
molecule verify -s source
molecule destroy -s source
molecule lint -s dynamic
molecule dependency -s dynamic
molecule syntax -s dynamic
molecule create -s dynamic
molecule prepare -s dynamic
molecule converge -s dynamic
{env:TRAVIS_WAIT:} molecule idempotence -s dynamic
molecule side-effect -s dynamic
molecule verify -s dynamic
# only the last scenario should lack a "destroy" task. (It wastes time, and makes debugging more difficult.)

[testenv:py36-upgrade]
Expand Down

0 comments on commit c16fdb0

Please sign in to comment.