summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/incidental_vyos_config/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/incidental_vyos_config/tests')
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli/backup.yaml113
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli/check_config.yaml63
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli/comment.yaml34
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli/config.cfg3
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli/save.yaml54
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli/simple.yaml53
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli_config/cli_backup.yaml114
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli_config/cli_basic.yaml28
-rw-r--r--test/integration/targets/incidental_vyos_config/tests/cli_config/cli_comment.yaml30
9 files changed, 492 insertions, 0 deletions
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli/backup.yaml b/test/integration/targets/incidental_vyos_config/tests/cli/backup.yaml
new file mode 100644
index 0000000..af6a772
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli/backup.yaml
@@ -0,0 +1,113 @@
+---
+- debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}"
+
+- name: collect any backup files
+ find:
+ paths: "{{ role_path }}/backup"
+ pattern: "{{ inventory_hostname_short }}_config*"
+ register: backup_files
+ connection: local
+
+- name: delete backup files
+ file:
+ path: "{{ item.path }}"
+ state: absent
+ with_items: "{{backup_files.files|default([])}}"
+
+- name: take configure backup
+ vyos.vyos.vyos_config:
+ backup: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: collect any backup files
+ find:
+ paths: "{{ role_path }}/backup"
+ pattern: "{{ inventory_hostname_short }}_config*"
+ register: backup_files
+ connection: local
+
+- assert:
+ that:
+ - "backup_files.files is defined"
+
+- name: delete configurable backup file path
+ file:
+ path: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ role_path }}/backup_test_dir/"
+ - "{{ role_path }}/backup/backup.cfg"
+
+- name: take configuration backup in custom filename and directory path
+ 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
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: check if the backup file-1 exist
+ find:
+ paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - "backup_file.files is defined"
+
+- name: take configuration backup in custom filename
+ vyos.vyos.vyos_config:
+ backup: true
+ backup_options:
+ filename: backup.cfg
+ become: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: check if the backup file-2 exist
+ find:
+ paths: "{{ role_path }}/backup/backup.cfg"
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - "backup_file.files is defined"
+
+- name: take configuration backup in custom path and default filename
+ vyos.vyos.vyos_config:
+ backup: true
+ backup_options:
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+ become: true
+ register: result
+
+- assert:
+ that:
+ - "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*"
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - "backup_file.files is defined"
+
+- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli/check_config.yaml b/test/integration/targets/incidental_vyos_config/tests/cli/check_config.yaml
new file mode 100644
index 0000000..f1ddc71
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli/check_config.yaml
@@ -0,0 +1,63 @@
+---
+- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}"
+
+- name: setup- ensure interface is not present
+ vyos.vyos.vyos_config:
+ lines: delete interfaces loopback lo
+
+- name: setup- create interface
+ 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"
+
+- name: Check that set is correctly prepended
+ assert:
+ that:
+ - "result.commands[0] == 'set interfaces loopback lo description test'"
+
+- name: configure config_check config command
+ vyos.vyos.vyos_config:
+ lines: delete interfaces loopback lo
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: check config_check config command idempontent
+ vyos.vyos.vyos_config:
+ lines: delete interfaces loopback lo
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: check multiple line config filter is working
+ 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"
+
+- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli/comment.yaml b/test/integration/targets/incidental_vyos_config/tests/cli/comment.yaml
new file mode 100644
index 0000000..2cd1350
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli/comment.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}"
+
+- name: setup
+ vyos.vyos.vyos_config:
+ lines: set system host-name {{ inventory_hostname_short }}
+ match: none
+
+- name: configure using comment
+ vyos.vyos.vyos_config:
+ lines: set system host-name foo
+ comment: this is a test
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'set system host-name foo' in result.commands"
+
+- name: collect system commits
+ vyos.vyos.vyos_command:
+ commands: show system commit
+ register: result
+
+- assert:
+ that:
+ - "'this is a test' in result.stdout_lines[0][1]"
+
+- name: teardown
+ vyos.vyos.vyos_config:
+ lines: set system host-name {{ inventory_hostname_short }}
+ match: none
+
+- debug: msg="END cli/comment.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli/config.cfg b/test/integration/targets/incidental_vyos_config/tests/cli/config.cfg
new file mode 100644
index 0000000..36c98f1
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli/config.cfg
@@ -0,0 +1,3 @@
+ set service lldp
+ set protocols static
+
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli/save.yaml b/test/integration/targets/incidental_vyos_config/tests/cli/save.yaml
new file mode 100644
index 0000000..d8e45e2
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli/save.yaml
@@ -0,0 +1,54 @@
+---
+- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}"
+
+- name: setup
+ vyos.vyos.vyos_config:
+ lines: set system host-name {{ inventory_hostname_short }}
+ match: none
+
+- name: configure hostaname and save
+ vyos.vyos.vyos_config:
+ lines: set system host-name foo
+ save: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'set system host-name foo' in result.commands"
+
+- name: configure hostaname and don't save
+ vyos.vyos.vyos_config:
+ lines: set system host-name bar
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'set system host-name bar' in result.commands"
+
+- name: save config
+ vyos.vyos.vyos_config:
+ save: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: save config again
+ vyos.vyos.vyos_config:
+ save: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ vyos.vyos.vyos_config:
+ lines: set system host-name {{ inventory_hostname_short }}
+ match: none
+ save: true
+
+- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli/simple.yaml b/test/integration/targets/incidental_vyos_config/tests/cli/simple.yaml
new file mode 100644
index 0000000..c082673
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli/simple.yaml
@@ -0,0 +1,53 @@
+---
+- debug: msg="START cli/simple.yaml on connection={{ ansible_connection }}"
+
+- name: setup
+ vyos.vyos.vyos_config:
+ lines: set system host-name {{ inventory_hostname_short }}
+ match: none
+
+- name: configure simple config command
+ vyos.vyos.vyos_config:
+ lines: set system host-name foo
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'set system host-name foo' in result.commands"
+
+- name: check simple config command idempontent
+ vyos.vyos.vyos_config:
+ lines: set system host-name foo
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: Delete services
+ vyos.vyos.vyos_config: &del
+ lines:
+ - delete service lldp
+ - delete protocols static
+
+- name: Configuring when commands starts with whitespaces
+ vyos.vyos.vyos_config:
+ src: "{{ role_path }}/tests/cli/config.cfg"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - '"set service lldp" in result.commands'
+ - '"set protocols static" in result.commands'
+
+- name: Delete services
+ vyos.vyos.vyos_config: *del
+
+- name: teardown
+ vyos.vyos.vyos_config:
+ lines: set system host-name {{ inventory_hostname_short }}
+ match: none
+
+- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_backup.yaml b/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_backup.yaml
new file mode 100644
index 0000000..744bb7e
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_backup.yaml
@@ -0,0 +1,114 @@
+---
+- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
+
+- name: delete configurable backup file path
+ file:
+ path: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ 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*"
+ register: backup_files
+ connection: local
+
+- name: delete backup files
+ file:
+ path: "{{ item.path }}"
+ state: absent
+ with_items: "{{backup_files.files|default([])}}"
+
+- name: take config backup
+ ansible.netcommon.cli_config:
+ backup: true
+ become: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: collect any backup files
+ find:
+ paths: "{{ role_path }}/backup"
+ pattern: "{{ inventory_hostname_short }}_config*"
+ register: backup_files
+ connection: local
+
+- assert:
+ that:
+ - "backup_files.files is defined"
+
+- name: take configuration backup in custom filename and directory path
+ 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
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: check if the backup file-1 exist
+ find:
+ paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - "backup_file.files is defined"
+
+- name: take configuration backup in custom filename
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ filename: backup.cfg
+ become: true
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: check if the backup file-2 exist
+ find:
+ paths: "{{ role_path }}/backup/backup.cfg"
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - "backup_file.files is defined"
+
+- name: take configuration backup in custom path and default filename
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+ become: true
+ register: result
+
+- assert:
+ that:
+ - "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*"
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - "backup_file.files is defined"
+
+- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_basic.yaml b/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_basic.yaml
new file mode 100644
index 0000000..c6c4f59
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_basic.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
+
+- name: setup - remove interface description
+ ansible.netcommon.cli_config: &rm
+ config: delete interfaces loopback lo description
+
+- name: configure device with config
+ ansible.netcommon.cli_config: &conf
+ config: set interfaces loopback lo description 'this is a test'
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: Idempotence
+ ansible.netcommon.cli_config: *conf
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ansible.netcommon.cli_config: *rm
+
+- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_comment.yaml b/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_comment.yaml
new file mode 100644
index 0000000..90ee1c8
--- /dev/null
+++ b/test/integration/targets/incidental_vyos_config/tests/cli_config/cli_comment.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
+
+- name: setup
+ ansible.netcommon.cli_config: &rm
+ config: set system host-name {{ inventory_hostname_short }}
+
+- name: configure using comment
+ ansible.netcommon.cli_config:
+ config: set system host-name foo
+ commit_comment: this is a test
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: collect system commits
+ vyos.vyos.vyos_command:
+ commands: show system commit
+ register: result
+
+- assert:
+ that:
+ - "'this is a test' in result.stdout_lines[0][1]"
+
+- name: teardown
+ ansible.netcommon.cli_config: *rm
+
+- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}"