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

EC2 Inventory Plugin parameter use_ssm_inventory is not effective #1977

Closed
1 task done
vijayreddiar opened this issue Feb 15, 2024 · 3 comments
Closed
1 task done

Comments

@vijayreddiar
Copy link

Summary

EC2 Inventory Plugin parameter use_ssm_inventory is not effective irrespective of the count of instances in the account.

Issue Type

Bug Report

Component Name

aws_ec2

Ansible Version

$ ansible --version
ansible [core 2.15.9]
  config file = None
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.18 (main, Jan 24 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

Collection Versions

$ ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection              Version
----------------------- -------
amazon.aws              7.3.0

AWS SDK versions

$ pip show boto boto3 botocore
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.34.42
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.34.42
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed

OS / Environment

No response

Steps to Reproduce

---
plugin: amazon.aws.aws_ec2
regions:
  - us-east-1
hostnames:
  - name: tag:Name
    prefix: ""
compose:
  ansible_host: private_ip_address
groups:
  linux: "'windows' not in platform_details|lower"
  windows: "'windows' in platform_details|lower"
use_ssm_inventory: true

Expected Results

Above inventory source code in AWX fetch ssm_inventory host variable as below.

ssm_inventory:
  agent_type: amazon-ssm-agent
  agent_version: 3.2.2222.0
  computer_name: wmgtpadoagt01.WORKGROUP
  instance_id: i-032a8eda18421b1e4
  instance_status: Active
  ip_address: 10.255.26.83
  platform_name: Microsoft Windows Server 2022 Datacenter
  platform_type: Windows
  platform_version: 10.0.20348
  resource_type: EC2Instance

Actual Results

No ssm_inventory host variable

Code of Conduct

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

Based on the issue reported in #1713 , I see a fix is merged through #1957
Now, we don't see failures in inventory sync when the count of EC2 instances in an account is more than the allowed limit of instances (default value is 40) for SSM send_command, but no host variables are fetched through SSM now. The scenario is same even if the count of instances in the account is lesser than 40 - which means the parameter use_ssm_inventory is not at all effective now.

@hakbailey
Copy link
Contributor

@vijayreddiar I am unable to reproduce this locally, the ssm_inventory variable is returned as expected for all managed instances with inventory enabled -- note though that ssm_inventory is not present in the host variables for any instances that are not managed with inventory enabled. Just to confirm, does your Systems Manager Inventory include the instances for which you are not seeing that host variable in the result?

@vijayreddiar
Copy link
Author

@vijayreddiar I am unable to reproduce this locally, the ssm_inventory variable is returned as expected for all managed instances with inventory enabled -- note though that ssm_inventory is not present in the host variables for any instances that are not managed with inventory enabled. Just to confirm, does your Systems Manager Inventory include the instances for which you are not seeing that host variable in the result?

My bad, I had randomly checked a few instances which were not managed instances, hence not part of SSM Inventory due to a change in IaC (remained unnoticed). Thanks for pointing out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants