Docker with z/OS: Yeah – it’s fun!

unsplash-logo
Rodion Kutsaev

It is pretty cool to be able to use Z Open Automation Utilities to work with datasets in the Unix System Services environment using Python, Java or the shell. But sometimes, I want to work with datasets from Linux, or my mac. So I began to experiment with using ssh, similar to the way Ansible works.

I started with a remote dls command. dls is a shell command that lists datasets. To use the remote dls command, you have to set some environment variables to describe what the host is you want to connect to, along with the way to connect, and then you are good to go. Here are the environment variables:

  • RMVSDIR: The location where the IBM Z Open Automation Utilities reside on the target z/OS system. In my case, this is /usr/lpp/zoau/bin
  • RMVSHOST: The name of the z/OS system you want to connect to. In my case, this is mike11.fyre.ibm.com
  • RMVSUSER: The user to connect to the z/OS system with. In my case, this is ibmuser
  • RMVSSCP: The name of the secure copy program to run. For most people, this is just scp
  • RMVSSCPOPTS: The options to pass to the secure copy (e.g. scp) program. For most people, this will be ‘ ‘, but for my system, I use an alternate port, so I specify: ‘-P 2022’
  • RMVSSSH: Similar to RMVSSCP, this is the name of the secure shell to run. For most people, this is just ssh
  • RMVSSSHOPTS: The options to pass to the secure shell (e.g. ssh) program. For most people, this will be ‘ ‘, but for my system, I use an alternate port, so I specify: ‘-p 2022’

The tools also presume you have configured your z/OS system and client with keys so that you can avoid passwords. If you already are able to ssh to z/OS on your Desktop without specifying a password already, you can skip this next section.

Connecting your Desktop to z/OS with ssh

Previously, I discussed ssh configuration for setting up git on z/OS, where you run a git client on z/OS. You are connecting from z/OS out to github. For this scenario, you are connecting from your Desktop out to z/OS (so the client and server are reversed). Here’s what you need to do.

If you have a file called ~/.ssh/id_rsa.pub, skip the next step where you create your public/private key pair.

  • Generate a public/private key pair, if you don’t have the file ~/.ssh/id_rsa.pub
ssh-keygen -t rsa -b 4096 -C "my-email-account"
hit return to choose default location
choose a passphrase for access
eval "$(ssh-agent -s)" start the ssh-agent
ssh-add ~/.ssh/id_rsa
  • Copy the contents of ~/.ssh/id_rsa.pub to your clipboard
  • Log in to your z/OS system, and create the file ~/.ssh/authorized_keys if it does not exist.
  • Append the contents of your clipboard to the end of the file ~/.ssh/authorized_keys
  • Log off
  • Verify that you can now log in to z/OS via ssh and you are not prompted.

Running the Remote dls command

Now that you have connectivity to your z/OS system, clone the samples on your Desktop client as follows:

Now you can run the dls program as follows;

  • cd Samples/rzoau/bin
  • dls “$RMVSUSER.*”

You should see the list of all the datasets under the $RMVSUSER id printed to the console. The remote dls code is just some wrapper code to ssh to z/OS and then run dls on the host.

Docker Anyone?

One of the problems you might hit is that perhaps your ssh client works a little different than mine, or perhaps the shell you use by default isn’t the same as the one I use. Docker eliminates the works for me set of problems that are so annoying.

I wrote a Dockerfile that takes arguments for the server, user, port, z/OS directory as described above, along with the private and public keys of the client. These arguments get built into the docker image, making it very easy to then extend the image or use it directly to run dls.

Note that my Dockerfile does not support a passphrase for access. If you want to use a passphrase, you will need to tweak the Dockerfile a bit. I actually created a second public/private key (without the passphrase) that I use for this docker experiment, so that I wasn’t using my personal keys with docker.

To see the docker file in action:

  • cd Samples/rzoau
  • edit the rzoau-build script to match your target z/OS system
  • Run rzoau-build to build the docker image that provides the remote dls support
  • Run devenv-build to build the docker image that extends the rzoau image and includes a simple development environment (in this case, vim).
  • devenv to run the development environment docker image interactively with sh

At this point, you will see a shell prompt. If you enter:

  • dls “$RMVSUSER.*”

you should see the list of your datasets on z/OS.

With a little imagination, you could see how all the IBM Z Open Automation Utilities could have remote interfaces.


Posted

in

by

Tags:

Comments

One response to “Docker with z/OS: Yeah – it’s fun!”

  1. Carlos Herrera Avatar

    Thank you for this post. I have been consolidating a list of resources for newbies in my team and this article will fit perfectly.

    Like

Leave a comment