我尝试使用boto.vpc验证亚马逊VPC的内容。但它没有验证子网的内容,而是试图创建它。我在init.sls文件中提供了现有子网的详细信息:
Ensure VPC exists:
boto_vpc.present:
- name: dlab
- cidr_block: 10.xx.xx.0/24
- dns_hostnames: True
- region: us-east-1
- keyid: keyid
- key: key
Ensure subnet exists:
boto_vpc.subnet_present:
- name: dlab
- vpc_id: vpc-xxxxxxx
- cidr_block: 10.xx.xx.0/24
- region: us-east-1
- keyid: keyid
- key: key
当我运行命令时,这是我得到的结果:
[root@salt get_vpc]# salt '*' state.apply
salt.localdomain:
----------
ID: Ensure VPC exists
Function: boto_vpc.present
Name: dlab
Result: True
Comment: VPC present.
Started: 14:36:19.166569
Duration: 312.981 ms
Changes:
----------
ID: Ensure subnet exists
Function: boto_vpc.subnet_present
Name: dlab
Result: False
Comment: Failed to create subnet: Bad Request: The CIDR '10.60.58.0/24' conflicts with another subnet
Started: 14:36:19.479896
Duration: 355.565 ms
Changes:
Summary for salt.localdomain
------------
Succeeded: 1
Failed: 1
------------
Total states run: 2
Total run time: 668.546 ms
ERROR: Minions returned with non-zero exit code
验证了VPC。但盐试图建立一个新的子网,而不是告诉我那个已经存在的子网。在确保子网下的顶部文件中指定的子网名称是对的!
为什么会这样?如何获取salt来验证子网而不是尝试创建它?
答案 0 :(得分:0)
我建议使用此解决方案,我尚未对其进行测试,但如果您拥有subnet_id
,那么您可以使用它
Ensure subnet exists:
module.run:
- name: boto_vpc.subnet_exists
- subnet_id: subnet-foo-id
此模块将检查子网是否存在。如果子网存在,则返回True,否则返回False。根据{{3}}