Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#31425 affects variables assigned to implicit localhost in a backwards-incompatible way #31857

Closed
flowerysong opened this issue Oct 18, 2017 · 2 comments · Fixed by #31895
Closed
Assignees
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. inventory Inventory category support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@flowerysong
Copy link
Contributor

flowerysong commented Oct 18, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

inventory

ANSIBLE VERSION
ansible 2.5.0 (detached HEAD 7623c2fbda) last updated 2017/10/17 20:12:26 (GMT -400)
  config file = /home/ec2-user/ansible-aws-dev/ansible/ansible.cfg
  configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ec2-user/ansible-aws-dev/git/ansible.git/lib/ansible
  executable location = /home/ec2-user/ansible-aws-dev/git/ansible.git/bin/ansible
  python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
CONFIGURATION
ANSIBLE_PIPELINING(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = True
ANSIBLE_SSH_CONTROL_PATH(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = %(directory)s/%%h-%%p-%%r
DEFAULT_BECOME(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = sudo
DEFAULT_HOST_LIST(env: ANSIBLE_INVENTORY) = [u'/home/ec2-user/ansible-aws-dev/inventory']
DEFAULT_PRIVATE_KEY_FILE(env: ANSIBLE_PRIVATE_KEY_FILE) = /home/ec2-user/ansible-aws-dev/id_rsa
DEFAULT_REMOTE_USER(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = ec2-user
HOST_KEY_CHECKING(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/ec2-user/ansible-aws-dev/ansible/ansible.cfg) = False
OS / ENVIRONMENT

N/A

SUMMARY

Before #31425 was merged, and going back at least as far as ansible 2.0, the implicit localhost entry was assigned group vars from 'all'. Now it is not.

STEPS TO REPRODUCE

test.yml:

- hosts: localhost
  gather_facts: false
  tasks:
    - debug:
        var: flowerysong

group_vars/all.yml:

flowerysong: foo

Run ansible-playbook -i /dev/null test.yml

EXPECTED RESULTS

ansible 2.0.2.0 and all other versions tested before this pull request show the variable as defined:

 [WARNING]: provided hosts list is empty, only localhost is available


PLAY [localhost] ***************************************************************

TASK [debug] *******************************************************************
ok: [localhost] => {
    "flowerysong": "foo"
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0
ACTUAL RESULTS

The variable is now shown as undefined.

 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available


PLAY [localhost] *****************************************************************************************************

TASK [debug] *********************************************************************************************************
ok: [localhost] => {
    "flowerysong": "VARIABLE IS NOT DEFINED!"
}

PLAY RECAP ***********************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0
@ansibot
Copy link
Contributor

ansibot commented Oct 18, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug_report needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 18, 2017
@gundalow gundalow added the inventory Inventory category label Oct 18, 2017
@gundalow
Copy link
Contributor

I wonder if this is something that needs covering in #31840

@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Oct 18, 2017
bcoca added a commit to bcoca/ansible that referenced this issue Oct 18, 2017
abadger pushed a commit that referenced this issue Oct 18, 2017
fixes #31857
reverts #31425

(cherry picked from commit 7fe6a8d)
abadger pushed a commit that referenced this issue Oct 18, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. inventory Inventory category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants