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

unsure if module_defaults is supported anymore for ec2 modules #557

Closed
1 task done
IPvSean opened this issue Nov 4, 2021 · 10 comments · Fixed by #558
Closed
1 task done

unsure if module_defaults is supported anymore for ec2 modules #557

IPvSean opened this issue Nov 4, 2021 · 10 comments · Fixed by #558
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) python3

Comments

@IPvSean
Copy link
Contributor

IPvSean commented Nov 4, 2021

Summary

I have the following in my play header->

  module_defaults:
    group/aws:
      region: "{{ aws_region | default('us-west-1') }}"

Here is an example task->

    - name: grab facts for TEST_INSTANCE
      ec2_instance_facts:
        filters:
          "tag:Name": "TEST_INSTANCE"
      register: TEST_INSTANCE

I am getting this error->
image

Issue Type

Bug Report

Component Name

ec2_instance_facts

Ansible Version

$ ansible --version
[awx@ansible-1 ~]$ podman run 3a5db4a1de36 ansible --version
ansible [core 2.11.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.6 (default, Jan 22 2021, 11:41:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True

Collection Versions

$ ansible-galaxy collection list
[awx@ansible-1 ~]$ podman run 3a5db4a1de36 ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection               Version
------------------------ -------
amazon.aws               2.0.0
ansible.controller       4.0.0
ansible.netcommon        2.2.0
ansible.network          1.0.1
ansible.posix            1.2.0
ansible.security         1.0.0
ansible.utils            2.3.0
ansible.windows          1.5.0
arista.eos               2.2.0
cisco.asa                2.0.2
cisco.ios                2.3.0
cisco.iosxr              2.3.0
cisco.nxos               2.4.0
cloud.common             2.0.3
community.aws            2.0.0
frr.frr                  1.0.3
ibm.qradar               1.0.3
junipernetworks.junos    2.2.0
kubernetes.core          2.1.1
openvswitch.openvswitch  2.0.0
redhat.insights          1.0.5
redhat.openshift         2.0.1
redhat.rhel_system_roles 1.0.1
redhat.rhv               1.4.4
redhat.satellite         2.0.1
servicenow.itsm          1.1.0
splunk.es                1.0.2
trendmicro.deepsec       1.1.0
vmware.vmware_rest       2.0.0
vyos.vyos                2.3.1

AWS SDK versions

$ pip show boto boto3 botocore
[awx@ansible-1 ~]$ podman run 3a5db4a1de36 pip show boto boto3 botocore
[dumb-init] pip: No such file or directory
[awx@ansible-1 ~]$ ansible-navigator
[awx@ansible-1 ~]$ podman run 3a5db4a1de36 pip3 show boto boto3 botocore
Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: mitch@garnaat.com
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires:
Required-by:
---
Name: boto3
Version: 1.17.56
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.8/site-packages
Requires: botocore, s3transfer, jmespath
Required-by:
---
Name: botocore
Version: 1.20.56
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.8/site-packages
Requires: urllib3, python-dateutil, jmespath
Required-by: s3transfer, boto3

Configuration

$ ansible-config dump --only-changed

OS / Environment

RHEL 8

Steps to Reproduce

---
- name: AWS ec2 de-provisioning
  connection: local
  hosts: localhost
  gather_facts: false
  # The paramater region will be set for all ec2 modules by specifying it here under module_defaults
  module_defaults:
    group/aws:
      region: "{{ aws_region | default('us-west-1') }}"

  tasks:
    - name: grab facts for TEST_INSTANCE
      ec2_instance_facts:
        filters:
          "tag:Name": "TEST_INSTANCE"
      register: TEST_INSTANCE

Expected Results

No error with missing region

Actual Results

{
  "msg": "The ec2_instance_facts module requires a region and none was found in configuration, environment variables or module parameters",
  "invocation": {
    "module_args": {
      "filters": {
        "tag:Name": "TEST_INSTANCE"
      },
      "debug_botocore_endpoint_logs": false,
      "validate_certs": true,
      "instance_ids": [],
      "ec2_url": null,
      "aws_access_key": null,
      "aws_secret_key": null,
      "security_token": null,
      "aws_ca_bundle": null,
      "profile": null,
      "aws_config": null,
      "region": null,
      "minimum_uptime": null
    }
  },
  "deprecations": [
    {
      "msg": "The 'ec2_instance_facts' module has been renamed to 'ec2_instance_info'",
      "date": "2021-12-01",
      "collection_name": "amazon.aws"
    },
    {
      "msg": "Distribution rhel 8.4 on host localhost should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.11/reference_appendices/interpreter_discovery.html for more information",
      "version": "2.12"
    }
  ],
  "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python"
  },
  "_ansible_no_log": false,
  "changed": false
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 labels Nov 4, 2021
@gravesm
Copy link
Member

gravesm commented Nov 4, 2021

@IPvSean what happens if you use ec2_instance_info instead? ec2_instance_facts isn't specifically listed in the action group config and I'm guessing the redirect logic won't handle this.

@tremble
Copy link
Contributor

tremble commented Nov 4, 2021

@IPvSean It looks like the issue here is that we missed adding the ec2_instance_facts alias to the group. The name ec2_instance_facts is deprecated, I'd recommend using ec2_instance_info as @gravesm suggests that should work (we use the groups in our integration tests)

@IPvSean
Copy link
Contributor Author

IPvSean commented Nov 4, 2021

so that one works now, but now I hit another issue with another module->

image

@IPvSean
Copy link
Contributor Author

IPvSean commented Nov 4, 2021

This is the module->

    - name: Get the VPC ID
      amazon.aws.ec2_vpc_net_info:
        filters:
          "tag:Name": "aws-demo-vpc"
      register: vpc_net_facts

@tremble
Copy link
Contributor

tremble commented Nov 4, 2021

Could you try dropping the "amazon.aws"?

@IPvSean
Copy link
Contributor Author

IPvSean commented Nov 4, 2021

OK that works.... so if I use amazon.aws on any of the modules trying to use the defaults it will break, if I use the short name, it will work

so this works->

    - name: grab facts for TEST_INSTANCE
      ec2_instance_info:
        filters:
          "tag:Name": "TEST_INSTANCE"
      register: TEST_INSTANCE

@s-hertel
Copy link
Collaborator

s-hertel commented Nov 4, 2021

It looks like a duplicate of the issue ansible/ansible#76171 is fixing. It's fixed in ansible-core 2.12 because we resolve and cache the action groups rather than just taking them as-is. The action_groups in runtime.yml is not using fully qualified action names (which would allow both to work).

ansible-zuul bot pushed a commit that referenced this issue Nov 5, 2021
Add missing entry to AWS action group

SUMMARY
When migrating ec2_instance we missed adding the ec2_instance_facts alias to the AWS action group
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
meta/runtime.yml
ADDITIONAL INFORMATION
fixes: #557

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
@tremble
Copy link
Contributor

tremble commented Nov 5, 2021

Hi @IPvSean,

The missing entry has now been added to module_defaults. We hope to have the next release (2.1.0) of amazon.aws out in the next couple of weeks.

As @s-hertel outlined, there's also the open issue with Ansible itself that means you currently need to use the "short" name rather than it's fully-qualified name. Because that's a backport it's not automatically merged but it looks like it's got the necessary approvals so hopefully that will be available in a released version of 2.11 'soon' (already fixed in 2.12).

ansible-zuul bot pushed a commit to ansible-collections/community.aws that referenced this issue Nov 5, 2021
Add missing entries to AWS action group

SUMMARY
A couple of entries are missing from the AWS action group
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
meta/runtime.yml
ADDITIONAL INFORMATION
Spotted while investigating ansible-collections/amazon.aws#557

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants