mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 23:14:02 -07:00
Manage Fortios/Fortigate Address (#21542)
* New module fortios_address * Add module_utils required_if + fix Doc * Merge spec & required_if from module_utils * Fix pep8 * Py2.5 compat , cosmetic changes * Fix param timeout * Fortios_address module + integration tests * add netaddr library in requirements for integration tests * Pep8 problems * ANSIBLE_METADATA.version -> ANSIBLE_METADATA.metadata_version
This commit is contained in:
parent
1b7ac73c85
commit
753b26ccf9
9 changed files with 6848 additions and 0 deletions
1
test/integration/targets/fortios_address/aliases
Normal file
1
test/integration/targets/fortios_address/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
posix/ci/group1
|
3134
test/integration/targets/fortios_address/files/default_config.conf
Normal file
3134
test/integration/targets/fortios_address/files/default_config.conf
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,2 @@
|
|||
pyfg>=0.50
|
||||
netaddr
|
14
test/integration/targets/fortios_address/tasks/main.yml
Normal file
14
test/integration/targets/fortios_address/tasks/main.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- name: install required libraries
|
||||
pip:
|
||||
requirements: "{{ role_path }}/files/requirements.txt"
|
||||
become: True
|
||||
|
||||
- name: copy backup config file to config file
|
||||
copy:
|
||||
src: "{{ role_path }}/files/default_config.conf.backup"
|
||||
dest: "{{ role_path }}/files/default_config.conf"
|
||||
|
||||
- { include: test_indempotency.yml }
|
||||
- { include: test_params_state_absent.yml }
|
||||
- { include: test_params_state_present.yml }
|
|
@ -0,0 +1,82 @@
|
|||
---
|
||||
- name: Add address
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: github
|
||||
value: 192.30.253.113
|
||||
state: present
|
||||
register: add_addr
|
||||
|
||||
- name: Assert
|
||||
assert:
|
||||
that:
|
||||
- "add_addr.changed == true"
|
||||
|
||||
- name: Add the same address
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: github
|
||||
value: 192.30.253.113
|
||||
state: present
|
||||
register: add_addr
|
||||
|
||||
- name: Assert
|
||||
assert:
|
||||
that:
|
||||
- "add_addr.changed == false"
|
||||
|
||||
- name: change value
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: github
|
||||
value: 192.1.2.3
|
||||
state: present
|
||||
register: change_addr
|
||||
|
||||
- name: Assert
|
||||
assert:
|
||||
that:
|
||||
- "change_addr.changed == true"
|
||||
|
||||
- name: change value second time
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: github
|
||||
value: 192.1.2.3
|
||||
state: present
|
||||
register: change_addr
|
||||
|
||||
- name: Assert
|
||||
assert:
|
||||
that:
|
||||
- "change_addr.changed == false"
|
||||
|
||||
- name: Delete existing address
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: github
|
||||
state: absent
|
||||
register: del_addr
|
||||
|
||||
- name: Assert
|
||||
assert:
|
||||
that:
|
||||
- "del_addr.changed == true"
|
||||
|
||||
- name: Delete same existing address
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: github
|
||||
state: absent
|
||||
register: del_addr
|
||||
|
||||
- name: Assert
|
||||
assert:
|
||||
that:
|
||||
- "del_addr.changed == false"
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
# Check made for absent state
|
||||
- name: missing name
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: absent
|
||||
register: missing_name
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted type fqdn
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
type: fqdn
|
||||
register: unwanted_fqdn
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted type geography
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
type: geography
|
||||
register: unwanted_geography
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted param start_ip
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
start_ip: 10.1.1.1
|
||||
register: unwanted_start_ip
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted param end_ip
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
end_ip: 10.1.1.1
|
||||
register: unwanted_end_ip
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted param country
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
country: FR
|
||||
register: unwanted_country
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted param comment
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
comment: blabla
|
||||
register: unwanted_comment
|
||||
ignore_errors: True
|
||||
|
||||
- name: not wanted param value
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
name: some name
|
||||
state: absent
|
||||
value: blabla
|
||||
register: unwanted_value
|
||||
ignore_errors: True
|
||||
|
||||
- name: Verify that all previous test have failed
|
||||
assert:
|
||||
that:
|
||||
- "missing_name.failed == True"
|
||||
- "unwanted_fqdn.failed == True"
|
||||
- "unwanted_geography.failed == True"
|
||||
- "unwanted_start_ip.failed == True"
|
||||
- "unwanted_end_ip.failed == True"
|
||||
- "unwanted_country.failed == True"
|
||||
- "unwanted_comment.failed == True"
|
||||
- "unwanted_value.failed == True"
|
|
@ -0,0 +1,86 @@
|
|||
---
|
||||
# Check made for present state
|
||||
# type ipmask
|
||||
- name: missing name
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
value: blabla
|
||||
register: missing_name
|
||||
ignore_errors: True
|
||||
|
||||
- name: missing value
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
name: blabla
|
||||
register: missing_value
|
||||
ignore_errors: True
|
||||
|
||||
- name: bad ip mask value
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
name: blabla
|
||||
value: pwet
|
||||
register: bad_ipmask
|
||||
ignore_errors: True
|
||||
|
||||
# type geography
|
||||
- name: missing country
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
name: blabla
|
||||
type: geography
|
||||
register: missing_country
|
||||
ignore_errors: True
|
||||
|
||||
- name: bad country
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
name: blabla
|
||||
type: geography
|
||||
country: FRA
|
||||
register: bad_country
|
||||
ignore_errors: True
|
||||
|
||||
# type iprange
|
||||
- name: missing start_ip
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
name: blabla
|
||||
type: iprange
|
||||
end_ip: 10.10.10.10
|
||||
register: missing_sart_ip
|
||||
ignore_errors: True
|
||||
|
||||
- name: missing end_ip
|
||||
fortios_address:
|
||||
file_mode: true
|
||||
config_file: "{{role_path}}/files/default_config.conf"
|
||||
state: present
|
||||
name: blabla
|
||||
type: iprange
|
||||
start_ip: 10.10.10.10
|
||||
register: missing_end_ip
|
||||
ignore_errors: True
|
||||
|
||||
- name: Verify that all previous test have failed
|
||||
assert:
|
||||
that:
|
||||
- "missing_name.failed == True"
|
||||
- "missing_value.failed == True"
|
||||
- "bad_ipmask.failed == True"
|
||||
- "missing_country.failed == True"
|
||||
- "bad_country.failed == True"
|
||||
- "missing_sart_ip.failed == True"
|
||||
- "missing_end_ip.failed == True"
|
Loading…
Add table
Add a link
Reference in a new issue