ansible-builderとansible-navigatorをちょっとだけ触る。

はじめに

取り合えずlocalhostdebugモジュールを動かすだけのPlaybookを流すまで。なるべくシンプルに。

WSL2 Ubuntu-20.04上で実施。podman導入済み。EEのバージョンは下記。

$ podman --version
podman version 3.3.1
$ ansible-builder --version
1.0.1
$ ansible-navigator --version
ansible-navigator 1.1.0
$ ansible-runner --version
2.0.3

ansible-builder

主に下記を参考。

docs.ansible.com

↓でも可。正直、↑の方が取っつきやすかった。

https://ansible-builder.readthedocs.io/en/stable/index.html

pip install ansible-builder
cat << EOF > execution-environment.yml
---
version: 1
dependencies:
  galaxy: requirements.yml
EOF
cat << EOF > requirements.yml
---
collections:
  - name: awx.awx
EOF
ansible-builder build --tag=general -v 3
  • collectionsは形だけ指定。
  • 数分かかるので、進捗気になる人は-v推奨。
  • ansible-builder build実行に伴って、dangling image(<none>:<none>)が作成される。
    • 不要であればpodman image prune等で削除しても良いが、イメージの微調整が想定される場合は、残しておいた方が良いかも?

ansible-navigator

pip install ansible-navigator
  • ansible-runnerも一緒にインストールされる。
sudo mkdir /dev/mqueue
cat << EOF > ~/.ansible-navigator.yml
---
ansible-navigator:
  execution-environment:
    image: general
    pull-policy: never
EOF
ansible-navigator -m stdout run playbook.yml -i inventory.ini 

下記、実行結果。

$ ansible-navigator -m stdout run playbook.yml -i inventory.ini 

PLAY [localhost] ***************************************************************

TASK [debug] *******************************************************************
ok: [localhost] => {
    "msg": "Hello world!"
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  
Error: statfs /dev/mqueue: no such file or directory

以上。