summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/check_config.yaml4
-rw-r--r--tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml4
-rw-r--r--tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml6
-rw-r--r--tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml6
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/_get_version.yaml28
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml15
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml36
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml5
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml3
-rw-r--r--tests/integration/targets/vyos_logging_global/vars/main.yaml66
-rw-r--r--tests/integration/targets/vyos_logging_global/vars/pre-v1_4.yaml68
-rw-r--r--tests/integration/targets/vyos_logging_global/vars/v1_4.yaml74
12 files changed, 189 insertions, 126 deletions
diff --git a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
index 5e028549..8e2e8372 100644
--- a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
@@ -45,9 +45,9 @@
register: result
vyos.vyos.vyos_config:
lines:
- - set system login user esa level admin
+ - set system login user esa full-name 'ESA admin'
- set system login user esa authentication encrypted-password '!abc!'
- - set system login user vyos level admin
+ - set system login user vyos full-name 'VyOS admin'
- set system login user vyos authentication encrypted-password 'abc'
- assert:
diff --git a/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
index 33fb3be5..0d88d0cb 100644
--- a/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
+++ b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
@@ -45,9 +45,9 @@
register: result
vyos.vyos.config:
lines:
- - set system login user esa level admin
+ - set system login user esa full-name 'ESA admin'
- set system login user esa authentication encrypted-password '!abc!'
- - set system login user vyos level admin
+ - set system login user vyos full-name 'VyOS admin'
- set system login user vyos authentication encrypted-password 'abc'
- assert:
diff --git a/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml b/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml
index 232132e1..50e95889 100644
--- a/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml
+++ b/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml
@@ -31,9 +31,9 @@
- name: check that version info is present
assert:
that:
- - result.ansible_facts.ansible_net_version in vyos_version.stdout_lines[0][0]
- - result.ansible_facts.ansible_net_model in vyos_version.stdout_lines[0][9]
- - result.ansible_facts.ansible_net_serialnum in vyos_version.stdout_lines[0][10]
+ - result.ansible_facts.ansible_net_version in (vyos_version.stdout_lines[0] | select('search', 'Version:') | list | first)
+ - result.ansible_facts.ansible_net_model in (vyos_version.stdout_lines[0] | select('search', 'Hardware model:') | list | first)
+ - result.ansible_facts.ansible_net_serialnum in (vyos_version.stdout_lines[0] | select('search', 'Hardware S/N:') | list | first)
- name: check that config info is present
assert:
diff --git a/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml
index 05399f1d..35233728 100644
--- a/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml
+++ b/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml
@@ -31,9 +31,9 @@
- name: check that version info is present
assert:
that:
- - result.ansible_facts.ansible_net_version in vyos_version.stdout_lines[0][0]
- - result.ansible_facts.ansible_net_model in vyos_version.stdout_lines[0][9]
- - result.ansible_facts.ansible_net_serialnum in vyos_version.stdout_lines[0][10]
+ - result.ansible_facts.ansible_net_version in (vyos_version.stdout_lines[0] | select('search', 'Version:') | list | first)
+ - result.ansible_facts.ansible_net_model in (vyos_version.stdout_lines[0] | select('search', 'Hardware model:') | list | first)
+ - result.ansible_facts.ansible_net_serialnum in (vyos_version.stdout_lines[0] | select('search', 'Hardware S/N:') | list | first)
- name: check that config info is present
assert:
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/_get_version.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/_get_version.yaml
new file mode 100644
index 00000000..2588b194
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/_get_version.yaml
@@ -0,0 +1,28 @@
+- name: make sure to get facts
+ vyos.vyos.vyos_facts:
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ register: vyos_facts
+ when: vyos_version is not defined
+
+- name: debug vyos_facts
+ debug:
+ var: vyos_facts
+
+- name: pull version from facts
+ set_fact:
+ vyos_version: "{{ vyos_facts.ansible_facts.ansible_net_version.split('-')[0].split(' ')[-1] }}"
+ when: vyos_version is not defined
+
+- name: fix '.0' versions
+ set_fact:
+ vyos_version: "{{ vyos_version }}.0"
+ when: vyos_version.count('.') == 1
+
+- name: include correct vars
+ include_vars: pre-v1_4.yaml
+ when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: include correct vars
+ include_vars: v1_4.yaml
+ when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml
index 516df94a..89fb8e51 100644
--- a/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml
@@ -21,17 +21,7 @@
severity: emerg
- facility: local7
severity: emerg
- hosts:
- - hostname: 172.16.2.15
- facilities:
- - facility: all
- severity: all
- - facility: all
- protocol: udp
- - hostname: 172.16.2.12
- facilities:
- - facility: all
- protocol: udp
+ hosts: "{{ populate_logging_global_hosts }}"
users:
- username: vyos
facilities:
@@ -44,9 +34,6 @@
- facility: local7
severity: err
global_params:
- archive:
- file_num: 2
- size: 111
facilities:
- facility: cron
severity: debug
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml
index b4d38565..02c4c618 100644
--- a/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml
@@ -2,47 +2,25 @@
- debug:
msg: START vyos_logging_global merged integration tests on connection={{ ansible_connection }}
+- include_tasks: _get_version.yaml
- include_tasks: _remove_config.yaml
- block:
- # no after state match because 1.1.8 vyos does show all commands on show command
- name: Merge the provided configuration with the existing running configuration
register: result
vyos.vyos.vyos_logging_global: &id001
- config:
- console:
- facilities:
- - facility: all
- files:
- - path: def
- archive:
- file_num: 2
- facilities:
- - facility: local6
- severity: emerg
- hosts:
- - hostname: 172.16.2.15
- facilities:
- - facility: all
- severity: all
- users:
- - username: vyos
- facilities:
- - facility: local7
- severity: debug
- global_params:
- archive:
- file_num: 2
- size: 111
- facilities:
- - facility: cron
- severity: debug
+ config: "{{ merged.after }}"
state: merged
+ - debug:
+ var: merged['commands'] | symmetric_difference(result['commands'])
+
- name: Assert that correct set of commands were generated
assert:
that:
- "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - result.changed == true
+ - result.after == merged.after
- name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
register: result
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml
index eacdca22..b0ca2ffd 100644
--- a/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml
@@ -5,7 +5,6 @@
- include_tasks: _populate.yaml
- block:
- # no after state match because 1.1.8 vyos does show all commands on show command
- name: Overrides all device configuration with provided configuration
register: result
vyos.vyos.vyos_logging_global: &id001
@@ -17,15 +16,13 @@
severity: err
- facility: news
severity: debug
- global_params:
- archive:
- file_num: 2
state: overridden
- name: Assert that correct commands were generated
assert:
that:
- "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "result.changed == true"
- name: Overrides all device configuration with provided configurations (IDEMPOTENT)
register: result
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml
index 3746dd71..27d5d6e3 100644
--- a/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml
@@ -27,9 +27,6 @@
- facility: local7
severity: debug
global_params:
- archive:
- file_num: 2
- size: 111
facilities:
- facility: cron
severity: debug
diff --git a/tests/integration/targets/vyos_logging_global/vars/main.yaml b/tests/integration/targets/vyos_logging_global/vars/main.yaml
index 8d22af0b..13ca654f 100644
--- a/tests/integration/targets/vyos_logging_global/vars/main.yaml
+++ b/tests/integration/targets/vyos_logging_global/vars/main.yaml
@@ -1,68 +1,4 @@
---
-merged:
- before: {}
- commands:
- - set system syslog host 172.16.2.15 facility all level all
- - set system syslog console facility all
- - set system syslog user vyos facility local7 level debug
- - set system syslog global facility cron level debug
- - set system syslog global archive file 2
- - set system syslog global archive size 111
- - set system syslog file def archive file 2
- - set system syslog file def facility local6 level emerg
- after:
- console:
- facilities:
- - facility: all
- files:
- - path: def
- facilities:
- - facility: local6
- severity: emerg
- hosts:
- - hostname: 172.16.2.15
- facilities:
- - facility: all
- severity: all
- users:
- - username: vyos
- facilities:
- - facility: local7
- severity: debug
- global_params:
- archive:
- size: 111
- facilities:
- - facility: cron
- severity: debug
-
-overridden:
- commands:
- - delete system syslog file def
- - delete system syslog global facility cron
- - delete system syslog global facility local7
- - delete system syslog host 172.16.2.12
- - delete system syslog host 172.16.2.15
- - delete system syslog user paul
- - delete system syslog user vyos
- - set system syslog console facility all
- - set system syslog global archive file 2
- - delete system syslog global archive size 111
-
- after:
- console:
- facilities:
- - facility: all
- - facility: local7
- severity: err
- - facility: news
- severity: debug
- files:
- - path: Myfile
- global_params:
- archive:
- file_num: 2
-
rendered:
commands:
- set system syslog console facility all
@@ -70,8 +6,6 @@ rendered:
- set system syslog host 172.16.2.15 facility all level all
- set system syslog user vyos facility local7 level debug
- set system syslog global facility cron level debug
- - set system syslog global archive file 2
- - set system syslog global archive size 111
deleted:
commands:
diff --git a/tests/integration/targets/vyos_logging_global/vars/pre-v1_4.yaml b/tests/integration/targets/vyos_logging_global/vars/pre-v1_4.yaml
new file mode 100644
index 00000000..6af72488
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/vars/pre-v1_4.yaml
@@ -0,0 +1,68 @@
+---
+host_172_16_2_15: &host_172_16_2_15
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+
+merged:
+ before: {}
+ commands:
+ - set system syslog host 172.16.2.15 facility all level all
+ - set system syslog console facility all
+ - set system syslog user vyos facility local7 level debug
+ - set system syslog global facility cron level debug
+ - set system syslog file def archive file 2
+ - set system syslog file def facility local6 level emerg
+ after:
+ console:
+ facilities:
+ - facility: all
+ files:
+ - path: def
+ facilities:
+ - facility: local6
+ severity: emerg
+ archive:
+ file_num: 2
+ hosts: *host_172_16_2_15
+ users:
+ - username: vyos
+ facilities:
+ - facility: local7
+ severity: debug
+ global_params:
+ facilities:
+ - facility: cron
+ severity: debug
+
+overridden:
+ commands:
+ - delete system syslog file def
+ - delete system syslog global facility cron
+ - delete system syslog global facility local7
+ - delete system syslog host 172.16.2.12
+ - delete system syslog host 172.16.2.15
+ - delete system syslog user paul
+ - delete system syslog user vyos
+
+ after:
+ console:
+ facilities:
+ - facility: all
+ - facility: local7
+ severity: err
+ - facility: news
+ severity: debug
+ files:
+ - path: Myfile
+
+populate_logging_global_hosts:
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ protocol: udp
+ - hostname: 172.16.2.12
+ facilities:
+ - facility: all
+ protocol: udp
diff --git a/tests/integration/targets/vyos_logging_global/vars/v1_4.yaml b/tests/integration/targets/vyos_logging_global/vars/v1_4.yaml
new file mode 100644
index 00000000..bfe5e12d
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/vars/v1_4.yaml
@@ -0,0 +1,74 @@
+---
+host_172_16_2_15: &host_172_16_2_15
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+ protocol: tcp
+
+merged:
+ before: {}
+ commands:
+ - set system syslog host 172.16.2.15 facility all level all
+ - set system syslog host 172.16.2.15 protocol tcp
+ - set system syslog console facility all
+ - set system syslog user vyos facility local7 level debug
+ - set system syslog global facility cron level debug
+ - set system syslog file def archive file 2
+ - set system syslog file def facility local6 level emerg
+ after:
+ console:
+ facilities:
+ - facility: all
+ files:
+ - path: def
+ facilities:
+ - facility: local6
+ severity: emerg
+ archive:
+ file_num: 2
+ hosts: *host_172_16_2_15
+ users:
+ - username: vyos
+ facilities:
+ - facility: local7
+ severity: debug
+ global_params:
+ facilities:
+ - facility: cron
+ severity: debug
+
+overridden:
+ commands:
+ - delete system syslog file def
+ - delete system syslog global facility cron
+ - delete system syslog global facility local7
+ - delete system syslog host 172.16.2.12 protocol udp
+ - delete system syslog host 172.16.2.15 protocol udp
+ - delete system syslog host 172.16.2.12
+ - delete system syslog host 172.16.2.15
+ - delete system syslog user paul
+ - delete system syslog user vyos
+
+ after:
+ console:
+ facilities:
+ - facility: all
+ - facility: local7
+ severity: err
+ - facility: news
+ severity: debug
+ files:
+ - path: Myfile
+
+populate_logging_global_hosts:
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+ - facility: all
+ protocol: udp
+ - hostname: 172.16.2.12
+ facilities:
+ - facility: all
+ protocol: udp