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

Ansible 2.4 doesn't recognise 'localhost' on EC2 instances #32967

Closed
cazorla19 opened this issue Nov 16, 2017 · 5 comments
Closed

Ansible 2.4 doesn't recognise 'localhost' on EC2 instances #32967

cazorla19 opened this issue Nov 16, 2017 · 5 comments
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. c:cli/pull support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@cazorla19
Copy link

cazorla19 commented Nov 16, 2017

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible 2.4.1.0
  config file = None
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.12 (default, Nov  2 2017, 19:20:38) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
COMPONENT NAME

ansible-pull

CONFIGURATION
ansible-config dump --only-changed
[empty line]
OS / ENVIRONMENT
cat /etc/os-release

NAME="Amazon Linux AMI"
VERSION="2017.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.03"
PRETTY_NAME="Amazon Linux AMI 2017.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
SUMMARY

Ansible 2.4.1 doesn't match localhost in the inventory file explicitly set in playbook options. It mostly matters EC2 instances with custom DNS name.

Here is the case:

I'm running ansible-pull EC2 userdata to:

  1. Fetch the Github repo with playbook
  2. Run the playbook on localhost

The first step everywhere is fine, but I've got issues with playbook, because it doesn't look into inventory where I set the localhost in the host group.

Playbook head [with host mention]:

- hosts: "tag_aws_autoscaling_groupName_simple_fluent"
  serial: 1
  user: myuser
  become: True
  gather_facts: True

Inventory file:

[all]
localhost

[tag_aws_autoscaling_groupName_simple_fluent]
localhost

So, host match works fine in 2.3, but fails in 2.4

The version 2.4.1 pops up these warning. Probably, the issue is there.

 [WARNING]: Could not match supplied host pattern, ignoring: ip-10-2-119-213
 [WARNING]: Could not match supplied host pattern, ignoring: ip-10-2-119-213.ec2.internal
 [WARNING]: Could not match supplied host pattern, ignoring: tag_aws_autoscaling_groupName_simple_fluent
PLAY [tag_aws_autoscaling_groupName_simple_fluent] *******************************************************************************************************************************
skipping: no hosts matched

I could set the wrong issue header, may be the problem is not only on EC2, but it breaks the compatibility. What was run in 2.3, doesn't run 2.4 with no description in CHANGELOG.

Also I've run debug mode in both versions and read the diff. The one major difference is only at this warning, the subcommands on Bash/Python to run the playbook are actually the same.

STEPS TO REPRODUCE

Run the command like this on both 2.3 and 2.4 Ansible versions. Or convert this to ansible-playbook command

/usr/local/bin/ansible-pull -v -U git@github.com:simple/simple-infra.git -d /tmp/simple-infra --purge --private-key ansible_pull_key -i production/inventory_simple/local setup_fluent.yml
EXPECTED RESULTS
No config file found; using defaults
localhost | SUCCESS => {
    "after": "28b1688f74a0626e7157862c4773d14ed1e8e0d1",
    "before": null,
    "changed": true,
    "failed": false
}
Using /tmp/simple-infra/ansible.cfg as config file
PLAY [tag_aws_autoscaling_groupName_simple_fluent] *******************************************************************************************************************************
** Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
ok: [localhost]

TASK [Gathering Facts] ************************************************************************************************************************************************************
** Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
ok: [localhost]
ACTUAL RESULTS
No config file found; using defaults
 [WARNING]: Could not match supplied host pattern, ignoring: ip-10-2-119-213
 [WARNING]: Could not match supplied host pattern, ignoring: ip-10-2-119-213.ec2.internal
localhost | SUCCESS => {
    "after": "28b1688f74a0626e7157862c4773d14ed1e8e0d1",
    "before": null,
    "changed": true,
    "failed": false
}
Using /tmp/simple-infra/ansible.cfg as config file
 [WARNING]: Could not match supplied host pattern, ignoring: ip-10-2-119-213
 [WARNING]: Could not match supplied host pattern, ignoring: ip-10-2-119-213.ec2.internal
 [WARNING]: Could not match supplied host pattern, ignoring: tag_aws_autoscaling_groupName_simple_fluent
PLAY [tag_aws_autoscaling_groupName_simple_fluent] *******************************************************************************************************************************
skipping: no hosts matched
PLAY RECAP **************************************************************************************************************************************************************************
@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@cazorla19 Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

  • component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

click here for bot help

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. 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 Nov 16, 2017
@cazorla19
Copy link
Author

Thanks, I've set the component name, guess it's the core issue.

@ansibot ansibot removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Nov 16, 2017
@samdoran samdoran added c:cli/pull and removed needs_triage Needs a first human triage before being processed. labels Nov 16, 2017
@cazorla19
Copy link
Author

Sorry, I noticed the labels needs_info and needs_template in my issue. What kind of info do you need to investigate this case?

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Dec 5, 2017
@pilou-
Copy link
Contributor

pilou- commented Dec 13, 2017

@cazorla19 the bot removed both labels but needs info was added again because you used it in your comment. You should either edit this comment or add another comment containing !needs_info.

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Dec 13, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@samdoran samdoran added the needs_verified This issue needs to be verified/reproduced by maintainer label May 10, 2019
@bcoca
Copy link
Member

bcoca commented Sep 13, 2023

I cannot reproduce with any supported version, so I'm going to close this as resolved unless as new reproducer is supplied.

@bcoca bcoca closed this as completed Sep 13, 2023
@sivel sivel removed the needs_verified This issue needs to be verified/reproduced by maintainer label Sep 19, 2023
@ansible ansible locked and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. c:cli/pull support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

6 participants