feat: dynamic security group (#46571)

pull/47402/head
abarbare 6 years ago committed by John R Barker
parent 06d23019e7
commit 6d6245db0f

@ -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 - name: Create a scaleway security_group
debug: scaleway_security_group:
msg: "SCW_SG env variable is required" state: present
failed_when: security_group == "" 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 - name: Create security_group_rule check
check_mode: true check_mode: true
@ -19,7 +26,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task - debug: var=security_group_rule_creation_task
@ -39,7 +46,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task - debug: var=security_group_rule_creation_task
@ -58,7 +65,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task - debug: var=security_group_rule_creation_task
@ -78,7 +85,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task - debug: var=security_group_rule_deletion_task
@ -98,7 +105,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task - debug: var=security_group_rule_deletion_task
@ -117,7 +124,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task - debug: var=security_group_rule_deletion_task
@ -137,7 +144,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task - debug: var=security_group_rule_creation_task
@ -156,7 +163,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_creation_task register: security_group_rule_creation_task
- debug: var=security_group_rule_creation_task - debug: var=security_group_rule_creation_task
@ -176,7 +183,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task - debug: var=security_group_rule_deletion_task
@ -196,7 +203,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task - debug: var=security_group_rule_deletion_task
@ -215,7 +222,7 @@
ip_range: '{{ ip_range }}' ip_range: '{{ ip_range }}'
direction: '{{ direction }}' direction: '{{ direction }}'
action: '{{ action }}' action: '{{ action }}'
security_group: '{{ security_group }}' security_group: '{{ security_group.scaleway_security_group.id }}'
register: security_group_rule_deletion_task register: security_group_rule_deletion_task
- debug: var=security_group_rule_deletion_task - debug: var=security_group_rule_deletion_task
@ -224,3 +231,15 @@
that: that:
- security_group_rule_deletion_task is success - security_group_rule_deletion_task is success
- security_group_rule_deletion_task is not changed - 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
Loading…
Cancel
Save