z/OS Connect

z/OS Connect

z/OS Connect

Truly RESTful APIs to and from your IBM Z mainframe

 View Only

Deploying z/OS Connect APIs with Ansible

By Andrew Smithson posted 8 hours ago

  

The zosConnect-3.0 feature which introduced support for OpenAPI 3 based APIs only supports deploying APIs on z/OS by copying the generated WAR file into the correct location on the zFS and then refreshing the server.

There are a number of ways that files can be transferred from a build system but ideally this should be an automated process and adapting configuration as code means that the process is repeatable and any changes are reviewed and approved.

Ansible fulfils all of these requirements with it's YAML based file format and ability to integrate into DevOps pipelines and so using some of the tasks made available in the IBM z/OS Collection we can define how to upload the generated WAR file and any configuration files and then refresh the server to make those changes live.

Uploading files

The zos_copy task provides the ability to get the generated API war file and the configuration files to the correct directories for the server. This example shows how to copy from the local directory where the ansible task is running onto a remote z/OS system.

tasks:
    - name: Upload WAR file
      ibm.ibm_zos_core.zos_copy:
         src: api.war
         dest: "{{ WLP_USER_DIR }}/servers/{{ SERVER_NAME }}/apps/{{ API_NAME }}.war"
         is_binary: true
         force: true

The use of variables (between the {{ and }}) allows the playbook to be used on multiple servers and for different APIs reducing the amount of duplicate definitions required.

Refreshing the server

To make the changes live in the server a modify command can be used to first refresh the configuration and then secondly the API. The zos_operator task allows us to issue a command against the server task so as per the example below the commands can be issued programatically.

tasks:
    - name: Refresh configuration
      ibm.ibm_zos_core.zos_operator:
          cmd: 'f {{ TASK_NAME }},refresh,config'

A full example project for doing all these steps is available on GitHub.

1 comment
6 views

Permalink

Comments

4 hours ago

Very helpful, Andrew. Does this require any prerequisites, such as having zosmf  installed?