Running Ansible to manage IBM i systems

Ansible Basic Concepts

Refer to Ansible community doc to learn Ansible Basic Concepts https://docs.ansible.com/ansible/latest/network/getting_started/basic_concepts.html

Configure your Ansible

Refer to Ansible community doc to learn Ansible Configuration Settings https://docs.ansible.com/ansible/latest/reference_appendices/config.html

Here is an example of an ansible.cfg

[defaults]
library=~/.ansible/collections/ansible_collections/ibm/power_ibmi/plugins/modules
action_plugins=~/.ansible/collections/ansible_collections/ibm/power_ibmi/plugins/action
interpreter_python=/QOpenSys/pkgs/bin/python3

Using python3 for interpreter_python will point to a specific python release, which is typically the latest installed python level. You may want to specify the level, such as python3.13, to ensure a specific level is utilized on the managed node(s). If the set of managed nodes spans different platforms beyond IBM i or if different python levels are desired for different managed nodes, then it is recommended to specify interpreter_python in the Ansible inventory file instead of the config file.

Build your inventory

Refer to Ansible community doc to learn how to build your first inventory https://docs.ansible.com/ansible/latest/network/getting_started/first_inventory.html

Here is an example of the inventory file:

[ibmi]
your_ibmi_ip ansible_ssh_user=your_user ansible_ssh_pass=your_host_password

[ibmi:vars]
ansible_python_interpreter="/QOpensys/pkgs/bin/python3"
ansible_ssh_common_args='-o StrictHostKeyChecking=no'

Run your first command or playbook

Refer to Ansible community doc to learn how to run Ansible command or playbook https://docs.ansible.com/ansible/latest/network/getting_started/first_playbook.html

Examples:

ansible -i inventory.ini ibmi -m ibm.power_ibmi.ibmi_cl_command -a "cmd='crtlib lib(demo111)'"
ansible -i inventory.ini ibmi -m ibm.power_ibmi.ibmi_reboot