Skip to content

Commit

Permalink
Fix sg_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
GomathiselviS committed Dec 2, 2024
1 parent 7b9b729 commit 00507da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,13 @@
hosts: localhost
gather_facts: false
tasks:
- name: Create a list of dictionaries for security group rules
- name: Get list of internal sg rules
ansible.builtin.set_fact:
sg_internal_rules: >-
{{
[
{
'proto': security_group_1_proto,
'ports': security_group_1_port,
'cidr_ip': security_group_1_cidr
},
{
'proto': security_group_2_proto,
'ports': security_group_2_port,
'cidr_ip': security_group_2_cidr
},
{
'proto': security_group_3_proto,
'ports': security_group_3_port,
'cidr_ip': security_group_3_cidr
}
] | selectattr('proto', 'defined') | selectattr('ports', 'defined') | selectattr('cidr_ip', 'defined') | list
}}
sg_rules: "{{ security_group_rules | split(';') | list }}"

- name: Set default value for the security group rules if nothing is passed.
ansible.builtin.set_fact:
sg_internal_rules: "{{ sg_internal_rules | default([
sg_internal_rules: "{{ sg_rules | default([
{'proto': 'tcp', 'port': '22', 'cidr_ip': vpc_cidr}
]) }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ spec:
required: true

- type: "text"
question_name: "Internal Security Group rule 1 protocol"
question_description: "The IP protocol name. If not provided, ssh will be used"
variable: "security_group_1_proto"
question_name: "Dict of Internal Security Group rules, seperated by semi colon"
question_description: 'Dictionaries of Security Group Rules. e.g. {"proto": "tcp", "ports": "22", "cidr_ip": "10.1.1.0/16"}; {"proto": "tcp", "ports": "8000-8010", "cidr_ip": "10.1.1.0/16"}'
variable: "security_group_rules"
required: false

- type: "text"
Expand Down

0 comments on commit 00507da

Please sign in to comment.