Replies: 2 comments 2 replies
-
Hi @SRv6d Could you please provide a minimal reproducible example? |
Beta Was this translation helpful? Give feedback.
-
Hi @zhan9san Sure. Creating a minimal role
---
- name: Converge
hosts: all
tasks:
- name: "Include molecule_test"
include_role:
name: "molecule_test"
- name: debug example_variable
debug:
var: example_variable
---
scenario:
test_sequence:
- lint
- destroy
- dependency
- syntax
- create
- prepare
- converge
- idempotence
- verify
- side_effect
- converge
- idempotence
- verify
- destroy
dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
driver:
name: docker
platforms:
- name: ubuntu-20.04
image: srv6d/ubuntu-systemd:20.04
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
privileged: true
command: "/sbin/init"
pre_build_image: true
provisioner:
name: ansible
playbooks:
side_effect: side_effect.yml
inventory:
group_vars:
all:
example_variable: "init"
verifier:
name: testinfra
---
- hosts: all
become: true
tasks:
- name: change example variable
ansible.builtin.set_fact:
example_variable: "after_side_effect"
INFO default scenario test matrix: lint, destroy, dependency, syntax, create, prepare, converge, idempotence, verify, side_effect, converge, idempotence, verify, destroy
INFO Performing prerun...
INFO Set ANSIBLE_LIBRARY=/Users/marvin/.cache/ansible-compat/6147c9/modules:/Users/marvin/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO Set ANSIBLE_COLLECTIONS_PATH=/Users/marvin/.cache/ansible-compat/6147c9/collections:/Users/marvin/.ansible/collections:/usr/share/ansible/collections
INFO Set ANSIBLE_ROLES_PATH=/Users/marvin/.cache/ansible-compat/6147c9/roles:/Users/marvin/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO Running default > lint
INFO Lint is disabled.
INFO Running default > destroy
INFO Sanity checks: 'docker'
PLAY [Destroy] *****************************************************************
TASK [Destroy molecule instance(s)] ********************************************
changed: [localhost] => (item=ubuntu-20.04)
TASK [Wait for instance(s) deletion to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (300 retries left).
ok: [localhost] => (item=ubuntu-20.04)
TASK [Delete docker networks(s)] ***********************************************
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
INFO Running default > dependency
INFO Running ansible-galaxy collection install -v community.docker:>=1.9.1
WARNING Skipping, missing the requirements file.
WARNING Skipping, missing the requirements file.
INFO Running default > syntax
playbook: /private/tmp/molecule_test/molecule/default/converge.yml
INFO Running default > create
PLAY [Create] ******************************************************************
TASK [Log into a Docker registry] **********************************************
skipping: [localhost] => (item=None)
skipping: [localhost]
TASK [Check presence of custom Dockerfiles] ************************************
ok: [localhost] => (item={'capabilities': ['SYS_ADMIN'], 'command': '/sbin/init', 'image': 'srv6d/ubuntu-systemd:20.04', 'name': 'ubuntu-20.04', 'pre_build_image': True, 'privileged': True, 'tmpfs': ['/run', '/tmp'], 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
TASK [Create Dockerfiles from image names] *************************************
skipping: [localhost] => (item={'capabilities': ['SYS_ADMIN'], 'command': '/sbin/init', 'image': 'srv6d/ubuntu-systemd:20.04', 'name': 'ubuntu-20.04', 'pre_build_image': True, 'privileged': True, 'tmpfs': ['/run', '/tmp'], 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
TASK [Discover local Docker images] ********************************************
ok: [localhost] => (item={'changed': False, 'skipped': True, 'skip_reason': 'Conditional result was False', 'item': {'capabilities': ['SYS_ADMIN'], 'command': '/sbin/init', 'image': 'srv6d/ubuntu-systemd:20.04', 'name': 'ubuntu-20.04', 'pre_build_image': True, 'privileged': True, 'tmpfs': ['/run', '/tmp'], 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item', 'i': 0, 'ansible_index_var': 'i'})
TASK [Build an Ansible compatible image (new)] *********************************
skipping: [localhost] => (item=molecule_local/srv6d/ubuntu-systemd:20.04)
TASK [Create docker network(s)] ************************************************
TASK [Determine the CMD directives] ********************************************
ok: [localhost] => (item={'capabilities': ['SYS_ADMIN'], 'command': '/sbin/init', 'image': 'srv6d/ubuntu-systemd:20.04', 'name': 'ubuntu-20.04', 'pre_build_image': True, 'privileged': True, 'tmpfs': ['/run', '/tmp'], 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']})
TASK [Create molecule instance(s)] *********************************************
changed: [localhost] => (item=ubuntu-20.04)
TASK [Wait for instance(s) creation to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) creation to complete (300 retries left).
changed: [localhost] => (item={'failed': 0, 'started': 1, 'finished': 0, 'ansible_job_id': '655973914856.36842', 'results_file': '/Users/marvin/.ansible_async/655973914856.36842', 'changed': True, 'item': {'capabilities': ['SYS_ADMIN'], 'command': '/sbin/init', 'image': 'srv6d/ubuntu-systemd:20.04', 'name': 'ubuntu-20.04', 'pre_build_image': True, 'privileged': True, 'tmpfs': ['/run', '/tmp'], 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item'})
PLAY RECAP *********************************************************************
localhost : ok=5 changed=2 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0
INFO Running default > prepare
WARNING Skipping, prepare playbook not configured.
INFO Running default > converge
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [ubuntu-20.04]
TASK [Include molecule_test] ***************************************************
TASK [molecule_test : debug example_variable] **********************************
ok: [ubuntu-20.04] => {
"example_variable": "init"
}
PLAY RECAP *********************************************************************
ubuntu-20.04 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
INFO Running default > idempotence
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [ubuntu-20.04]
TASK [Include molecule_test] ***************************************************
TASK [molecule_test : debug example_variable] **********************************
ok: [ubuntu-20.04] => {
"example_variable": "init"
}
PLAY RECAP *********************************************************************
ubuntu-20.04 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
INFO Idempotence completed successfully.
INFO Running default > verify
WARNING Skipping, no tests found.
INFO Running default > side_effect
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [ubuntu-20.04]
TASK [change example variable] *************************************************
ok: [ubuntu-20.04]
PLAY RECAP *********************************************************************
ubuntu-20.04 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
INFO Running default > converge
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [ubuntu-20.04]
TASK [Include molecule_test] ***************************************************
TASK [molecule_test : debug example_variable] **********************************
ok: [ubuntu-20.04] => {
"example_variable": "init"
}
PLAY RECAP *********************************************************************
ubuntu-20.04 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
INFO Running default > idempotence
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [ubuntu-20.04]
TASK [Include molecule_test] ***************************************************
TASK [molecule_test : debug example_variable] **********************************
ok: [ubuntu-20.04] => {
"example_variable": "init"
}
PLAY RECAP *********************************************************************
ubuntu-20.04 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
INFO Idempotence completed successfully.
INFO Running default > verify
WARNING Skipping, no tests found.
INFO Running default > destroy
PLAY [Destroy] *****************************************************************
TASK [Destroy molecule instance(s)] ********************************************
changed: [localhost] => (item=ubuntu-20.04)
TASK [Wait for instance(s) deletion to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (300 retries left).
changed: [localhost] => (item=ubuntu-20.04)
TASK [Delete docker networks(s)] ***********************************************
PLAY RECAP *********************************************************************
localhost : ok=2 changed=2 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
INFO Pruning extra files from scenario ephemeral directory As you can see the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to be able to test how my roles behave if variables are changed after initial run. I've tried to use
set_facts
within side effects using a custom test sequence, but overriding role variables this way doesn't seem to work.Beta Was this translation helpful? Give feedback.
All reactions