Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ok: [localhost] => {
- "changed": false,
- "failed": false,
- "invocation": {
- "module_args": {
- "aws_access_key": null,
- "aws_secret_key": null,
- "ec2_url": null,
- "filters": {
- "vpc-id": "vpc-841054ff"
- },
- "profile": null,
- "region": "us-east-1",
- "security_token": null,
- "validate_certs": true
- }
- },
- "subnets": [
- {
- "availability_zone": "us-east-1b",
- "available_ip_address_count": 59,
- "cidr_block": "10.0.19.192/26",
- "default_for_az": "false",
- "id": "subnet-db100986",
- "map_public_ip_on_launch": "false",
- "state": "available",
- "tags": {
- "Name": "abc-east-private-2",
- "business_unit": "ESP",
- "created_by": "xxx",
- "customer": "abc",
- "product": "SMC"
- },
- "vpc_id": "vpc-841054ff"
- },
- {
- "availability_zone": "us-east-1b",
- "available_ip_address_count": 58,
- "cidr_block": "10.0.19.64/26",
- "default_for_az": "false",
- "id": "subnet-01657c5c",
- "map_public_ip_on_launch": "true",
- "state": "available",
- "tags": {
- "Name": "abc-east-public-2",
- "business_unit": "ESP",
- "created_by": "xxx",
- "customer": "abc",
- "product": "SMC"
- },
- "vpc_id": "vpc-841054ff"
- },
- {
- "availability_zone": "us-east-1a",
- "available_ip_address_count": 58,
- "cidr_block": "10.0.19.0/26",
- "default_for_az": "false",
- "id": "subnet-fcf65bb6",
- "map_public_ip_on_launch": "true",
- "state": "available",
- "tags": {
- "Name": "abc-east-public-1",
- "business_unit": "ESP",
- "created_by": "xxx",
- "customer": "abc",
- "product": "SMC"
- },
- "vpc_id": "vpc-841054ff"
- },
- {
- "availability_zone": "us-east-1a",
- "available_ip_address_count": 59,
- "cidr_block": "10.0.19.128/26",
- "default_for_az": "false",
- "id": "subnet-9dc16cd7",
- "map_public_ip_on_launch": "false",
- "state": "available",
- "tags": {
- "Name": "abc-east-private-1",
- "business_unit": "ESP",
- "created_by": "xxx",
- "customer": "abc",
- "product": "SMC"
- },
- "vpc_id": "vpc-841054ff"
- }
- ]
- }
- I'm trying to make:
- {
- "abc-east-private-2": "subnet-db100986",
- "abc-east-public-2": "subnet-01657c5c",
- "abc-east-private-1": "subnet-9dc16cd7",
- "abc-east-public-1": "subnet-fcf65bb6",
- }
- right now I do:
- - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Gathering VPC Subnet facts."
- ec2_vpc_subnet_facts:
- region: "{{ aws_vpc_map[_aws_vpc_name] }}"
- filters:
- vpc-id: "{{ _aws_vpc['id'] }}"
- register: _aws_subnet_facts
- - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Initializing _aws_subnets."
- set_fact:
- _aws_subnets: "{{ _aws_subnet_facts['subnets'] }}"
- - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Initializing _aws_subnets_map."
- set_fact:
- _aws_subnets_map: {}
- - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Constructing _aws_subnets_map."
- set_fact:
- _aws_subnets_map: "{{ { subnet['tags']['Name']: subnet['id'] } |combine(_aws_subnets_map) }}"
- with_items: "{{ _aws_subnets }}"
- loop_control:
- loop_var: subnet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement