- Ansible 2 Cloud Automation Cookbook
- Aditya Patawari Vikas Aggarwal
- 109字
- 2021-06-24 18:43:37
How to do it...
We can create a security group, using an ec2_group module, this will take the VPC ID, the region, and rules as input.
Let's create a task for a security group:
---
- name: Create EC2 Security Group
ec2_group:
name: my_first_sg
description: A sample security group webservers
vpc_id: "{{ my_first_vpc.vpc.id }}"
region: "{{ aws_region }}"
aws_secret_key: "{{ secret_key }}"
aws_access_key: "{{ access_key }}"
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: "{{ vpc_cidr_block }}"
- proto: tcp
from_port: 443
to_port: 443
cidr_ip: 0.0.0.0/0
- proto: icmp
from_port: 8
to_port: -1
cidr_ip: "{{ vpc_cidr_block }}"
rules_egress:
- proto: all
cidr_ip: 0.0.0.0/0
register: my_first_sg
推薦閱讀
- Dreamweaver CS3+Flash CS3+Fireworks CS3創(chuàng)意網站構建實例詳解
- 大數據項目管理:從規(guī)劃到實現
- Mastering Spark for Data Science
- 精通MATLAB神經網絡
- 精通Windows Vista必讀
- Visual C# 2008開發(fā)技術實例詳解
- 群體智能與數據挖掘
- 機器學習流水線實戰(zhàn)
- 中國戰(zhàn)略性新興產業(yè)研究與發(fā)展·智能制造
- Apache源代碼全景分析(第1卷):體系結構與核心模塊
- INSTANT Adobe Story Starter
- Web編程基礎
- 傳感器原理及實用技術
- 巧學活用Linux
- Qt中的C++技術