Skip to content

Commit

Permalink
Merge pull request #1 from IBM/1.0.1
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
stewartfrancis committed Oct 23, 2023
2 parents b8a959f + ba45802 commit ce79b38
Show file tree
Hide file tree
Showing 31 changed files with 336 additions and 107 deletions.
1 change: 1 addition & 0 deletions collections-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kubernetes==28.1.0
53 changes: 52 additions & 1 deletion collections/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
kubernetes==11.0.0
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=collections/requirements.txt collections-requirements.txt
#
cachetools==5.3.1
# via google-auth
certifi==2023.7.22
# via
# kubernetes
# requests
charset-normalizer==3.3.0
# via requests
google-auth==2.23.3
# via kubernetes
idna==3.4
# via requests
kubernetes==28.1.0
# via -r collections-requirements.txt
oauthlib==3.2.2
# via
# kubernetes
# requests-oauthlib
pyasn1==0.5.0
# via
# pyasn1-modules
# rsa
pyasn1-modules==0.3.0
# via google-auth
python-dateutil==2.8.2
# via kubernetes
pyyaml==6.0.1
# via kubernetes
requests==2.31.0
# via
# kubernetes
# requests-oauthlib
requests-oauthlib==1.3.1
# via kubernetes
rsa==4.9
# via google-auth
six==1.16.0
# via
# kubernetes
# python-dateutil
urllib3==1.26.18
# via
# kubernetes
# requests
websocket-client==1.6.4
# via kubernetes
2 changes: 1 addition & 1 deletion collections/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ collections:
- name: ibm.ibm_zos_core
version: 1.6.0
- name: operator_sdk.util
version: 0.4.0
version: 0.5.0
- name: kubernetes.core
version: 2.4.0
12 changes: 10 additions & 2 deletions deprovision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,13 @@
when:
- validation_error is not defined
- run_result != "duplicate"
ansible.builtin.include_role:
name: deprovision
block:
- name: Deprovision region {{ DFH_REGION_APPLID }}
ansible.builtin.include_role:
name: deprovision

- name: Remove metadata file
environment: "{{ z_environment_vars }}"
ansible.builtin.file:
path: "{{ DFH_ZFS_METADATA }}/{{ DFH_REGION_APPLID }}"
state: absent
7 changes: 4 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-r collections/requirements.txt
ansible-core
ansible-lint
ansible-core==2.15.5
ansible-lint==6.21.1
pytest==7.4.0
pytest-xdist==1.34.0
pytest-xdist==1.34.0
pylint==3.0.1
19 changes: 11 additions & 8 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: ibm
name: zos_cics_operator

# The version of the collection. Must be compatible with semantic versioning
version: 1.0.0
version: 1.0.1

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down Expand Up @@ -58,18 +58,21 @@ issues: https://github.com/IBM/zos_cics_operator/issues
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered
build_ignore:
- .jenkins
- Jenkinsfile
- .devcontainer
- .venv
- collections/ansible_collections
- .gitignore
- dev-requirements.txt
- ibm-zos_cics_operator-*.tar.gz
- tests
- inventories
- .DS_Store
- .jenkins
- Jenkinsfile
- .vscode
- .release-it.yml
- .utils
- .DS_Store
- .whitesource
- release_os.py
# Items beyond here will be included in the OS repo
- OS-INCLUDE
- .gitignore
- dev-requirements.txt
- tests
- collections-requirements.txt
4 changes: 0 additions & 4 deletions group_vars/all.yml

This file was deleted.

2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (c) Copyright IBM Corp. 2023
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
---
requires_ansible: ">=2.9.10"
requires_ansible: ">=2.13.0"
2 changes: 1 addition & 1 deletion operator-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: zos-cics-ts-operator
displayName: IBM Z and Cloud Modernization Stack - CICS TS Operator
domain: ibm
version: 1.0.0
version: 1.0.1
description: >-
# IBM Z and Cloud Modernization Stack - CICS TS Operator
The **IBM CICS TS Operator Collection** provides automation around provisioning CICS Transaction Server for z/OS to one or more Wazi Sandbox instances and
Expand Down
80 changes: 80 additions & 0 deletions plugins/action/detect_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (c) Copyright IBM Corp. 2023
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
from ansible.plugins.action import ActionBase

