AIX Open Source

Expand all | Collapse all

NIM / Ansible - Creating "spot" Resource failing when using shell or command module

  • 1.  NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Mon October 04, 2021 12:47 PM
    Edited by Steve Munday Thu October 07, 2021 12:50 PM
    I'm trying to create a mksysb and spot Resource from a mksysb image using an Ansible playbook. When I run the commands natively on the AIX 7.2 TL5 SP2 command line both Resources are created as expected.

    nim -o define -t mksysb -a server=master -a location=/export/nim/mksysb/goldimage/goldimage_aix7252_2021_1001 goldimage_aix7252_2021_1001​

    nim -o define -t spot -a server=master -a location=/export/nim/spot -a source=goldimage_aix7252_2021_1001 goldimage_aix7252_2021_1001_spot​

    However, when I run the commands via an Ansible playbook using either the command or shell "builtin" modules the mksysb Resource is successfully created however the spot Resource fails with:

    0042-001 nim: processing error encountered on "master"
    0042-103 m_mkspot: unable to restore from goldimage_aix7252_2021_1001

    # ansible --version
    ansible 2.9.14
      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.7/site-packages/ansible
      executable location = /usr/bin/ansible
      python version = 3.7.9 (default, Sep 14 2020, 06:09:55) [GCC 8.3.0]​


    Has anyone managed to get a "spot" Resource successfully created via a playbook?

    Many thanks, Steve


    ** Resolution (07-Oct-2021) **
    Having cross checked the environment variables between the AWX and ansible CLI execuions of the playbook I add ODMDIR to the playbook (AWX) and re-ran, the "spot" was successfully created.

        - name: Create NIM spot Resource
          shell: |
              nim -o define -t spot -a server=master -a location=/export/nim/spot -a source=goldimage_aix7252_2021_1001 goldimage_aix7252_2021_1001_spot
          environment:
            ODMDIR: /etc/objrepos



    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------


  • 2.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 06:06 AM

    Hi,

    maybe, because I never did this with ansible,  you need a full qualified interactive shell for the spot creation. Try to do:

    ksh -ic "nim -o define -t spot -a server=master -a location=/export/nim/spot -a source=goldimage_aix7252_2021_1001 goldimage_aix7252_2021_1001_spot​"



    ------------------------------
    Marcel Mages-Veidt
    ------------------------------



  • 3.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 12:01 PM
    Marcel,

    Hi, thanks for the suggestion which I've tried however it's still erroring.  I have been successful with an ansible-playbook CLI approach, the 2 NIM Resources are successfully created.

    Running that same playbook via AWX still errors out on the second (spot) Resource so running some c_mkspot debugging to see what I can find between a "good" and "failed" playbook.

    Many thanks, Steve

    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------



  • 4.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 08:58 AM
    Steve,

    I would start by comparing the process environment.  What are the differences of the output of the env command in the command line environment vs the automation tool? What are the differences of "/usr/bin/ulimit -Sa"?  "/usr/bin/ulimit -Ha"?

    ------------------------------
    Edward Davignon
    ------------------------------



  • 5.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 12:03 PM
    Edward,

    Hi, running those two commands (a) via the CLI and (b) via AWX generates the same results, detailed below.

    /# /usr/bin/ulimit -Sa	-- same for both via CLI and AWX
    time(seconds)        unlimited
    file(blocks)         unlimited
    data(kbytes)         unlimited
    stack(kbytes)        unlimited
    memory(kbytes)       unlimited
    coredump(blocks)     unlimited
    nofiles(descriptors) unlimited
    threads(per process) 262144
    processes(per user)  262144
    /# /usr/bin/ulimit -Ha	-- same for both via CLI and AWX
    time(seconds)        unlimited
    file(blocks)         unlimited
    data(kbytes)         unlimited
    stack(kbytes)        unlimited
    memory(kbytes)       unlimited
    coredump(blocks)     unlimited
    nofiles(descriptors) unlimited
    threads(per process) unlimited
    processes(per user)  unlimited​

    Many thanks, Steve

    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------



  • 6.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 12:53 PM
    try, /usr/bin/env
    then diff the two outputs.

    ------------------------------
    Edward Davignon
    ------------------------------



  • 7.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 01:12 PM
    Edward,

    Hi, there are quite a few differences.  I'm presuming I want to bring AWX closer to the native AIX "env" so where am I needing to make these (AWX) changes please?

    Many thanks, Steve

    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------



  • 8.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 02:07 PM
    You should probably make sure ODMDIR=/etc/objrepos and the NIM variables from /etc/environment or your shell login scripts, and/or sudoers configuration match between the environments.  For example, these environment variables: NIM_MKSYSB_SUBDIRS, NIMSH_FORCE_KSH, and NIM_STD_AUTH_METHOD.

    Here is a useful command:
    grep '^[^#]' /etc/environment

    ------------------------------
    Edward Davignon
    ------------------------------



  • 9.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 02:12 PM
    Edward,

    Thank-you.  I'll check into all of this tomorrow and see where it takes me.

    Have a good evening.

    Regards, Steve

    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------



  • 10.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Tue October 05, 2021 02:15 PM
    Edward,

    Apologies, stupid question coming up.  Where I do have differences then I'll need to update the AWX environment.  "Where" in the AWX environment would I, for example, update ODMDIR so it matches the AIX CLI value?

    Many thanks, Steve

    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------



  • 11.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Wed October 06, 2021 08:54 AM

    Steve,

    I don't know.  I don't currently use AWX/Ansible.

    Sometimes you can just prefix environment variables to the command you are running like is:

    ODMDIR=/etc/objrepos /usr/sbin/nim



    ------------------------------
    Edward Davignon
    ------------------------------



  • 12.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Thu October 07, 2021 01:33 PM
    Edward,

    Hi, you were spot on.  I added ODMDIR as an Environment Variable to the playbook and the "spot" Resource was successfully created :-)

    Many thanks, Steve

    ------------------------------
    Steve Munday
    AIX, IBM i, HMC, PowerVM
    ------------------------------



  • 13.  RE: NIM / Ansible - Creating "spot" Resource failing when using shell or command module

    Posted Thu October 07, 2021 09:06 AM
    ​Have you tried just using ssh with the command string in quotes" I have found a few time where the command is interpreted and not executed directly in tact.

    You may also try the Ansible raw module.

    https://docs.ansible.com/ansible/latest/collections/ansible/builtin/raw_module.html

    I hope this helps!

    Stan

    ------------------------------
    Stanley
    ------------------------------