Created
August 14, 2017 09:23
-
-
Save nitanka/a660532fb27207316fb8de95fdf1f1e8 to your computer and use it in GitHub Desktop.
Ansible: Creating Internate Gateway
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: To set up internet gateway | |
hosts: all | |
tasks: | |
- name: creating vpc | |
ec2_vpc: | |
region: ap-northeast-1 | |
state: present | |
cidr_block: 20.0.0.0/16 | |
resource_tags: { "Name":"Test" } | |
register: vpc | |
- name: Creating internet gateway for the vpc created | |
ec2_vpc_igw: | |
region: ap-northeast-1 | |
state: present | |
vpc_id: "{{ vpc.vpc_id }}" | |
register: igw | |
- name: print gateway id | |
command: /bin/echo {{igw.gateway_id}} | |
- name: print vpc id | |
command: /bin/echo {{vpc.vpc_id}} | |
#resource_tags: { "Name":"vpc-6c31ac09-gateway" } | |
- name: Tagging the gateway we just created | |
ec2_tag: | |
resource: "{{ igw.gateway_id }}" | |
#with_items: igw.gateway_id | |
state: present | |
region: ap-northeast-1 | |
tags: | |
Name: test-test | |
- name: Creating route table | |
ec2_vpc_route_table: | |
region: ap-northeast-1 | |
propagating_vgw_ids: yes | |
vpc_id: "{{ vpc.vpc_id }}" | |
subnets: | |
- '20.0.0.0/16' | |
routes: | |
- dest: 0.0.0.0/0 | |
gateway_id: "{{ igw.gateway_id }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment