1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

feat: dynamic security group (#46571)

This commit is contained in:
abarbare 2018-10-21 17:05:30 +02:00 committed by John R Barker
parent 06d23019e7
commit 6d6245db0f

View file

@ -1,13 +1,20 @@
# SCW_API_KEY='XXX' SCW_SG='GGG' ansible-playbook ./test/legacy/scaleway.yml --tags test_scaleway_security_group_rule
# SCW_API_KEY='XXX' ansible-playbook ./test/legacy/scaleway.yml --tags test_scaleway_security_group_rule
- name: Set security group fact
set_fact:
security_group: "{{ lookup('env','SCW_SG') }}"
- name: Check if SCW_SG is defined
debug:
msg: "SCW_SG env variable is required"
failed_when: security_group == ""
- name: Create a scaleway security_group
scaleway_security_group:
state: present
region: '{{ scaleway_region }}'
name: test_compute
description: test_compute
organization: '{{ scaleway_organization }}'
stateful: true
inbound_default_policy: accept
outbound_default_policy: accept
organization_default: false
register: security_group
- debug: var=security_group
- name: Create security_group_rule check
check_mode: true
@ -19,7 +26,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task
@ -39,7 +46,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task
@ -58,7 +65,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task
@ -78,7 +85,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task
@ -98,7 +105,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task
@ -117,7 +124,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task
@ -137,7 +144,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task
@ -156,7 +163,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task
@ -176,7 +183,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task
@ -196,7 +203,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task
@ -215,7 +222,7 @@
ip_range: '{{ ip_range }}'
direction: '{{ direction }}'
action: '{{ action }}'
security_group: '{{ security_group }}'
security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task
@ -224,3 +231,15 @@
that:
- security_group_rule_deletion_task is success
- security_group_rule_deletion_task is not changed
- name: Delete scaleway security_group
scaleway_security_group:
state: absent
region: '{{ scaleway_region }}'
name: test_compute
description: test_compute
organization: '{{ scaleway_organization }}'
stateful: true
inbound_default_policy: accept
outbound_default_policy: accept
organization_default: false