- name: Web Security group
ec2_group:
name: "{{ vpc_name }}-web-db-sg"
state: present
description: Security group for RDS servers in the VPC
vpc_id: "{{vpc_id}}"
region: "{{ aws_region }}"
rules:
- proto: tcp
group_id: "{{ item }}"
ports:
- 5432
- 3306
- 1433
with_items: "{{public_sg_ids}}"
register: web_sg这是我试图运行的代码片段,但无法运行。我的目标是为AWS安全组创建三个规则,其中public_sg_ids是三个公共安全组'sg-03198a28b7edf1f0e','sg-038b16577691b2d2f','sg-047fe11a7290946b5‘的安全组is列表。错误是
The task includes an option with an undefined variable. The error was: 'item' is undefined发布于 2019-09-19 19:06:00
检查您的缩进:
- name: Web Security group
ec2_group:
name: "{{ vpc_name }}-web-db-sg"
state: present
description: Security group for RDS servers in the VPC
vpc_id: "{{vpc_id}}"
region: "{{ aws_region }}"
rules:
- proto: tcp
group_id: "{{ item }}"
ports:
- 5432
- 3306
- 1433
with_items: "{{public_sg_ids}}"
register: web_sg有关Loops的更多示例,请参阅Documentation
发布于 2019-09-20 02:08:49
我会使用“loop”而不是“with_items”
https://stackoverflow.com/questions/58009232
复制相似问题