For strictly the purpose of speeding up the Ansible flow, I need just a few details to be retrieved from the host. The information that I need most often is the ansible_hostname, to make sure I'm landing on the correct host as I have a dynamic DNS.
Under which gather_subset does the hostname fall?
This is about limiting the data that is gathered from the host, as opposed to the filter
option.

- 53
- 1
- 9
1 Answers
It is possible to restrict the information gathered using gather_facts. Please check the docs of the ansible setup module on how to restrict information based on various subsets.
- hosts: my_target
gather_facts:no
pre_tasks:
- setup:
gather_subset: 'network'
tasks:
- debug: var=ansible_hostname
The available subsets from which the information can be gathered from is as follows
all, all_ipv4_addresses, all_ipv6_addresses, apparmor, architecture, caps, chroot, cmdline, date_time, default_ipv4, default_ipv6, devices, distribution, distribution_major_version, distribution_release, distribution_version, dns, effective_group_ids, effective_user_id, env, facter, fips, hardware, interfaces, is_chroot, kernel, local, lsb, machine, machine_id, mounts, network, ohai, os_family, pkg_mgr, platform, processor, processor_cores, processor_count, python, python_version, real_user_id, selinux, service_mgr, ssh_host_key_dsa_public, ssh_host_key_ecdsa_public, ssh_host_key_ed25519_public, ssh_host_key_rsa_public, ssh_host_pub_keys, ssh_pub_keys, system, system_capabilities, system_capabilities_enforced, user, user_dir, user_gecos, user_gid, user_id, user_shell, user_uid, virtual, virtualization_role, virtualization_type
These values are mentioned in the error, when we provide an unsupported value.
The documentation mentions only a few values, between which are "min" and "any" which are not mentioned in the error.
This is a known bug: https://github.com/ansible/ansible/issues/47603