summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_config
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets/vyos_config')
-rw-r--r--tests/integration/targets/vyos_config/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_config/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_config/tasks/cli_config.yaml10
-rw-r--r--tests/integration/targets/vyos_config/tasks/main.yaml9
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/backup.yaml60
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/check_config.yaml24
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/comment.yaml6
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/config.cfg3
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/save.yaml16
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/simple.yaml26
-rw-r--r--tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml68
-rw-r--r--tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml20
-rw-r--r--tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml18
13 files changed, 151 insertions, 125 deletions
diff --git a/tests/integration/targets/vyos_config/defaults/main.yaml b/tests/integration/targets/vyos_config/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_config/defaults/main.yaml
+++ b/tests/integration/targets/vyos_config/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_config/tasks/cli.yaml b/tests/integration/targets/vyos_config/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_config/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_config/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
register: test_cases
delegate_to: localhost
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
-- name: run test case (connection=network_cli)
- include: "{{ test_case_to_run }} ansible_connection=network_cli"
- with_items: "{{ test_items }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli'
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
- include: "{{ test_case_to_run }} ansible_connection=local"
- with_first_found: "{{ test_items }}"
+ include: '{{ test_case_to_run }} ansible_connection=local'
+ with_first_found: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_config/tasks/cli_config.yaml b/tests/integration/targets/vyos_config/tasks/cli_config.yaml
index f5d5b55..98bd1fc 100644
--- a/tests/integration/targets/vyos_config/tasks/cli_config.yaml
+++ b/tests/integration/targets/vyos_config/tasks/cli_config.yaml
@@ -1,16 +1,16 @@
---
- name: collect all cli_config test cases
find:
- paths: "{{ role_path }}/tests/cli_config"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli_config'
+ patterns: '{{ testcase }}.yaml'
register: test_cases
delegate_to: localhost
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
-- name: run test case (connection=network_cli)
- include: "{{ test_case_to_run }} ansible_connection=network_cli"
- with_items: "{{ test_items }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli'
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_config/tasks/main.yaml b/tests/integration/targets/vyos_config/tasks/main.yaml
index 13977a4..8d10ebb 100644
--- a/tests/integration/targets/vyos_config/tasks/main.yaml
+++ b/tests/integration/targets/vyos_config/tasks/main.yaml
@@ -1,3 +1,8 @@
---
-- {include: cli.yaml, tags: ['cli']}
-- {include: cli_config.yaml, tags: ['cli_config']}
+- include: cli.yaml
+ tags:
+ - cli
+
+- include: cli_config.yaml
+ tags:
+ - cli_config
diff --git a/tests/integration/targets/vyos_config/tests/cli/backup.yaml b/tests/integration/targets/vyos_config/tests/cli/backup.yaml
index af6a772..ae59a0d 100644
--- a/tests/integration/targets/vyos_config/tests/cli/backup.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/backup.yaml
@@ -3,111 +3,111 @@
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- name: delete backup files
file:
- path: "{{ item.path }}"
+ path: '{{ item.path }}'
state: absent
- with_items: "{{backup_files.files|default([])}}"
+ with_items: '{{backup_files.files|default([])}}'
- name: take configure backup
+ register: result
vyos.vyos.vyos_config:
backup: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- assert:
that:
- - "backup_files.files is defined"
+ - backup_files.files is defined
- name: delete configurable backup file path
file:
- path: "{{ item }}"
+ path: '{{ item }}'
state: absent
with_items:
- - "{{ role_path }}/backup_test_dir/"
- - "{{ role_path }}/backup/backup.cfg"
+ - '{{ role_path }}/backup_test_dir/'
+ - '{{ role_path }}/backup/backup.cfg'
- name: take configuration backup in custom filename and directory path
+ become: true
+ register: result
vyos.vyos.vyos_config:
backup: true
backup_options:
filename: backup.cfg
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- become: true
- register: result
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-1 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom filename
+ become: true
+ register: result
vyos.vyos.vyos_config:
backup: true
backup_options:
filename: backup.cfg
- become: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-2 exist
find:
- paths: "{{ role_path }}/backup/backup.cfg"
+ paths: '{{ role_path }}/backup/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom path and default filename
+ become: true
+ register: result
vyos.vyos.vyos_config:
backup: true
backup_options:
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- become: true
- register: result
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-3 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}"
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 f1ddc71..4300c10 100644
--- a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
@@ -6,58 +6,52 @@
lines: delete interfaces loopback lo
- name: setup- create interface
+ register: result
vyos.vyos.vyos_config:
lines:
- interfaces
- interfaces loopback lo
- interfaces loopback lo description test
- register: result
-
-# note collapsing the duplicate lines doesn't work if
-# lines:
-# - interfaces loopback lo description test
-# - interfaces loopback lo
-# - interfaces
- name: Check that multiple duplicate lines collapse into a single commands
assert:
that:
- - "{{ result.commands|length }} == 1"
+ - '{{ result.commands|length }} == 1'
- name: Check that set is correctly prepended
assert:
that:
- - "result.commands[0] == 'set interfaces loopback lo description test'"
+ - result.commands[0] == 'set interfaces loopback lo description test'
- name: configure config_check config command
+ register: result
vyos.vyos.vyos_config:
lines: delete interfaces loopback lo
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check config_check config command idempontent
+ register: result
vyos.vyos.vyos_config:
lines: delete interfaces loopback lo
- register: result
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: check multiple line config filter is working
+ register: result
vyos.vyos.vyos_config:
lines:
- set system login user esa level admin
- set system login user esa authentication encrypted-password '!abc!'
- set system login user vyos level admin
- set system login user vyos authentication encrypted-password 'abc'
- register: result
- assert:
that:
- - "{{ result.filtered|length }} == 2"
+ - '{{ result.filtered|length }} == 2'
- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli/comment.yaml b/tests/integration/targets/vyos_config/tests/cli/comment.yaml
index 2cd1350..3032585 100644
--- a/tests/integration/targets/vyos_config/tests/cli/comment.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/comment.yaml
@@ -7,20 +7,20 @@
match: none
- name: configure using comment
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
comment: this is a test
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name foo' in result.commands"
- name: collect system commits
+ register: result
vyos.vyos.vyos_command:
commands: show system commit
- register: result
- assert:
that:
diff --git a/tests/integration/targets/vyos_config/tests/cli/config.cfg b/tests/integration/targets/vyos_config/tests/cli/config.cfg
new file mode 100644
index 0000000..36c98f1
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tests/cli/config.cfg
@@ -0,0 +1,3 @@
+ set service lldp
+ set protocols static
+
diff --git a/tests/integration/targets/vyos_config/tests/cli/save.yaml b/tests/integration/targets/vyos_config/tests/cli/save.yaml
index d8e45e2..e8a9035 100644
--- a/tests/integration/targets/vyos_config/tests/cli/save.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/save.yaml
@@ -7,43 +7,43 @@
match: none
- name: configure hostaname and save
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
save: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name foo' in result.commands"
- name: configure hostaname and don't save
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name bar
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name bar' in result.commands"
- name: save config
+ register: result
vyos.vyos.vyos_config:
save: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: save config again
+ register: result
vyos.vyos.vyos_config:
save: true
- register: result
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: teardown
vyos.vyos.vyos_config:
diff --git a/tests/integration/targets/vyos_config/tests/cli/simple.yaml b/tests/integration/targets/vyos_config/tests/cli/simple.yaml
index af211f5..4e2db4e 100644
--- a/tests/integration/targets/vyos_config/tests/cli/simple.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/simple.yaml
@@ -7,23 +7,43 @@
match: none
- name: configure simple config command
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name foo' in result.commands"
- name: check simple config command idempontent
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
+
+- assert:
+ that:
+ - result.changed == false
+
+- name: Delete services
+ vyos.vyos.vyos_config: &id001
+ lines:
+ - delete service lldp
+ - delete protocols static
+
+- name: Configuring when commands starts with whitespaces
register: result
+ vyos.vyos.vyos_config:
+ src: '{{ role_path }}/tests/cli/config.cfg'
- assert:
that:
- - "result.changed == false"
+ - result.changed == true
+ - '"set service lldp" in result.commands'
+ - '"set protocols static" in result.commands'
+
+- name: Delete services
+ vyos.vyos.vyos_config: *id001
- name: teardown
vyos.vyos.vyos_config:
diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
index a573d6c..3880a04 100644
--- a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
@@ -3,112 +3,112 @@
- name: delete configurable backup file path
file:
- path: "{{ item }}"
+ path: '{{ item }}'
state: absent
with_items:
- - "{{ role_path }}/backup_test_dir/"
- - "{{ role_path }}/backup/backup.cfg"
+ - '{{ role_path }}/backup_test_dir/'
+ - '{{ role_path }}/backup/backup.cfg'
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- name: delete backup files
file:
- path: "{{ item.path }}"
+ path: '{{ item.path }}'
state: absent
- with_items: "{{backup_files.files|default([])}}"
+ with_items: '{{backup_files.files|default([])}}'
- name: take config backup
- network.cli.cli_config:
- backup: true
become: true
register: result
+ ansible.netcommon.cli_config:
+ backup: true
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- assert:
that:
- - "backup_files.files is defined"
+ - backup_files.files is defined
- name: take configuration backup in custom filename and directory path
- network.cli.cli_config:
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
backup: true
backup_options:
filename: backup.cfg
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- become: true
- register: result
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-1 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom filename
- network.cli.cli_config:
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
backup: true
backup_options:
filename: backup.cfg
- become: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-2 exist
find:
- paths: "{{ role_path }}/backup/backup.cfg"
+ paths: '{{ role_path }}/backup/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom path and default filename
- network.cli.cli_config:
- backup: true
- backup_options:
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
become: true
register: result
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-3 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
index e5e3edb..6b71144 100644
--- a/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
@@ -1,28 +1,30 @@
---
-- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
+- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection
+ }}"
- name: setup - remove interface description
- network.cli.cli_config: &rm
+ ansible.netcommon.cli_config: &id002
config: delete interfaces loopback lo description
- name: configure device with config
- network.cli.cli_config: &conf
- config: set interfaces loopback lo description 'this is a test'
register: result
+ ansible.netcommon.cli_config: &id001
+ config: set interfaces loopback lo description 'this is a test'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: Idempotence
- network.cli.cli_config: *conf
register: result
+ ansible.netcommon.cli_config: *id001
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: teardown
- network.cli.cli_config: *rm
+ ansible.netcommon.cli_config: *id002
-- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
+- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
index ecc9e8c..030b75d 100644
--- a/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
@@ -1,30 +1,32 @@
---
-- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
+- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection
+ }}"
- name: setup
- network.cli.cli_config: &rm
+ ansible.netcommon.cli_config: &id001
config: set system host-name {{ inventory_hostname_short }}
- name: configure using comment
- network.cli.cli_config:
+ register: result
+ ansible.netcommon.cli_config:
config: set system host-name foo
commit_comment: this is a test
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: collect system commits
+ register: result
vyos.vyos.vyos_command:
commands: show system commit
- register: result
- assert:
that:
- "'this is a test' in result.stdout_lines[0][1]"
- name: teardown
- network.cli.cli_config: *rm
+ ansible.netcommon.cli_config: *id001
-- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
+- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection
+ }}"