# All instances of this role must be identical. Cloud broker does not execute playbooks
# in this collection using FQCN, so as far as Ansible in CB is concerned, we're
# executing an ad-hoc playbook. That means that Ansible will search for referenced
# assets differently.
#
# In this case in CB, Ansible will look for action plugins relative to the
# playbook in an action_plugins directory, rather than the collection-specific
# location plugins/actions, relative to the collection root. In order to make this
# collection executable as a collection and by cloud broker, this file is instead
# embedded in all roles that require it independently, to work around this limitation.
#
# These files must be identical and tests/unit/test_detect_environment_duplicated.py
# verifies this constraint.

WAZI_SANDBOX_PRE_26_PYTHON_HOME = "/usr/lpp/IBM/cyp/v3r9/pyz"
WAZI_SANDBOX_26_PYTHON_HOME = "/usr/lpp/IBM/cyp/pyz"


class ActionModule(ActionBase):

def run(self, tmp=None, task_vars=None):
super(ActionModule, self).run(tmp, task_vars)

# Execute an SSH command that doesn't require a python interepreter
shell_result = self._low_level_execute_command(f"file {WAZI_SANDBOX_PRE_26_PYTHON_HOME}/bin/python3")

discovered = {}
if "FSUM6484" not in shell_result['stdout']:
# wazi sandbox pre 2.6
pyz = WAZI_SANDBOX_PRE_26_PYTHON_HOME
dfh_zos_stcjobs = "USER.Z25C.PROCLIB"
else:
# wazi sandbox 2.6
pyz = WAZI_SANDBOX_26_PYTHON_HOME
dfh_zos_stcjobs = "USER.Z25D.PROCLIB"

zoau_home = "/usr/lpp/IBM/zoautil"
dfh_zfs_mountpoint = "/u/ibmuser/regions"

discovered.update({
"pyz": pyz,
"z_environment_vars": {
"_BPXK_AUTOCVT": "ON",
"ZOAU_HOME": zoau_home,
"LIBPATH": f"{ zoau_home }/lib:{ pyz }/lib:/lib:/usr/lib:.",
"PATH": f"{ zoau_home }/bin:{ pyz }/bin:/bin:/var/bin",
"_CEE_RUNOPTS": "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)",
"_TAG_REDIR_ERR": "txt",
"_TAG_REDIR_IN": "txt",
"_TAG_REDIR_OUT": "txt",
"LANG": "C",
"PYTHONSTDINENCODING": "cp1047"
},

"DFH_APPLID_PREFIX": "ZCICS",
"JOB_CARD": "JOB REGION=0M,MSGLEVEL=(1,1),MSGCLASS=R",
"DFH_CICS_HLQ": "DFH610.CICS",
"DFH_CICS_LICENSE_DATASET": "DFH610.SDFHLIC",
"DFH_LE_HLQ": "CEE",
"DFH_ZOS_STCJOBS": dfh_zos_stcjobs,
"DFH_CICS_USSHOME": "/usr/lpp/cicsts/cicsts61",
"DFH_REGION_CICSSVC": 216,
"DFH_REGION_SIT": "6$",
"DFH_REGION_DFLTUSER": "CICSUSER",
"DFH_REGION_HLQ": "IBMUSER.REGIONS",
"DFH_ZFS_MOUNTPOINT": dfh_zfs_mountpoint,
"DFH_ZFS_METADATA": f"{ dfh_zfs_mountpoint }/metadata",
"DFH_STC_JOB_CARD": "JOB REGION=0M,MSGLEVEL=(1,1),MSGCLASS=R,NOTIFY=IBMUSER",
"DFH_ZOS_VSAM_UNIT": "SYSDA"
})

return dict(
ansible_facts=discovered
)
12 changes: 4 additions & 8 deletions plugins/action/is_job_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
from ansible.plugins.action import ActionBase

# The files
# roles/start_cics/actions_plugins/is_job_running.py
# roles/stop_cics/actions_plugins/is_job_running.py
# roles/validate/actions_plugins/is_job_running.py
# All instances of this role must be identical. Cloud broker does not execute playbooks
# in this collection using FQCN, so as far as Ansible in CB is concerned, we're
# executing an ad-hoc playbook. That means that Ansible will search for referenced
# assets differently.
#
# Must be identical. Cloud broker does not execute playbooks in this collection
# using FQCN, so as far as Ansible in CB is concerned, we're executing an ad-hoc
# playbook. That means that Ansible will search for referenced assets differently.
# In this case in CB, Ansible will look for action plugins relative to the
# playbook in an action_plugins directory, rather than the collection-specific
# location plugins/actions, relative to the collection root. In order to make this
Expand All @@ -20,7 +17,6 @@
#
# These files must be identical and tests/unit/test_is_job_running_duplicated.py
# verifies this constraint.
#


