diff --git a/tests/integration/targets/vyos_config/tests/cli/backup.yaml b/tests/integration/targets/vyos_config/tests/cli/backup.yaml index adfa2ad7..3bcd5d35 100644 --- a/tests/integration/targets/vyos_config/tests/cli/backup.yaml +++ b/tests/integration/targets/vyos_config/tests/cli/backup.yaml @@ -1,111 +1,113 @@ --- - debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" - name: collect any backup files - find: + ansible.builtin.find: paths: "{{ role_path }}/backup" pattern: "{{ inventory_hostname_short }}_config*" register: backup_files connection: local - name: delete backup files - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{ backup_files.files|default([]) }}" + connection: local - name: take configure backup register: result vyos.vyos.vyos_config: backup: true - assert: that: - result.changed == true - name: collect any backup files - find: + ansible.builtin.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: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: - "{{ role_path }}/backup_test_dir/" - "{{ role_path }}/backup/backup.cfg" run_once: true + connection: local - name: take configuration backup in custom filename and directory path register: result vyos.vyos.vyos_config: backup: true backup_options: filename: backup.cfg dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - assert: that: - result.changed == true - name: check if the backup file-1 exist - find: + ansible.builtin.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 register: result vyos.vyos.vyos_config: backup: true backup_options: filename: backup.cfg - assert: that: - result.changed == true - name: check if the backup file-2 exist - find: + ansible.builtin.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 register: result vyos.vyos.vyos_config: backup: true backup_options: dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - assert: that: - result.changed == true - name: check if the backup file-3 exist - find: + ansible.builtin.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/tests/integration/targets/vyos_config/tests/cli/check_config.yaml b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml index 57317754..a03a3115 100644 --- a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml +++ b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml @@ -1,109 +1,111 @@ --- - 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 register: result vyos.vyos.vyos_config: lines: - interfaces - interfaces loopback lo - interfaces loopback lo description test - 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 register: result vyos.vyos.vyos_config: lines: delete interfaces loopback lo - assert: that: - result.changed == true - name: check config_check config command idempontent register: result vyos.vyos.vyos_config: lines: delete interfaces loopback lo - assert: that: - result.changed == false - name: setup- ensure test login accounts are not present vyos.vyos.vyos_config: lines: - delete system login user testesa - delete system login user testadmin - delete system login user testjohn match: none + ignore_errors: true - block: - name: check multiple line config filter is working register: result vyos.vyos.vyos_config: lines: - set system login user testesa full-name 'ESA admin' - set system login user testesa authentication encrypted-password '!abc!' - set system login user testadmin full-name 'Test admin' - set system login user testadmin authentication encrypted-password 'abc' - set system login user testjohn full-name 'John' - set system login user testjohn authentication plaintext-password 'xyz' - assert: that: - result.filtered|length == 2 - name: check multiple line config filter is working register: result vyos.vyos.vyos_config: allow_password_change: none lines: - set system login user testesa full-name 'ESA admin' - set system login user testesa authentication encrypted-password '!abc!' - set system login user testadmin full-name 'Test admin' - set system login user testadmin authentication encrypted-password 'abc' - set system login user testjohn full-name 'John' - set system login user testjohn authentication plaintext-password 'xyz' - assert: that: - result.filtered|length == 3 - name: check multiple line config filter is working register: result vyos.vyos.vyos_config: allow_password_change: all lines: - set system login user testesa full-name 'ESA admin' - set system login user testesa authentication encrypted-password '$5$jR0jeXg3jHzSN7k3$33fO1qz3CVzsWJhxksLE7.KTIizYWGAMsd6LH9ItJmB' - set system login user testadmin full-name 'Test admin' - set system login user testadmin authentication encrypted-password '$5$YVhfNdmQbKQpDROb$N1b2nKh69wvrtQu7JwiIp/IsWlLHU8QCDcNGVaRWh6.' - set system login user testjohn full-name 'John' - set system login user testjohn authentication plaintext-password 'xyz' - assert: that: - result.filtered|length == 0 always: - name: cleanup test login accounts created by password filter checks vyos.vyos.vyos_config: lines: - delete system login user testesa - delete system login user testadmin - delete system login user testjohn match: none + ignore_errors: true - debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" 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 03450c31..0bc55e26 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 @@ -1,111 +1,111 @@ --- - debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" - name: delete configurable backup file path - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: - "{{ role_path }}/backup_test_dir/" - "{{ role_path }}/backup/backup.cfg" run_once: true - name: collect any backup files - find: + ansible.builtin.find: paths: "{{ role_path }}/backup" pattern: "{{ inventory_hostname_short }}_config*" register: backup_files connection: local - name: delete backup files - file: + ansible.builtin.file: path: "{{ item.path }}" state: absent with_items: "{{backup_files.files|default([])}}" - name: take config backup register: result ansible.netcommon.cli_config: backup: true - assert: that: - result.changed == true - name: collect any backup files - find: + ansible.builtin.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 register: result ansible.netcommon.cli_config: backup: true backup_options: filename: backup.cfg dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - assert: that: - result.changed == true - name: check if the backup file-1 exist - find: + ansible.builtin.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 register: result ansible.netcommon.cli_config: backup: true backup_options: filename: backup.cfg - assert: that: - result.changed == true - name: check if the backup file-2 exist - find: + ansible.builtin.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 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 - name: check if the backup file-3 exist - find: + ansible.builtin.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 }}"