Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. ok: [localhost] => {
  2. "changed": false,
  3. "failed": false,
  4. "invocation": {
  5. "module_args": {
  6. "aws_access_key": null,
  7. "aws_secret_key": null,
  8. "ec2_url": null,
  9. "filters": {
  10. "vpc-id": "vpc-841054ff"
  11. },
  12. "profile": null,
  13. "region": "us-east-1",
  14. "security_token": null,
  15. "validate_certs": true
  16. }
  17. },
  18. "subnets": [
  19. {
  20. "availability_zone": "us-east-1b",
  21. "available_ip_address_count": 59,
  22. "cidr_block": "10.0.19.192/26",
  23. "default_for_az": "false",
  24. "id": "subnet-db100986",
  25. "map_public_ip_on_launch": "false",
  26. "state": "available",
  27. "tags": {
  28. "Name": "abc-east-private-2",
  29. "business_unit": "ESP",
  30. "created_by": "xxx",
  31. "customer": "abc",
  32. "product": "SMC"
  33. },
  34. "vpc_id": "vpc-841054ff"
  35. },
  36. {
  37. "availability_zone": "us-east-1b",
  38. "available_ip_address_count": 58,
  39. "cidr_block": "10.0.19.64/26",
  40. "default_for_az": "false",
  41. "id": "subnet-01657c5c",
  42. "map_public_ip_on_launch": "true",
  43. "state": "available",
  44. "tags": {
  45. "Name": "abc-east-public-2",
  46. "business_unit": "ESP",
  47. "created_by": "xxx",
  48. "customer": "abc",
  49. "product": "SMC"
  50. },
  51. "vpc_id": "vpc-841054ff"
  52. },
  53. {
  54. "availability_zone": "us-east-1a",
  55. "available_ip_address_count": 58,
  56. "cidr_block": "10.0.19.0/26",
  57. "default_for_az": "false",
  58. "id": "subnet-fcf65bb6",
  59. "map_public_ip_on_launch": "true",
  60. "state": "available",
  61. "tags": {
  62. "Name": "abc-east-public-1",
  63. "business_unit": "ESP",
  64. "created_by": "xxx",
  65. "customer": "abc",
  66. "product": "SMC"
  67. },
  68. "vpc_id": "vpc-841054ff"
  69. },
  70. {
  71. "availability_zone": "us-east-1a",
  72. "available_ip_address_count": 59,
  73. "cidr_block": "10.0.19.128/26",
  74. "default_for_az": "false",
  75. "id": "subnet-9dc16cd7",
  76. "map_public_ip_on_launch": "false",
  77. "state": "available",
  78. "tags": {
  79. "Name": "abc-east-private-1",
  80. "business_unit": "ESP",
  81. "created_by": "xxx",
  82. "customer": "abc",
  83. "product": "SMC"
  84. },
  85. "vpc_id": "vpc-841054ff"
  86. }
  87. ]
  88. }
  89.  
  90.  
  91. I'm trying to make:
  92.  
  93. {
  94. "abc-east-private-2": "subnet-db100986",
  95. "abc-east-public-2": "subnet-01657c5c",
  96. "abc-east-private-1": "subnet-9dc16cd7",
  97. "abc-east-public-1": "subnet-fcf65bb6",
  98.  
  99. }
  100.  
  101. right now I do:
  102.  
  103. - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Gathering VPC Subnet facts."
  104. ec2_vpc_subnet_facts:
  105. region: "{{ aws_vpc_map[_aws_vpc_name] }}"
  106. filters:
  107. vpc-id: "{{ _aws_vpc['id'] }}"
  108. register: _aws_subnet_facts
  109.  
  110. - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Initializing _aws_subnets."
  111. set_fact:
  112. _aws_subnets: "{{ _aws_subnet_facts['subnets'] }}"
  113.  
  114. - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Initializing _aws_subnets_map."
  115. set_fact:
  116. _aws_subnets_map: {}
  117.  
  118. - name: "[{{ _aws_role_config.role }}::{{ _aws_vpc_name }}] Constructing _aws_subnets_map."
  119. set_fact:
  120. _aws_subnets_map: "{{ { subnet['tags']['Name']: subnet['id'] } |combine(_aws_subnets_map) }}"
  121. with_items: "{{ _aws_subnets }}"
  122. loop_control:
  123. loop_var: subnet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement