WindowsのWSL LinuxにてPodmanを使用するAnsible Molecule環境を構築する

備忘

Podmanコンテナ環境をターゲットとするAnsible MoleculeによるAnsible検証環境を構成する

# 環境
- Windows WSL2上Linux環境
    - Fedora Linux 39 (Container Image)
- Podman v5.0.2

https://qiita.com/hiroyuki_onodera/items/fb7e372bac11d10cf9f1

# Ansible, Moleculeなどの導入

https://ansible.readthedocs.io/projects/molecule/installation/

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ sudo dnf install python3-pip
...

Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ python3 -m pip install molecule ansible-core
...

Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ pip3 install ansible-dev-tools
...
```

https://github.com/ansible-community/molecule-podman

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ ansible-galaxy collection install containers.podman
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/containers-podman-1.12.1.tar.gz to /home/hiro/.ansible/tmp/ansible-local-12417h3fp2lk/tmpuy_ai280/containers-podman-1.12.1-nmeuatn2
Installing 'containers.podman:1.12.1' to '/home/hiro/.ansible/collections/ansible_collections/containers/podman'
containers.podman:1.12.1 was installed successfully
```

https://github.com/ansible-community/molecule-plugins

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ pip3 install 'molecule-plugins[podman]'
...
```


## molecule検証

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ ansible --version
ansible [core 2.16.6]
  config file = None
  configured module search path = ['/home/hiro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/hiro/.local/lib/python3.12/site-packages/ansible
  ansible collection location = /home/hiro/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/hiro/.local/bin/ansible
  python version = 3.12.2 (main, Feb 21 2024, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ molecule --version
molecule 24.2.1 using python 3.12
    ansible:2.16.6
    azure:23.5.3 from molecule_plugins
    containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    default:24.2.1 from molecule
    docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
    ec2:23.5.3 from molecule_plugins
    gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.5.3 from molecule_plugins
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ ansible-lint --version
ansible-lint 24.2.2 using ansible-core:2.16.6 ansible-compat:4.1.11 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
```

# role構築
## 作業ディレクトリー作成
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ mkdir repo
Fedora Linux 39 [hiro@DESKTOP-72JFO1B ~]$ cd repo
```

## ロール作成


## ansible-galaxy init myrole
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B repo]$ ansible-galaxy init myrole
- Role myrole was created successfully
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B repo]$ cd myrole/
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ tree .
.
├── README.md
├── defaults
│   └── main.yml
├── files
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── tasks
│   └── main.yml
├── templates
├── tests
│   ├── inventory
│   └── test.yml
└── vars
    └── main.yml

9 directories, 8 files
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ cat tasks/main.yml
---
# tasks file for myrole
```



### molecule処理におけるRole name check失敗を回避する設定
生成されたファイルのままでは、以降のmolecule処理においてRole name checkで失敗するため、以下のいずれかの対応が必要。

- a) meta/main.ymlにおけるgalaxy_info:にnamespace: xxxxを追記
- b) meta/main.ymlファイルを削除
- c) molecule.ymlにてrole_name_check: 1という設定を追加 (後述)


#### a) meta/main.ymlにおけるgalaxy_info:にnamespace: xxxxを追記 することによるRole name check失敗回避
xxxxは任意の文字列。Ansible Galaxyでのネームスペースであり、通常はユーザー名や組織名。

```yaml:meta/main.yml
galaxy_info:
  author: your name
  description: your role description
  company: your company (optional)
...
```
↓
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ grep -q "^  namespace:" meta/main.yml || sed -i '/^galaxy_info:/a \ \ namespace: my_galaxy_namespace' meta/main.yml
```
↓
```yaml:meta/main.yml
galaxy_info:
  namespace: my_galaxy_namespace  # 追加。Ansible Galaxyでのネームスペース、通常はユーザー名や組織名
  author: your name
  description: your role description
  company: your company (optional)
...
```

#### b) meta/main.ymlファイルを削除 することによるRole name check失敗回避

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ rm -fr meta
```


## molecule init scenario -d podman
moleculeの設定ファイルをpodmanドライバーを指定して生成する。
scenario名を指定していないのでdefaultというscenario名が使用される。
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule init scenario -d podman
INFO     Initializing new scenario default...

PLAY [Create a new molecule scenario] ******************************************

TASK [Check if destination folder exists] **************************************
changed: [localhost]

TASK [Check if destination folder is empty] ************************************
ok: [localhost]

TASK [Fail if destination folder is not empty] *********************************
skipping: [localhost]

TASK [Expand templates] ********************************************************
skipping: [localhost] => (item=molecule/default/destroy.yml)
changed: [localhost] => (item=molecule/default/molecule.yml)
changed: [localhost] => (item=molecule/default/converge.yml)
skipping: [localhost] => (item=molecule/default/create.yml)

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

