ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.72k stars 23.87k forks source link

Fact ansible_mounts does not exist if facter facts are excluded #30929

Closed Nosmoht closed 2 years ago

Nosmoht commented 7 years ago
ISSUE TYPE
COMPONENT NAME

setup

ANSIBLE VERSION
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = []
  ansible python module location = /home/tkrahn/.virtualenvs/ansible/lib/python2.7/site-packages/ansible
  executable location = /home/tkrahn/.virtualenvs/ansible/bin/ansible
  python version = 2.7.14 (default, Sep 20 2017, 01:25:59) [GCC 7.2.0]
CONFIGURATION

DEFAULT_GATHER_SUBSET(/home/tkrahn/workspace/ansible/ansible.cfg) = !facter

OS / ENVIRONMENT
SUMMARY

If facter facts are not gathered fact _ansiblemounts does not exist.

STEPS TO REPRODUCE
---
- hosts: all
  gather_facts: true
  tasks:
  - debug: var=ansible_mounts
EXPECTED RESULTS

Fact _ansiblemounts is provided

ACTUAL RESULTS

Fact _ansiblemounts is not provided.

I might be wrong but as far as i remember facter facts are always prefixed with facter

alikins commented 7 years ago

I can reproduce this with stable-2.4

[newswoop:F25:ansible (stable-2.4 % u=)]$ ansible localhost -m setup -a 'gather_subset=!facter' | grep mount
[newswoop:F25:ansible (stable-2.4 % u=)]$ ansible localhost -m setup | grep mounts
        "ansible_mounts": [

works in stable-2.3:

[newswoop:F25:ansible (stable-2.3 % u=)]$ ansible localhost -m setup | grep mounts
        "ansible_mounts": [
[newswoop:F25:ansible (stable-2.3 % u=)]$ ansible localhost -m setup -a 'gather_subset=!facter' | grep mounts
        "ansible_mounts": [
Nosmoht commented 7 years ago

Just realized that also ansible_product_name is not defined if Factor facts are excluded

Nosmoht commented 6 years ago

Next one: ansible_default_ipv4 not available

ansibot commented 6 years ago

cc @david_obrien click here for bot help

rouge8 commented 6 years ago

I can also reproduce when excluding ohai facts.

rouge8 commented 6 years ago

This was broken by https://github.com/ansible/ansible/commit/27a015f0ad79a33af2d7ed4d39635ca8f7c02fd8. Previously, gather_subset = !ohai,!facter implied gather_subset = all,!ohai,!facter (which works on Ansible 2.4.x!), but that commit changed it to imply gather_subset = min,!ohai,!facter

bcoca commented 6 years ago

@rouge8 so the issue here is that all is the default, but once you add !facter it does not include all, only min is implied. So =!facter is the same as =min,!facter not =all,!facter as you expected.

i'm not sure this is wrong but we might want to be clearer in docs about how this works.

ansibot commented 5 years ago

cc @davidobrien1985 click here for bot help

nitzmahone commented 2 years ago

This was arguably a regression when the fact gathering code was reorganized, but it's been working this way for so long that changing it back now would probably cause more problems than it solves. Closing for "as-designed"-ish. ;)