I'm trying to get Ansible to create a launch configuration (using ec2_lc
) and auto scaling group (ec2_asg
). My playbook creates the launch configuration just fine, but the ASG is creating an error:
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "msg": "No launch config found with name {'name': 'dockerLC', 'instance_type': 't2.micro', 'image_id': 'ami-e97c548c', 'changed': False, 'failed': False, 'arn': None, 'created_time': 'None', 'security_groups': ['sg-e0c0de88'], 'result': {'image_id': 'ami-e97c548c', 'key_name': 'ansible-keys', 'launch_configuration_name': 'dockerLC', 'ebs_optimized': False, 'instance_type': 't2.micro', 'created_time': 'None', 'associate_public_ip_address': True, 'instance_monitoring': False, 'placement_tenancy': 'default', 'security_groups': ['sg-e0c0de88'], 'block_device_mappings': []}}"}
I'm unsure why this error is being thrown because I certainly have a dockerLC
launch configuration in the AWS EC2 web interface. My playbook is below.
tasks:
- name: Create Launch Configuration
local_action:
module: ec2_lc
name: dockerLC
region: '{{ aws_region }}'
image_id: '{{ ami_id }}'
key_name: '{{ key_name }}'
security_groups: '{{ security_group_id }}'
# security_groups: '{{ security_group }}'
instance_type: '{{ instance_type }}'
assign_public_ip: True
vpc_id: '{{ vpc }}'
register: lc
# - pause:
# seconds: 10
- name: Create Auto Scaling Group
local_action:
module: ec2_asg
name: dockerASG
region: '{{ aws_region }}'
launch_config_name: '{{ lc }}'
min_size: 3
max_size: 5
wait_for_instances: True
availability_zones: ['us-east-2a', 'us-east-2b', 'us-east-2c']
vpc_zone_identifier: ' {{ vpc_zones }} '
tags:
- function: docker
billingGroup: Work