INFO     Initialized scenario in /home/hiro/repo/myrole/molecule/default successfully.
```
以下が追加される
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ tree .
...
├── molecule
│   └── default
│       ├── converge.yml
│       └── molecule.yml
...
```
### molecule/default/molecule.yml
moleculeの設定ファイル
ここでは、1つのcentos stream8コンテナをinstanceという名前で利用することを意味している
テンプレートであり、必要に応じて書き換えを行う
```yaml:molecule/default/molecule.yml
---
driver:
  name: podman
platforms:
  - name: instance
    image: quay.io/centos/centos:stream8
    pre_build_image: true
```

#### c) molecule.ymlに、role_name_check: 1という設定を追加することによるRole name check失敗回避
前述のmeta/main.ymlによる対応を行っていない場合、以下の様にrole_name_check: 1という設定を追加してチェックを回避する対応が可能

```yaml:molecule/default/molecule.yml
---
driver:
  name: podman
platforms:
  - name: instance
    image: quay.io/centos/centos:stream8
    pre_build_image: true
role_name_check: 1                         # <= 追記
```

参照

https://ansible.readthedocs.io/projects/molecule/configuration/#role-name-check

### molecule/default/converge.yml
Moleculeが実行するAnsible Playbook本体。
必要に応じて書き換えを行う。
```yaml:molecule/default/converge.yml
---
- name: Converge
  hosts: all
  gather_facts: false
  tasks:
    - name: Replace this task with one that validates your content
      ansible.builtin.debug:
        msg: "This is the effective test"
```

# converge.ymlなどを未編集のままでmolecule動作を確認

## molecule list
状況の確認
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ false   │ false
                ╵             ╵                  ╵               ╵         ╵
```
Created falseは、コンテナが実行されていないことを意味する
Converged falseは、converge.yml playbookが実行されていないことを意味する

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ podman ps -a
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
```
podmanコンテナは起動されていない

## molecule create
podmanコンテナを起動する
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule create
WARNING  Driver podman does not provide a schema.
INFO     default scenario test matrix: dependency, create, prepare
INFO     Performing prerun with role_name_check=0...
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > create
INFO     Sanity checks: 'podman'

PLAY [Create] ******************************************************************

TASK [Log into a container registry] *******************************************
skipping: [localhost] => (item="instance registry username: None specified")
skipping: [localhost]

TASK [Check presence of custom Dockerfiles] ************************************
ok: [localhost] => (item=Dockerfile: None specified)

TASK [Create Dockerfiles from image names] *************************************
skipping: [localhost] => (item="Dockerfile: None specified; Image: quay.io/centos/centos:stream8")
skipping: [localhost]

TASK [Discover local Podman images] ********************************************
ok: [localhost] => (item=instance)

TASK [Build an Ansible compatible image] ***************************************
skipping: [localhost] => (item=quay.io/centos/centos:stream8)
skipping: [localhost]

TASK [Determine the CMD directives] ********************************************
ok: [localhost] => (item="instance command: None specified")

TASK [Discover local podman networks] ******************************************
skipping: [localhost] => (item=instance: None specified)
skipping: [localhost]

TASK [Create podman network dedicated to this scenario] ************************
skipping: [localhost]

TASK [Create molecule instance(s)] *********************************************
ok: [localhost] => (item=instance)

TASK [Wait for instance(s) creation to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) creation to complete (300 retries left).
changed: [localhost] => (item=instance)

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=1    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0

INFO     Running default > prepare
WARNING  Skipping, prepare playbook not configured.
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ true    │ false
                ╵             ╵                  ╵               ╵         ╵
```
Createdがtrueとなった。
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ podman ps -a
CONTAINER ID  IMAGE                          COMMAND               CREATED             STATUS             PORTS       NAMES
c6e35bb3bacd  quay.io/centos/centos:stream8  bash -c while tru...  About a minute ago  Up About a minute              instance
```
instanceというCentos stream8のコンテナが起動

## molecule converge

playbook適用(PLAY [Converge])を行う。

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule converge
WARNING  Driver podman does not provide a schema.
INFO     default scenario test matrix: dependency, create, prepare, converge
INFO     Performing prerun with role_name_check=0...
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > create
WARNING  Skipping, instances already created.
INFO     Running default > prepare
WARNING  Skipping, prepare playbook not configured.
INFO     Running default > converge
INFO     Sanity checks: 'podman'

PLAY [Converge] ****************************************************************

TASK [Replace this task with one that validates your content] ******************
ok: [instance] => {
    "msg": "This is the effective test"
}

