mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-03-26 21:43:02 +00:00
Refactored security_group_rule{,_info} modules
Change-Id: Ie953bee843a43b945d24d6152766b3ae418f797c
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
---
|
||||
- name: Create security group
|
||||
openstack.cloud.security_group:
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_security_group
|
||||
state: present
|
||||
description: Created from Ansible playbook
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_security_group
|
||||
state: present
|
||||
|
||||
- name: Create empty ICMP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert return values of security_group_rule module
|
||||
@@ -23,11 +22,11 @@
|
||||
|
||||
- name: Assert changed
|
||||
assert:
|
||||
that: security_group_rule is changed
|
||||
that: security_group_rule is changed
|
||||
|
||||
- name: Fetch all security group rule
|
||||
openstack.cloud.security_group_rule_info:
|
||||
cloud: "{{ cloud }}"
|
||||
cloud: "{{ cloud }}"
|
||||
register: security_group_rules
|
||||
|
||||
- name: Assert return values of security_group_rule_info module
|
||||
@@ -39,8 +38,8 @@
|
||||
|
||||
- name: Fetch security group rule based on rule
|
||||
openstack.cloud.security_group_rule_info:
|
||||
cloud: "{{ cloud }}"
|
||||
id: "{{ security_group_rule.rule.id }}"
|
||||
cloud: "{{ cloud }}"
|
||||
id: "{{ security_group_rule.rule.id }}"
|
||||
register: security_group_rules
|
||||
|
||||
- name: Assert return fields security_group_rule_info
|
||||
@@ -49,157 +48,157 @@
|
||||
|
||||
- name: Create empty ICMP rule again
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert not changed
|
||||
assert:
|
||||
that: security_group_rule is not changed
|
||||
that: security_group_rule is not changed
|
||||
|
||||
- name: Create -1 ICMP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert not changed
|
||||
assert:
|
||||
that: security_group_rule is not changed
|
||||
that: security_group_rule is not changed
|
||||
|
||||
- name: Create -1 ICMP rule again
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: icmp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert not changed
|
||||
assert:
|
||||
that: security_group_rule is not changed
|
||||
that: security_group_rule is not changed
|
||||
|
||||
- name: Create empty TCP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert changed
|
||||
assert:
|
||||
that: security_group_rule is changed
|
||||
that: security_group_rule is changed
|
||||
|
||||
- name: Create TCP rule again with port range (1, 65535)
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 1
|
||||
port_range_max: 65535
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 1
|
||||
port_range_max: 65535
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert changed
|
||||
assert:
|
||||
that: security_group_rule is not changed
|
||||
that: security_group_rule is not changed
|
||||
|
||||
- name: Create TCP rule again with port range (-1, -1)
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert changed
|
||||
assert:
|
||||
that: security_group_rule is not changed
|
||||
that: security_group_rule is not changed
|
||||
|
||||
- name: Create TCP rule again with defined range
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 8000
|
||||
port_range_max: 9000
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 8000
|
||||
port_range_max: 9000
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
register: security_group_rule
|
||||
|
||||
- name: Assert changed
|
||||
assert:
|
||||
that: security_group_rule is changed
|
||||
that: security_group_rule is changed
|
||||
|
||||
- name: Create empty UDP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: udp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: udp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Create UDP rule again with port range (1, 65535)
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: udp
|
||||
port_range_min: 1
|
||||
port_range_max: 65535
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: udp
|
||||
port_range_min: 1
|
||||
port_range_max: 65535
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Create UDP rule again with port range (-1, -1)
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: udp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: udp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Create HTTP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 80
|
||||
port_range_max: 80
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 80
|
||||
port_range_max: 80
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Create egress rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 30000
|
||||
port_range_max: 30001
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
direction: egress
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: present
|
||||
protocol: tcp
|
||||
port_range_min: 30000
|
||||
port_range_max: 30001
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
direction: egress
|
||||
|
||||
- name: List all available rules of all security groups in a project
|
||||
openstack.cloud.security_group_rule_info:
|
||||
cloud: "{{ cloud }}"
|
||||
cloud: "{{ cloud }}"
|
||||
register: security_group_rules
|
||||
|
||||
- name: Check - List all available rules of all security groups in a project
|
||||
@@ -209,8 +208,8 @@
|
||||
|
||||
- name: List all available rules of a specific security group
|
||||
openstack.cloud.security_group_rule_info:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
register: security_group_rules
|
||||
|
||||
- name: Check - List all available rules of a specific security group
|
||||
@@ -220,70 +219,80 @@
|
||||
|
||||
- name: List all available rules with filters
|
||||
openstack.cloud.security_group_rule_info:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
protocol: tcp
|
||||
port_range_min: 80
|
||||
port_range_max: 80
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete empty ICMP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: icmp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete -1 ICMP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: icmp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete empty TCP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete empty UDP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: udp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete HTTP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
port_range_min: 80
|
||||
port_range_max: 80
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
protocol: tcp
|
||||
port_range_min: 80
|
||||
port_range_max: 80
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete egress rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
port_range_min: 30000
|
||||
port_range_max: 30001
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
direction: egress
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
port_range_min: 30000
|
||||
port_range_max: 30001
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
direction: egress
|
||||
|
||||
- name: Delete HTTP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
port_range_min: 80
|
||||
port_range_max: 80
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete empty UDP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: udp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete TCP rule again with defined range
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
port_range_min: 8000
|
||||
port_range_max: 9000
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete empty TCP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: tcp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete -1 ICMP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: icmp
|
||||
port_range_min: -1
|
||||
port_range_max: -1
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete empty ICMP rule
|
||||
openstack.cloud.security_group_rule:
|
||||
cloud: "{{ cloud }}"
|
||||
security_group: ansible_security_group
|
||||
state: absent
|
||||
protocol: icmp
|
||||
remote_ip_prefix: 0.0.0.0/0
|
||||
|
||||
- name: Delete security group
|
||||
openstack.cloud.security_group:
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_security_group
|
||||
state: absent
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_security_group
|
||||
state: absent
|
||||
|
||||
Reference in New Issue
Block a user