英文:
What Ansible command to list or verify installed modules — whether built-in or add-on?
问题
我找不到任何有关运行的命令来显示/确认我的控制节点上安装了哪些附加的Ansible模块或内置的Ansible模块。 关于内置模块,我知道有一些网页列出了这些模块,但毫无疑问它们必须依赖于版本,这意味着我需要首先验证我的本地Ansible版本,然后找到一个列出该特定版本的所有内置模块的网页,这非常低效。
英文:
I can't find any info about any command to run, in order to show/confirm what add-on Ansible modules or built-in Ansible modules are installed on my control-node?
Regarding built-ins, I know that there are web-pages that list these things but surely they must be version-dependent, which means that I'd need to first verify my local Ansible version and then find a web-page that lists all built-ins for that specific version — i.e., very inefficient.
答案1
得分: 3
$ ansible-doc --list | head
add_host 添加主机(和可能的群组)到 ansible-playbook 的内存中...
amazon.aws.aws_az_info 收集关于可用性区域的信息...
amazon.aws.aws_caller_info 获取有关用于进行操作的用户和帐户的信息...
amazon.aws.aws_s3 管理对象...
amazon.aws.cloudformation 创建或删除 AWS CloudFormat...
amazon.aws.cloudformation_info 获取关于 AWS CloudFormat 的信息...
amazon.aws.ec2 创建、终止、启动或停止实例...
amazon.aws.ec2_ami 创建或销毁镜像(AMI)...
amazon.aws.ec2_ami_info 收集有关...
amazon.aws.ec2_eni 创建并可选附加弹性网络接口(ENI)到...
这也可以用于列出其他类型的可用插件,例如要显示所有查找插件,可以运行 ansible-doc -t lookup --list
。
英文:
$ ansible-doc --list | head
add_host Add a host (and alternatively a group) to the ansible-playbook in-memory ...
amazon.aws.aws_az_info Gather information about availability zon...
amazon.aws.aws_caller_info Get information about the user and account being used to make ...
amazon.aws.aws_s3 manage obje...
amazon.aws.cloudformation Create or delete an AWS CloudFormat...
amazon.aws.cloudformation_info Obtain information about an AWS CloudFormat...
amazon.aws.ec2 create, terminate, start or stop an instan...
amazon.aws.ec2_ami Create or destroy an image (AM...
amazon.aws.ec2_ami_info Gather information about...
amazon.aws.ec2_eni Create and optionally attach an Elastic Network Interface (ENI) to an...
This can also be used to list available plugins of other types, e.g. to show all lookup plugins you would run ansible-doc -t lookup --list
.
答案2
得分: 1
你可以创建已安装的集合和模块的字典。
- hosts: localhost
vars:
ansible_doc: /home/admin/.local/bin/ansible-doc
modules_all: "{{ (out.stdout|from_yaml).keys()|list }}"
modules_str: |
{% for i in modules_all %}
{% set arr = i.split('.') %}
- {collection: {{ arr[:-1]|join('.')|d('ansible.builtin', true) }}, module: {{ arr[-1] }}}
{% endfor %}
modules_grp: "{{ modules_str|from_yaml|groupby('collection') }}"
collections_list: "{{ modules_grp|map('first') }}"
modules_lists: "{{ modules_grp|map('last')|map('map', attribute='module') }}"
collections: "{{ dict(collections_list|zip(modules_lists)) }}"
tasks:
- command: "{{ ansible_doc }} -t module -l -j"
register: out
- debug:
var: out.stdout_lines
when: false
- debug:
var: out.stdout
when: false
- debug:
var: modules_all
when: false
- debug:
var: modules_str
when: false
- debug:
var: collections.keys()|list|to_yaml
when: true
- debug:
var: collections['ansible.builtin']|to_yaml
when: true
- debug:
var: collections['community.digitalocean']|to_yaml
when: true
- debug:
var: collections['community.general']|to_yaml
when: true
提供了集合的列表。
collections.keys()|list|to_yaml: |-
[amazon.aws, ansible.builtin, ansible.legacy, ansible.netcommon, ansible.posix, ansible.utils,
ansible.windows, arista.eos, awx.awx, azure.azcollection, check_point.mgmt, chocolatey.chocolatey,
cisco.aci, cisco.asa, cisco.dnac, cisco.intersight, cisco.ios, cisco.iosxr, cisco.ise,
cisco.meraki, cisco.mso, cisco.nso, cisco.nxos, cisco.nxos.storage, cisco.ucs, cloud.common,
cloudscale_ch.cloud, community.aws, community.ciscosmb, community.crypto, community.digitalocean,
community.dns, community.docker, community.fortios, community.general, community.google,
community.grafana, community.hashi_vault, community.hrobot, community.kubevirt,
community.libvirt, community.mongodb, community.mysql, community.network, community.okd,
community.postgresql, community.proxysql, community.rabbitmq, community.routeros,
community.sap, community.sap.database.saphana, community.sap.files, community.sap.identity,
community.sap.system, community.sap_libs, community.skydive, community.sops, community.vmware,
community.windows, community.zabbix, containers.podman, cyberark.pas, dellemc.enterprise_sonic,
dellemc.openmanage, dellemc.os10, dellemc.os6, dellemc.os9, dellemc.powerflex, dellemc.unity,
f5networks.f5_modules, fortinet.fortimanager, fortinet.fortios, frr.frr, gluster.gluster,
google.cloud, grafana.grafana, hetzner.hcloud, hpe.nimble, ibm.qradar, ibm.spectrum_virtualize,
infinidat.infinibox, infoblox.nios_modules, inspur.ispim, inspur.sm, junipernetworks.junos,
kubernetes.core, lowlydba.sqlserver, mellanox.onyx, netapp.aws, netapp.azure, netapp.cloudmanager,
netapp.elementsw, netapp.ontap, netapp.storagegrid, netapp.um_info, netapp_eseries.santricity,
netbox.netbox, ngine_io.cloudstack, ngine_io.exoscale, ngine_io.vultr, openstack.cloud,
openvswitch.openvswitch, ovirt.ovirt, purestorage.flasharray, purestorage.flashblade,
purestorage.fusion, sensu.sensu_go, servicenow.servicenow, splunk.es, t_systems_mms.icinga_director,
theforeman.foreman, vmware.vmware_rest, vultr.cloud, vyos.vyos, wti.remote]
模块 ansible.builtin。
collections['ansible.builtin']|to_yaml: |-
[_include, add_host, apt, apt_key, apt_repository, assemble, assert, async_status,
blockinfile, command, copy, cron, debconf, debug, dnf, dpkg_selections, expect,
fail, fetch, file, find, gather_facts, get_url, getent, git, group, group_by, hostname,
import_playbook, import_role, import_tasks, include_role, include_tasks, include_vars,
iptables, known_hosts, lineinfile, meta, package, package_facts, pause, ping, pip,
raw, reboot, replace, rpm_key, script, service, service_facts, set_fact, set_stats,
setup, shell, slurp, stat, subversion, systemd, systemd_service, sysvinit, tempfile,
template, unarchive, uri, user, validate_argument_spec, wait_for, wait_for_connection,
yum, yum_repository]
例如,集合 community.digitalocean。
collections['community.digitalocean']|to_yaml: |-
[digital_ocean, digital_ocean_account_facts, digital_ocean_account_info, digital_ocean_balance_info,
digital_ocean_block_storage, digital_ocean_cdn_endpoints, digital_ocean_cdn_endpoints_info,
digital_ocean_certificate, digital_ocean_certificate_facts, digital_ocean_certificate_info,
digital_ocean_database, digital_ocean_database_info, digital_ocean_domain, digital_ocean_domain_facts,
digital_ocean_domain_info, digital_ocean_domain_record, digital_ocean_domain_record_info,
digital_ocean_droplet, digital_ocean_droplet_info, digital_ocean_firewall, digital_ocean_firewall_facts,
digital_ocean_firewall_info, digital_ocean_floating_ip, digital_ocean_floating_ip_facts,
digital_ocean_floating_ip_info, digital_ocean_image_facts, digital_ocean_image_info,
digital_ocean_kubernetes, digital_ocean_kubernetes_info, digital_ocean_load_balancer,
digital_ocean_load_balancer_facts, digital_ocean_load_balancer_info, digital_ocean_monitoring_alerts,
digital_ocean_monitoring_alerts_info, digital_ocean_project, digital_ocean_project_info,
digital_ocean_region_facts, digital_ocean_region_info, digital_ocean_size_facts,
digital_ocean_size_info, digital_ocean_snapshot, digital_ocean
<details>
<summary>英文:</summary>
You can create the dictionary of installed collections and modules
```yaml
- hosts: localhost
vars:
ansible_doc: /home/admin/.local/bin/ansible-doc
modules_all: "{{ (out.stdout|from_yaml).keys()|list }}"
modules_str: |
{% for i in modules_all %}
{% set arr = i.split('.') %}
- {collection: {{ arr[:-1]|join('.')|d('ansible.builtin', true) }}, module: {{ arr[-1] }}}
{% endfor %}
modules_grp: "{{ modules_str|from_yaml|groupby('collection') }}"
collections_list: "{{ modules_grp|map('first') }}"
modules_lists: "{{ modules_grp|map('last')|map('map', attribute='module') }}"
collections: "{{ dict(collections_list|zip(modules_lists)) }}"
tasks:
- command: "{{ ansible_doc }} -t module -l -j"
register: out
- debug:
var: out.stdout_lines
when: false
- debug:
var: out.stdout
when: false
- debug:
var: modules_all
when: false
- debug:
var: modules_str
when: false
- debug:
var: collections.keys()|list|to_yaml
when: true
- debug:
var: collections['ansible.builtin']|to_yaml
when: true
- debug:
var: collections['community.digitalocean']|to_yaml
when: true
- debug:
var: collections['community.general']|to_yaml
when: true
<sup>
gives the list of the collections
collections.keys()|list|to_yaml: |-
[amazon.aws, ansible.builtin, ansible.legacy, ansible.netcommon, ansible.posix, ansible.utils,
ansible.windows, arista.eos, awx.awx, azure.azcollection, check_point.mgmt, chocolatey.chocolatey,
cisco.aci, cisco.asa, cisco.dnac, cisco.intersight, cisco.ios, cisco.iosxr, cisco.ise,
cisco.meraki, cisco.mso, cisco.nso, cisco.nxos, cisco.nxos.storage, cisco.ucs, cloud.common,
cloudscale_ch.cloud, community.aws, community.ciscosmb, community.crypto, community.digitalocean,
community.dns, community.docker, community.fortios, community.general, community.google,
community.grafana, community.hashi_vault, community.hrobot, community.kubevirt,
community.libvirt, community.mongodb, community.mysql, community.network, community.okd,
community.postgresql, community.proxysql, community.rabbitmq, community.routeros,
community.sap, community.sap.database.saphana, community.sap.files, community.sap.identity,
community.sap.system, community.sap_libs, community.skydive, community.sops, community.vmware,
community.windows, community.zabbix, containers.podman, cyberark.pas, dellemc.enterprise_sonic,
dellemc.openmanage, dellemc.os10, dellemc.os6, dellemc.os9, dellemc.powerflex, dellemc.unity,
f5networks.f5_modules, fortinet.fortimanager, fortinet.fortios, frr.frr, gluster.gluster,
google.cloud, grafana.grafana, hetzner.hcloud, hpe.nimble, ibm.qradar, ibm.spectrum_virtualize,
infinidat.infinibox, infoblox.nios_modules, inspur.ispim, inspur.sm, junipernetworks.junos,
kubernetes.core, lowlydba.sqlserver, mellanox.onyx, netapp.aws, netapp.azure, netapp.cloudmanager,
netapp.elementsw, netapp.ontap, netapp.storagegrid, netapp.um_info, netapp_eseries.santricity,
netbox.netbox, ngine_io.cloudstack, ngine_io.exoscale, ngine_io.vultr, openstack.cloud,
openvswitch.openvswitch, ovirt.ovirt, purestorage.flasharray, purestorage.flashblade,
purestorage.fusion, sensu.sensu_go, servicenow.servicenow, splunk.es, t_systems_mms.icinga_director,
theforeman.foreman, vmware.vmware_rest, vultr.cloud, vyos.vyos, wti.remote]
Modules ansible.builtin
collections['ansible.builtin']|to_yaml: |-
[_include, add_host, apt, apt_key, apt_repository, assemble, assert, async_status,
blockinfile, command, copy, cron, debconf, debug, dnf, dpkg_selections, expect,
fail, fetch, file, find, gather_facts, get_url, getent, git, group, group_by, hostname,
import_playbook, import_role, import_tasks, include_role, include_tasks, include_vars,
iptables, known_hosts, lineinfile, meta, package, package_facts, pause, ping, pip,
raw, reboot, replace, rpm_key, script, service, service_facts, set_fact, set_stats,
setup, shell, slurp, stat, subversion, systemd, systemd_service, sysvinit, tempfile,
template, unarchive, uri, user, validate_argument_spec, wait_for, wait_for_connection,
yum, yum_repository]
For example, collection community.digitalocean
collections['community.digitalocean']|to_yaml: |-
[digital_ocean, digital_ocean_account_facts, digital_ocean_account_info, digital_ocean_balance_info,
digital_ocean_block_storage, digital_ocean_cdn_endpoints, digital_ocean_cdn_endpoints_info,
digital_ocean_certificate, digital_ocean_certificate_facts, digital_ocean_certificate_info,
digital_ocean_database, digital_ocean_database_info, digital_ocean_domain, digital_ocean_domain_facts,
digital_ocean_domain_info, digital_ocean_domain_record, digital_ocean_domain_record_info,
digital_ocean_droplet, digital_ocean_droplet_info, digital_ocean_firewall, digital_ocean_firewall_facts,
digital_ocean_firewall_info, digital_ocean_floating_ip, digital_ocean_floating_ip_facts,
digital_ocean_floating_ip_info, digital_ocean_image_facts, digital_ocean_image_info,
digital_ocean_kubernetes, digital_ocean_kubernetes_info, digital_ocean_load_balancer,
digital_ocean_load_balancer_facts, digital_ocean_load_balancer_info, digital_ocean_monitoring_alerts,
digital_ocean_monitoring_alerts_info, digital_ocean_project, digital_ocean_project_info,
digital_ocean_region_facts, digital_ocean_region_info, digital_ocean_size_facts,
digital_ocean_size_info, digital_ocean_snapshot, digital_ocean_snapshot_facts, digital_ocean_snapshot_info,
digital_ocean_spaces, digital_ocean_spaces_info, digital_ocean_sshkey, digital_ocean_sshkey_facts,
digital_ocean_sshkey_info, digital_ocean_tag, digital_ocean_tag_facts, digital_ocean_tag_info,
digital_ocean_volume_facts, digital_ocean_volume_info, digital_ocean_vpc, digital_ocean_vpc_info]
Top 10
- debug:
msg: |
Top 10
------
{% for i in range(10) %}
{{ collections_len_list[i].key }}: {{ collections_len_list[i].value }}
{% endfor %}
vars:
modules_lists_len: "{{ modules_lists|map('length') }}"
collections_len: "{{ dict(collections_list|zip(modules_lists_len)) }}"
collections_len_list: "{{ collections_len|dict2items|sort(attribute='value', reverse=true) }}"
gives
Top 10
------
fortinet.fortimanager: 994
fortinet.fortios: 646
community.general: 571
cisco.ise: 383
cisco.dnac: 354
community.network: 315
azure.azcollection: 276
f5networks.f5_modules: 178
check_point.mgmt: 174
google.cloud: 170
</sup>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论