class ActionModule(ActionBase):
Expand Down
21 changes: 21 additions & 0 deletions plugins/modules/detect_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# (c) Copyright IBM Corp. 2023
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)

DOCUMENTATION = r"""
---
module: detect_environment
short_description: Detect environment and facts for Wazi Sandbox
description:
- Detect environment and facts for Wazi Sandbox
version_added: 1.0.0
author:
- IBM (@IBM)
"""

EXAMPLES = r"""
- name: Detect environment
detect_environment:
"""
2 changes: 1 addition & 1 deletion provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ansible.builtin.include_role:
name: check_for_reconciliation
vars:
metadata_folder: "{{ DFH_ZFS_MOUNTPATH }}"
metadata_folder: "{{ DFH_ZFS_METADATA }}"

- name: Provision the region
when: not reconcile_run
Expand Down
6 changes: 5 additions & 1 deletion roles/check_for_reconciliation/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
block:
- name: Set the path for the metadata file
ansible.builtin.set_fact:
metadata_filepath: "{{ metadata_folder }}/cicstsregion_metadata"
metadata_filepath: "{{ metadata_folder }}/{{ DFH_REGION_APPLID }}"

- name: Lookup the metadata file for the current APPLID
environment: "{{ z_environment_vars }}"
ansible.builtin.stat:
path: '{{ metadata_filepath }}'
register: cicstsregion_metadata_file
Expand All @@ -60,19 +61,22 @@
verbosity: 1

- name: Create the metadata directory if it does not exist
environment: "{{ z_environment_vars }}"
ansible.builtin.file:
path: '{{ metadata_folder }}'
state: directory
mode: "600"

- name: Write the metadata file if it doesn't exist already
environment: "{{ z_environment_vars }}"
when: not metadata_exists
ansible.builtin.copy:
content: '{{ cr_uid }}'
dest: '{{ metadata_filepath }}'
mode: "600"

- name: Fetch the UID value found in the metadata file
environment: "{{ z_environment_vars }}"
ansible.builtin.slurp:
src: '{{ metadata_filepath }}'
register: cicstsregion_metadata
Expand Down
1 change: 1 addition & 0 deletions roles/conventions/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# (c) Copyright IBM Corp. 2023
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
---
DFH_REGION_APPLID: "{{ DFH_APPLID_PREFIX ~ DFH_REGION_SYSID }}"
DFH_ZFS_MOUNTPATH: "{{ DFH_ZFS_MOUNTPOINT }}/{{ DFH_REGION_APPLID }}"
DFH_DFHCSD: "{{ DFH_REGION_HLQ }}.{{ DFH_REGION_APPLID }}.DFHCSD"
DFH_DFHGCD: "{{ DFH_REGION_HLQ }}.{{ DFH_REGION_APPLID }}.DFHGCD"
Expand Down
1 change: 1 addition & 0 deletions roles/deprovision_zfs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
---
- name: Check if the zFS filesystem is still mounted
environment: "{{ z_environment_vars }}"
ansible.builtin.stat:
path: '{{ DFH_ZFS_MOUNTPATH }}/PROVISION_OK'
register: mountpoint_exists
Expand Down
1 change: 1 addition & 0 deletions roles/provision_stc/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
force: true

- name: Delete the templated job tempfile for the STC
environment: "{{ z_environment_vars }}"
ansible.builtin.file:
state: absent
path: "{{ templated_stc.path }}"
Expand Down
12 changes: 4 additions & 8 deletions roles/start_cics/action_plugins/is_job_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
from ansible.plugins.action import ActionBase

# The files
# roles/start_cics/actions_plugins/is_job_running.py
# roles/stop_cics/actions_plugins/is_job_running.py
# roles/validate/actions_plugins/is_job_running.py
# All instances of this role must be identical. Cloud broker does not execute playbooks
# in this collection using FQCN, so as far as Ansible in CB is concerned, we're
# executing an ad-hoc playbook. That means that Ansible will search for referenced
# assets differently.
#
# Must be identical. Cloud broker does not execute playbooks in this collection
# using FQCN, so as far as Ansible in CB is concerned, we're executing an ad-hoc
# playbook. That means that Ansible will search for referenced assets differently.
# In this case in CB, Ansible will look for action plugins relative to the
# playbook in an action_plugins directory, rather than the collection-specific
# location plugins/actions, relative to the collection root. In order to make this
Expand All @@ -20,7 +17,6 @@
#
# These files must be identical and tests/unit/test_is_job_running_duplicated.py
# verifies this constraint.
#


class ActionModule(ActionBase):
Expand Down
Loading

0 comments on commit ce79b38

Please sign in to comment.