分子初始化角色无法执行

总体来看

我开始学习Ansible Molecule时遇到了一些困难,作为一个初学者,我记录了下来。

详细资料

我在各种野生资料中看到了执行下面的「molecule init role」的描述,但无法指定子子选项”role”。

$ molecule init role --driver-name docker --role-name rolehoge
Usage: molecule init [OPTIONS] COMMAND [ARGS]...
Try 'molecule init --help' for help.

Error: No such command 'role'.

我使用的版本如下所示。

$ molecule --version
molecule 6.0.2 using python 3.10 
    ansible:2.15.2
    default:6.0.2 from molecule

当查看最新(6系)的官方文件《开始使用分子》时,可以用ansible-galaxy命令。

    https://ansible.readthedocs.io/projects/molecule/getting-started/

当查看版本号为v.5.1.0时,发现创建步骤为“molecule init role”。

    https://github.com/ansible/molecule/blob/v5.1.0/docs/getting-started.md

我发现下面这个 PR 已经更新了内容。
https://github.com/ansible/molecule/pull/3959

在上述公关概要中提到,通过ansible-galaxy命令,已经包含了”molecule init role”的功能。

Removed 'init role' command due to already being covered by ansible-galaxy

另外,在Molecule的官方文档中也提到了类似的评论。

    https://ansible.readthedocs.io/projects/molecule/next/
molecule init command is now only available to create a scenario using molecule init scenario. Users will no longer be able to create a role. Instead, users can make use of ansible-galaxy to create a collection or role.

因此,将来需要使用ansible-galaxy命令进行创建。

$ ansible-galaxy role init my_role
广告
将在 10 秒后关闭
bannerAds