summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNilashish Chakraborty <nilashishchakraborty8@gmail.com>2020-07-28 20:57:08 +0530
committerGitHub <noreply@github.com>2020-07-28 15:27:08 +0000
commit1795b189f7a3ca83ff3c67e189cfd1c83cc4b433 (patch)
tree0e40b8b55f0fea4d4af3bf9a8cec28a875cd1d3b /tests
parentfbb82a0875dacc8200d3f663c3286104d0a1afbf (diff)
downloadvyos-ansible-old-1795b189f7a3ca83ff3c67e189cfd1c83cc4b433.tar.gz
vyos-ansible-old-1795b189f7a3ca83ff3c67e189cfd1c83cc4b433.zip
Make config modules work properly when module alias is used in task (#67)
Make config modules work properly when module alias is used in task Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/targets/vyos_config/templates/config.j22
-rw-r--r--tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml42
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_config/templates/config.j2 b/tests/integration/targets/vyos_config/templates/config.j2
new file mode 100644
index 0000000..fc4d42c
--- /dev/null
+++ b/tests/integration/targets/vyos_config/templates/config.j2
@@ -0,0 +1,2 @@
+set interfaces ethernet eth0 description TEST-INTF
+set system login user test_user
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 ac84154..3f3e489 100644
--- a/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
+++ b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml
@@ -54,4 +54,46 @@
that:
- '{{ result.filtered|length }} == 2'
+- name: Remove interface description and delete temp user
+ vyos.vyos.config: &cleanup
+ lines:
+ - "delete interfaces ethernet eth0 description TEST-INTF"
+ - "delete system login user test_user"
+
+- name: Use src with module alias
+ register: result
+ vyos.vyos.config:
+ src: config.j2
+
+- assert:
+ that:
+ - result.changed == true
+ - '"set interfaces ethernet eth0 description TEST-INTF" in result.commands'
+ - '"set system login user test_user" in result.commands'
+
+- name: "Restore hostname to {{ inventory_hostname }} and delete temp user"
+ vyos.vyos.config: *cleanup
+
+- name: use module alias to take configuration backup
+ register: result
+ vyos.vyos.config:
+ backup: true
+ backup_options:
+ filename: backup_with_alias.cfg
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
+
+- assert:
+ that:
+ - result.changed == true
+
+- name: check if the backup file-4 exist
+ find:
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup_with_alias.cfg'
+ register: backup_file
+ connection: local
+
+- assert:
+ that:
+ - backup_file.files is defined
+
- debug: msg="END cli/shortname.yaml on connection={{ ansible_connection }}"