amazon-web-services - ansible ec2_group 模块无法创建新的安全组

标签 amazon-web-services amazon-ec2 cloud ec2-api-tools ansible

我最近开始学习 ansible,所以这听起来像是一个菜鸟问题。我写了一个简单的剧本 (example.yml),它将使用 ansible 的 ec2_group 模块在 AWS ec2 中创建一个安全组。

剧本是——

---
- name: Add a security group to ec2
  hosts: local
  connection: local
  tasks:
    local_action:
      module: ec2_group
      name: TestSecurityGroup001
      description: A new ec2 security group via ansible playbook
      region: us-east-1
      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: 10.0.0.0/8

        - proto: udp
          from_port: 10050
          to_port: 10050
          cidr_ip: 10.0.0.0/8

        - proto: udp
          from_port: 10051
          to_port: 10051
          group_id: abc123

当我这样做

$ ansible-playbook example.yml

PLAY [Add a security group to ec2] ******************************************** 

GATHERING FACTS *************************************************************** 
ok: [localhost]

PLAY RECAP ******************************************************************** 
localhost                  : ok=1    changed=0    unreachable=0    failed=0   

现在当我列出安全组时

$ aws ec2 describe-security-groups --region=us-east-1 --group-name=TestSecurityGroup001
$ A client error (InvalidGroup.NotFound) occurred: The security group 'TestSecurityGroup001' does not exist

谁能告诉我应该怎么做才能解决这个问题。

最佳答案

我认为您的剧本中缺少 - ,ansible 期望任务是一个列表。试试这个:

 tasks:
    - local_action:

代替:

 tasks:
    local_action:

关于amazon-web-services - ansible ec2_group 模块无法创建新的安全组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18783846/

相关文章:

amazon-web-services - 如何让自己免于 AWS 费用?

amazon-web-services - ElasticBeanstalk "eb ssh"引发错误 : "Host key verification failed."

mysql - 如何将 Rstudio 连接到 mysql 数据库的 AWS 实例?

mysql - AWS Aurora 与 MySQL 的兼容性

amazon-web-services - Elastic Beanstalk : Application directory/script location on the EC2 Server

java - 使用 Play 框架的 EC2 连接到 RDS

python - 在 AWS Elastic Beanstalk 上部署 Python

cloud - 哪个开源云管理平台支持 Amazon-RDS?

php - mysql版本5.5.31加载数据infile语法错误

linux - 使用 gdrive 从 google drive 按名称删除文件夹