mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-30 07:50:43 +00:00
feat: add scaleway security_group_rule management (#45694)
* feat: add scaleway security_group_rule management
This commit is contained in:
parent
83e584577a
commit
c5d5d08b6b
5 changed files with 500 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
scaleway_organization: '{{ scw_org }}'
|
||||
scaleway_region: par1
|
||||
protocol: "TCP"
|
||||
port: 80
|
||||
ip_range: "0.0.0.0/0"
|
||||
direction: "inbound"
|
||||
action: "accept"
|
||||
226
test/legacy/roles/scaleway_security_group_rule/tasks/main.yml
Normal file
226
test/legacy/roles/scaleway_security_group_rule/tasks/main.yml
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
# SCW_API_KEY='XXX' SCW_SG='GGG' 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 security_group_rule check
|
||||
check_mode: true
|
||||
scaleway_security_group_rule:
|
||||
state: present
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: '{{ port }}'
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_creation_task
|
||||
|
||||
- debug: var=security_group_rule_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_creation_task is success
|
||||
- security_group_rule_creation_task is changed
|
||||
|
||||
- block:
|
||||
- name: Create security_group_rule check
|
||||
scaleway_security_group_rule:
|
||||
state: present
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: '{{ port }}'
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_creation_task
|
||||
|
||||
- debug: var=security_group_rule_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_creation_task is success
|
||||
- security_group_rule_creation_task is changed
|
||||
|
||||
- name: Create security_group_rule duplicate
|
||||
scaleway_security_group_rule:
|
||||
state: present
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: '{{ port }}'
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_creation_task
|
||||
|
||||
- debug: var=security_group_rule_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_creation_task is success
|
||||
- security_group_rule_creation_task is not changed
|
||||
|
||||
- name: Delete security_group_rule check
|
||||
check_mode: true
|
||||
scaleway_security_group_rule:
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: '{{ port }}'
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_deletion_task
|
||||
|
||||
- debug: var=security_group_rule_deletion_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_deletion_task is success
|
||||
- security_group_rule_deletion_task is changed
|
||||
|
||||
always:
|
||||
- name: Delete security_group_rule check
|
||||
scaleway_security_group_rule:
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: '{{ port }}'
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_deletion_task
|
||||
|
||||
- debug: var=security_group_rule_deletion_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_deletion_task is success
|
||||
- security_group_rule_deletion_task is changed
|
||||
|
||||
- name: Delete security_group_rule check
|
||||
scaleway_security_group_rule:
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: '{{ port }}'
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_deletion_task
|
||||
|
||||
- debug: var=security_group_rule_deletion_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_deletion_task is success
|
||||
- security_group_rule_deletion_task is not changed
|
||||
|
||||
- block:
|
||||
- name: Create security_group_rule with null check
|
||||
scaleway_security_group_rule:
|
||||
state: present
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: null
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_creation_task
|
||||
|
||||
- debug: var=security_group_rule_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_creation_task is success
|
||||
- security_group_rule_creation_task is changed
|
||||
|
||||
- name: Create security_group_rule with null duplicate
|
||||
scaleway_security_group_rule:
|
||||
state: present
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: null
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_creation_task
|
||||
|
||||
- debug: var=security_group_rule_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_creation_task is success
|
||||
- security_group_rule_creation_task is not changed
|
||||
|
||||
- name: Delete security_group_rule with null check
|
||||
check_mode: true
|
||||
scaleway_security_group_rule:
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: null
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_deletion_task
|
||||
|
||||
- debug: var=security_group_rule_deletion_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_deletion_task is success
|
||||
- security_group_rule_deletion_task is changed
|
||||
|
||||
always:
|
||||
- name: Delete security_group_rule with null check
|
||||
scaleway_security_group_rule:
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: null
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_deletion_task
|
||||
|
||||
- debug: var=security_group_rule_deletion_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_deletion_task is success
|
||||
- security_group_rule_deletion_task is changed
|
||||
|
||||
- name: Delete security_group_rule with null check
|
||||
scaleway_security_group_rule:
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
protocol: '{{ protocol }}'
|
||||
port: null
|
||||
ip_range: '{{ ip_range }}'
|
||||
direction: '{{ direction }}'
|
||||
action: '{{ action }}'
|
||||
security_group: '{{ security_group }}'
|
||||
register: security_group_rule_deletion_task
|
||||
|
||||
- debug: var=security_group_rule_deletion_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- security_group_rule_deletion_task is success
|
||||
- security_group_rule_deletion_task is not changed
|
||||
|
|
@ -19,3 +19,4 @@
|
|||
- { role: scaleway_volume, tags: test_scaleway_volume }
|
||||
- { role: scaleway_volume_facts, tags: test_scaleway_volume_facts }
|
||||
- { role: scaleway_security_group, tags: test_scaleway_security_group }
|
||||
- { role: scaleway_security_group_rule, tags: test_scaleway_security_group_rule }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue