Ansible Core の service モジュールをAIX で確認
Ansible 2.9 ドキュメントの Service モジュールを眺めていると、
「Notes : For AIX, group subsystem names can be used.」
という記載を見つけたので試してみます。
このモジュールは、galaxy collection ではなく、Core モジュール (Ansible Core チームがメンテナンス)です。
参考:Module Maintenance & Support
Ansible の Core モジュール一覧:https://github.com/ansible/ansible/tree/devel/lib/ansible/modules
serviceモジュール本体:service.py
抜粋
class AIX(Service):
"""
This is the AIX Service (SRC) manipulation class - it uses lssrc, startsrc, stopsrc
and refresh for service control. Enabling a service is currently not supported.
Would require to add an entry in the /etc/inittab file (mkitab, chitab and rmitab
commands)
"""
=> スタート、ストップ、リフレッシュ ができそうですね。
環境
・AIX:
AIX 7200-03-02-1846
(hostname : test )
・Anslbe 実行環境:
Mac
Ansible バージョン 2.9.9
準備
1) ansible.cfg
[defaults]
inventory = ./inventory
private_key_file = ~/.ssh/id_rsa
interpreter_python=/usr/bin/python
2) inventory
[test]
XX.XX.XX.XX <=対象サーバーのIPアドレス
3) service.yml
---
- hosts: all
tasks:
- name: Stop service group mail, if started
service:
name: mail
state: stopped
実行
まずは、現在の mail グループの状態を確認
$ ansible test -m command -a "lssrc -g mail"
test | CHANGED | rc=0 >>
Subsystem Group PID Status
sendmail mail 4981148 active
=> sendmail サービスがアクティブ状態です。
service.yml を実行します。
$ ansible-playbook service.yml
PLAY [all] ***********************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************
ok: [test]
TASK [Stop service group mail, if started] ***************************************************************************************
changed: [test]
PLAY RECAP ***********************************************************************************************************************
test : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
$
通りました!
では確認。
$ ansible test -m command -a "lssrc -g mail"
test | CHANGED | rc=0 >>
Subsystem Group PID Status
sendmail mail inoperative
=> mailグループのsendmailサービスは"inoperative"状態です。
Coreモジュールのservice モジュールでAIXサービスのmailグループの停止処理が確認できました。
まとめ
・Ansible の Coreモジュールである service モジュールは、AIX のグループ単位のサービスでサービスモジュールの一部の処理が可能(当文書では mail グループのストップのみを確認)
以上です。
Author And Source
この問題について(Ansible Core の service モジュールをAIX で確認), 我々は、より多くの情報をここで見つけました https://qiita.com/c_u/items/e4e04e642e3376be7306著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .