This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
ansible:ansible_for_aix [2021/11/03 18:06] manu |
ansible:ansible_for_aix [2024/10/10 14:28] (current) manu |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Ansible for AIX ====== | ====== Ansible for AIX ====== | ||
| - | https://www.ansible.com/blog/aix-patch-management-with-ansible | + | https://galaxy.ansible.com/ui/repo/published/ibm/power_aix/ |
| - | https://galaxy.ansible.com/search?deprecated=false&keywords=aix&order_by=-relevance&page=1 | + | https://galaxy.ansible.com/ui/repo/published/ibm/power_vios/ |
| + | |||
| + | https://galaxy.ansible.com/ui/repo/published/ibm/power_hmc/ | ||
| + | |||
| + | https://galaxy.ansible.com/ui/repo/published/brocade/fos/ | ||
| + | |||
| + | https://galaxy.ansible.com/ui/repo/published/ibm/storage_virtualize/ | ||
| + | |||
| + | https://www.ansible.com/blog/aix-patch-management-with-ansible | ||
| https://github.com/aixoss/ansible-playbooks | https://github.com/aixoss/ansible-playbooks | ||
| + | |||
| + | https://github.com/IBM/ansible-power-aix-oracle | ||
| + | |||
| + | https://github.com/IBM/ansible-power-hmc | ||
| + | |||
| + | https://github.com/lg4U (PowerVC) | ||
| + | |||
| + | If server is installed on AIX, then install prerequisites AIX packages: | ||
| + | * bos.loc.com.utf | ||
| + | * bos.loc.utf.EN_US | ||
| + | And set LANG: export LANG=en_US.UTF-8 | ||
| + | |||
| $ ansible-galaxy collection install ibm.power_aix | $ ansible-galaxy collection install ibm.power_aix | ||
| Line 19: | Line 39: | ||
| <cli prompt='$'> | <cli prompt='$'> | ||
| $ cat /etc/ansible/hosts | $ cat /etc/ansible/hosts | ||
| - | nim01 ansible_host=10.0.0.5 ansible_user=root | + | nim01 ansible_host=10.0.0.5 ansible_user=root ansible_python_interpreter=/usr/bin/python |
| - | bruce ansible_host=10.0.0.6 ansible_user=root | + | bruce ansible_host=10.0.0.6 ansible_user=root ansible_python_interpreter=/usr/bin/python |
| - | freddie ansible_host=10.0.0.7 ansible_user=root | + | freddie ansible_host=10.0.0.7 ansible_user=root ansible_python_interpreter=/usr/bin/python |
| </cli> | </cli> | ||
| Line 120: | Line 140: | ||
| First off, I’ll use a simple playbook to see what “oslevel” our NIM master and NIM clients are on, before I start. | First off, I’ll use a simple playbook to see what “oslevel” our NIM master and NIM clients are on, before I start. | ||
| <cli prompt='$'> | <cli prompt='$'> | ||
| - | $ cat aix_oslevel_check.yml | + | $ cat check_os_version.yml |
| --- | --- | ||
| + | - name: talk to all hosts just so we can learn about them | ||
| + | hosts: all | ||
| + | tasks: | ||
| + | - name: Classify hosts depending on their OS distribution | ||
| + | group_by: | ||
| + | key: os_{{ ansible_facts['distribution'] }} | ||
| - | - name: AIX oslevel checking playbook | + | - hosts: os_CentOS |
| - | hosts: all | + | gather_facts: False |
| tasks: | tasks: | ||
| + | - name: Check version of Linux system | ||
| + | shell: "cat /etc/centos-release | tail -1 | sed 's/(AltArch)//' | rev | awk '{print $1}' | rev" | ||
| + | register: output_oslevel | ||
| + | - name: Print the oslevel | ||
| + | debug: | ||
| + | msg: "{{ ansible_hostname }} has the {{ ansible_distribution }} oslevel of {{ output_oslevel.stdout }}" | ||
| - | - name: Gather LPP Facts | + | - hosts: os_AIX |
| - | shell: "oslevel -s" | + | gather_facts: False |
| - | register: output_oslevel | + | tasks: |
| - | + | - name: Check oslevel of AIX system | |
| - | - name: Print the oslevel | + | shell: "oslevel -s" |
| - | debug: | + | register: output_oslevel |
| - | msg: "{{ ansible_hostname }} has the AIX oslevel of {{ output_oslevel.stdout }}" | + | - name: Print the oslevel |
| + | debug: | ||
| + | msg: "{{ ansible_hostname }} has the {{ ansible_distribution }} oslevel of {{ output_oslevel.stdout }}" | ||
| </cli> | </cli> | ||
| Line 392: | Line 426: | ||
| Using **shell**, mount and umount | Using **shell**, mount and umount | ||
| <cli prompt='>'> | <cli prompt='>'> | ||
| - | [root@aix200]/root> [root@lnxa100 playbooks]# cat mount_nfs.yml | + | [root@aix200]/root> cat mksysb_nfs.yml |
| --- | --- | ||
| - name: "Run Mksysb" | - name: "Run Mksysb" | ||
| Line 483: | Line 517: | ||
| </cli> | </cli> | ||
| + | ===== Log and debug ===== | ||
| + | |||
| + | The IBM Power Systems AIX collection uses the standard Ansible log system that is using the syslog subsystem on the managed nodes. | ||
| + | |||
| + | To activate AIX syslog you can update the configuration file /etc/syslog.conf with a selector user.info (or user.debug for more details) such as: | ||
| + | <cli prompt='$'> | ||
| + | $ vi /etc/syslog.conf | ||
| + | user.info /var/log/syslog/user.info rotate size 1m files 4 compress | ||
| + | </cli> | ||
| + | |||
| + | and restarting syslogd subsystem and look for Ansible logs: | ||
| + | <cli prompt='$'> | ||
| + | $ > /var/log/syslog/user.info | ||
| + | $ refresh -s syslogd | ||
| + | </cli> | ||
| + | |||
| + | <cli prompt='#'> | ||
| + | $ grep ansible /var/log/syslog/user.info | ||
| + | May 6 03:28:27 nimmaster user:info ansible-nim: Invoked with resource=None force=False description=None script=damien_script lpp_source=None action=script asynchronous=True location=None device=None group=None operation=None targets=['nimclient01'] | ||
| + | May 6 03:28:27 nimmaster user:info ansible-nim: *** START *** | ||
| + | ... | ||
| + | </cli> | ||
| + | |||
| + | To see the full debug log messages you should set the selector field to user.debug and run the playbook with the environment variable ANSIBLE_DEBUG=1 | ||
| + | <cli prompt='$'> | ||
| + | $ vi /etc/syslog.conf | ||
| + | user.debug /var/log/syslog.user.debug rotate size 1m files 4 compress | ||
| + | $ >/var/log/syslog.user.debug | ||
| + | $ refresh -s syslogd | ||
| + | $ ANSIBLE_DEBUG=1 ansible-playbook -M plugins/modules ./demo_nim.yml -vvv | ||
| + | </cli> | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||
| + | ==== Upgrade AIX NIM ==== | ||
| + | |||
| + | <cli prompt='#'> | ||
| + | [root@lnx01 production]# cat upgrade_aix_nim.yml | ||
| + | --- | ||
| + | - name: "Run Mksysb" | ||
| + | hosts: aix07 | ||
| + | become: yes | ||
| + | become_user: root | ||
| + | vars: | ||
| + | NIM_Server: "nimsrv" | ||
| + | nim_lpp_source: "/export/aix7200-05/aix7200-05-03_lpp" | ||
| + | NFS_mount: "/mnt" | ||
| + | |||
| + | tasks: | ||
| + | |||
| + | - name: Mount AIX Filesets | ||
| + | shell: "mount -o vers=4 {{ NIM_Server }}:{{ nim_lpp_source }} {{ NFS_mount }}" | ||
| + | register: nfsmount | ||
| + | |||
| + | - name: upgrade OS | ||
| + | shell: install_all_updates -d "{{ NFS_mount }}" -rc -Y | ||
| + | when: ansible_distribution == 'AIX' | ||
| + | register: output | ||
| + | - debug: var=output | ||
| + | |||
| + | - name: "unmount NFS" | ||
| + | mount: | ||
| + | path: "{{ NFS_mount }}" | ||
| + | state: unmounted | ||
| + | </cli> | ||
| + | |||
| + | ==== mksysb AIX NIM ==== | ||
| + | |||
| + | <cli prompt='#'> | ||
| + | [root@lnx01 production]# cat mksysb.yml | ||
| + | --- | ||
| + | - name: "Run Mksysb" | ||
| + | hosts: aix07 | ||
| + | become: yes | ||
| + | become_user: root | ||
| + | vars: | ||
| + | NIM_Server: "nimsrv" | ||
| + | backup_repo: "/export/mksysb" | ||
| + | NFS_mount: "/mksysb" | ||
| + | nfsmounts: | ||
| + | - { path: "/mksysb", src: "nimsrv:/export/mksysb" } | ||
| + | tasks: | ||
| + | |||
| + | - name: Mount AIX Filesets | ||
| + | shell: "mount -o vers=4 {{ NIM_Server }}:{{ backup_repo }} {{ NFS_mount }}" | ||
| + | register: nfsmount | ||
| + | - name: "Run mksysb backup" | ||
| + | mksysb: | ||
| + | name: "{{ansible_hostname}}_mksysb_{{ansible_date_time.date}}" | ||
| + | storage_path: "{{ NFS_mount }}" | ||
| + | exclude_files: yes | ||
| + | create_map_files: yes | ||
| + | - name: "unmount NFS" | ||
| + | mount: | ||
| + | path: "{{ NFS_mount }}" | ||
| + | state: unmounted | ||
| + | </cli> | ||
| + | |||
| + | ==== AIX NIMadm alternate disk migration ==== | ||
| + | |||
| + | Below is an example of how to invoke the options. I'd added the "default('N/A')" to avoid errors if the variable was not defined, as the role is coded for "N/A", but should also work with "default(omit)" | ||
| + | <cli> | ||
| + | - name: Include nim_alt_disk_migration role | ||
| + | include_role: | ||
| + | name: nim_alt_disk_migration | ||
| + | apply: | ||
| + | delegate_to: "{{ NIM_Master }}" | ||
| + | connection: "{{ NIM_Conn }}" | ||
| + | vars: | ||
| + | nim_client: "{{ NIM_Client }}" | ||
| + | target_disk: | ||
| + | disk_name: "{{ Target_DISK.disk_name }}" | ||
| + | force: "{{ NIMADM_Force }}" | ||
| + | lpp_source: "{{ Target_LPPS }}" | ||
| + | spot: "{{ Target_SPOT }}" | ||
| + | nim_mast_lpp: "{{ NIM_Mast_LPP }}" | ||
| + | nimadm_cache_vg: "{{ NIMADM_VG | default('N/A') }}" | ||
| + | nimadm_bundle: "{{ Target_eFix | default('N/A') }}" | ||
| + | nimadm_bidata: "{{ BOS_Inst_Data | default('N/A') }}" | ||
| + | control_phases: | ||
| + | validate_nim_resources: "{{ NIM_Res_Check }}" | ||
| + | perform_migration: "{{ NIM_Migration }} | ||
| + | debug_skip_nimadm: "{{ Skip_nimadm }}" | ||
| + | </cli> | ||
| + | |||
| + | <cli> | ||
| + | # ansible-galaxy collection list ibm.power_aix | ||
| + | # /.ansible/collections/ansible_collections | ||
| + | Collection Version | ||
| + | ------------- ------- | ||
| + | ibm.power_aix 1.8.1 | ||
| + | </cli> | ||
| + | |||
| + | This Ansible role, nim_alt_disk_migration, can be used for “migrating an alternate disk to a higher AIX level”. | ||
| + | |||
| + | Here’s the playbook I used, called **nimadm.yml**: | ||
| + | <cli> | ||
| + | --- | ||
| + | - name: NIMADM playbook | ||
| + | hosts: aixmig | ||
| + | gather_facts: no | ||
| + | collections: | ||
| + | ibm.power_aix | ||
| + | tasks: | ||
| + | - include_role: | ||
| + | name: nim_alt_disk_migration | ||
| + | apply: | ||
| + | delegate_to: lpar1 | ||
| + | vars: | ||
| + | nimadm_cache_vg: nimadmvg | ||
| + | nim_client: aixmig | ||
| + | target_disk: | ||
| + | disk_name: hdisk0 | ||
| + | lpp_source: AIX73TL1SP1 | ||
| + | spot: spotAIX73TL1SP1 | ||
| + | register: nimadm_results | ||
| + | - name: "Debug: nimadm_results" | ||
| + | ansible.builtin.debug: var=nimadm_results | ||
| + | </cli> | ||