PLAY RECAP *********************************************************************
instance                   : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
```
podmanコンテナに対してplaybookが適用された。
ただ、この例ではplaybookの内容がdebugメッセージ出力のみのため、コンテナに対する操作は行われていない。
なお、もしインスタンス未起動状態で実行された場合には、先にインスタンス起動(create)が行われる。
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ true    │ true
                ╵             ╵                  ╵               ╵         ╵
```
Convergedがtrueに変更された

## molecule login
インスタンスにログインする
複数インスタンスが起動されている場合には、`molecule login -h インスタンス名`とインスタンス名を指定する
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule login
WARNING  Driver podman does not provide a schema.
INFO     Running default > login
[root@c6e35bb3bacd /]# grep PRE /etc/os-release
PRETTY_NAME="CentOS Stream 8"
[root@c6e35bb3bacd /]# id
uid=0(root) gid=0(root) groups=0(root)
[root@c6e35bb3bacd /]# exit
exit
```
## molecule destroy
インスタンスの破棄
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule destroy
WARNING  Driver podman does not provide a schema.
INFO     default scenario test matrix: dependency, cleanup, destroy
INFO     Performing prerun with role_name_check=0...
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > cleanup
WARNING  Skipping, cleanup playbook not configured.
INFO     Running default > destroy
INFO     Sanity checks: 'podman'

PLAY [Destroy] *****************************************************************

TASK [Destroy molecule instance(s)] ********************************************
changed: [localhost] => (item={'image': 'quay.io/centos/centos:stream8', 'name': 'instance', 'pre_build_image': True})

TASK [Wait for instance(s) deletion to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (300 retries left).
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (299 retries left).
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (298 retries left).
changed: [localhost] => (item={'failed': 0, 'started': 1, 'finished': 0, 'ansible_job_id': 'j126918266125.9757', 'results_file': '/home/hiro/.ansible_async/j126918266125.9757', 'changed': True, 'item': {'image': 'quay.io/centos/centos:stream8', 'name': 'instance', 'pre_build_image': True}, 'ansible_loop_var': 'item'})

TASK [Delete podman network dedicated to this scenario] ************************
skipping: [localhost] => (item=instance: None specified)
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

INFO     Pruning extra files from scenario ephemeral directory
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ false   │ false
                ╵             ╵                  ╵               ╵         ╵
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ podman ps -a
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
```

## molecule test
インスタンスの作成、playbook適用、インスタンス除去を一気通貫で行う。CI/CDなどで検証を行う場合などに有効。
冪等性(idempotence)確認の為にplaybook適用(PLAY [Converge])は2回行なわれる。


```
...
INFO     Running default > converge

PLAY [Converge] ****************************************************************

TASK [Replace this task with one that validates your content] ******************
ok: [instance] => {
    "msg": "This is the effective test"
}

PLAY RECAP *********************************************************************
instance                   : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

INFO     Running default > idempotence

PLAY [Converge] ****************************************************************

TASK [Replace this task with one that validates your content] ******************
ok: [instance] => {
    "msg": "This is the effective test"
}

PLAY RECAP *********************************************************************
instance                   : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

INFO     Idempotence completed successfully.
...
```
- 1回目のPLAY [Converge]に対するPLAY RECAPにおいて、通常は何らかの構成変更が行われchangedが1以上となる。
    - この例ではまだconverge.ymlがメッセージ出力のみの為、構成変更が行われていない。
- 2回目のPLAY [Converge]に対するPLAY RECAPにおいて、changed=0となる実装が望ましい。

## molecule verify
検証playbook(molecule/シナリオ名/verify.yml)を実行する。
verify.ymlがなければスキップされて終わる。




# より実践的なconverge.yml, tasks/main.ymlの例
molecule/default/converge.ymlを、ロール本体を呼び出す様に編集
```yaml:molecule/default/converge.yml
---
- name: Converge
  hosts: all
  gather_subset: ["!all"]
  tasks:
    - name: Include_role {{ role }}
      vars:
        role: "{{ playbook_dir | dirname | dirname | basename }}"
      ansible.builtin.include_role:
        name: "{{ role }}"
```
ロールのtasks/main.ymlを編集
```yaml:tasks/main.yml
---
# tasks file for myrole

- name: Debug ansible_distribution
  ansible.builtin.debug:
    var: ansible_distribution

- name: Add the user 'johnd'
  ansible.builtin.user:
    name: johnd
    comment: John Doe
```
ansible_distributionの表示、およびユーザー追加を行う

## molecule converge
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ false   │ false
                ╵             ╵                  ╵               ╵         ╵
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule converge
WARNING  Driver podman does not provide a schema.
INFO     default scenario test matrix: dependency, create, prepare, converge
INFO     Performing prerun with role_name_check=0...
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > create
INFO     Sanity checks: 'podman'

PLAY [Create] ******************************************************************

