Skip to content

Instantly share code, notes, and snippets.

@jwitko
Created March 15, 2018 21:47
Show Gist options
  • Save jwitko/e49c30ad384ad10cabc6d388284f52a0 to your computer and use it in GitHub Desktop.
Save jwitko/e49c30ad384ad10cabc6d388284f52a0 to your computer and use it in GitHub Desktop.
ansible 2.4 ec2_asg_Facts module error
-------------------------------------------------------------------------------------------------
ansible task which produces the error:
-------------------------------------------------------------------------------------------------
- name: ASG | Create Auto Scale Group for Application load balancer
ec2_asg:
name: "{{ deploy_env }}-{{ service }}-{{ swarm_type }}-{{ item.0.item.type|replace('.','-') }}"
health_check_period: "{{ item.1.asg_health_check_period|default(asg_health_check_period) }}"
health_check_type: "{{ item.1.asg_health_type | default(asg_health_type | default(omit)) }}"
launch_config_name: "{{ item.0.name }}"
region: "{{ region }}"
min_size: "{{ item.1.asg_min|default(asg_min) }}"
max_size: "{{ item.1.asg_max|default(asg_max) }}"
replace_batch_size: 1
wait_for_instances: True
vpc_zone_identifier: ["{{ all_private_subnets | join(', ') }}"]
target_group_arns: "{{ ec2_tg.results|json_query('[].target_group_arn')|list }}"
default_cooldown: "{{ item.1.asg_default_cooldown|default(asg_default_cooldown) }}"
desired_capacity: "{{ asg_desired_capacity[deploy_env + '-' + service + '-' + swarm_type + '-' + item.0.item.type|replace('.','-')] }}"
register: asg_alb_result
when:
- item.0.item.type == item.1.type
- elb_type is defined and elb_type == "alb"
with_nested:
- "{{ lc.results }}"
- "{{ swarm_slave.instance_types }}"
-------------------------------------------------------------------------------------------------
DEBUG of ec2_tg.results|json_query('[].target_group_arn')|list
-------------------------------------------------------------------------------------------------
TASK [ec2_swarm_asg : debug var=ec2_tg.results|json_query('[].target_group_arn')|list] **************************************************************************************
ok: [localhost] => {
"ec2_tg.results|json_query('[].target_group_arn')|list": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/us-east-1-test-dockerhub-5000/d33eab83c407f491",
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-gitlab/254838bf2f0ae804",
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-wazuh/4dc176be1d023d02",
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-inbound-int/fa9fa08c0bec9a39",
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-match-int/c049bc6be9dbada2",
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-outbound-int/1534e0b5dff8d03a",
"arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-optout-int/01d98f65aab29fa3"
]
}
I have verified all of the above ARNs exist
---------------------------------------------------------------------------------------------------------
DEBUG OF EC2_TG VARIABLE:
---------------------------------------------------------------------------------------------------------
TASK [ec2_swarm_asg : debug var=ec2_tg.results] *****************************************************************************************************************************
ok: [localhost] => {
"ec2_tg.results": [
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/v2/_catalog",
"health_check_port": "5000",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/v2/_catalog",
"health_check_port": 5000,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "us-east-1-test-dockerhub-5000",
"port": 5000,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "200",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/v2/_catalog",
"alb_tg_health_check_port": 5000,
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "us-east-1-test-dockerhub-5000",
"alb_tg_port": 5000,
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 200,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-dockerhub-alb/74e58ca35f864338"
],
"matcher": {
"http_code": "200"
},
"port": 5000,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/us-east-1-test-dockerhub-5000/d33eab83c407f491",
"target_group_name": "us-east-1-test-dockerhub-5000",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
},
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/users/sign_in",
"health_check_port": "8085",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/users/sign_in",
"health_check_port": 8085,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "test-swarm-general-gitlab",
"port": 8085,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "302",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/users/sign_in",
"alb_tg_health_check_port": "8085",
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "test-swarm-general-gitlab",
"alb_tg_port": "8085",
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 302,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-dockerhub-alb/74e58ca35f864338"
],
"matcher": {
"http_code": "302"
},
"port": 8085,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-gitlab/254838bf2f0ae804",
"target_group_name": "test-swarm-general-gitlab",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
},
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/",
"health_check_port": "8086",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/",
"health_check_port": 8086,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "test-swarm-general-wazuh",
"port": 8086,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "200",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/",
"alb_tg_health_check_port": "8086",
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "test-swarm-general-wazuh",
"alb_tg_port": "8086",
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 200,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-dockerhub-alb/74e58ca35f864338"
],
"matcher": {
"http_code": "200"
},
"port": 8086,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-wazuh/4dc176be1d023d02",
"target_group_name": "test-swarm-general-wazuh",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
},
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/info",
"health_check_port": "8080",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/info",
"health_check_port": 8080,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "test-swarm-general-inbound-int",
"port": 8080,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "200",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/info",
"alb_tg_health_check_port": "8080",
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "test-swarm-general-inbound-int",
"alb_tg_port": "8080",
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 200,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-swarm-general-int/2ba6f6369ee8de37"
],
"matcher": {
"http_code": "200"
},
"port": 8080,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-inbound-int/fa9fa08c0bec9a39",
"target_group_name": "test-swarm-general-inbound-int",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
},
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/info",
"health_check_port": "8081",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/info",
"health_check_port": 8081,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "test-swarm-general-match-int",
"port": 8081,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "200",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/info",
"alb_tg_health_check_port": "8081",
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "test-swarm-general-match-int",
"alb_tg_port": "8081",
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 200,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-swarm-general-int/2ba6f6369ee8de37"
],
"matcher": {
"http_code": "200"
},
"port": 8081,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-match-int/c049bc6be9dbada2",
"target_group_name": "test-swarm-general-match-int",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
},
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/info",
"health_check_port": "8082",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/info",
"health_check_port": 8082,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "test-swarm-general-outbound-int",
"port": 8082,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "200",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/info",
"alb_tg_health_check_port": "8082",
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "test-swarm-general-outbound-int",
"alb_tg_port": "8082",
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 200,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-swarm-general-int/2ba6f6369ee8de37"
],
"matcher": {
"http_code": "200"
},
"port": 8082,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-outbound-int/1534e0b5dff8d03a",
"target_group_name": "test-swarm-general-outbound-int",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
},
{
"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"deregistration_delay_timeout_seconds": "300",
"failed": false,
"health_check_interval_seconds": 20,
"health_check_path": "/info",
"health_check_port": "8083",
"health_check_protocol": "HTTP",
"health_check_timeout_seconds": 15,
"healthy_threshold_count": 3,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_secret_key": null,
"deregistration_delay_timeout": null,
"ec2_url": null,
"health_check_interval": 20,
"health_check_path": "/info",
"health_check_port": 8083,
"health_check_protocol": "http",
"health_check_timeout": 15,
"healthy_threshold_count": 3,
"modify_targets": false,
"name": "test-swarm-general-optout-int",
"port": 8083,
"profile": null,
"protocol": "HTTP",
"purge_tags": true,
"region": "us-east-1",
"security_token": null,
"state": "present",
"stickiness_enabled": null,
"stickiness_lb_cookie_duration": null,
"stickiness_type": "lb_cookie",
"successful_response_codes": "200",
"tags": {},
"targets": null,
"unhealthy_threshold_count": 3,
"validate_certs": true,
"vpc_id": "vpc-XXXX",
"wait": null,
"wait_timeout": null
}
},
"item": {
"alb_tg_health_check_interval": 20,
"alb_tg_health_check_path": "/info",
"alb_tg_health_check_port": "8083",
"alb_tg_health_check_protocol": "http",
"alb_tg_health_check_timeout": 15,
"alb_tg_healthy_threshold_count": 3,
"alb_tg_name": "test-swarm-general-optout-int",
"alb_tg_port": "8083",
"alb_tg_protocol": "http",
"alb_tg_return_code_matcher": 200,
"alb_tg_unhealthy_threshold_count": 3
},
"load_balancer_arns": [
"arn:aws:elasticloadbalancing:us-east-1:XXXX:loadbalancer/app/us-east-1-test-swarm-general-int/2ba6f6369ee8de37"
],
"matcher": {
"http_code": "200"
},
"port": 8083,
"protocol": "HTTP",
"stickiness_enabled": "false",
"stickiness_lb_cookie_duration_seconds": "86400",
"stickiness_type": "lb_cookie",
"tags": {},
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:XXXX:targetgroup/test-swarm-general-optout-int/01d98f65aab29fa3",
"target_group_name": "test-swarm-general-optout-int",
"target_type": "instance",
"unhealthy_threshold_count": 3,
"vpc_id": "vpc-XXXX"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment