For something like this, I think you want ansible.builtin.command instead. The best practice is to only use ansible.builtin.shell is you are actually using shell redirects, etc.
--
Stephen L. Ulmer
Enterprise Architect
Mainline Information Systems
Original Message:
Sent: 11/9/2023 3:36:00 AM
From: Niklas V.
Subject: RE: Ansible playbook to validate HBA connectivity
I think this is not covered by any existing AIX module and "ansible.builtin.shell" will help to execute your well-known AIX commands.
- name: Gather fcstat data
ansible.builtin.shell: fcstat fcs0
changed_when: false
register: fcstat_data
- debug:
var: fcstat_data
You can place any idea for new modules here as "Issue": GitHub - IBM/ansible-power-aix: Developer contributions for Ansible Automation on Power
------------------------------
Niklas
System Engineer UNIX and Linux on Power
------------------------------
Original Message:
Sent: Wed November 08, 2023 10:14 AM
From: Mark Steele
Subject: Ansible playbook to validate HBA connectivity
Thanks Niklas, however, the mpio module shows me information about disks paths, not the state of the HBA and if it's connected. Maybe I should clarify. This playbook would be run on a newly deployed system to help validate all the cabling is completed and shows connectivity. So simply, if the fcstat command returns anything, we are likely connected and if it errors out, we are not. Not sure if I've found a different command that will show link status.
ok: [aixtest01] => {
"ansible_facts.mpio": {
"drivers": {
"2107DS8K": {
"option": "NO_OVERRIDE",
"options": [
"NO_OVERRIDE",
"AIX_AAPCM",
"AIX_non_MPIO"
...
"paths": {
"hdisk0": {
"fscsi0": {
"5005076810115357,0": {
"path_id": 1,
"path_status": "Available",
"status": "Enabled"
},
"500507681011536e,0": {
"path_id": 0,
"path_status": "Available",
"status": "Enabled"
}
},
...
------------------------------
Mark Steele
Original Message:
Sent: Tue November 07, 2023 11:06 AM
From: Niklas V.
Subject: Ansible playbook to validate HBA connectivity
I think we have to split this into smaller steps. First we have to gather data with the "setup" module or "gather_facts: true" in your playbook and maybe add some AIX specific data with the module "ibm.power_aix.mpio". When we have all the data we are able to automate the further steps with "ibm.power_aix.devices" when some fc-adapter is missing in your environment.
Just a small piece of code to give you an example of how to gather all the data you maybe need to evaluate the system state:
- hosts: all gather_facts: true become: true tasks: - name: Gather mpio data ibm.power_aix.mpio: - name: Show all the ansible facts debug: var: ansible_facts... some checks and maybe re-creation by using ibm.power_aix.devices ...
------------------------------
Niklas
System Engineer UNIX and Linux on Power
Original Message:
Sent: Mon November 06, 2023 05:40 PM
From: Mark Steele
Subject: Ansible playbook to validate HBA connectivity
I'm fairly new to Ansible and have been looking for a way to use it to help validate all my fcs devices are connected to the fabric. So in looking at community.general.aix_devices and ibm.power_aix.devices I can see ways to rmdev, mkdev and change attributes, but what I'm hoping for, is a playbook that for each fcs device, validates it's connected to the fabric (fcstat) and if not, run a rmdev and mkdev on it.
Anyone have any pointers on where I can find something like that, that I can work off of?
------------------------------
Mark Steele
------------------------------