AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
  • 1.  Ansible for AIX / alt_disk – Alternate rootvg disk management. / How to keep a trace of executed playbooks ?

    Posted Thu September 07, 2023 08:43 AM

    Hello,

    We were able to run an Alternate Rootvg disk copy on our test AIX partition.

    The playbook ran successfully but we would appreciate more details ...

    As you can see in CASE N°2 we ran the playbook with -vv parameter.

    Does that mean it is a good practise to use the -vv parameter when running playbooks ?

    How to keep a trace of playbooks execution ? Redirections in specific log files ? 

    One day we will run playbooks on our production lpars so we have to keep a trace and details of executed playbooks.

    We thank you very much for your help,

    CASE  N°1

    ataai018(root) /opt/freeware/etc/ansible/roles # /opt/freeware/bin/ansible-playbook derouet_alt_disk.yml

    PLAY [Playbook derouet] ****************************************************************************************************************************************************

    TASK [List interim fix on the system] **************************************************************************************************************************************
    [WARNING]: Platform aix on host ataai017 is using the discovered Python interpreter at /usr/bin/python3, but future installation of another Python interpreter could change
    the meaning of that path. See https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html for more information.
    ok: [ataai017]

    TASK [Perform a cleanup of any existing alternate disk copy] ***************************************************************************************************************
    changed: [ataai017]

    TASK [Perform an alternate disk copy of the rootvg to the smallest disk that can be selected] ******************************************************************************
    changed: [ataai017]

    PLAY RECAP *****************************************************************************************************************************************************************
    ataai017                   : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

    ataai018(root) /opt/freeware/etc/ansible/roles #

    CASE  N°2 :

    ataai018(root) /opt/freeware/etc/ansible/roles #
    ataai018(root) /opt/freeware/etc/ansible/roles # /opt/freeware/bin/ansible-playbook derouet_alt_disk.yml -vv
    ansible-playbook [core 2.14.2]
      config file = /etc/ansible/ansible.cfg
      configured module search path = ['/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = /opt/freeware/lib/python3.9/site-packages/ansible
      ansible collection location = /.ansible/collections:/usr/share/ansible/collections
      executable location = /opt/freeware/bin/ansible-playbook
      python version = 3.9.16 (main, Jun 28 2023, 12:45:03) [GCC 8.3.0] (/opt/freeware/bin/python3.9)
      jinja version = 3.0.3
      libyaml = True
    Using /etc/ansible/ansible.cfg as config file
    Skipping callback 'default', as we already have a stdout callback.
    Skipping callback 'minimal', as we already have a stdout callback.
    Skipping callback 'oneline', as we already have a stdout callback.

    PLAYBOOK: derouet_alt_disk.yml *********************************************************************************************************************************************
    1 plays in derouet_alt_disk.yml

    PLAY [Playbook derouet] ****************************************************************************************************************************************************

    TASK [List interim fix on the system] **************************************************************************************************************************************
    task path: /opt/freeware/etc/ansible/roles/derouet_alt_disk.yml:11
    [WARNING]: Platform aix on host ataai017 is using the discovered Python interpreter at /usr/bin/python3, but future installation of another Python interpreter could change
    the meaning of that path. See https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html for more information.
    ok: [ataai017] => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "ifix_details": [], "msg": "", "stderr": "There is no efix data on this system.\n", "stderr_lines": ["There is no efix data on this system."], "stdout": "", "stdout_lines": []}

    TASK [Perform a cleanup of any existing alternate disk copy] ***************************************************************************************************************
    task path: /opt/freeware/etc/ansible/roles/derouet_alt_disk.yml:16
    changed: [ataai017] => {"changed": true, "cmd": "/usr/sbin/alt_rootvg_op -X altinst_rootvg", "msg": "alt_disk clean operation completed successfully", "rc": 0, "stderr": "", "stderr_lines": [], "stdout": "Bootlist is set to the boot disk: hdisk0 blv=hd5\n", "stdout_lines": ["Bootlist is set to the boot disk: hdisk0 blv=hd5"]}

    TASK [Perform an alternate disk copy of the rootvg to the smallest disk that can be selected] ******************************************************************************
    task path: /opt/freeware/etc/ansible/roles/derouet_alt_disk.yml:21
    changed: [ataai017] => {"changed": true, "cmd": "alt_disk_copy -d hdisk1 -B", "msg": "alt_disk copy operation completed successfully", "rc": 0, "stderr": "cannot access ./tmp/croutZmyqg_: No such file or directory\ncannot access ./var/tmp/lpar2rrd-agent-rrdservPA6.appli-lpar2rrd-wlmstat-14483828.txt: No such file or directory\n0505-148 alt_disk_install: WARNING: an error occurred during backup.\n", "stderr_lines": ["cannot access ./tmp/croutZmyqg_: No such file or directory", "cannot access ./var/tmp/lpar2rrd-agent-rrdservPA6.appli-lpar2rrd-wlmstat-14483828.txt: No such file or directory", "0505-148 alt_disk_install: WARNING: an error occurred during backup."], "stdout": "Calling mkszfile to create new /image.data file.\nChecking disk sizes.\nCreating cloned rootvg volume group and associated logical volumes.\nCreating logical volume alt_hd5.\nCreating logical volume alt_hd6.\nCreating logical volume alt_hd8.\nCreating logical volume alt_hd4.\nCreating logical volume alt_hd2.\nCreating logical volume alt_hd9var.\nCreating logical volume alt_hd3.\nCreating logical volume alt_hd1.\nCreating logical volume alt_hd10opt.\nCreating logical volume alt_hd11admin.\nCreating logical volume alt_lg_dumplv.\nCreating logical volume alt_livedump.\nCreating logical volume alt_lv_envf.\nCreating /alt_inst/ file system.\nCreating /alt_inst/admin file system.\nCreating /alt_inst/envf file system.\nCreating /alt_inst/home file system.\nCreating /alt_inst/opt file system.\nCreating /alt_inst/tmp file system.\nCreating /alt_inst/usr file system.\nCreating /alt_inst/var file system.\nCreating /alt_inst/var/adm/ras/livedump file system.\nGenerating a list of files \nfor backup and restore into the alternate file system...\nBacking-up the rootvg files and restoring them to the alternate file system...\nModifying ODM on cloned disk.\nBuilding boot image on cloned disk.\nforced unmount of /alt_inst/var/adm/ras/livedump\nforced unmount of /alt_inst/var/adm/ras/livedump\nforced unmount of /alt_inst/var\nforced unmount of /alt_inst/var\nforced unmount of /alt_inst/usr\nforced unmount of /alt_inst/usr\nforced unmount of /alt_inst/tmp\nforced unmount of /alt_inst/tmp\nforced unmount of /alt_inst/opt\nforced unmount of /alt_inst/opt\nforced unmount of /alt_inst/home\nforced unmount of /alt_inst/home\nforced unmount of /alt_inst/envf\nforced unmount of /alt_inst/envf\nforced unmount of /alt_inst/admin\nforced unmount of /alt_inst/admin\nforced unmount of /alt_inst\nforced unmount of /alt_inst\nChanging logical volume names in volume group descriptor area.\nFixing LV control blocks...\nFixing file system superblocks...\n", "stdout_lines": ["Calling mkszfile to create new /image.data file.", "Checking disk sizes.", "Creating cloned rootvg volume group and associated logical volumes.", "Creating logical volume alt_hd5.", "Creating logical volume alt_hd6.", "Creating logical volume alt_hd8.", "Creating logical volume alt_hd4.", "Creating logical volume alt_hd2.", "Creating logical volume alt_hd9var.", "Creating logical volume alt_hd3.", "Creating logical volume alt_hd1.", "Creating logical volume alt_hd10opt.", "Creating logical volume alt_hd11admin.", "Creating logical volume alt_lg_dumplv.", "Creating logical volume alt_livedump.", "Creating logical volume alt_lv_envf.", "Creating /alt_inst/ file system.", "Creating /alt_inst/admin file system.", "Creating /alt_inst/envf file system.", "Creating /alt_inst/home file system.", "Creating /alt_inst/opt file system.", "Creating /alt_inst/tmp file system.", "Creating /alt_inst/usr file system.", "Creating /alt_inst/var file system.", "Creating /alt_inst/var/adm/ras/livedump file system.", "Generating a list of files ", "for backup and restore into the alternate file system...", "Backing-up the rootvg files and restoring them to the alternate file system...", "Modifying ODM on cloned disk.", "Building boot image on cloned disk.", "forced unmount of /alt_inst/var/adm/ras/livedump", "forced unmount of /alt_inst/var/adm/ras/livedump", "forced unmount of /alt_inst/var", "forced unmount of /alt_inst/var", "forced unmount of /alt_inst/usr", "forced unmount of /alt_inst/usr", "forced unmount of /alt_inst/tmp", "forced unmount of /alt_inst/tmp", "forced unmount of /alt_inst/opt", "forced unmount of /alt_inst/opt", "forced unmount of /alt_inst/home", "forced unmount of /alt_inst/home", "forced unmount of /alt_inst/envf", "forced unmount of /alt_inst/envf", "forced unmount of /alt_inst/admin", "forced unmount of /alt_inst/admin", "forced unmount of /alt_inst", "forced unmount of /alt_inst", "Changing logical volume names in volume group descriptor area.", "Fixing LV control blocks...", "Fixing file system superblocks..."]}

    PLAY RECAP *****************************************************************************************************************************************************************
    ataai017                   : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

    ataai018(root) /opt/freeware/etc/ansible/roles #
    ataai018(root) /opt/freeware/etc/ansible/roles #



    ------------------------------
    christophe derouet
    ------------------------------


  • 2.  RE: Ansible for AIX / alt_disk – Alternate rootvg disk management. / How to keep a trace of executed playbooks ?

    Posted Fri September 08, 2023 02:11 AM

    Regarding logging I do a link to me again. Here I described how to enable logging of Ansible actions on AIX.



    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 3.  RE: Ansible for AIX / alt_disk – Alternate rootvg disk management. / How to keep a trace of executed playbooks ?

    Posted Thu May 15, 2025 09:56 AM

    Hi Andrey, regarding alt_disk_copy automation with ansible I'm writing a simple playbook , in my environment  each lpar has alternate disk on different disk.-name  so I take the name of the disk with a script inside the playbook. The problem is when rootvg is splitted on 2 disks and so the alternate has to be done on 2 disks:

    here is my code:

    ---
    - name: AIX Patching Playbook
      hosts: all
      collections:
        - ibm.power_aix
      tasks:
        - name: find target disk
          shell: lspv |grep -w altinst_rootvg |awk '{print $1}'
          register: targetdisk
        - name: Cleanup any existing alt_disk_copy
          collections: ibm.power_aix
          alt_disk:
            action: clean
        - name: Create an alt_disk_copy for backup
          alt_disk:
            action: copy
            targets: "{{ targetdisk.stdout }}"
            bootlist: false
            device_reset: false
            force: true
    
    
    


    asked to IA and suggested to replace targets with:          targets: "{{ targetdisk.stdout_lines | join(' ') }}"    but it fails. 

    Any ideas ?
    Thankyou very much

    Michele



    ------------------------------
    michele dainotti
    ------------------------------



  • 4.  RE: Ansible for AIX / alt_disk – Alternate rootvg disk management. / How to keep a trace of executed playbooks ?

    Posted Fri May 16, 2025 03:28 AM

    Hi Michelle,

    the documentation states that targets is a list of string elements:

       targets  Specifies the target disks.
                Either targets or disk_size_policy must be specified.
                If no targets disk is specified, it will look for a valid candidate disk based on the provided disk_size_policy policy.
            default: null
            elements: str
            type: list
    

    It means that you could try to use targetdisk.stdout_lines without join, and it should work:

    targets: "{{ targetdisk.stdout_lines }}"



    ------------------------------
    Andrey Klyachkin

    https://www.power-devops.com
    ------------------------------



  • 5.  RE: Ansible for AIX / alt_disk – Alternate rootvg disk management. / How to keep a trace of executed playbooks ?

    Posted Mon September 11, 2023 10:31 AM

    Hello Christophe,
    I've developed Ansible patching playbooks for a couple of customers.  For logging, I have redirected the output of commands to a log file and then used the fetch module to pull the log file back to the Ansible server as a record of who patched the server and when.

    Below is a very crude example that I haven't tested, but should give you a general idea. 

    I use a handler to retrieve the log with force handlers set to true, as that way if one of the tasks fails for any reason, the handler will still copy the log file to the Ansible server.

    ---
    - hosts: all
      gather_facts: false
      force_handlers: true
    
    - vars:
        DISK: hdisk0
        LOG: /tmp/patching_log
        LOG_DIRECTORY: /tmp/logs
    
    - handlers:
      - name: Retrieve log
        fetch:
          src: "{{ LOG }}"
          dest: "{{ LOG_DIRECTORY }}"
          mode: 0664
          flat: yes
    
    - tasks:
     
      - name: Create log
        file:
          path: "{{ LOG }}"
          mode: 0664
        notify: Retrieve log
    
      - name: Perform Clean up alt_disk
        shell: alt_rootvg_op -X altinst_rootvg 2>&1 > {{ LOG }}
        become: true
    
      - name: Perform alt_disk_copy to {{ DISK }}
        shell: alt_disk_copy -d {{ DISK }} -B 2>&1 > {{ LOG }}
        become: true
    
    


    ------------------------------
    Craig Murray
    ------------------------------



  • 6.  RE: Ansible for AIX / alt_disk – Alternate rootvg disk management. / How to keep a trace of executed playbooks ?

    Posted Fri May 16, 2025 06:39 AM

    Is it not easier to use the IBM Ansible module specifically for alt_disks: alt_disk – Alternate rootvg disk management. - IBM Power Systems AIX 1.0.0-beta1 documentation
    Or is this too limited for your purpose? 



    ------------------------------
    Erwin Groeneveld
    ------------------------------