Thanks Damien for all your help, playbook working fine as expected. Really appreciate for the help.
Original Message:
Sent: Mon August 28, 2023 11:36 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Sorry Damien, please ignore the previous query on playbook is not working. Actually I was running wrong command. It must be --check rather than -check.
I will keep you posted for the result. Apologies for the inconvenience.
------------------------------
Manoj Kumar
Original Message:
Sent: Mon August 28, 2023 11:30 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Hi Damien,
I try to update the command but getting below error once try to run playbook. Do we have any idea on this?
ansible-playbook alt_disk_copy.yml -check
PLAY [Alt Disk copy in AIX] ********************************************************************************************************************************************
TASK [Retrieve disk list with lspv command] ****************************************************************************************************************************
fatal: [host]: FAILED! => {"msg": "the connection plugin 'heck' was not found"}
PLAY RECAP *************************************************************************************************************************************************************
host: ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Now playbook look like this.
---
- name: Alt Disk copy in AIX
hosts: all
strategy: linear
gather_facts: false
# Tasks
tasks:
# Retrieve disk list
- name: Retrieve disk list with lspv command
ansible.builtin.shell:
cmd: 'lspv | grep -i "_rootvg"|grep -v grep'
register: pv_list
# Create sysalt on existing altinst_rootvg or old_rootvg disk
- name: Create sysalt on existing altinst_rootvg or old_rootvg disk
ibm.power_aix.alt_disk:
action: copy
force: True
allow_old_rootvg: True
targets: "{{ lspv_disk[0] }}"
register: sysalt_run
when: '"_rootvg" in lspv_disk[2]'
vars:
lspv_disk: "{{ item|split() }}"
with_list: "{{ pv_list.stdout_lines }}"
# Fail if no sysalt processed
- name: Fail if no sysalt processed
ansible.builtin.fail:
msg: No sysalt have been processed
when: sysalt_run.changed == false
------------------------------
Manoj Kumar
Original Message:
Sent: Sat August 26, 2023 08:05 AM
From: Damien LEMAGNEN
Subject: Alt_disk_copy ansible playbook issue for AIX
Thanks for trying this playbook.
I agree with you, if there are to much disks on the host, the task log can bee very long If you want to easily known wich disk have been used for the alt_disk.
The easiest way is to modify the command in shell task to put something like :
lspv | grep -E "_rootvg" | grep -v grep
But for me the PLAY RECAP is suffisant to know if a sys_alt have been created on each host.
Regards,
------------------------------
Damien LEMAGNEN
AIX System Engineer/Architect
NETIXWARE
Original Message:
Sent: Fri August 25, 2023 11:17 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Thanks Damien, the playbook which you shared above is working fine and also the playbook which you shared earlier after making some changes in indentation and we are able to take the clone on the server, however we tested this on one server which is having total 3 disk. But while creating sysalt it is scanning all disk like I given below output. But if a server having more than 100 disk, will it show all 100 disk in ansible logs? We have to create clone across more than 300 servers so in that case it will generate lot of logs. Is there any option available so that only altinst_rootvg or old_rootvg would be read.
PLAY [Template for AIX playbooks] ***********************************************************************************************************************************************************************************************************
TASK [Retrieve disk list with lspv command] *************************************************************************************************************************************************************************************************
changed: [host]
TASK [Create sysalt on existing altinst_rootvg or old_rootvg disk] **************************************************************************************************************************************************************************
skipping: [host] => (item=hdisk3 00f84014c5ab287b rootvg active )
changed: [host] => (item=hdisk4 00f84014c9e430b8 altinst_rootvg )
skipping: [host] => (item=hdisk5 00f840145032f877 vg01 active )
TASK [Fail if no sysalt processed] **********************************************************************************************************************************************************************************************************
skipping: [host]
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
host: ok=2 changed=2 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
------------------------------
Manoj Kumar
Original Message:
Sent: Fri August 25, 2023 09:38 AM
From: Damien LEMAGNEN
Subject: Alt_disk_copy ansible playbook issue for AIX
Please copy and respect spaces and blank lines.
Replace "{{ my_host }}" by what you want
---- name: Template for AIX playbooks hosts: "{{ my_host }}" strategy: linear gather_facts: false
------------------------------
Damien LEMAGNEN
AIX System Engineer/Architect
NETIXWARE
Original Message:
Sent: Fri August 25, 2023 08:43 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Hello Damien
Thanks for sharing this. I am getting the following error. Please check the playbook which I have created and see if I am missing something.
Error:
TASK [Create sysalt on existing altinst_rootvg or old_rootvg disk] **************************************************************************************************************************************************************************
fatal: [host]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ item|split() }}: Unable to look up a name or access an attribute in template string ({{ item|split() }}).\nMake sure your variable name does not contain invalid characters like '-': descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. Unable to look up a name or access an attribute in template string ({{ item|split() }}).\nMake sure your variable name does not contain invalid characters like '-': descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. {{ item|split() }}: Unable to look up a name or access an attribute in template string ({{ item|split() }}).\nMake sure your variable name does not contain invalid characters like '-': descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. Unable to look up a name or access an attribute in template string ({{ item|split() }}).\nMake sure your variable name does not contain invalid characters like '-': descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object. descriptor 'split' for 'str' objects doesn't apply to a 'AnsibleUndefined' object\n\nThe error appears to be in '/home/automation/ansible/AIX/alt_disk_copy.yml': line 15, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n # Create sysalt on existing altinst_rootvg or old_rootvg disk\n - name: Create sysalt on existing altinst_rootvg or old_rootvg disk\n ^ here\n"}
My Playbook
---
- name: Alt_Disk in AIX
hosts: host
gather_facts: no
tasks:
# Retrieve disk list
- name: Retrieve disk list with lspv command
ansible.builtin.shell:
cmd: "lspv"
register: pv_list
# Create sysalt on existing altinst_rootvg or old_rootvg disk
- name: Create sysalt on existing altinst_rootvg or old_rootvg disk
ibm.power_aix.alt_disk:
action: copy
force: True
allow_old_rootvg: True
targets: "{{ lspv_disk[0] }}"
vars:
lspv_disk: "{{ item|split() }}"
with_list: "{{ pv_list.stdout_lines }}"
when: '"_rootvg" in lspv_disk[2]'
------------------------------
Manoj Kumar
Original Message:
Sent: Thu August 24, 2023 09:55 AM
From: Damien LEMAGNEN
Subject: Alt_disk_copy ansible playbook issue for AIX
Hi Manoj,
You can try use this perfectible ansible code I wrote :
It retrieve pv list with lspv command. It would be better to use facts, but there are no facts that provide pv informations for alt_disk because it is not varyon...
And for each pv line (from lspv), if the vgname is like "_rootvg" I force an alt_disk_copy even if it is an old_rootvg.
I have to perfect the code to exit after the first clone (if there is multiple clone), anb failed if no alt_disk have been found.
This code won't work too, if rootvg is mirrored.
Please say me if it helps you.
Regards.
------------------------------
Damien LEMAGNEN
AIX System Engineer/Architect
NETIXWARE
Original Message:
Sent: Wed August 16, 2023 09:17 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Hi Team,
Did anyone check the above query? It would be really helpful.
------------------------------
Manoj Kumar
Original Message:
Sent: Fri August 11, 2023 10:09 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Thanks Nitish. Actually I just wanted to know if we have bulk servers and we already have clone disk available so we just wanted to remove existing clone on each servers and create new one on same disk. In that case this playbook is not going to work as we have to put lot of variable. I will also raise this issue on the link you suggested.
------------------------------
Manoj Kumar
Original Message:
Sent: Fri August 11, 2023 08:13 AM
From: Nitish Mishra
Subject: Alt_disk_copy ansible playbook issue for AIX
Hi Manoj !
In the "vars" section of the playbook which currently looks like this:
vars:
hosts_val: all
targets_val: hdisk1
You can add as many variables as you want and later use it in your tasks. Something like this:
vars:
hosts_val: all
targets_val: hdisk1
alt_target_val: hdisk2
It could be any name. This is just an example.
If you have any query regarding AIX ansible/vios collection, you can raise an issue here: https://github.com/IBM/ansible-power-aix/issues
Thanks,
Nitish
------------------------------
Nitish Mishra
Original Message:
Sent: Tue August 08, 2023 11:12 AM
From: Manoj Kumar
Subject: Alt_disk_copy ansible playbook issue for AIX
Hi Team,
We are running playbook for alternate disk copy on AIX servers. So if we define the disk name it is working perfectly fine. But how we can use the same disk where we had clone previously. Because sometime disk number would be vary. So what option we should use in that playbook.
---
- name: Alt_Disk in AIX
hosts: "{{ hosts_val }}"
gather_facts: no
collections:
- ibm.power_aix
vars:
hosts_val: all
targets_val: hdisk1
tasks:
- name: Perform a cleanup of any existing alternate disk copy and old rootvg
alt_disk:
action: clean
allow_old_rootvg: yes
- name: Perform an alternate disk copy of the rootvg to hdisk1
alt_disk:
action: copy
targets: "{{ targets_val }}"
------------------------------
Manoj Kumar
------------------------------