User Tools

Site Tools


ansible:ansible_for_aix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ansible:ansible_for_aix [2021/11/05 16:37]
manu [Log and debug]
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 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'​] }}
  
-nameAIX oslevel checking playbook ​ +hostsos_CentOS 
-  ​hostsall +  ​gather_factsFalse
   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 507: Line 541:
  
 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 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='​#'>+<cli prompt='​$'>
 $ vi /​etc/​syslog.conf $ vi /​etc/​syslog.conf
 user.debug /​var/​log/​syslog.user.debug rotate size 1m files 4 compress user.debug /​var/​log/​syslog.user.debug rotate size 1m files 4 compress
Line 514: Line 548:
 $ ANSIBLE_DEBUG=1 ansible-playbook -M plugins/​modules ./​demo_nim.yml -vvv $ ANSIBLE_DEBUG=1 ansible-playbook -M plugins/​modules ./​demo_nim.yml -vvv
 </​cli>​ </​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> ​
ansible/ansible_for_aix.1636126662.txt.gz · Last modified: 2021/11/05 16:37 by manu