3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ansible Galaxy: ibm.power_aix を使ってみる - installp

Last updated at Posted at 2020-08-29
はじめに

最近の自動化の流れで PowerSystems にも Ansible の影響が広がっています。

参考:
・[Ansible による PowerSystems の自動化]
(https://www.ibm.com/blogs/systems/jp-ja/ansible-automation-for-ibm-power-systems/)

IBM Power Systems AIX Collection

Ansible Galaxy に ibm.power_aix がリリースされ、AIX モジュールが拡充されています。
参考:
ibm.power_aix
Ansible PowerSystems AIX
GitHub Repository: ansible-power-aix

今回は Galaxy版 ibm.power_aix を使って、以前の記事:「Ansible : AIX モジュールの確認 - installp 」で実行できなかった installp モジュールでの update を試してみたいと思います。


環境

・Ansible サーバー Mac PC
 - Ansible version 2.9
 
・管理対象サーバー AIX 7.2 TL03 SP03

  • python 2.7

検証
  1. ibm.power_aix の導入
    手順は https://ibm.github.io/ansible-power-aix/installation.html を参照
$ ansible-galaxy collection install ibm.power_aix
Process install dependency map
Starting collection install process
Installing 'ibm.power_aix:1.0.2' to '/Users/c_u/.ansible/collections/ansible_collections/ibm/power_aix'

$ ls -l /Users/c_u/.ansible/collections/ansible_collections/ibm/power_aix
total 160
-rw-r--r--   1 user  staff   3227 Aug 28 11:25 CODE_OF_CONDUCT.md
-rw-r--r--   1 user  staff   2869 Aug 28 11:25 CONTRIBUTING.md
-rw-r--r--   1 user  staff  18105 Aug 28 11:25 FILES.json
-rw-r--r--   1 user  staff  35149 Aug 28 11:25 LICENSE
-rw-r--r--   1 user  staff    222 Aug 28 11:25 MAINTAINERS.md
-rw-r--r--   1 user  staff    920 Aug 28 11:25 MANIFEST.json
-rw-r--r--   1 user  staff   1352 Aug 28 11:25 README.md
-rw-r--r--   1 user  staff     25 Aug 28 11:25 _config.yml
drwxr-xr-x   3 user  staff     96 Aug 28 11:25 collections
drwxr-xr-x   5 user  staff    160 Aug 28 11:25 docs
drwxr-xr-x   3 user  staff     96 Aug 28 11:25 meta
drwxr-xr-x  18 user  staff    576 Aug 28 11:25 playbooks
drwxr-xr-x   3 user  staff     96 Aug 28 11:25 plugins
drwxr-xr-x   4 user  staff    128 Aug 28 11:25 roles

「ibm.power_aix:1.0.2」 が導入されました。
デフォルトでは、ユーザー・ホームディレクトリ の .ansible 下に導入されています。
導入ディレクトリも -p オプションで指定変更できるとのこと。


  1. ibm.power_aix モジュールの確認
$ ls -l /Users/c_u/.ansible/collections/ansible_collections/ibm/power_aix/plugins/modules
total 1144
-rw-r--r--  1 user  staff   9909 Aug 28 11:25 devices.py
-rw-r--r--  1 user  staff  21228 Aug 28 11:25 emgr.py
-rw-r--r--  1 user  staff  12395 Aug 28 11:25 filesystem.py
-rw-r--r--  1 user  staff  47141 Aug 28 11:25 flrtvc.py
-rw-r--r--  1 user  staff   4670 Aug 28 11:25 geninstall.py
-rw-r--r--  1 user  staff  11142 Aug 28 11:25 installp.py    #<= 今回試したいモジュール
-rw-r--r--  1 user  staff  15613 Aug 28 11:25 lvg.py
-rw-r--r--  1 user  staff   4383 Aug 28 11:25 mktcpip.py
-rw-r--r--  1 user  staff   8581 Aug 28 11:25 mount.py
-rw-r--r--  1 user  staff  50696 Aug 28 11:25 nim.py
-rw-r--r--  1 user  staff  42418 Aug 28 11:25 nim_backup.py
-rw-r--r--  1 user  staff  60807 Aug 28 11:25 nim_flrtvc.py
-rw-r--r--  1 user  staff  35808 Aug 28 11:25 nim_suma.py
-rw-r--r--  1 user  staff  36950 Aug 28 11:25 nim_updateios.py
-rw-r--r--  1 user  staff  49891 Aug 28 11:25 nim_upgradeios.py
-rw-r--r--  1 user  staff  54317 Aug 28 11:25 nim_vios_alt_disk.py
-rw-r--r--  1 user  staff  22222 Aug 28 11:25 nim_vios_hc.py
-rw-r--r--  1 user  staff  18387 Aug 28 11:25 nim_viosupgrade.py
-rw-r--r--  1 user  staff  29612 Aug 28 11:25 suma.py

  1. ansible 環境の準備

・inventory ファイルの用意

$ cat inventory
[test]
xx.xxx.xx.xxx        #<= 対象IPアドレス

・ansible.cfg の用意

ansible.cfg
$ cat ansible.cfg
[defaults]
inventory = ./inventory
remote_user = root
ask_pass = false
become = true
private_key_file = ./id_rsa

繋がるかな? ping モジュールを試してみます。

$ ansible test -m ping
[WARNING]: Platform aix on host xx.xxx.xx.xxx is using the discovered Python interpreter at /usr/bin/python, but future
installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
xx.xxx.xx.xxx | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

接続されていますが、ansible_facts 表示が出ているので、ansible.cfg に「interpreter_python=/usr/bin/python」を付け加えます。

ansible.cfg
[defaults]
inventory = ./inventory
remote_user = root
ask_pass = false
become = true
interpreter_python=/usr/bin/python              #<= 追加
private_key_file = ./id_rsa 

・ping モジュールを試します。

$ ansible test -m ping
xx.xxx.xx.xxx | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

"pong"!通りました。
先ほどの interpreter_python メッセージは表示されなくなりました。


  1. 実行する playbook の準備

install モジュール と、QuickStartの記載を読みながら、"bos.sysmgt.nim.client" ファイルセットのアップデートを目的とする "update.yml" という playbook を作りました。

** installp はansible 公式モジュールにも同じ名前の installp モジュールが存在します。power_aix 版のモジュールの指定が必要です。

update.yml
---
- hosts: all
  collections:           
  - ibm.power_aix    #<= 今回導入した ibm.power_aix を指定。                            

  tasks:
   - name: Update bos.sysmgt.nim.client
     installp:
        action: apply
        device: /mnt    #<= 対象AIXサーバー /mnt ディレクトリにアップデート・モジュールを配置しています
        install_list: bos.sysmgt.nim.client   #<= 対象ファイルセット
        agree_licenses: yes

  1. 実行前対象サーバーの状態確認

・oslevel と "bos.sysmgt.nim.client" のファイルセット・レベルを確認。

$ ansible test -a 'oslevel -s'
xx.xx.xx.xxx | CHANGED | rc=0 >>
7200-03-03-1914

$ ansible test -a 'lslpp -l bos.sysmgt.nim.client'
xx.xx.xx.xxx | CHANGED | rc=0 >>
  Fileset                      Level  State      Description
  ----------------------------------------------------------------------------
Path: /usr/lib/objrepos
  bos.sysmgt.nim.client     7.2.3.17  COMMITTED  Network Install Manager -
                                                 Client Tools

Path: /etc/objrepos
  bos.sysmgt.nim.client     7.2.3.17  COMMITTED  Network Install Manager -
                                                 Client Tools

ファイルセット "bos.sysmgt.nim.client" の現在のレベルは 7.2.3.17 です。


  1. 実行

さて、update.yml の実行検証を行ってみます。

$ ansible-playbook update.yml --check

PLAY [all] ***********************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************
ok: [xx.xx.xx.xxx]

TASK [Update bos.sysmgt.nim.client] **********************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'NoneType' object is not iterable
fatal: [xx.xx.xx.xxx]: FAILED! => {"changed": false, "module_stderr": "Shared connection to xx.xx.xx.xxx closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/.ansible/tmp/ansible-tmp-1598704575.200843-28397-151765467413263/AnsiballZ_installp.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/.ansible/tmp/ansible-tmp-1598704575.200843-28397-151765467413263/AnsiballZ_installp.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/.ansible/tmp/ansible-tmp-1598704575.200843-28397-151765467413263/AnsiballZ_installp.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.installp', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/opt/freeware/lib/python2.7/runpy.py\", line 188, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/opt/freeware/lib/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/opt/freeware/lib/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_installp_payload_ZuI7Tg/ansible_installp_payload.zip/ansible/modules/installp.py\", line 344, in <module>\r\n  File \"/tmp/ansible_installp_payload_ZuI7Tg/ansible_installp_payload.zip/ansible/modules/installp.py\", line 282, in main\r\nTypeError: 'NoneType' object is not iterable\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ***********************************************************************************************************************
xx.xx.xx.xxx              : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

「'NoneType' object is not iterable」というエラーで failed になります。


調べていると、dev-collection ブランチで修正されていることを確認しました。
ダウンロードした 1.0.2 ではまだ反映されていないようです。

・ブランチ dev-collection
https://github.com/IBM/ansible-power-aix/blob/dev-collection/plugins/modules/installp.py
・変更履歴:
https://github.com/IBM/ansible-power-aix/commit/1c4142715dcee11066e8b5acf683ada07cc05b9f#diff-ff778c4f6c7d881ad8fffe0dbc130fc3


上記の dev-collection の install.py に置き換えて実行してみました。

$ ansible-playbook update.yml --check

PLAY [all] ***********************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************
ok: [xx.xx.xx.xxx]

TASK [Update bos.sysmgt.nim.client] **********************************************************************************************
changed: [xx.xx.xx.xxx]

PLAY RECAP ***********************************************************************************************************************
xx.xx.xx.xxx              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

通りそうです!
では、実行。

$ ansible-playbook update.yml

PLAY [all] ***********************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************
ok: [xx.xx.xx.xxx]

TASK [Update bos.sysmgt.nim.client] **********************************************************************************************
changed: [xx.xx.xx.xxx]

PLAY RECAP ***********************************************************************************************************************
xx.xx.xx.xxx              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

通りました。


  1. 確認
$ ansible test -a 'oslevel -s'
xx.xx.xx.xxx | CHANGED | rc=0 >>
7200-03-03-1914

$ ansible test -a 'lslpp -l bos.sysmgt.nim.client'
xx.xx.xx.xxx | CHANGED | rc=0 >>
  Fileset                      Level  State      Description
  ----------------------------------------------------------------------------
Path: /usr/lib/objrepos
  bos.sysmgt.nim.client     7.2.3.18  COMMITTED  Network Install Manager -
                                                 Client Tools

Path: /etc/objrepos
  bos.sysmgt.nim.client     7.2.3.18  COMMITTED  Network Install Manager -
                                                 Client Tools

OSレベルの変化はなし。
ファイルセット "bos.sysmgt.nim.client" は 7.2.3.18 にアップデートされています。成功!


まとめ

・2020/8/29時点 リリース・バージョン ibm.power_aix 1.0.2 の installp.py モジュール はバグがあります。
・dev-collection ブランチで修正中の様子です。
 Commit : 1c41427 「installp: check "parts" is not None before iterating. 」
 https://github.com/IBM/ansible-power-aix/commit/1c4142715dcee11066e8b5acf683ada07cc05b9f

修正された installp モジュールの今後の正式リリースを期待...

以上です。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?