TASK [Log into a container registry] *******************************************
skipping: [localhost] => (item="instance registry username: None specified")
skipping: [localhost]

TASK [Check presence of custom Dockerfiles] ************************************
ok: [localhost] => (item=Dockerfile: None specified)

TASK [Create Dockerfiles from image names] *************************************
skipping: [localhost] => (item="Dockerfile: None specified; Image: quay.io/centos/centos:stream8")
skipping: [localhost]

TASK [Discover local Podman images] ********************************************
ok: [localhost] => (item=instance)

TASK [Build an Ansible compatible image] ***************************************
skipping: [localhost] => (item=quay.io/centos/centos:stream8)
skipping: [localhost]

TASK [Determine the CMD directives] ********************************************
ok: [localhost] => (item="instance command: None specified")

TASK [Discover local podman networks] ******************************************
skipping: [localhost] => (item=instance: None specified)
skipping: [localhost]

TASK [Create podman network dedicated to this scenario] ************************
skipping: [localhost]

TASK [Create molecule instance(s)] *********************************************
ok: [localhost] => (item=instance)

TASK [Wait for instance(s) creation to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) creation to complete (300 retries left).
changed: [localhost] => (item=instance)

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=1    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0

INFO     Running default > prepare
WARNING  Skipping, prepare playbook not configured.
INFO     Running default > converge

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [instance]

TASK [Include_role myrole] *****************************************************

TASK [myrole : Debug ansible_distribution] *************************************
ok: [instance] => {
    "ansible_distribution": "CentOS"
}

TASK [myrole : Add the user 'johnd'] *******************************************
changed: [instance]

PLAY RECAP *********************************************************************
instance                   : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
```
ansible_distributionとしてCentOSが表示されている
ユーザー追加はchangedとしてカウント
## molecule loginにて確認
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ true    │ true
                ╵             ╵                  ╵               ╵         ╵
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule login
WARNING  Driver podman does not provide a schema.
INFO     Running default > login
[root@427135f1875d /]#
[root@427135f1875d /]# grep John /etc/passwd
johnd:x:1000:1000:John Doe:/home/johnd:/bin/bash
[root@427135f1875d /]#
[root@427135f1875d /]# exit
exit
```
指定ユーザーが追加されていた。
## molecule destroy
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule destroy
WARNING  Driver podman does not provide a schema.
INFO     default scenario test matrix: dependency, cleanup, destroy
INFO     Performing prerun with role_name_check=0...
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > cleanup
WARNING  Skipping, cleanup playbook not configured.
INFO     Running default > destroy
INFO     Sanity checks: 'podman'

PLAY [Destroy] *****************************************************************

TASK [Destroy molecule instance(s)] ********************************************
changed: [localhost] => (item={'image': 'quay.io/centos/centos:stream8', 'name': 'instance', 'pre_build_image': True})

TASK [Wait for instance(s) deletion to complete] *******************************
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (300 retries left).
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (299 retries left).
FAILED - RETRYING: [localhost]: Wait for instance(s) deletion to complete (298 retries left).
changed: [localhost] => (item={'failed': 0, 'started': 1, 'finished': 0, 'ansible_job_id': 'j513434916604.10948', 'results_file': '/home/hiro/.ansible_async/j513434916604.10948', 'changed': True, 'item': {'image': 'quay.io/centos/centos:stream8', 'name': 'instance', 'pre_build_image': True}, 'ansible_loop_var': 'item'})

TASK [Delete podman network dedicated to this scenario] ************************
skipping: [localhost] => (item=instance: None specified)
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

INFO     Pruning extra files from scenario ephemeral directory
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule list
WARNING  Driver podman does not provide a schema.
INFO     Running default > list
                ╷             ╷                  ╷               ╷         ╷
  Instance Name │ Driver Name │ Provisioner Name │ Scenario Name │ Created │ Converged
╶───────────────┼─────────────┼──────────────────┼───────────────┼─────────┼───────────╴
  instance      │ podman      │ ansible          │ default       │ false   │ false
                ╵             ╵                  ╵               ╵         ╵
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ podman ps -a
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
```

# 気づいた変更点

- molecule init roleが使用できなくなっていた。roleひな形の作成はansible-galaxyコマンドを利用する必要がある。

```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule init --help
Usage: molecule init [OPTIONS] COMMAND [ARGS]...

  Initialize a new scenario.

Options:
  --help  Show this message and exit.

Commands:
  scenario  Initialize a new scenario for use with Molecule.
```
```
Fedora Linux 39 [hiro@DESKTOP-72JFO1B myrole]$ molecule --version
molecule 24.2.1 using python 3.12
...
```

- デフォルトで作成されるmolecule.ymlの内容がシンプルとなっていた。


# 参考
https://qiita.com/jyotti/items/cd260e5c1f8546055e01