Automating IBM i from Scratch Using Ansible
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.
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)
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)
ansible --version
ansible-galaxy collection install ibm.power_ibmi
mkdir -p /home/ansibleadm/ansible_ibmi/{inventories,playbooks,group_vars} cd /home/ansibleadm/ansible_ibmi
[defaults] inventory = ./inventories/hosts host_key_checking = False interpreter_python = /QOpenSys/pkgs/bin/python3
[ibmiclients] 192.168.10.101 ansible_user=ansibleadm ansible_password=yourpass ansible_connection=ssh ansible_shell_type=sh
# group_vars/ibmiclients.yml ansible_become: false
Check connectivity:
ansible ibmiclients -m ping
You should see pong responses from the target IBM i systems.
ansible ibmiclients -m ibm.power_ibmi.ibmi_cl_command -a "cmd='CRTLIB LIB(DEMO)'"
ansible ibmiclients -m ibm.power_ibmi.ibmi_cl_command -a "cmd='DLTLIB LIB(DEMO)'"
- 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
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
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.
Blog Author
The author is passionate about sharing knowledge and experiences through writing.