项目作者: maishsk

项目描述 :
AWS role to create subnets in an Existing VPC
高级语言:
项目地址: git://github.com/maishsk/aws-subnet.git
创建时间: 2019-03-07T18:12:26Z
项目社区:https://github.com/maishsk/aws-subnet

开源协议:BSD 2-Clause "Simplified" License

下载


aws-subnet

Will create a subnet(s) in an existing VPC

Requirements

  • AWS credentials and the correct permissions to create the resources
  • An existing VPC with a tagged Name
  • List of subnets and their location is defined in teh subnets variable (see example below)

Role Variables

The variables uses in this role are

Variable Name Required Description
region Yes The region that you will deploy into
vpc_name Yes Used for identification of VPC
subnets Yes List of subnets for deployment
wait_timeout Optional Period of time to wait for timeout
- Default 300
wait Optional Wait for subnet to become available
- Default yes
map_public Optional Assign public IP addresses by default to instances
- Default no

Dependencies

None

Example Playbook

Download dependencies

Create requirements file

Create a requirements.yml file with the following contents

  1. - src: https://github.com/maishsk/aws-subnet
  2. version: master

Download dependencies

Run the following command:

  1. ansible-galaxy install -r requirements.yml --force -p .

Create playbook

Create a main.yaml file with the following contents:

  1. ---
  2. - name: Create Subnets
  3. hosts: localhost
  4. connection: local
  5. gather_facts: false
  6. vars_files:
  7. - vars/vars.yml
  8. tasks:
  9. - name: Create Process
  10. include_role:
  11. name: "{{ item }}"
  12. with_items:
  13. - aws-subnet
  14. tags: [ 'never', 'create' ]
  15. - name: Rollback Process
  16. include_role:
  17. name: "{{ item }}"
  18. with_items:
  19. - aws-subnet
  20. tags: [ 'never', 'rollback' ]

Create a vars/vars.yml with the content similar to:

  1. vpc_name: maish_test
  2. region: us-east-2
  3. subnets:
  4. - subnet_name: "{{ vpc_name | default (omit) }}-Public-{{ region }}a"
  5. subnet_cidr: 192.168.100.0/26
  6. subnet_az: "{{ region }}a"
  7. subnet_map_public: yes
  8. - subnet_name: "{{ vpc_name | default (omit) }}-Public-{{ region }}b"
  9. subnet_cidr: 192.168.100.64/26
  10. subnet_az: "{{ region }}b"
  11. subnet_map_public: yes
  12. - subnet_name: "{{ vpc_name | default (omit) }}-Private-{{ region }}a"
  13. subnet_cidr: 192.168.100.128/26
  14. subnet_az: "{{ region }}a"
  15. - subnet_name: "{{ vpc_name | default (omit) }}-Private-{{ region }}b"
  16. subnet_cidr: 192.168.100.192/26
  17. subnet_az: "{{ region }}b"

Running the playbook

To create the VPC

ansible-playbook main.yml --tags create

To remove the VPC

ansible-playbook main.yml --tags rollback

License

BSD

Author Information

This role was created by Maish Saidel-Keesing, author of The Cloud Walkabout.