Skip to content

Commit

Permalink
Fixed Ansible and Molecule test files.
Browse files Browse the repository at this point in the history
Signed-off-by: Yemi Kelani <Yemi.Kelani@ibm.com>
  • Loading branch information
Yemi Kelani authored and Yemi Kelani committed May 3, 2024
1 parent e0de1fa commit 3e15d3b
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 516 deletions.
74 changes: 0 additions & 74 deletions ibm/operator_collection_sdk/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,77 +70,3 @@ build_ignore:
# 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive
# with 'build_ignore'
# manifest: null

### REQUIRED
# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with
# underscores or numbers and cannot contain consecutive underscores
namespace: ibm

# The name of the collection. Has the same character restrictions as 'namespace'
name: operator_collection_sdk

# The version of the collection. Must be compatible with semantic versioning
version: 2.0.0-alpha.2

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md

# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
# @nicks:irc/im.site#channel'
authors:
- Latrell Freeman <latrell.freeman@us.ibm.com>


### OPTIONAL but strongly recommended
# A short summary description of the collection
description: The IBM Operator Collection SDK provides the resources and tools that are needed to develop Operator Collections against the IBM® z/OS® Cloud Broker as part of the IBM Z® and Cloud Modernization Stack.

# The path to the license file for the collection. This path is relative to the root of the collection. This key is
# mutually exclusive with 'license'
license_file: LICENSE

# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags:
- ibm
- operator_collection
- operator_collection_sdk
- zos
- z_os
- z

# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
# range specifiers can be set and are separated by ','
dependencies: {}

# The URL of the originating SCM repository
repository: https://github.com/IBM/operator-collection-sdk

# The URL to any online docs
documentation: https://github.com/IBM/operator-collection-sdk/blob/main/ibm/operator_collection_sdk/README.md

# The URL to the homepage of the collection/project
homepage: https://github.com/IBM/operator-collection-sdk/blob/main/ibm/operator_collection_sdk

# The URL to the collection issue tracker
issues: https://github.com/IBM/operator-collection-sdk/issues

# A list of file glob-like patterns used to filter any files or directories that should not be included in the build
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered. Mutually exclusive with 'manifest'
build_ignore:
- .gitignore
- playbooks/molecule
- ansible_venv

# A dict controlling use of manifest directives used in building the collection artifact. The key 'directives' is a
# list of MANIFEST.in style
# L(directives,https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands). The key
# 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive
# with 'build_ignore'
# manifest: null

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
connection: local
gather_facts: false
tasks:
- name: Install dependency # necessary for gh-actions use
- name: Install dependency # necessary for gh-actions ansible tests
pip:
name:
- kubernetes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
connection: local
gather_facts: false
tasks:
- name: Install dependency # necessary for gh-actions use
- name: Install dependency # necessary for gh-actions ansible tests
pip:
name:
- kubernetes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,101 +4,8 @@
#

---
- name: Converge
hosts: all
connection: local
gather_facts: false
vars:
ocpnamespace: "{{ ocpNamespace | lower | replace('_','-') | replace('/','-') }}"

tasks:
- name: Create Namespace
kubernetes.core.k8s:
state: present
definition:
kind: Namespace
metadata:
name: "{{ ocpnamespace }}"

- name: Create OperatorGroup
kubernetes.core.k8s:
state: present
definition:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: "{{ ocpnamespace }}"
namespace: "{{ ocpnamespace }}"
spec:
targetNamespaces:
- "{{ ocpnamespace }}"
upgradeStrategy: Default

- name: Create Subscripton
kubernetes.core.k8s:
state: present
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: "{{ subscription_name }}"
namespace: "{{ ocpnamespace }}"
spec:
channel: v2.2
installPlanApproval: Automatic
name: ibm-zoscb
source: ibm-operator-catalog
sourceNamespace: openshift-marketplace
startingCSV: "{{ zoscb_release }}"

- name: Validate Subscription installed successfully
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1alpha1
kind: Subscription
name: "{{ subscription_name }}"
namespace: "{{ ocpnamespace }}"
register: subscription_results
until: "subscription_results.resources[0].status.installedCSV is defined and subscription_results.resources[0].status.currentCSV"
retries: 30
delay: 5

- name: Validate CSV installed successfully
kubernetes.core.k8s_info:
api_version: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
name: "{{ subscription_results.resources[0].status.installedCSV }}"
namespace: "{{ ocpnamespace }}"
register: csv_results
until: "csv_results.resources[0].status.phase is defined and csv_results.resources[0].status.phase == 'Succeeded'"
retries: 30
delay: 5
- name: Set up test environment
import_playbook: ../cluster_setup.yml

