Development Guide
IBM Operator Collection SDK project development guide.
Testing changes in a forked repo
When working in a forked repository, there may be times where performing the ansible-playbook
command from within the OC SDK collection is restricted, since most playbooks are required to be executed from the root of another Operator Collection. This requires that the OC SDK collection be installed globally, and below are the steps to do so.
Installing local collection
From the operator-collection-sdk/ibm
directory issue the following command:
Installing from forked GitHub repo
Executing GitHub Workflows in a forked GitHub repo
GitHub doesn’t allow GitHub workflow Secrets to be passed to forked repositories. Since the current Ansible® Molecule tests require access to an OpenShift® cluster, you are required to configure the following two variables in your workspace before successfully executing an end to end test of your changes.
- Navigate to
Setting > Secrets and variables > Actions
and click the “New repository secret” button - Configure the
OPENSHIFT_SERVER
secret. This value can be retrieved using the following command: - Generate a new Service Account token in OpenShift and configure the
OPENSHIFT_TOKEN
secret in GitHub. Follow the steps below to generate a token with the proper access in the cluster
Ansible Molecule Setup
The steps below describe how to setup Ansible Molecule in a vitrual environment on your machine.
- Install virtualenv.
- Create a vitualenv directory in your project.
- Navigate to the new virtual environment directory.
- Activate the virtual environment.
- Install the following packages after activating the virtual environment.
- Navigate to the
playbooks
directory to execute the available Molecule scenarios. Example: - When you are ready to exit the virtual environment, simply execute the
deactivate
command to exit.
Writing Molecule Tests
Below are a few links I’d recommend to review to get started with Ansible Molecule:
Ansible Molecule Overview: https://www.toptechskills.com/ansible-tutorials-courses/rapidly-build-test-ansible-roles-molecule-docker/
Video Tutorial on Molecule playbook testing: https://www.youtube.com/watch?v=CYghlf-6Opc