From 1795b189f7a3ca83ff3c67e189cfd1c83cc4b433 Mon Sep 17 00:00:00 2001 From: Nilashish Chakraborty Date: Tue, 28 Jul 2020 20:57:08 +0530 Subject: 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 --- .../targets/vyos_config/templates/config.j2 | 2 ++ .../tests/redirection/cli/shortname.yaml | 42 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/integration/targets/vyos_config/templates/config.j2 (limited to 'tests/integration/targets') 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 }}" -- cgit v1.2.3