- name: Create ZosCloudBroker
ibm.operator_collection_sdk.oc_zoscloudbroker:
state: present
namespace: "{{ ocpnamespace }}"
accept_license: true
multi_namespace: true
log_level: trace
storage:
configure: false
enabled: false
storage_size: 5Gi
volume_mode: Filesystem

- name: Validate ZosCloudBroker installed successfully
kubernetes.core.k8s_info:
api_version: zoscb.ibm.com/v2beta1
kind: ZosCloudBroker
name: "{{ zoscloudbroker_name }}"
namespace: "{{ ocpnamespace }}"
register: zoscb_results
until: "zoscb_results.resources[0].status.phase == 'Successful'"
retries: 30
delay: 5


- import_playbook: ../../create_operator.yml
vars:
filepath: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../examples/racf-operator"
ocpnamespace: "{{ ocpNamespace | lower | replace('_','-') | replace('/','-') }}"
- name: Converge
import_playbook: ../../create_operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,87 +8,16 @@
import_playbook: ../../delete_operator.yml
vars:
filepath: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../examples/racf-operator"
ocpnamespace: "{{ ocpNamespace | lower | replace('_','-') | replace('/','-') }}"

- name: Clean test environment
import_playbook: ../cluster_clean.yml

- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
ocpnamespace: "{{ ocpNamespace | lower | replace('_','-') | replace('/','-') }}"

tasks:
- name: Get SubOperatorConfigs
kubernetes.core.k8s_info:
api_version: zoscb.ibm.com/v2beta2
kind: SubOperatorConfig
namespace: "{{ target_namespace }}"
register: soc_results

- name: Remove Orphaned SubOperatorConfigs
kubernetes.core.k8s_json_patch:
api_version: zoscb.ibm.com/v2beta2
kind: SubOperatorConfig
namespace: "{{ target_namespace }}"
name: "{{ item.metadata.name }}"
patch:
- op: replace
path: /metadata/finalizers
value: []
when: soc_results.resources | length > 0
with_items: "{{ soc_results.resources }}"

- name: Delete ZosEndpoint
kubernetes.core.k8s:
state: absent
api_version: zoscb.ibm.com/v2beta2
kind: ZosEndpoint
name: "{{ zosendpoint_name }}"
namespace: "{{ ocpnamespace }}"
wait: true
wait_sleep: 5
wait_timeout: 140

- name: Delete ZosCloudBoker
kubernetes.core.k8s:
state: absent
api_version: zoscb.ibm.com/v2beta1
kind: ZosCloudBroker
name: "{{ zoscloudbroker_name }}"
namespace: "{{ ocpnamespace }}"
wait: true
wait_sleep: 5
wait_timeout: 140

- name: Delete Subscripton
kubernetes.core.k8s:
state: absent
api_version: operators.coreos.com/v1alpha1
kind: Subscription
name: "{{ subscription_name }}"
namespace: "{{ ocpnamespace }}"
wait: true
wait_sleep: 5
wait_timeout: 140

- name: Delete OperatorGroup
kubernetes.core.k8s:
state: absent
api_version: operators.coreos.com/v1
kind: OperatorGroup
name: "{{ ocpnamespace }}"
namespace: "{{ ocpnamespace }}"

- name: Delete Namespace
kubernetes.core.k8s:
state: absent
kind: Namespace
name: "{{ ocpnamespace }}"
wait: true
wait_sleep: 5
wait_timeout: 140
ignore_errors: true

- name: Remove local build
ansible.builtin.file:
path: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../examples/racf-operator/local"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ provisioner:
config_options:
defaults:
jinja2_native: true
playbooks:
cleanup: cleanup.yml

## extra-vars needed to bypass vars_prompts
ansible_args:
Expand All @@ -26,7 +28,8 @@ provisioner:
collection_namespace: ibm
subscription_name: ibm-zoscb
zoscloudbroker_name: zoscloudbroker
ocpNamespace: ${OCP_NAMESPACE:-molecule}
ocpnamespace: "{{ '${OCP_NAMESPACE:-molecule}' | lower | regex_replace('[^-a-zA-Z0-9]','-') }}"
operator_path: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../examples/racf-operator"
zosendpoint_name: ibmcloud-vm
openshift_token: ${OPENSHIFT_TOKEN}
openshift_server: ${OPENSHIFT_SERVER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
hosts: all
connection: local
gather_facts: false
vars:
ocpnamespace: "{{ ocpNamespace | lower | replace('_','-') | replace('/','-') }}"

tasks:
- name: Validate OCP cluster authorization
ansible.builtin.command: oc project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
hosts: all
connection: local
gather_facts: false
vars:
ocpnamespace: "{{ ocpNamespace | lower | replace('_','-') | replace('/','-') }}"

tasks:
- name: Validate ZosEndpoint
kubernetes.core.k8s_info:
Expand Down

0 comments on commit 3e15d3b

Please sign in to comment.