Setting up Ansible for IBM Wazi
Ansible and the Red Hat Ansible Certified Content for IBM Z collections provide important capabilities that help administrators with enterprise automation scenarios and help developers automate their development setup.
In particular, you can use Ansible to prepare a remote z/OS system such as IBM Wazi Sandbox for the development prerequisites that are necessary for building and running applications right from your IDE.
You can edit and run Ansible playbooks directly in IBM Wazi by using editing capabilities such as the Red Hat Ansible language server, as well as running playbooks that use the Ansible Certified Content for IBM Z.
To familiarize yourself with these Ansible collections, check out these resources:
-
GitHub repository with examples for using Red Hat Ansible Certified Content for IBM Z for many more scenarios.
IBM Wazi for Dev Spaces has all of these capabilities preinstalled and configured when you use the IBM Wazi for Dev Spaces stack and container image. When you create your workspace, it has Ansible and its prerequisites installed and ready to use, including Python, Red Hat Ansible Certified Content for IBM Z, the VS Code extension, and the language server for Ansible editing that offers features such as code completion and linking.
If you are using other editors, such as IBM Wazi for VS Code or IBM Wazi for Eclipse, you need to set up Ansible on your development desktop machine.
Setting up Ansible in IBM Wazi for Dev Spaces
You can create or open an Ansible playbook file with the extension .yml
or .yaml
, and select Ansible
in the language selector of the editor in the status bar. (The default language is YAML
,
which does not provide the right language capabilities.)
After you select Ansible
as the language, the editor provides features such as rich hovers with help text, code completion through ctrl-space, and linking warnings and errors that are added or removed when you save a file.
To enable these features for the preinstalled Red Hat Ansible Certified Content for IBM Z, add the following code to your playbook:
collections:
- ibm.ibm_zos_core
To learn more about the Ansible editor and additional configuration options, see Ansible VS Code Extension by Red Hat .
To run Ansible playbooks directly out of IBM Wazi for Dev Spaces, open the wazi-terminal
from the Terminal menu and run the ansible
or ansible-playbook
commands. Check out Configuring your development workspace with Ansible for running playbooks that support COBOL development.
Setting up Ansible on MacOS
To use the same capabilities that are described previously for IBM Wazi for Dev Spaces, you need to install Ansible on your Mac, and then install and configure the VS Code extension.
You can install Ansible by using the Brew package manager, which also takes care of all prerequisites, such as Python.
brew install ansible
brew install ansible-lint
If the package manager is not available, see the Ansible Documentation that outlines alternative methods.
After the installation is completed, you can add the z/OS collections by running the following command:
ansible-galaxy collection install ibm.ibm_zos_core ibm.ibm_zos_ims ibm.ibm_zos_cics ibm.ibm_zhmc ibm.ibm_zos_sysauto
Check out Installation instructions for more details.
You can now run Ansible collections from any command-line tool, such as the Mac Terminal program or the terminal view in VS Code.
If you use IBM Wazi for Eclipse, the MacOS terminal is the preferred option.
If you use IBM Wazi for VS Code, to edit Ansible playbooks with the exact same features for IBM Wazi for Dev Spaces, install the Red Hat Ansible VS Code extension from the VS Code Marketplace.
Setting up Ansible on Windows
To install and run Ansible on Windows, you can use the Windows Subsystem for Linux (WSL) . Follow these basic steps:
-
Follow the instructions for installing WSL . Run the following command from a Powershell:
wsl --install
The default WSL is installed by using Ubuntu. Review the configuration documentation for various configuration options. You need to create a username and a password. The Microsoft documentation also has a special page for using WSL with VS Code to review. This document outlines two basic modes of working with WSL:
a. Keeping the source code on Windows and accessing it from WSL for running commands such as playbooks.
b. Moving the source code into WSL and opening it in VS Code as a remote workspace. For that model, you can install the WSL VS Code extension from Microsoft that manages such a remote access for you. You can also use the second approach to clone Git repos into WSL and open VS Code folders on WSL.
-
Install Ansible into WSL/Ubuntu. See the Ansible Documentation for more information.
sudo apt update sudo apt install software-properties-common sudo add-apt-repository --yes --update ppa:ansible/ansible sudo apt install ansible sudo apt install ansible-lint
-
Install Red Hat Ansible Certified Content for IBM Z Collection. Check out Installation instructions for more information.
ansible-galaxy collection install ibm.ibm_zos_core
-
Set up passwordless SSH from the WSL/Ubuntu shell to your z/OS system:
ssh-keygen -t rsa -b 4096 -C "username@your-org.com" ssh-copy-id username@zos_ip_address
Now you are ready to run Ansible playbooks from the WSL Ubuntu command shell from within VS Code or a separate window.
-
Finally, install the Ansible VS Code extension for Ansible to get VS Code editing support. Depending on whether you are working with your source code from Windows or the WSL/Ubuntu environment, you need to install the extension locally or remotely through the WSL extension. The same applies to the Z Open Editor and Zowe Explorer extension.
Advanced WSL setup steps for Zowe CLI
If you are working with your Git repo from WSL/Ubuntu, you can also install Zowe CLI for additional automation scripts, which requires Node.js.
sudo apt install nodejs npm
To avoid a conflict with the Windows path that automatically gets appended to your Ubuntu path, create the file /etc/wsl.conf
with the following content:
[interop]
appendWindowsPath = false
After you save the file, restart WSL with wsl --shutdown
from a Windows Powershell. Restart WSL/Ubuntu and run the following commands:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Edit your ~/.profile file to add the following code at the end:
export PATH=~/.npm-global/bin:$PATH
Then, run the following command:
source ~/.profile
npm install -g @zowe/cli@zowe-v1-lts
Now you can install additional plug-ins that are needed for your work.