From 2343adbb203f770a771d45d19675b6a19ded9e36 Mon Sep 17 00:00:00 2001 From: Ben Partridge Date: Wed, 25 Mar 2020 11:15:45 +1100 Subject: [PATCH] Create dynamic inventory for AWS autoscaling groups --- ansible.cfg | 3 +++ inv/atl_cluster_aws_ec2.yml | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 inv/atl_cluster_aws_ec2.yml diff --git a/ansible.cfg b/ansible.cfg index bb157df..e7e1433 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,6 @@ [defaults] retry_files_enabled = False callback_whitelist = profile_tasks + +[inventory] +enable_plugins = aws_ec2 \ No newline at end of file diff --git a/inv/atl_cluster_aws_ec2.yml b/inv/atl_cluster_aws_ec2.yml new file mode 100644 index 0000000..01b36ac --- /dev/null +++ b/inv/atl_cluster_aws_ec2.yml @@ -0,0 +1,16 @@ +## Creates an inventory from your application cluster autoscaling group +## You need to provide the following environment variables +# AWS_ACCESS_KEY_ID +# AWS_SECRET_ACCESS_KEY +# +# Replace "your_autoscaling_group" with the name of the EC2 autoscaling group your application cluster is running in +# Replace "your deployment region" with the AWS region your cluster is running in +# The Ansible controller node will need to have SSH access to the autoscaling group so ensure its private key is authorised and there +# the security group allows SSH connection + +plugin: aws_ec2 + +filters: + tag:aws:autoscaling:groupName: your_autoscaling_group +regions: + - your_deployment_region \ No newline at end of file