Automating IBM i from Scratch Using Ansible

Automating IBM i from Scratch Using Ansible

Home / Insights on AI, Automation & Enterprise IT / Automating IBM i from Scratch Using Ansible
Blog post image
June 12, 2025 Admin IBM Power Systems

Automating IBM i from Scratch Using Ansible

Automating IBM i from Scratch Using Ansible: A Code24 Implementation Guide

By Code24 Pty Ltd | June 2025

Modernizing IBM i environments doesn't have to be complex or manual. At Code24, we help businesses bring infrastructure automation to IBM i using industry-standard, open-source tools. One such tool is Red Hat Ansible. This guide outlines how to set up and run Ansible for IBM i environments from scratch using IBM i itself as the Ansible control node—perfect for customer data centers, on-premises infrastructure, or hybrid cloud setups.

⚙️ Infrastructure Overview

We assume an environment with the following components:

1 IBM i LPAR (Ansible Control Node) running IBM i 7.4 or 7.5 with Open Source support

1 or more IBM i LPARs (targets) to be managed

SSH access from the controller to all target LPARs

Python and SSH enabled using IBM i Open Source Package Management (Yum)

🔐 Step 1: Prepare the IBM i Control Node

Install Required Tools via Yum (on IBM i):

yum install git python3 python3-pip gcc-c++ yum install openssh ansible

Ensure SSH server is active:

STRTCPSVR SERVER(*SSHD)

Optional: Add a dedicated user for automation (e.g., ANSIBLEADM)

CRTUSRPRF USRPRF(ANSIBLEADM) PASSWORD(TEMP123) USRCLS(*SECOFR) STATUS(*ENABLED)

Verify Ansible:

ansible --version

Install IBM i Collection:

ansible-galaxy collection install ibm.power_ibmi

🛠️ Step 2: Configure Ansible

Create configuration directory:

mkdir -p /home/ansibleadm/ansible_ibmi/{inventories,playbooks,group_vars} cd /home/ansibleadm/ansible_ibmi

Create ansible.cfg

[defaults] inventory = ./inventories/hosts host_key_checking = False interpreter_python = /QOpenSys/pkgs/bin/python3

Inventory file: inventories/hosts

[ibmiclients] 192.168.10.101 ansible_user=ansibleadm ansible_password=yourpass ansible_connection=ssh ansible_shell_type=sh

Disable privilege escalation (sudo not used on IBM i):

# group_vars/ibmiclients.yml ansible_become: false

✦ Step 3: Verify Communication

Check connectivity:

ansible ibmiclients -m ping

You should see pong responses from the target IBM i systems.

🧪 Step 4: Run IBM i Commands

Create Library:

ansible ibmiclients -m ibm.power_ibmi.ibmi_cl_command -a "cmd='CRTLIB LIB(DEMO)'"

Remove Library:

ansible ibmiclients -m ibm.power_ibmi.ibmi_cl_command -a "cmd='DLTLIB LIB(DEMO)'"

📝 Step 5: Example Playbook

Create user only if not exists

- hosts: ibmiclients  tasks:    - name: Check if user exists      ibm.power_ibmi.ibmi_sql_query:        sql: "SELECT COUNT(*) AS EXIST FROM QSYS2.USER_INFO WHERE AUTHORIZATION_NAME = 'DEMOUSER'"      register: result    - name: Create user if not exists      ibm.power_ibmi.ibmi_user_and_group:        operation: create        user: DEMOUSER        password: "'TempPass123'"        status: '*ENABLED'        text: 'Demo User'      when: result.row[0].EXIST == 0

Run with:

ansible-playbook playbooks/create_user.yml

✦ Code24's Offering

We use this approach for:

IBM i environment automation from within IBM i itself

Seamless user and system configuration management

Securing and monitoring IBM i configurations

Integrating IBM i with enterprise-wide automation workflows

✍︎ Request a Live Demo

Want to see IBM i managing IBM i via Ansible? We offer:

End-to-end IBM i automation using native tools

Tailored playbook development

POC and production setup for customers and MSPs

📩 Get in touch with Code24 for a hands-on demo and automation assessment today.

About the Author

Admin

Blog Author

The author is passionate about sharing knowledge and experiences through writing.

Other Blogs

Stay informed with our expert insights! Explore articles on the latest trends, tips, and strategies in web design, digital marketing, and more.