generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version of the system_settings_logging module (#61)
* initial version of the system_settings_logging module --------- Co-authored-by: KiLLuuuhh <[email protected]>
- Loading branch information
Showing
7 changed files
with
368 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
- name: converge | ||
hosts: all | ||
become: true | ||
tasks: | ||
|
||
- name: Converge - Get OPNsense version | ||
ansible.builtin.command: opnsense-version -O | ||
register: opnsense_version_cmd | ||
|
||
- name: Converge - Set OPNsense version fact | ||
ansible.builtin.set_fact: | ||
opnsense_version: "{{ opnsense_version_cmd.stdout | from_json }}" | ||
|
||
- name: Converge - Set preserve logs | ||
puzzle.opnsense.system_settings_logging: | ||
preserve_logs: 11 | ||
|
||
- name: Converge - Set max log file size on supported opnsense versions | ||
puzzle.opnsense.system_settings_logging: | ||
max_log_file_size_mb: 15 | ||
when: opnsense_version["product_version"] is version('24.1', '>=') | ||
|
||
- name: Converge - Set max log file size on unsupported opnsense versions | ||
puzzle.opnsense.system_settings_logging: | ||
max_log_file_size_mb: 15 | ||
when: opnsense_version["product_version"] is version('24.1', '<') | ||
register: test_unsupported_max_log_file_size_mb | ||
ignore_errors: yes | ||
|
||
- name: Verify that setting max_log_file_size_mb failed to to unsupported OPNsense version | ||
ansible.builtin.assert: | ||
that: | ||
- test_unsupported_max_log_file_size_mb is failed | ||
fail_msg: "Setting max_log_file_size_mb should fail on unsupported OPNsense versions" | ||
success_msg: "Setting max_log_file_size_mb failed as expected due to unsupported OPNsense version" | ||
when: opnsense_version["product_version"] is version('24.1', '<') | ||
|
||
# we have no alternative way to compare the values | ||
# other than getting them from the config | ||
# see https://github.com/opnsense/core/blob/24.1/src/opnsense/scripts/syslog/log_archive#L36 | ||
- name: Get current config | ||
ansible.builtin.slurp: | ||
src: /conf/config.xml | ||
register: current_config | ||
|
||
- name: Compare preserve logs | ||
ansible.builtin.assert: | ||
that: "'<preservelogs>11</preservelogs>' in ( current_config.content | b64decode )" | ||
|
||
- name: Compare max log file size | ||
ansible.builtin.assert: | ||
that: "'<maxfilesize>15</maxfilesize>' in ( current_config.content | b64decode )" | ||
when: opnsense_version["product_version"] is version('24.1', '>=') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
scenario: | ||
name: system_settings_logging | ||
test_sequence: | ||
# - dependency not relevant unless we have requirements | ||
- destroy | ||
- syntax | ||
- create | ||
- converge | ||
- idempotence | ||
- verify | ||
- destroy | ||
|
||
driver: | ||
name: vagrant | ||
parallel: true | ||
|
||
platforms: | ||
- name: "22.7" | ||
hostname: false | ||
box: puzzle/opnsense | ||
box_version: "22.7" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "23.1" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "23.1" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "23.7" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "23.7" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
- name: "24.1" | ||
box: puzzle/opnsense | ||
hostname: false | ||
box_version: "24.1" | ||
memory: 1024 | ||
cpus: 2 | ||
instance_raw_config_args: | ||
- 'vm.guest = :freebsd' | ||
- 'ssh.sudo_command = "%c"' | ||
- 'ssh.shell = "/bin/sh"' | ||
|
||
provisioner: | ||
name: ansible | ||
env: | ||
ANSIBLE_VERBOSITY: 3 | ||
verifier: | ||
name: ansible | ||
options: | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Verify connectivity to server | ||
hosts: all | ||
tasks: | ||
- name: Ping the server | ||
ansible.builtin.ping: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.