Skip to content

Commit 39fba35

Browse files
committed
Make mol_config_dir optional; update molecule development doc
The molecule config parameter should be optional, just to give possibility to create molecule config file that contains all required parameters. Also update molecule development document, that would explain in better way how to start molecule job manually. Signed-off-by: Daniel Pawlik <[email protected]>
1 parent be5cdb0 commit 39fba35

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

ci/playbooks/molecule-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@
5555
chdir: "{{ roles_dir }}"
5656
cmd: >-
5757
set -o pipefail;
58-
molecule -c {{ mol_config_dir }} test --all |
58+
molecule
59+
{% if mol_config_dir is defined and mol_config_dir %} -c {{ mol_config_dir }} {% endif %}
60+
test --all |
5961
tee {{ ansible_user_dir }}/ci-framework-data/logs/molecule-execution.log

docs/source/development/02_molecule.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ cifmw_artifacts_basedir: "{{ ansible_user_dir }}/ci-framework-data/artifacts "
7777
cifmw_installyamls_repos: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/install_yamls"
7878
nodepool:
7979
cloud: ""
80-
roles_dir: /home/$(whoami)/src/github.com/openstack-k8s-operators/ci-framework/roles
8180
mol_config_dir: /home/$(whoami)/src/github.com/openstack-k8s-operators/ci-framework/.config/molecule/config_local.yml
8281
cifmw_zuul_target_host: localhost
8382
EOF
@@ -87,6 +86,7 @@ ansible-galaxy install -r requirements.yml
8786
# Mock some roles, that are needed for Zuul CI, but not for local deployment
8887
mkdir -p roles/mirror-info-fork/tasks
8988
mkdir -p roles/prepare-workspace/tasks
89+
mkdir -p group_vars
9090

9191
# Execute Ansible to prepare molecule environment
9292
ansible-playbook -i inventory.yml \
@@ -97,21 +97,35 @@ ansible-playbook -i inventory.yml \
9797
### START MOLECULE JOB ###
9898
##########################
9999

100-
# Copy molecule job - example: crc_layout
101-
mkdir -p roles/molecule/default/
102-
cp -a ./roles/reproducer/molecule/crc_layout/* roles/molecule/default/
100+
# Execute molecule job
101+
## Example
102+
## role: reproducer, scenario: crc_layout
103103

104104
# It can be done using:
105-
# - Ansible
105+
106+
### - Ansible - recommended ###
106107

107108
ansible-playbook -i inventory.yml \
109+
-e roles_dir="$(pwd)/roles/reproducer" \
108110
109111
ci/playbooks/molecule-test.yml
110112

111-
# - shell steps
112-
ln -s roles/molecule .
113+
#### - shell steps ####
113114
pip3 install -r test-requirements.txt
114-
molecule -c .config/molecule/config_local.yml test --all
115+
cd roles/reproducer
116+
117+
# NOTE: Usually it is: config_local.yml. There is also config_podman.yml scenario
118+
# NOTE: In some cases, when molecule provides all parameters,
119+
# do not include config file (skip adding '-c' parameter)
120+
molecule -c ../../.config/molecule/config_local.yml test --all
121+
122+
# or just one scenario
123+
molecule -c ../../.config/molecule/config_local.yml test -s crc_layout
124+
125+
# Sometimes it is required to force recreate preparation.
126+
# For example for crc_layout scenario
127+
cd roles/reproducer
128+
molecule prepare --force -s crc_layout
115129
```
116130

117131
### SSH to controller-0 - molecule VM

0 commit comments

Comments
 (0)