feat(ansible): use aws dynamic inventories properly with ssm and host variables

This commit is contained in:
Michele Cereda
2025-08-09 00:12:02 +02:00
parent a4423457db
commit a439a4e9ef
7 changed files with 105 additions and 29 deletions

View File

@@ -14,7 +14,8 @@ forks=10
gathering=smart
host_key_checking=False
nocows=True
remote_tmp=/tmp
remote_tmp=/tmp/ansible
async_dir = ~/.ansible/async # default: ~/.ansible_async/
use_persistent_connections=True
verbosity=3

View File

@@ -1,26 +0,0 @@
---
################################################################################
## aws_ec2.yml
##
## Dynamic inventory for integration with AWS SSM.
## Makes use of the 'aws_ec2' plugin.
## The file must be named 'aws_ec2.yml'.
################################################################################
plugin: aws_ec2
regions:
- eu-east-2
keyed_groups:
- key: tags.Name
# add hosts to 'tag_Name_<tag_value>' groups for each aws_ec2 host's 'Tags.Name' attribute
prefix: tag_Name_
separator: ""
- key: tags.application
# add hosts to 'tag_application_<tag_value>' groups for each aws_ec2 host's 'Tags.application' attribute
prefix: tag_application_
separator: ""
hostnames:
- instance-id
# acts as keyword to use the instances' 'InstanceId' attribute
# use 'private-ip-address' to use the instances' 'PrivateIpAddress' attribute instead