5.2. 从 Automation 内容导航器浏览集合

您可以使用交互模式的自动化内容浏览或基于文本的用户界面浏览 Ansible 集合,并转至各个集合。自动化内容导航器显示当前项目目录中的集合,以及自动化执行环境中可用的集合

先决条件

  • 本地可访问的集合或安装的自动化执行环境。

流程

  1. 启动自动化内容导航器

    $ ansible-navigator
  2. 浏览该集合。或者,您也可以键入 ansible-navigator collections 来直接浏览集合。

    $ :collections
    在自动化内容导航器中显示的 Ansible 集合列表
  3. 键入您要浏览的集合数。

    :4
    自动化内容导航器中显示的集合
  4. 键入与您要转至的模块对应的数字。

    ANSIBLE.UTILS.IP_ADDRESS: Test if something in an IP address
     0│---
     1│additional_information: {}
     2│collection_info:
     3│  authors:
     4│  - Ansible Community
     5│  dependencies: {}
     6│  description: Ansible Collection with utilities to ease the management, manipulation,
     7│    and validation of data within a playbook
     8│  documentation: null
     9│  homepage: null
    10│  issues: null
    11│  license: []
    12│  license_file: LICENSE
    13│  name: ansible.utils
    14│  namespace: ansible
    15│  path:/usr/share/ansible/collections/ansible_collections/ansible/utils/
    16│  readme: README.md
    <... output truncated...>
  5. 可选:跳至此模块的文档示例。

    :{{ examples }}
    
    0│
    1│
    2│#### Simple examples
    3│
    4│- name: Check if 10.1.1.1 is a valid IP address
    5│  ansible.builtin.set_fact:
    6│    data: "{{ '10.1.1.1' is ansible.utils.ip_address }}"
    7│
    8│# TASK [Check if 10.1.1.1 is a valid IP address] *********************
    9│# ok: [localhost] => {
    10│#     "ansible_facts": {
    11│#         "data": true
    12│#     },
    13│#     "changed": false
    14│# }
    15│
  6. 可选:打开编辑器中的示例,将其复制到 playbook 中。

    :open
    编辑工具中显示的文档示例

验证

  • 浏览集合列表。

    集合列表