如何在 Ansible Tower 中使用集合

如何在 Ansible Tower 中使用集合

我们正在使用装有 Ansible 2.9.13 的 Ansible Tower 3.7.4,我们还安装了“theforeman”ansible 集合。

我的测试剧本是

---
- name: Test foreman roles
  hosts: localhost
  become: false
  gather_facts: false

  tasks:

  - add_host:
      name: victim.local
      group: my_inv

- name: Test foreman roles
  hosts: my_inv
  become: false
  gather_facts: false

  tasks:

  - theforeman.foreman.host:
      server_url: "https://foreman-server.local"
      username: "admin"
      password: "password"
      parameters:
        name: "param_name"
        value: "param_value"
        parameter_type: "string"
    delegate_to: localhost

无论我使用“theforeman.foreman.host”还是仅使用“host”,都会报告“错误!无法解析模块/操作”

定位命令显示了安装路径:

locate theforeman | grep host
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/foreman_host.py
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/foreman_host_power.py
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/foreman_hostgroup.py
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/katello_host_collection.py

我已将其放入 ansible.cfg 文件中:

grep collections /etc/ansible/ansible.cfg
collections_paths = /var/lib/awx/vendor/inventory_collections/ansible_collections

如何使用已安装的集合?

谢谢

答案1

ansible_collections是集合路径下目录结构的一部分,不应包含在搜索路径中。

collections_paths = /var/lib/awx/vendor/inventory_collections

相关内容