diff options
Diffstat (limited to 'collections-debian-merged/ansible_collections/arista/eos/tests/integration')
519 files changed, 20181 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/network-integration.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/network-integration.cfg new file mode 100644 index 00000000..d12c1efe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/network-integration.cfg @@ -0,0 +1,4 @@ +[persistent_connection] +command_timeout = 100 +connect_timeout = 100 +connect_retry_timeout = 100 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/target-prefixes.network b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/target-prefixes.network new file mode 100644 index 00000000..90c4079c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +eos
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/defaults/main.yaml new file mode 100644 index 00000000..aeb94781 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..59e767e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,6 @@ +interface GigabitEthernet0/0 +ip access-group aclv401 in +ip access-group aclv402 out +ipv6 traffic-filter aclv601 out +interface GigabitEthernet0/1 +ipv6 traffic-filter aclv601 in diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_populate.yaml new file mode 100644 index 00000000..12d095c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_populate.yaml @@ -0,0 +1,33 @@ +--- +- name: Setup + become: true + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: merged diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_remove_config.yaml new file mode 100644 index 00000000..2423bb74 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/_remove_config.yaml @@ -0,0 +1,10 @@ +--- +- name: Setup + become: true + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + + - name: "{{ Interfaces['int2'] }}" + state: deleted diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..4aa0470f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/deleted.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: Start eos_acl_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of given acl_interfaces of an afi. + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv6 + state: deleted + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - "'no ipv6 traffic-filter aclv601 out' in result.commands" + + - name: Delete attributes of given acl_interfaces configuration. + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + state: deleted + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - "'no ip access-group aclv401 in' in result.commands" + + - name: Delete attributes of given acl_interfaces of an interface. + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + state: deleted + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - "'no ip access-group aclv402 out' in result.commands" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..f836f086 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START eos_acl_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_acl_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..209aac3f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_acl_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_acl_interfaces: + config: + state: gathered + + - name: Assert + assert: + that: + - gathered['config'] | symmetric_difference(result.gathered) == [] + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..af1967ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/merged.yaml @@ -0,0 +1,59 @@ +--- +- debug: + msg: Start eos_acl_interfaces merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: &id001 + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: merged + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acl_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..6dba3e0f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/overridden.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_acl_interfaces overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: &id001 + config: + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + state: overridden + + - assert: + that: + - result.commands|length == 7 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acl_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..9bdf029a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_acl_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_acl_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result.parsed) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..354f34a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rendered.yaml @@ -0,0 +1,45 @@ +--- +- debug: + msg: Start eos_acl_interfaces rendered integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: render given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..9746ca34 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/replaced.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_acl_interfaces replced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given acl interfaces configuration + become: true + register: result + arista.eos.eos_acl_interfaces: &id001 + config: + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + state: replaced + + - assert: + that: + - result.commands|length == 3 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acl_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..f66ad3c7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/tests/common/rtt.yaml @@ -0,0 +1,82 @@ +--- +- debug: + msg: Start eos_acl_interfaces merged round trip tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given acl interfaces configuration(apply base config) + become: true + register: base_config + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int1'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: aclv402 + direction: out + + - afi: ipv6 + acls: + + - name: aclv601 + direction: out + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv6 + acls: + + - name: aclv601 + direction: in + state: merged + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_acl_interfaces: + config: + + - name: "{{ Interfaces['int2'] }}" + access_groups: + + - afi: ipv4 + acls: + + - name: aclv401 + direction: in + + - name: Assert that changes were applied + assert: + that: + - "{{ round_trip['commands'] | symmetric_difference(result['commands']) == [] }}" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_acl_interfaces: + config: "{{ ansible_facts['network_resources']['acl_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) == [] }}" + + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/vars/main.yaml new file mode 100644 index 00000000..5dd042bf --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acl_interfaces/vars/main.yaml @@ -0,0 +1,79 @@ +--- +Interfaces: + int1: GigabitEthernet0/0 + int2: GigabitEthernet0/1 +deleted1: + commands: + - interface GigabitEthernet0/0 + - no ip access-group aclv401 in + - no ip access-group aclv402 out + - no ipv6 traffic-filter aclv601 out +merged: + commands: + - interface GigabitEthernet0/0 + - ip access-group aclv401 in + - ip access-group aclv402 out + - ipv6 traffic-filter aclv601 out + - interface GigabitEthernet0/1 + - ipv6 traffic-filter aclv601 in +replaced: + commands: + - interface GigabitEthernet0/1 + - no ipv6 traffic-filter aclv601 in + - ip access-group aclv401 in +overridden: + commands: + - interface GigabitEthernet0/0 + - no ip access-group aclv401 in + - no ip access-group aclv402 out + - no ipv6 traffic-filter aclv601 out + - interface GigabitEthernet0/1 + - no ipv6 traffic-filter aclv601 in + - ip access-group aclv401 in +roundtrip: + commands: + - interface GigabitEthernet0/1 + - ip access-group aclv401 in +gathered: + config: + - name: Loopback888 + - access_groups: + - acls: + - direction: in + name: aclv401 + - direction: out + name: aclv402 + afi: ipv4 + - acls: + - direction: out + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/0 + - access_groups: + - acls: + - direction: in + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/1 + - name: GigabitEthernet0/2 + - name: GigabitEthernet0/3 +parsed: + config: + - access_groups: + - acls: + - direction: in + name: aclv401 + - direction: out + name: aclv402 + afi: ipv4 + - acls: + - direction: out + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/0 + - access_groups: + - acls: + - direction: in + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/1 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/cli.yaml new file mode 100644 index 00000000..2497b2be --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/cli.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/eapi.yaml new file mode 100644 index 00000000..e3f29514 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/eapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed.cfg new file mode 100644 index 00000000..11758ce5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed.cfg @@ -0,0 +1,4 @@ +ip access-list test1 +35 deny tcp 20.0.0.0/8 any log +45 remark Run by ansible +55 permit tcp any any diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed_cfg.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed_cfg.yaml new file mode 100644 index 00000000..4380ec23 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_parsed_cfg.yaml @@ -0,0 +1,10 @@ +--- +- name: Setup + become: true + vars: + arista.eos.eos_config: + lines: + - "ip access-list test1" + - "35 deny tcp 20.0.0.0/8 any log" + - "45 remark Run by ansible" + - "55 permit tcp any any" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_populate.yaml new file mode 100644 index 00000000..ac493189 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_populate.yaml @@ -0,0 +1,59 @@ +--- +- name: Setup + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: merged diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_remove_config.yaml new file mode 100644 index 00000000..a3b44aef --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/_remove_config.yaml @@ -0,0 +1,10 @@ +--- +- name: Setup + become: true + arista.eos.eos_acls: + config: + + - afi: ipv4 + + - afi: ipv6 + state: deleted diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/deleted.yaml new file mode 100644 index 00000000..92b9faae --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/deleted.yaml @@ -0,0 +1,165 @@ +--- +- debug: + msg: Start eos_acls deleted integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- set_fact: + config1: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 55 + grant: permit + protocol: tcp + source: + any: true + destination: + any: true + + - remark: Run by ansible + sequence: 45 + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + sequence: 10 + log: 'true' + source: + any: true + +- set_fact: + config2: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + sequence: 45 + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + +- set_fact: + config3: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + sequence: 45 + +- block: + + - name: Delete afi of given acls. + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv6 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - 'ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] ' + become: true + + - name: Delete attributes of given named acl. + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test4 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - 'ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] ' + become: true + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/gathered.yaml new file mode 100644 index 00000000..9fc86f06 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/gathered.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START eos_acls gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_acls: &id001 + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - name: Assert + assert: + that: + - ansible_facts.network_resources.acls | symmetric_difference(result.gathered) + == [] + + - name: Gather the existing running configuration (IDEMPOTENT) + become: true + register: result + arista.eos.eos_acls: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/merged.yaml new file mode 100644 index 00000000..85f3c2d7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/merged.yaml @@ -0,0 +1,176 @@ +--- +- debug: + msg: Start eos_acls merged integration tests ansible_connection={{ ansible_connection + }} + +- set_fact: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + sequence: 45 + + - grant: permit + sequence: 55 + protocol: tcp + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + sequence: 10 + log: 'true' + source: + any: true + +- block: + + - name: merge attributes of given acls. + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 8 + - result.changed == true + become: true + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acls: *id001 + + - assert: + that: + - result.changed == false + - result.commands|length == 0 + - ansible_facts.network_resources.acls|symmetric_difference(result.before) + == [] + + - name: merge attributes with an existing ace + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + log: true + ttl: + eq: 33 + source: + any: true + state: merged + + - assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'no 35' in result.commands" + - "'35 deny tcp any any ttl eq 33 log' in result.commands" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/overridden.yaml new file mode 100644 index 00000000..0114000b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/overridden.yaml @@ -0,0 +1,81 @@ +--- +- debug: + msg: Start eos_acls merged integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 10 + grant: permit + protocol: ospf + source: + any: true + destination: + any: true + log: true + +- block: + + - name: overriden attributes with given acls. + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - grant: permit + sequence: 10 + protocol: ospf + source: + any: true + destination: + any: true + log: true + state: overridden + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 7 + - result.changed == true + - "'ip access-list test1' in result.commands" + - "'10 permit ospf any any log' in result.commands" + - ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] + become: true + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acls: *id001 + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.changed == false + - result.commands|length == 0 + - ansible_facts.network_resources.acls|symmetric_difference(result.before) + == [] + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/parsed.yaml new file mode 100644 index 00000000..40a4b76f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/parsed.yaml @@ -0,0 +1,30 @@ +--- +- debug: + msg: START eos_acls parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _parsed_cfg.yaml + +- name: Gather acls facts + become: true + register: acls_facts + arista.eos.eos_facts: + gather_subset: + - default + gather_network_resources: + - acls + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_acls: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - ansible_facts.network_resources.acls|symmetric_difference(result.parsed) + == [] + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rendered.yaml new file mode 100644 index 00000000..6f36239e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rendered.yaml @@ -0,0 +1,89 @@ +--- +- debug: + msg: START eos_acls rendered integration tests on connection={{ ansible_connection + }} + +- block: + + - name: Structure provided configuration into device specific commands + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: rendered + + - name: Assert that correct set of commands were generated + vars: + lines: + - ip access-list test1 + - 35 deny tcp 20.0.0.0/8 any log + - remark Run by ansible + - permit tcp any any + - ip access-list test4 + - permit tcp any eq smtp any eq www ttl eq 55 + - ipv6 access-list standard test2 + - permit any log + assert: + that: + - "{{ lines | symmetric_difference(result['rendered']) |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + arista.eos.eos_acls: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/replaced.yaml new file mode 100644 index 00000000..153985f6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/replaced.yaml @@ -0,0 +1,109 @@ +--- +- debug: + msg: Start eos_acls replaced integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 10 + grant: permit + protocol: ospf + source: + any: true + destination: + any: true + log: true + + - name: test4 + aces: + + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + sequence: 10 + log: 'true' + source: + any: true + +- block: + + - name: replace attributes with given acls. + become: true + register: result + arista.eos.eos_acls: &id001 + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - grant: permit + sequence: 10 + protocol: ospf + source: + any: true + destination: + any: true + log: true + state: replaced + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.commands|length == 5 + - result.changed == true + - ansible_facts.network_resources.acls|symmetric_difference(result.after) + == [] + become: true + + - name: Idempotency check + become: true + register: result + arista.eos.eos_acls: *id001 + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - result.changed == false + - result.commands|length == 0 + - ansible_facts.network_resources.acls|symmetric_difference(result.before) + == [] + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rtt.yaml new file mode 100644 index 00000000..84114c68 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/tests/common/rtt.yaml @@ -0,0 +1,118 @@ +--- +- debug: + msg: Start eos_acls round trip integration tests ansible_connection={{ ansible_connection + }} + +- block: + + - name: merge attributes of given acls(apply base config). + become: true + register: base_config + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test1 + aces: + + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + + - remark: Run by ansible + + - grant: permit + protocol: '6' + source: + any: true + destination: + any: true + + - name: test4 + aces: + + - grant: permit + source: + any: true + port_protocol: + eq: '25' + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + + - afi: ipv6 + acls: + + - name: test2 + standard: true + aces: + + - grant: permit + log: 'true' + source: + any: true + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: acls + + - assert: + that: + - base_config.commands|length == 8 + - base_config.changed == true + - ansible_facts.network_resources.acls|symmetric_difference(base_config.after) + == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_acls: + config: + + - afi: ipv4 + acls: + + - name: test3 + aces: + + - sequence: 100 + grant: permit + protocol: icmp + source: + any: true + destination: + any: true + log: true + + - name: Assert that changes were applied + assert: + that: + - "{{ round_trip['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_acls: + config: "{{ ansible_facts['network_resources']['acls'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/vars/main.yaml new file mode 100644 index 00000000..53447982 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_acls/vars/main.yaml @@ -0,0 +1,109 @@ +--- +round_trip: + after: + - afi: ipv4 + acls: + - name: test1 + aces: + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + - remark: Run by ansible + sequence: 45 + - grant: permit + sequence: 55 + protocol: tcp + source: + any: true + destination: + any: true + - name: test3 + aces: + - sequence: 100 + grant: permit + protocol: icmp + source: + any: true + destination: + any: true + log: true + - name: test4 + aces: + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + - afi: ipv6 + acls: + - name: test2 + standard: true + aces: + - grant: permit + sequence: 10 + log: true + source: + any: true + commands: + - ip access-list test3 + - 100 permit icmp any any log +base_config: + after: + - afi: ipv4 + acls: + - name: test1 + aces: + - sequence: 35 + grant: deny + protocol: tcp + source: + subnet_address: 20.0.0.0/8 + destination: + any: true + log: true + - remark: Run by ansible + sequence: 45 + - grant: permit + sequence: 55 + protocol: tcp + source: + any: true + destination: + any: true + - name: test4 + aces: + - grant: permit + sequence: 10 + source: + any: true + port_protocol: + eq: smtp + destination: + any: true + port_protocol: + eq: www + protocol: tcp + ttl: + eq: '55' + - afi: ipv6 + acls: + - name: test2 + standard: true + aces: + - grant: permit + log: 'true' + source: + any: true diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-login.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-login.yaml new file mode 100644 index 00000000..34d500f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-login.yaml @@ -0,0 +1,56 @@ +--- +- debug: msg="START cli/basic-login.yaml on connection={{ ansible_connection }}" + +- name: Remove previous login banner + become: true + arista.eos.eos_config: + lines: no banner login + +- name: Create login banner + become: true + register: result + arista.eos.eos_banner: &id001 + banner: login + text: "Junk login banner\n \nover multiple lines\n" + state: present + +- assert: + that: + - result.changed == true + - "'banner login' in result.commands[0]" + - "'ansible_1' in result.session_name" + +- name: Create login banner again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id001 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove login + become: true + register: result + arista.eos.eos_banner: &id002 + banner: login + state: absent + +- assert: + that: + - result.changed == true + - "'no banner login' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove login again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id002 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-motd.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-motd.yaml new file mode 100644 index 00000000..2108e1f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/basic-motd.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START cli/basic-motd.yaml on connection={{ ansible_connection }}" + +- name: Remove previous motd banner + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: Set motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner' in result.commands" + - "'that has a multiline' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Set motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == true + - "'no banner motd' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/net_banner.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/net_banner.yaml new file mode 100644 index 00000000..1789b6dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/cli/net_banner.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START eos cli/net_banner.yaml on connection={{ ansible_connection + }}" + +- name: Remove previous motd banner (setup) + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: create motd + become: true + register: result + ansible.netcommon.net_banner: + banner: motd + text: this is my motd banner configure by net_banner + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner configure by net_banner' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove previous motd banner (teardown) + become: true + arista.eos.eos_config: + lines: no banner motd + +- debug: msg="END eos cli/net_banner.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-login.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-login.yaml new file mode 100644 index 00000000..c3b64861 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-login.yaml @@ -0,0 +1,57 @@ +--- +- debug: msg="START eapi/basic-login.yaml on connection={{ ansible_connection }}" + +- name: Remove previous login banner + become: true + arista.eos.eos_config: + lines: no banner login + +- name: Create login banner + become: true + register: result + arista.eos.eos_banner: &id001 + banner: login + text: "this is my login banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == true + - "'banner login' in result.commands[0]" + - "'ansible_1' in result.session_name" + +- name: Create login banner again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id001 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove login + become: true + register: result + arista.eos.eos_banner: &id002 + banner: login + text: "this is my login banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == true + - "'no banner login' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove login again (idempotent) + become: true + register: result + arista.eos.eos_banner: *id002 + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-motd.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-motd.yaml new file mode 100644 index 00000000..d1027124 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/basic-motd.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START eapi/basic-motd.yaml on connection={{ ansible_connection }}" + +- name: Remove previous motd banner + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: Set motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner' in result.commands" + - "'that has a multiline' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Set motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Remove motd + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == true + - "'no banner motd' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove motd again (idempotent) + become: true + register: result + arista.eos.eos_banner: + banner: motd + text: "this is my motd banner\nthat has a multiline\nstring\n" + state: absent + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/net_banner.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/net_banner.yaml new file mode 100644 index 00000000..f59f9db9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_banner/tests/eapi/net_banner.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START eos eapi/net_banner.yaml on connection={{ ansible_connection + }}" + +- name: Remove previous motd banner (setup) + become: true + arista.eos.eos_config: + lines: no banner motd + +- name: create motd + become: true + register: result + ansible.netcommon.net_banner: + banner: motd + text: this is my motd banner configure by net_banner + state: present + +- assert: + that: + - result.changed == true + - "'this is my motd banner configure by net_banner' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove previous motd banner (teardown) + become: true + arista.eos.eos_config: + lines: no banner motd + +- debug: msg="END eos eapi/net_banner.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tests/cli/basic.yaml new file mode 100644 index 00000000..6e4aa52d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp/tests/cli/basic.yaml @@ -0,0 +1,410 @@ +--- +- debug: msg="START eos cli/eos_bgp.yaml on connection={{ ansible_connection }}" + +- name: Clear existing BGP config + become: true + ignore_errors: true + arista.eos.eos_bgp: &id011 + operation: delete + +- name: Configure BGP with AS 64496 and a router-id + become: true + register: result + arista.eos.eos_bgp: &id001 + operation: merge + config: + bgp_as: 64496 + router_id: 192.0.2.2 + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'router-id 192.0.2.2' in result.commands" + +- name: Configure BGP with AS 64496 and a router-id (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id001 + +- assert: + that: + - result.changed == false + +- name: Configure BGP neighbors + become: true + register: result + arista.eos.eos_bgp: &id002 + operation: merge + config: + bgp_as: 64496 + neighbors: + + - neighbor: 192.0.2.10 + remote_as: 64496 + description: IBGP_NBR_1 + ebgp_multihop: 100 + timers: + keepalive: 300 + holdtime: 360 + + - neighbor: 192.0.2.15 + remote_as: 64496 + description: IBGP_NBR_2 + ebgp_multihop: 150 + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'neighbor 192.0.2.10 remote-as 64496' in result.commands" + - "'neighbor 192.0.2.10 description IBGP_NBR_1' in result.commands" + - "'neighbor 192.0.2.10 ebgp-multihop 100' in result.commands" + - "'neighbor 192.0.2.10 timers 300 360' in result.commands" + - "'neighbor 192.0.2.15 remote-as 64496' in result.commands" + - "'neighbor 192.0.2.15 description IBGP_NBR_2' in result.commands" + - "'neighbor 192.0.2.15 ebgp-multihop 150' in result.commands" + +- name: Configure BGP neighbors (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id002 + +- assert: + that: + - result.changed == false + +- name: Configure BGP neighbors with operation replace + become: true + register: result + arista.eos.eos_bgp: &id003 + operation: replace + config: + bgp_as: 64496 + neighbors: + + - neighbor: 192.0.2.15 + remote_as: 64496 + description: IBGP_NBR_2 + ebgp_multihop: 150 + + - neighbor: 203.0.113.10 + remote_as: 64511 + description: EBGP_NBR_1 + +- assert: + that: + - result.changed == true + - "'neighbor 203.0.113.10 remote-as 64511' in result.commands" + - "'neighbor 203.0.113.10 description EBGP_NBR_1' in result.commands" + - "'no neighbor 192.0.2.10' in result.commands" + +- name: Configure BGP neighbors with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id003 + +- assert: + that: + - result.changed == false + +- name: Configure root-level networks for BGP + become: true + register: result + arista.eos.eos_bgp: &id004 + operation: merge + config: + bgp_as: 64496 + networks: + + - prefix: 203.0.113.0 + masklen: 27 + route_map: RMAP_1 + + - prefix: 203.0.113.32 + masklen: 27 + route_map: RMAP_2 + +- assert: + that: + - result.changed == True + - "'router bgp 64496' in result.commands" + - "'network 203.0.113.0/27 route-map RMAP_1' in result.commands" + - "'network 203.0.113.32/27 route-map RMAP_2' in result.commands" + +- name: Configure root-level networks for BGP (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id004 + +- assert: + that: + - result.changed == false + +- name: Configure root-level networks for BGP with operation replace + become: true + register: result + arista.eos.eos_bgp: &id005 + operation: replace + config: + bgp_as: 64496 + networks: + + - prefix: 203.0.113.0 + masklen: 27 + route_map: RMAP_1 + + - prefix: 198.51.100.16 + masklen: 28 + +- assert: + that: + - result.changed == True + - "'router bgp 64496' in result.commands" + - "'network 198.51.100.16/28' in result.commands" + - "'no network 203.0.113.32/27' in result.commands" + +- name: Configure root-level networks for BGP with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id005 + +- assert: + that: + - result.changed == false + +- name: Configure BGP route redistribute information + become: true + register: result + arista.eos.eos_bgp: &id006 + operation: merge + config: + bgp_as: 64496 + redistribute: + + - protocol: ospf + route_map: RMAP_1 + + - protocol: rip + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'redistribute ospf route-map RMAP_1' in result.commands" + - "'redistribute rip' in result.commands" + +- name: Configure BGP route redistribute information (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id006 + +- assert: + that: + - result.changed == false + +- name: Configure BGP route redistribute information with operation replace + become: true + register: result + arista.eos.eos_bgp: &id007 + operation: replace + config: + bgp_as: 64496 + redistribute: + + - protocol: ospf + route_map: RMAP_1 + + - protocol: static + route_map: RMAP_2 + +- assert: + that: + - result.changed == true + - "'redistribute static route-map RMAP_2' in result.commands" + - "'no redistribute rip' in result.commands" + +- name: Configure BGP route redistribute information with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id007 + +- assert: + that: + - result.changed == false + +- name: Configure BGP neighbors under address family mode + become: true + register: result + arista.eos.eos_bgp: &id008 + operation: merge + config: + bgp_as: 64496 + address_family: + + - afi: ipv4 + neighbors: + + - neighbor: 203.0.113.10 + activate: true + default_originate: true + + - neighbor: 192.0.2.15 + activate: true + graceful_restart: false + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'address-family ipv4' in result.commands" + - "'neighbor 203.0.113.10 activate' in result.commands" + - "'neighbor 203.0.113.10 default-originate' in result.commands" + - "'neighbor 192.0.2.15 activate' in result.commands" + - "'no neighbor 192.0.2.15 graceful-restart' in result.commands" + +- name: Configure BGP neighbors under address family mode (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id008 + +- assert: + that: + - result.changed == false + +- name: Configure networks under address family + become: true + register: result + arista.eos.eos_bgp: &id009 + operation: merge + config: + bgp_as: 64496 + address_family: + + - afi: ipv4 + networks: + + - prefix: 198.51.100.48 + masklen: 28 + route_map: RMAP_1 + + - prefix: 192.0.2.64 + masklen: 27 + + - prefix: 203.0.113.160 + masklen: 27 + route_map: RMAP_2 + + - afi: ipv6 + networks: + + - prefix: '2001:db8::' + masklen: 33 + +- assert: + that: + - result.changed == true + - "'router bgp 64496' in result.commands" + - "'address-family ipv4' in result.commands" + - "'network 198.51.100.48/28 route-map RMAP_1' in result.commands" + - "'network 192.0.2.64/27' in result.commands" + - "'network 203.0.113.160/27 route-map RMAP_2' in result.commands" + - "'address-family ipv6' in result.commands" + - "'network 2001:db8::/33' in result.commands" + +- name: Configure networks under address family (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id009 + +- assert: + that: + - result.changed == false + +- name: Configure networks under address family with operation replace + become: true + register: result + arista.eos.eos_bgp: &id010 + operation: replace + config: + bgp_as: 64496 + address_family: + + - afi: ipv4 + networks: + + - prefix: 198.51.100.80 + masklen: 28 + + - prefix: 192.0.2.64 + masklen: 27 + + - prefix: 203.0.113.192 + masklen: 27 + + - afi: ipv6 + networks: + + - prefix: '2001:db8:1000::' + masklen: 37 + +- assert: + that: + - result.changed == true + - '"router bgp 64496" in result.commands' + - '"address-family ipv4" in result.commands' + - '"network 198.51.100.80/28" in result.commands' + - '"network 203.0.113.192/27" in result.commands' + - '"no network 198.51.100.48/28" in result.commands' + - '"no network 203.0.113.160/27" in result.commands' + - '"address-family ipv6" in result.commands' + - '"network 2001:db8:1000::/37" in result.commands' + - '"no network 2001:db8::/33" in result.commands' + +- name: Configure networks under address family with operation replace (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id010 + +- assert: + that: + - result.changed == false + +- name: Override all the exisiting BGP config + become: true + register: result + arista.eos.eos_bgp: + operation: override + config: + bgp_as: 64497 + router_id: 192.0.2.10 + log_neighbor_changes: true + +- assert: + that: + - result.changed == true + - "'no router bgp 64496' in result.commands" + - "'router bgp 64497' in result.commands" + - "'router-id 192.0.2.10' in result.commands" + - "'bgp log-neighbor-changes' in result.commands" + +- name: Teardown + become: true + register: result + arista.eos.eos_bgp: *id011 + +- assert: + that: + - result.changed == true + - "'no router bgp 64497' in result.commands" + +- name: Teardown again (idempotent) + become: true + register: result + arista.eos.eos_bgp: *id011 + +- assert: + that: + - result.changed == false + +- debug: msg="END eos cli/eos_bgp.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/templates/populate.cfg new file mode 100644 index 00000000..a6a10d80 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/templates/populate.cfg @@ -0,0 +1,24 @@ +router bgp 65536 + neighbor n2 peer-group + neighbor n2 next-hop-unchanged + neighbor n2 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + ! + address-family ipv4 + bgp additional-paths receive + neighbor peer2 default-originate always + neighbor 192.0.2.1 activate + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + redistribute ospf3 match external + ! + vrf vrft + address-family ipv4 + bgp additional-paths receive + ! + address-family ipv6 + redistribute isis level-2 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_parsed.cfg new file mode 100644 index 00000000..a6a10d80 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_parsed.cfg @@ -0,0 +1,24 @@ +router bgp 65536 + neighbor n2 peer-group + neighbor n2 next-hop-unchanged + neighbor n2 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + ! + address-family ipv4 + bgp additional-paths receive + neighbor peer2 default-originate always + neighbor 192.0.2.1 activate + network 192.0.2.0/24 + network 203.0.113.0/24 route-map MAP01 + redistribute ospf3 match external + ! + vrf vrft + address-family ipv4 + bgp additional-paths receive + ! + address-family ipv6 + redistribute isis level-2 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_remove_config.yaml new file mode 100644 index 00000000..0d2ec11c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router bgp 65536" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/deleted.yaml new file mode 100644 index 00000000..5ca77031 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/deleted.yaml @@ -0,0 +1,46 @@ +--- +- debug: + msg: Start eos_bgp_address_family deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &deleted + config: + as_number: "65536" + address_family: + - afi: "ipv4" + - afi: "ipv6" + vrf: "vrft" + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_address_family + + - assert: + that: + - result.commands|length == 4 + - result.changed == true + - ansible_facts.network_resources.bgp_address_family == result.after + - result.after.address_family|symmetric_difference(deleted.after.address_family) == [] + - result.before.address_family|symmetric_difference(replaced.before.address_family) == [] + - result.commands|symmetric_difference(deleted.commands) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/empty_config.yaml new file mode 100644 index 00000000..66e0207f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/empty_config.yaml @@ -0,0 +1,64 @@ +--- +- debug: + msg: START eos_bgp_address_family empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: overridden + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_address_family: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/gathered.yaml new file mode 100644 index 00000000..b340b606 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_bgp_address_family gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_bgp_address_family: + config: + state: gathered + + - name: Assert + assert: + that: + - result.gathered == gathered.populate + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/merged.yaml new file mode 100644 index 00000000..e6b8dfd5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/merged.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: Start eos_bgp_address_family merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &merged + config: + as_number: "65536" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + vrf: "vrft" + + - assert: + that: + - result.commands|length == 17 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after.address_family|symmetric_difference(merged.after.address_family) == [] + - result.before == {} + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/overridden.yaml new file mode 100644 index 00000000..39733adc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/overridden.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: Start eos_bgp_address_family overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &overridden + state: overridden + config: + as_number: "65536" + address_family: + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - assert: + that: + - result.commands|length == 12 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after.address_family|symmetric_difference(overridden.after.address_family) == [] + - result.before.address_family|symmetric_difference(replaced.before.address_family) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *overridden + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/parsed.yaml new file mode 100644 index 00000000..9cf5f716 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_bgp_address_family_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_bgp_address_family: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed.address_family|symmetric_difference(replaced.before.address_family) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rendered.yaml new file mode 100644 index 00000000..cea72b9a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rendered.yaml @@ -0,0 +1,46 @@ +--- +- debug: + msg: Start eos_bgp_address_family rendered integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: render given bgp_address_family configuration as device commands + become: true + register: result + arista.eos.eos_bgp_address_family: + state: rendered + config: + as_number: "65536" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + vrf: "vrft" + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/replaced.yaml new file mode 100644 index 00000000..6fd53736 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/replaced.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: Start eos_bgp_address_family replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Replace given bgp_address_family configuration + become: true + register: result + arista.eos.eos_bgp_address_family: &replaced + state: replaced + config: + as_number: "65536" + address_family: + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + - afi: "ipv4" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - assert: + that: + - result.commands|length == 15 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after.address_family|symmetric_difference(replaced.after.address_family) == [] + - result.before.address_family|symmetric_difference(replaced.before.address_family) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_address_family: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rtt.yaml new file mode 100644 index 00000000..7bb961c7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/tests/common/rtt.yaml @@ -0,0 +1,83 @@ +--- +- debug: + msg: Start eos_bgp_address_family rtt integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_address_family configuration + become: true + register: baseconfig + arista.eos.eos_bgp_address_family: &merged + config: + as_number: "65536" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + vrf: "vrft" + + - assert: + that: + - baseconfig.commands|length == 17 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after.address_family|symmetric_difference(merged.after.address_family) == [] + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_address_family + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_bgp_address_family: + config: + as_number: "65536" + address_family: + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + - afi: "evpn" + graceful_restart: true + bgp_params: + additional_paths: "send" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_bgp_address_family: + config: "{{ ansible_facts['network_resources']['bgp_address_family'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/vars/main.yaml new file mode 100644 index 00000000..97d02b13 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_address_family/vars/main.yaml @@ -0,0 +1,185 @@ +--- +merged: + commands: + - router bgp 65536 + - address-family ipv4 + - redistribute ospf3 match external + - network 192.0.2.0/24 + - network 203.0.113.0/24 route-map MAP01 + - neighbor 192.0.2.1 activate + - exit + - address-family ipv6 + - neighbor peer2 default-originate always + - bgp additional-paths receive + - exit + - vrf vrft + - address-family ipv6 + - redistribute isis level-2 + - route-target export 33:11 + - exit + - exit + + after: + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "192.0.2.1" + activate: true + - afi: "ipv6" + bgp_params: + additional_paths: "receive" + neighbor: + - peer: "peer2" + default_originate: + always: true + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + mode: "export" + target: "33:11" + +deleted: + after: + address_family: + - afi: "ipv4" + vrf: "vrft" + bgp_params: + additional_paths: "receive" + + commands: + - router bgp 65536 + - no address-family ipv4 + - vrf vrft + - no address-family ipv6 + +replaced: + commands: + - router bgp 65536 + - vrf vrft + - address-family ipv4 + - redistribute ospf3 match external + - exit + - exit + - address-family ipv4 + - redistribute isis level-2 + - no redistribute ospf3 match external + - no network 192.0.2.0/24 + - no network 203.0.113.0/24 route-map MAP01 + - no neighbor peer2 default-originate always + - no neighbor 192.0.2.1 activate + - no bgp additional-paths receive + - exit + before: + address_family: + - afi: "ipv4" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + neighbor: + - peer: "peer2" + default_originate: + always: true + - peer: "192.0.2.1" + activate: true + bgp_params: + additional_paths: "receive" + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "isis" + isis_level: "level-2" + - afi: "ipv4" + vrf: "vrft" + bgp_params: + additional_paths: "receive" + after: + address_family: + - afi: "ipv4" + redistribute: + - protocol: "isis" + isis_level: "level-2" + - afi: "ipv6" + vrf: "vrft" + redistribute: + - protocol: "isis" + isis_level: "level-2" + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + +overridden: + commands: + - router bgp 65536 + - vrf vrft + - address-family ipv4 + - redistribute ospf3 match external + - exit + - exit + - address-family ipv6 + - redistribute isis level-2 + - exit + - no address-family ipv4 + - vrf vrft + - no address-family ipv6 + + after: + address_family: + - afi: "ipv4" + vrf: "vrft" + redistribute: + - protocol: "ospf3" + ospf_route: "external" + bgp_params: + additional_paths: "receive" + - afi: "ipv6" + redistribute: + - protocol: "isis" + isis_level: "level-2" + +gathered: + populate: + address_family: + - afi: "ipv4" + bgp_params: + additional_paths: "receive" + neighbor: + - default_originate: + always: true + peer: "peer2" + - activate: true + peer: "192.0.2.1" + network: + - address: "192.0.2.0/24" + - address: "203.0.113.0/24" + route_map: "MAP01" + redistribute: + - ospf_route: "external" + protocol: "ospf3" + - afi: "ipv4" + bgp_params: + additional_paths: "receive" + vrf: "vrft" + - afi: "ipv6" + redistribute: + - isis_level: "level-2" + protocol: "isis" + vrf: "vrft" + as_number: "65536" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate.cfg new file mode 100644 index 00000000..175a034b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate.cfg @@ -0,0 +1,22 @@ +router bgp 65536 + timers bgp 44 100 + ucmp link-bandwidth recursive + neighbor peer1 peer-group + neighbor peer1 send-community link-bandwidth divide ratio + neighbor peer1 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + aggregate-address 203.0.113.0/24 as-set summary-only + aggregate-address 192.0.2.0/24 attribute-map attrmap + redistribute ospf match nssa-external 2 + redistribute static + redistribute rip route-map MAP01 + ! + vlan-aware-bundle bundle1 bundle3 + ! + vrf vrf01 + route-target export 44:22 + default-metric 433 + network 6.6.6.0/24 route-map netmap1 + network 10.1.0.0/16 + redistribute isis level-2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate_af.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate_af.cfg new file mode 100644 index 00000000..2bc00601 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/templates/populate_af.cfg @@ -0,0 +1,4 @@ +router bgp 65536 + vrf vrf01 + address-family ipv4 + bgp additional-paths receive diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_parsed.cfg new file mode 100644 index 00000000..175a034b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_parsed.cfg @@ -0,0 +1,22 @@ +router bgp 65536 + timers bgp 44 100 + ucmp link-bandwidth recursive + neighbor peer1 peer-group + neighbor peer1 send-community link-bandwidth divide ratio + neighbor peer1 maximum-routes 12000 + neighbor peer2 peer-group + neighbor peer2 maximum-routes 12000 + aggregate-address 203.0.113.0/24 as-set summary-only + aggregate-address 192.0.2.0/24 attribute-map attrmap + redistribute ospf match nssa-external 2 + redistribute static + redistribute rip route-map MAP01 + ! + vlan-aware-bundle bundle1 bundle3 + ! + vrf vrf01 + route-target export 44:22 + default-metric 433 + network 6.6.6.0/24 route-map netmap1 + network 10.1.0.0/16 + redistribute isis level-2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate_af.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate_af.yaml new file mode 100644 index 00000000..04ab196a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_populate_af.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate_af.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_remove_config.yaml new file mode 100644 index 00000000..0d2ec11c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router bgp 65536" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/deleted.yaml new file mode 100644 index 00000000..db58a740 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/deleted.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: Start eos_bgp_global deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &deleted + config: + as_number: "65536" + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_global + + - assert: + that: + - result.commands|length == 15 + - result.changed == true + - "'no router bgp 65536' not in result.commands" + - ansible_facts.network_resources.bgp_global == result.after + - result.after == deleted.after + - result.before == populate.global + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/empty_config.yaml new file mode 100644 index 00000000..e5ca0e1b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/empty_config.yaml @@ -0,0 +1,52 @@ +--- +- debug: + msg: START eos_bgp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_bgp_global: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/gathered.yaml new file mode 100644 index 00000000..fd30b979 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_bgp_global gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_bgp_global: + config: + state: gathered + + - name: Assert + assert: + that: + - populate.global == result.gathered + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/merged.yaml new file mode 100644 index 00000000..9327987d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/merged.yaml @@ -0,0 +1,79 @@ +--- +- debug: + msg: Start eos_bgp_global merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &merged + config: + as_number: "65536" + aggregate_address: + - address: "203.0.113.0/24" + as_set: true + summary_only: true + - address: "192.0.2.0/24" + attribute_map: "attrmap" + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" + + - assert: + that: + - result.commands|length == 21 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after == populate.global + - result.before == {} + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/parsed.yaml new file mode 100644 index 00000000..2ec182ad --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_bgp_global_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_bgp_global: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed == populate.global diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/purged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/purged.yaml new file mode 100644 index 00000000..19bc3bb5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/purged.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: Start eos_bgp_global purged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Purge given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &purged + config: + as_number: "65536" + state: purged + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_global + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - "'no router bgp 65536' in result.commands" + - ansible_facts.network_resources.bgp_global == [] + - result.after == {} + - result.before == populate.global + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *purged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rendered.yaml new file mode 100644 index 00000000..85c120f3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rendered.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: Start eos_bgp_global rendered integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: Render given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &rendered + state: "rendered" + config: + as_number: "65536" + aggregate_address: + - address: "203.0.113.0/24" + as_set: true + summary_only: true + - address: "192.0.2.0/24" + attribute_map: "attrmap" + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/replaced.yaml new file mode 100644 index 00000000..4f2c4470 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/replaced.yaml @@ -0,0 +1,68 @@ +--- +- debug: + msg: Start eos_bgp_global replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given bgp_global configuration + become: true + register: result + arista.eos.eos_bgp_global: &replaced + state: "replaced" + config: + as_number: "65536" + vrfs: + - vrf: "vrf02" + redistribute: + - protocol: "isis" + isis_level: "level-2" + timers: + holdtime: 100 + keepalive: 44 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - assert: + that: + - result.commands|length == 22 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after == replaced.after + - result.before == populate.global + + - name: Idempotency check + become: true + register: result + arista.eos.eos_bgp_global: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + + - name: Configure address_family under vrf + become: true + arista.eos.eos_config: + src: populate_af.cfg + + - name: Replace in presence of address_family + become: true + ignore_errors: true + register: result + arista.eos.eos_bgp_global: *replaced + + - assert: + that: + - result.msg == 'Use the _bgp_address_family module to delete the address_family under vrf, before replacing/deleting the vrf.' + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rtt.yaml new file mode 100644 index 00000000..3e3a3433 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/tests/common/rtt.yaml @@ -0,0 +1,104 @@ +--- +- debug: + msg: Start eos_bgp_global rtt integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given bgp_global configuration + become: true + register: baseconfig + arista.eos.eos_bgp_global: &merged + config: + as_number: "65536" + aggregate_address: + - address: "203.0.113.0/24" + as_set: true + summary_only: true + - address: "192.0.2.0/24" + attribute_map: "attrmap" + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "6.6.6.0/24" + route_map: "netmap1" + - address: "10.1.0.0/16" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" + + - assert: + that: + - baseconfig.commands|length == 21 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after == populate.global + + - become: true + arista.eos.eos_facts: + gather_network_resources: bgp_global + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_bgp_global: + config: + as_number: "65536" + vrfs: + - vrf: "vrf01" + aggregate_address: + - address: "10.1.1.0/24" + as_set: true + summary_only: true + attribute_map: "attrmap" + default_metric: 433 + network: + - address: "4.1.1.0/24" + route_map: "netmap2" + redistribute: + - protocol: "isis" + isis_level: "level-2" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_bgp_global: + config: "{{ ansible_facts['network_resources']['bgp_global'] }}" + state: replaced + + - assert: + that: + - baseconfig.after == revert.after + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/vars/main.yaml new file mode 100644 index 00000000..10dfcd45 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_bgp_global/vars/main.yaml @@ -0,0 +1,118 @@ +--- +merged: + commands: + - router bgp 65536 + - vrf vrf01 + - redistribute isis level-2 + - network 6.6.6.0/24 route-map netmap1 + - network 10.1.0.0/16 + - default-metric 433 + - route-target export 44:22 + - exit + - neighbor peer1 maximum-routes 12000 + - neighbor peer1 peer-group + - neighbor peer1 send-community link-bandwidth divide ratio + - neighbor peer2 maximum-routes 12000 + - neighbor peer2 peer-group + - redistribute ospf match nssa-external 2 + - redistribute static + - redistribute rip route-map MAP01 + - aggregate-address 203.0.113.0/24 as-set summary-only + - aggregate-address 192.0.2.0/24 attribute-map attrmap + - timers bgp 44 100 + - ucmp link-bandwidth recursive + - vlan-aware-bundle bundle1 bundle3 + +deleted: + after: + as_number: "65536" + +replaced: + commands: + - router bgp 65536 + - vrf vrf02 + - redistribute isis level-2 + - timers bgp 44 100 + - exit + - no vrf vrf01 + - no neighbor peer1 peer-group + - no neighbor peer1 send-community link-bandwidth divide ratio + - no neighbor peer1 maximum-routes 12000 + - no neighbor peer2 peer-group + - no neighbor peer2 maximum-routes 12000 + - redistribute isis level-2 + - no redistribute ospf match nssa-external 2 + - no redistribute static + - no redistribute rip route-map MAP01 + - network 6.6.6.0/24 route-map netmap1 + - network 10.1.0.0/16 + - no aggregate-address 203.0.113.0/24 as-set summary-only + - no aggregate-address 192.0.2.0/24 attribute-map attrmap + - no timers bgp 44 100 + - no ucmp link-bandwidth recursive + - no vlan-aware-bundle bundle1 bundle3 + after: + as_number: "65536" + redistribute: + - protocol: "isis" + isis_level: "level-2" + network: + - address: "10.1.0.0/16" + - address: "6.6.6.0/24" + route_map: "netmap1" + vrfs: + - vrf: "vrf02" + timers: + holdtime: 100 + keepalive: 44 + redistribute: + - protocol: "isis" + isis_level: "level-2" +populate: + global: + as_number: "65536" + aggregate_address: + - address: "192.0.2.0/24" + attribute_map: "attrmap" + - address: "203.0.113.0/24" + as_set: true + summary_only: true + neighbor: + - maximum_received_routes: + count: 12000 + peer: "peer1" + peer_group: "peer1" + send_community: + community_attribute: "link-bandwidth" + divide: "ratio" + link_bandwidth_attribute: "divide" + - maximum_received_routes: + count: 12000 + peer: "peer2" + peer_group: "peer2" + redistribute: + - protocol: "ospf" + ospf_route: "nssa_external_2" + - protocol: "static" + - protocol: "rip" + route_map: "MAP01" + timers: + holdtime: 100 + keepalive: 44 + ucmp: + link_bandwidth: + mode: "recursive" + vlan_aware_bundle: "bundle1 bundle3" + vrfs: + - vrf: "vrf01" + default_metric: 433 + network: + - address: "10.1.0.0/16" + - address: "6.6.6.0/24" + route_map: "netmap1" + redistribute: + - protocol: "isis" + isis_level: "level-2" + route_target: + action: "export" + target: "44:22" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/bad_operator.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/bad_operator.yaml new file mode 100644 index 00000000..d9559736 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" + +- name: test bad operator + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name foo Management + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/cli_command.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/cli_command.yaml new file mode 100644 index 00000000..9cf021d7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/cli_command.yaml @@ -0,0 +1,65 @@ +--- +- debug: + msg: START cli/cli_command.yaml on connection={{ ansible_connection }} + +- block: + + - name: get output for single command + register: result + ansible.netcommon.cli_command: + command: show version + + - assert: + that: + - result.changed == false + - result.stdout is defined + + - name: send invalid command + register: result + ignore_errors: true + ansible.netcommon.cli_command: + command: show foo + + - assert: + that: + - result.failed == true + - result.msg is defined + + - name: get output in JSON format + register: result + ansible.netcommon.cli_command: + command: show version | json + + - assert: + that: + - result.changed == false + - result.stdout is defined + - result.json is defined + + - name: command that does require become (should fail) + become: false + ignore_errors: true + register: result + ansible.netcommon.cli_command: + command: show running-config + + - assert: + that: + - result.failed == true + - '"privileged mode required" in result.msg' + when: ansible_connection == 'ansible.netcommon.network_cli' + +- block: + + - name: test failure for local connection + register: result + ansible.netcommon.cli_command: + command: show version + + - assert: + that: + - result.failed == true + - "'Connection type local is not valid for this module' in result.msg" + when: ansible_connection == 'local' + +- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/contains.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/contains.yaml new file mode 100644 index 00000000..faabb1c8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/contains.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[0] contains EOS + - result[1].interfaces.Management1.name contains Manage + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/equal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/equal.yaml new file mode 100644 index 00000000..ab1808a2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/equal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/equal.yaml on connection={{ ansible_connection }}" + +- name: test eq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name eq Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test == operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name == Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/equal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthan.yaml new file mode 100644 index 00000000..933fe335 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/greaterthan.yaml on connection={{ ansible_connection }}" + +- name: test gt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu gt 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test > operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu > 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/greaterthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml new file mode 100644 index 00000000..64b9869e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START cli/greaterthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test ge operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu ge 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test >= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu >= 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/greaterthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/invalid.yaml new file mode 100644 index 00000000..7fc9fb77 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/invalid.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" + +- name: run invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- name: run commands that include invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthan.yaml new file mode 100644 index 00000000..0cdf3baa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/lessthan.yaml on connection={{ ansible_connection }}" + +- name: test lt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu lt 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test < operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu < 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/lessthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthanorequal.yaml new file mode 100644 index 00000000..dc650186 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/lessthanorequal.yaml @@ -0,0 +1,33 @@ +--- +- debug: msg="START cli/lessthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test le operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu le 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test <= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu <= 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/lessthanorequal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/notequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/notequal.yaml new file mode 100644 index 00000000..1c2e023c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/notequal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli/notequal.yaml on connection={{ ansible_connection }}" + +- name: test neq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name neq Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test != operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name != Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/notequal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/output.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/output.yaml new file mode 100644 index 00000000..88c7e8da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/output.yaml @@ -0,0 +1,27 @@ +--- +- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" + +- name: get output for single command + register: result + arista.eos.eos_command: + commands: + - show version + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: get output for multiple commands + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/timeout.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/timeout.yaml new file mode 100644 index 00000000..49c4131f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/cli/timeout.yaml @@ -0,0 +1,18 @@ +--- +- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" + +- name: test bad condition + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/bad_operator.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/bad_operator.yaml new file mode 100644 index 00000000..cc8d0066 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START eapi/bad_operator.yaml" + +- name: test bad operator + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 + wait_for: + - result[1].interfaces.Management1.name foo Management + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END eapi/bad_operator.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/contains.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/contains.yaml new file mode 100644 index 00000000..5849bbd8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/contains.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START eapi/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[0] contains EOS + - result[1].interfaces.Management1.name contains Manage + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/contains.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/equal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/equal.yaml new file mode 100644 index 00000000..a3a4809e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/equal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/equal.yaml on connection={{ ansible_connection }}" + +- name: test eq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name eq Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test == operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name == Management1 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/equal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthan.yaml new file mode 100644 index 00000000..622eddab --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/greaterthan.yaml on connection={{ ansible_connection }}" + +- name: test gt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu gt 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test > operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu > 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/greaterthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml new file mode 100644 index 00000000..e4a66cc8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eapi/greaterthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test ge operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu ge 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test >= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu >= 0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/greaterthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/invalid.yaml new file mode 100644 index 00000000..f105f9ef --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/invalid.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START eapi/invalid.yaml" + +- name: run invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- name: run commands that include invalid command + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + - show foo + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END eapi/invalid.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthan.yaml new file mode 100644 index 00000000..79be9691 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthan.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/lessthan.yaml on connection={{ ansible_connection }}" + +- name: test lt operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu lt 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test < operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu < 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/lessthan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml new file mode 100644 index 00000000..e6dbde5f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eapi/lessthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: test le operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu le 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test <= operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.mtu <= 1600 + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/lessthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/notequal.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/notequal.yaml new file mode 100644 index 00000000..82d5f101 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/notequal.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START eapi/notequal.yaml on connection={{ ansible_connection }}" + +- name: test neq operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name neq Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: test != operator + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces Management1 | json + wait_for: + - result[1].interfaces.Management1.name != Ethernet + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/notequal.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/output.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/output.yaml new file mode 100644 index 00000000..cbfdacb5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/output.yaml @@ -0,0 +1,27 @@ +--- +- debug: msg="START eapi/output.yaml" + +- name: get output for single command + register: result + arista.eos.eos_command: + commands: + - show version + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- name: get output for multiple commands + register: result + arista.eos.eos_command: + commands: + - show version + - show interfaces + +- assert: + that: + - result.changed == false + - result.stdout is defined + +- debug: msg="END eapi/output.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/timeout.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/timeout.yaml new file mode 100644 index 00000000..80992734 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_command/tests/eapi/timeout.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START eapi/timeout.yaml" + +- name: test bad condition + register: result + ignore_errors: true + arista.eos.eos_command: + commands: + - show version + wait_for: + - result[0].version foo 4.15 + retries: 1 + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END eapi/timeout.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/config.txt b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/config.txt new file mode 100644 index 00000000..fba5bde0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/config.txt @@ -0,0 +1,21 @@ +! +! boot system flash:/vEOS-lab.swi +! +transceiver qsfp default-mode 4x10G +! +hostname localhost +! +spanning-tree mode mstp +! +no aaa root +! +interface Ethernet1 +! +interface Ethernet2 +! +! +no ip routing +! +! +end + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli_config.yaml new file mode 100644 index 00000000..98bd1fce --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/cli_config.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli_config test cases + find: + 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=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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/main.yaml new file mode 100644 index 00000000..3986c294 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/main.yaml @@ -0,0 +1,15 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: cli_config.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- 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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/cmds.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/cmds.j2 new file mode 100644 index 00000000..c68cce8e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/cmds.j2 @@ -0,0 +1,4 @@ +ip access-list test + 10 permit ip host 192.168.0.2 host 192.168.0.1 + 20 permit ip host 192.168.0.1 host 192.168.0.2 +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/config.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/config.j2 new file mode 100644 index 00000000..82a61b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/basic/config.j2 @@ -0,0 +1,4 @@ +interface Ethernet2 + description this is a test + shutdown + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/config.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/config.j2 new file mode 100644 index 00000000..8ff8f305 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/config.j2 @@ -0,0 +1,3 @@ +interface Ethernet2 + description this is a test + no shutdown diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/test.j2 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/test.j2 new file mode 100644 index 00000000..82a61b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/templates/defaults/test.j2 @@ -0,0 +1,4 @@ +interface Ethernet2 + description this is a test + shutdown + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/backup.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/backup.yaml new file mode 100644 index 00000000..19fc53dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/backup.yaml @@ -0,0 +1,133 @@ +--- +- debug: msg="START cli/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: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- 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: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + backup: true + +- assert: + that: + - result.changed == true + - result.updates is defined + +- 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 + become: true + register: result + arista.eos.eos_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: + 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 + become: true + register: result + arista.eos.eos_config: + backup: true + backup_options: + filename: backup.cfg + +- 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 + become: true + register: result + arista.eos.eos_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: + 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/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/check_mode.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/check_mode.yaml new file mode 100644 index 00000000..3a07636c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/check_mode.yaml @@ -0,0 +1,93 @@ +--- +- debug: + msg: START cli/check_mode.yaml on connection={{ ansible_connection }} + +- name: invalid configuration in check mode + become: true + check_mode: 1 + vars: + ansible_eos_use_sessions: 1 + register: result + ignore_errors: true + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.256 + parents: interface Loopback911 + +- assert: + that: + - result.msg is defined + - result.failed == true + - "'Invalid input' in result.msg" + +- name: valid configuration in check mode + become: true + check_mode: true + register: config + arista.eos.eos_config: + before: + - no ip access-list test + src: basic/cmds.j2 + +- name: check if session is removed + become: true + register: result + arista.eos.eos_command: + commands: + - show configuration sessions | json + +- assert: + that: + - config.session not in result.stdout[0].sessions + +- name: configuration in check mode + no config session + become: true + check_mode: 1 + vars: + ansible_eos_use_sessions: 0 + register: result + ignore_errors: true + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.254 + parents: interface Loopback911 + +- assert: + that: + - result.failed == true + +- name: invalid configuration in check mode + no config session + become: true + check_mode: 1 + vars: + ansible_eos_use_sessions: 0 + register: result + ignore_errors: true + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.256 + parents: interface Loopback911 + diff_against: running + +- assert: + that: + - result.changed == true + +- name: valid configuration in check mode + no config session + become: true + check_mode: true + register: result + vars: + ansible_eos_use_sessions: 0 + arista.eos.eos_config: + lines: + - ip address 119.31.1.1 255.255.255.255 + parents: interface Loopback911 + diff_against: running + +- assert: + that: + - result.changed == true + - "'session' not in result" + +- debug: msg="END cli/check_mode.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/config.yaml new file mode 100644 index 00000000..8f9137b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/config.yaml @@ -0,0 +1,51 @@ +--- +- debug: msg="START cli/config.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- name: get current running-config + become: true + register: config + arista.eos.eos_command: + commands: show running-config + +- name: configure hostname + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + config: '{{ config.stdout[0] }}' + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + +- name: get current running-config + become: true + register: config + arista.eos.eos_command: + commands: show running-config + +- name: configure hostname again + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + config: '{{ config.stdout[0] }}' + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/defaults.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/defaults.yaml new file mode 100644 index 00000000..98aae1f2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/defaults.yaml @@ -0,0 +1,42 @@ +--- +- debug: msg="START cli/defaults.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END cli/defaults.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/save.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/save.yaml new file mode 100644 index 00000000..13340695 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/save.yaml @@ -0,0 +1,31 @@ +--- +- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: save config always + become: true + register: result + arista.eos.eos_config: &id001 + save_when: always + +- assert: &id002 + that: + - result.changed == true + +- name: save should always run + become: true + register: result + arista.eos.eos_config: *id001 + +- assert: *id002 + +- debug: msg="END cli/save.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_basic.yaml new file mode 100644 index 00000000..75f8dff3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_basic.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/src_basic.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + defaults: true + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_invalid.yaml new file mode 100644 index 00000000..1ac9ef5b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_invalid.yaml @@ -0,0 +1,17 @@ +--- +- debug: msg="START cli/src_invalid.yaml on connection={{ ansible_connection }}" + +- name: configure with invalid src + become: true + register: result + ignore_errors: true + arista.eos.eos_config: + src: basic/foobar.j2 + +- assert: + that: + - result.changed == false + - result.failed == true + - result.msg == 'path specified in src not found' + +- debug: msg="END cli/src_invalid.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_match_none.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_match_none.yaml new file mode 100644 index 00000000..a229d1e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/src_match_none.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START cli/src_match_none.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + match: none + +- assert: + that: + - result.changed == true + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + defaults: true + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END cli/src_match_none.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel.yaml new file mode 100644 index 00000000..78d65999 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START cli/sublevel.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: no vlan 10 + match: none + +- name: configure sub level command + become: true + register: result + arista.eos.eos_config: + lines: name test + parents: vlan 10 + +- assert: + that: + - result.changed == true + - "'vlan 10' in result.updates" + - "'name test' in result.updates" + +- name: configure sub level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: name test + parents: vlan 10 + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no vlan 10 + match: none + +- debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_block.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_block.yaml new file mode 100644 index 00000000..959d0ba1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_block.yaml @@ -0,0 +1,62 @@ +--- +- debug: msg="START cli/sublevel_block.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using block resplace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + +- name: check sub level command using block replace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_exact.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_exact.yaml new file mode 100644 index 00000000..7ae4fb33 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_exact.yaml @@ -0,0 +1,66 @@ +--- +- debug: msg="START cli/sublevel_exact.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: exact + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + match: exact + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict.yaml new file mode 100644 index 00000000..cb399707 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict.yaml @@ -0,0 +1,66 @@ +--- +- debug: msg="START cli/sublevel_strict.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'30 permit ip host 192.0.2.2 any log' in result.updates" + - "'20 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + match: strict + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict_mul_parents.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict_mul_parents.yaml new file mode 100644 index 00000000..b9ccf19b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/sublevel_strict_mul_parents.yaml @@ -0,0 +1,86 @@ +--- +- debug: + msg: START cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection + }} + +- name: setup + become: true + arista.eos.eos_config: + lines: + - class-map type qos match-any c1 + - match ip access-group 10 + - policy-map type qos p1 + - class c1 + before: + - no policy-map type qos p1 + - no class-map type qos match-any c1 + match: none + +- block: + + - name: configure sub level command using strict match + register: result + become: true + arista.eos.eos_config: + lines: + - set cos 1 + - set dscp 62 + parents: + - policy-map type qos p1 + - class c1 + match: strict + diff_against: running + + - assert: + that: + - result.changed == true + - "'set cos 1' in result.updates" + - "'set dscp 62' in result.updates" + + - name: change sub level command order and config with strict match + register: result + become: true + arista.eos.eos_config: + lines: + - set dscp 62 + - set cos 1 + parents: + - policy-map type qos p1 + - class c1 + match: strict + diff_against: running + + - assert: + that: + - result.changed == true + - "'set cos 1' in result.updates" + - "'set dscp 62' in result.updates" + + - name: Config sub level command with strict match (Idempotency) + register: result + become: true + arista.eos.eos_config: + lines: + - set cos 1 + - set dscp 62 + parents: + - policy-map type qos p1 + - class c1 + match: strict + diff_against: running + + - assert: + that: + - result.changed == false + always: + + - name: teardown + become: true + arista.eos.eos_config: + lines: + - no policy-map type qos p1 + - no class-map type qos match-any c1 + match: none + +- debug: msg="END cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel.yaml new file mode 100644 index 00000000..ae92eba3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_after.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_after.yaml new file mode 100644 index 00000000..fe1920f6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_after.yaml @@ -0,0 +1,45 @@ +--- +- debug: msg="START cli/toplevel_after.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_before.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_before.yaml new file mode 100644 index 00000000..0f48a190 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli/toplevel_before.yaml @@ -0,0 +1,45 @@ +--- +- debug: msg="START cli/toplevel_before.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_backup.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_backup.yaml new file mode 100644 index 00000000..3880a040 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_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 + become: true + register: result + ansible.netcommon.cli_config: + backup: true + +- 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 + 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 }}' + +- 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 + become: true + 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: + 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 + 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 + +- 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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_basic.yaml new file mode 100644 index 00000000..0dd90785 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/cli_config/cli_basic.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + ansible.netcommon.cli_config: &id002 + config: "interface Ethernet2\nno description\nno shutdown\n" + +- name: configure device with config + register: result + become: true + ansible.netcommon.cli_config: &id001 + config: "{{ lookup('template', 'basic/config.j2') }}" + +- assert: + that: + - result.changed == true + +- name: Idempotence + register: result + become: true + ansible.netcommon.cli_config: *id001 + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + ansible.netcommon.cli_config: *id002 + +- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/backup.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/backup.yaml new file mode 100644 index 00000000..6786e02a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/backup.yaml @@ -0,0 +1,50 @@ +--- +- debug: msg="START eapi/backup.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- 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: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + backup: true + +- assert: + that: + - result.changed == true + - result.updates is defined + +- 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 + +- debug: msg="END eapi/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/defaults.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/defaults.yaml new file mode 100644 index 00000000..fee19874 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/defaults.yaml @@ -0,0 +1,42 @@ +--- +- debug: msg="START eapi/defaults.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with defaults included + become: true + register: result + arista.eos.eos_config: + src: defaults/config.j2 + defaults: true + +- debug: var=result + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END eapi/defaults.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/save.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/save.yaml new file mode 100644 index 00000000..5ac37f4c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/save.yaml @@ -0,0 +1,31 @@ +--- +- debug: msg="START eapi/save.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: save config always + become: true + register: result + arista.eos.eos_config: &id001 + save_when: always + +- assert: &id002 + that: + - result.changed == true + +- name: save should always run + become: true + register: result + arista.eos.eos_config: *id001 + +- assert: *id002 + +- debug: msg="END eapi/save.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_basic.yaml new file mode 100644 index 00000000..9f64858b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_basic.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START eapi/src_basic.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END eapi/src_basic.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_invalid.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_invalid.yaml new file mode 100644 index 00000000..1300041a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_invalid.yaml @@ -0,0 +1,16 @@ +--- +- debug: msg="START eapi/src_invalid.yaml" + +- name: configure with invalid src + register: result + ignore_errors: true + arista.eos.eos_config: + src: basic/foobar.j2 + +- assert: + that: + - result.changed == false + - result.failed == true + - result.msg == 'path specified in src not found' + +- debug: msg="END eapi/src_invalid.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_match_none.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_match_none.yaml new file mode 100644 index 00000000..e0e3e8d3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/src_match_none.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START eapi/src_match_none.yaml" + +- name: setup + become: true + arista.eos.eos_config: + commands: + - no description + - no shutdown + parents: + - interface Ethernet2 + match: none + +- name: configure device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + match: none + +- assert: + that: + - result.changed == true + - result.updates is defined + +- name: check device with config + become: true + register: result + arista.eos.eos_config: + src: basic/config.j2 + +- assert: + that: + - result.changed == false + - result.updates is not defined + +- debug: msg="END eapi/src_match_none.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel.yaml new file mode 100644 index 00000000..ffe51858 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel.yaml @@ -0,0 +1,41 @@ +--- +- debug: msg="START eapi/sublevel.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- name: configure sub level command + become: true + register: result + arista.eos.eos_config: + lines: 10 permit ip any any log + parents: ip access-list test + after: exit + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip any any log' in result.updates" + +- name: configure sub level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: 10 permit ip any any log + parents: ip access-list test + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_block.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_block.yaml new file mode 100644 index 00000000..c0d87a19 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_block.yaml @@ -0,0 +1,59 @@ +--- +- debug: msg="START eapi/sublevel_block.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + match: none + +- name: configure sub level command using block resplace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + after: end + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + +- name: check sub level command using block replace + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel_block.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml new file mode 100644 index 00000000..296c67e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml @@ -0,0 +1,65 @@ +--- +- debug: msg="START eapi/sublevel_exact.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: none + +- name: configure sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: exact + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using exact match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + before: no ip access-list test + parents: ip access-list test + match: exact + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel_exact.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml new file mode 100644 index 00000000..092ad1d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START eapi/sublevel_strict.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + - 50 permit ip host 192.0.2.5 any log + parents: ip access-list test + before: no ip access-list test + match: none + +- name: configure sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + replace: block + +- assert: + that: + - result.changed == true + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'30 permit ip host 192.0.2.2 any log' in result.updates" + - "'20 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + - "'50 permit ip host 192.0.2.5 any log' not in result.updates" + +- name: check sub level command using strict match + become: true + register: result + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.3 any log + - 30 permit ip host 192.0.2.2 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + match: strict + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip access-list test + match: none + +- debug: msg="END eapi/sublevel_strict.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel.yaml new file mode 100644 index 00000000..85d6c5ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START eapi/toplevel.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + +- name: configure top level command idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END eapi/toplevel.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_after.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_after.yaml new file mode 100644 index 00000000..feae7e37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_after.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START eapi/toplevel_after.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + after: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END eapi/toplevel_after.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_before.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_before.yaml new file mode 100644 index 00000000..04d956b3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/eapi/toplevel_before.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START eapi/toplevel_before.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - snmp-server contact ansible + - hostname {{ inventory_hostname_short }} + match: none + +- name: configure top level command with before + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact bar + +- assert: + that: + - result.changed == true + - "'hostname foo' in result.updates" + - "'snmp-server contact bar' in result.updates" + +- name: configure top level command with before idempotent check + become: true + register: result + arista.eos.eos_config: + lines: hostname foo + before: snmp-server contact foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no snmp-server contact + - hostname {{ inventory_hostname_short }} + match: none + +- debug: msg="END eapi/toplevel_before.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..7eb3ef68 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_config/tests/redirection/cli/shortname.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START redirection/shortname.yaml on connection={{ ansible_connection }}" + +- name: Use src with module alias + register: result + become: true + arista.eos.config: + src: basic/config.j2 + +- assert: + that: + # make sure that the template content was read and not the path + - result.failed == false + +- name: use module alias to take configuration backup + register: result + become: true + arista.eos.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 redirection/shortname.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/badtransport.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/badtransport.yaml new file mode 100644 index 00000000..c3aa51c5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/badtransport.yaml @@ -0,0 +1,16 @@ +--- +- debug: msg="START CLI/BADTRANSPORT.YAML" + +- block: + + - name: Expect transport other than cli to fail + register: eos_eapi_output + ignore_errors: true + arista.eos.eos_eapi: + provider: '{{ eapi }}' + + - assert: + that: eos_eapi_output.failed == true + when: ansible_connection == 'local' + +- debug: msg="START CLI/BADTRANSPORT.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/config.yaml new file mode 100644 index 00000000..5954853c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/config.yaml @@ -0,0 +1,49 @@ +--- +- debug: msg="START cli/config.yaml on connection={{ ansible_connection }}" + +- name: Setup + become: true + arista.eos.eos_config: + lines: no management api http-commands + match: none + provider: '{{ cli }}' + +- name: Get running-config + become: true + register: config + arista.eos.eos_command: + commands: show running-config + provider: '{{ cli }}' + +- name: Set config + become: true + register: config + arista.eos.eos_eapi: + config: '{{ config.stdout[0] }}' + provider: '{{ cli }}' + +- name: Ensure that this triggered a change + assert: + that: + - config.changed == true + +- name: Get running-config again + become: true + register: config + arista.eos.eos_command: + commands: show running-config + provider: '{{ cli }}' + +- name: Set config + become: true + register: config + arista.eos.eos_eapi: + config: '{{ config.stdout[0] }}' + provider: '{{ cli }}' + +- name: Idempotency check + assert: + that: + - config.changed == false + +- debug: msg="END cli/config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/configure.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/configure.yaml new file mode 100644 index 00000000..868aee05 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/configure.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START CLI/CONFIGURE.YAML" + +- name: Change endpoint ports + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: false + http_port: 81 + https_port: 4443 + enable_local_http: true + enable_https: true + local_http_port: 8181 + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- name: Expect endpoint ports to be set + assert: + that: + - http_config.stdout[0].httpServer.port == 80 + - http_config.stdout[0].httpsServer.port == 4443 + - http_config.stdout[0].localHttpServer.port == 8181 + +- name: Change endpoint ports again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + http_port: 80 + https_port: 4443 + enable_local_http: true + local_http_port: 8181 + provider: '{{ cli }}' + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="END CLI/CONFIGURE.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/off.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/off.yaml new file mode 100644 index 00000000..85b386bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/off.yaml @@ -0,0 +1,50 @@ +--- +- debug: msg="START CLI/OFF.YAML" + +- name: Turn all endpoints off + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: false + enable_https: false + enable_local_http: false + enable_socket: false + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + +- name: Expect all EAPI endpoints to be in off state + assert: + that: + - http_config.stdout[0].httpServer.running == false + - http_config.stdout[0].httpsServer.running == false + - http_config.stdout[0].localHttpServer.running == false + - http_config.stdout[0].unixSocketServer.running == false + +- name: Turn all endpoints off again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: false + enable_https: false + enable_local_http: false + enable_socket: false + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="END CLI/OFF.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/on.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/on.yaml new file mode 100644 index 00000000..56631ae0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/on.yaml @@ -0,0 +1,48 @@ +--- +- debug: msg="START CLI/ON.YAML" + +- name: Turn on all endpoints + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: true + enable_https: true + enable_local_http: true + enable_socket: true + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + when: debug + +- name: Expect all EAPI endpoints to be in on state + assert: + that: + - http_config.stdout[0].httpServer.running == true + - http_config.stdout[0].httpsServer.running == true + - http_config.stdout[0].localHttpServer.running == true + - http_config.stdout[0].unixSocketServer.running == true + +- name: Turn on all endpoints again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + enable_http: true + enable_https: true + enable_local_http: true + enable_socket: true + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="START CLI/ON.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/start.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/start.yaml new file mode 100644 index 00000000..de4d718f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/start.yaml @@ -0,0 +1,39 @@ +--- +- debug: msg="START CLI/START.YAML" + +- name: Set state to started + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: started + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + when: debug + +- name: Expect EAPI state is on + assert: + that: http_config.stdout[0].enabled == true + +- name: Set state to running again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: started + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="STOP CLI/START.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/stop.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/stop.yaml new file mode 100644 index 00000000..d2f762da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/stop.yaml @@ -0,0 +1,39 @@ +--- +- debug: msg="START CLI/STOP.YAML" + +- name: Set state to stopped + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: stopped + provider: '{{ cli }}' + +- register: http_config + arista.eos.eos_command: + commands: + - show management api http-commands | json + provider: '{{ cli }}' + +- debug: var=http_config + when: debug + +- name: Expect EAPI state is off + assert: + that: http_config.stdout[0].enabled == false + +- name: Set state to stopped again + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + state: stopped + provider: '{{ cli }}' + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - eos_eapi_output.changed == false + +- debug: msg="STOP CLI/ENABLE.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/vrf.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/vrf.yaml new file mode 100644 index 00000000..7ab138f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/vrf.yaml @@ -0,0 +1,46 @@ +--- +- debug: msg="START cli/vrf.yaml on connection={{ ansible_connection }}" + +- name: Set invalid VRF + become: true + register: eos_eapi_output + ignore_errors: true + arista.eos.eos_eapi: + vrf: foobar + provider: '{{ cli }}' + +- name: Ensure that setting VRF failed + assert: + that: + - eos_eapi_output.failed == true + - eos_eapi_output.changed == false + - eos_eapi_output.msg == "vrf `foobar` is not configured on the system" + +- name: Set VRF to default + become: true + register: eos_eapi_output + ignore_errors: true + arista.eos.eos_eapi: + vrf: default + provider: '{{ cli }}' + +- name: Set VRF to default again (idempotent) + become: true + register: eos_eapi_output + arista.eos.eos_eapi: + vrf: default + provider: '{{ cli }}' + +- name: Ensure idempotent + assert: + that: + - eos_eapi_output.changed == false + +- name: DEBUG show vrf + register: eos_eapi_output + when: false + arista.eos.eos_command: + commands: show vrf + provider: '{{ cli }}' + +- debug: msg="END cli/vrf.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/zzz_reset.1 b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/zzz_reset.1 new file mode 100644 index 00000000..b489ae80 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_eapi/tests/cli/zzz_reset.1 @@ -0,0 +1,38 @@ +- debug: msg="START CLI/RESET.YAML" + +- name: Change endpoint ports back to default values + eos_config: + lines: default management api http-commands + match: none + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- name: Expect endpoint ports to have default port values + assert: + that: + - http_config.stdout[0].httpServer.port == 80 + - http_config.stdout[0].httpsServer.port == 443 + - http_config.stdout[0].localHttpServer.port == 8080 + +- name: Change endpoint ports back to default values again + eos_config: + lines: default management api http-commands + match: none + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="END CLI/RESET.YAML" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/cli.yaml new file mode 100644 index 00000000..7e1717c1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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 + tags: network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/eapi.yaml new file mode 100644 index 00000000..40522749 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + 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 cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/main.yaml new file mode 100644 index 00000000..47a877e6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + +- include: eapi.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/all_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/all_facts.yaml new file mode 100644 index 00000000..d0e12981 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/all_facts.yaml @@ -0,0 +1,23 @@ +--- +- debug: msg="START cli/all_facts.yaml on connection={{ ansible_connection }}" + +- name: test getting all facts + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - all + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_memfree_mb > 1 + - result.ansible_facts.ansible_net_memtotal_mb > 1 + +- debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/default_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/default_facts.yaml new file mode 100644 index 00000000..ea1dcb67 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/default_facts.yaml @@ -0,0 +1,23 @@ +--- +- debug: msg="START cli/default_facts.yaml on connection={{ ansible_connection }}" + +- name: test getting default facts + become: true + register: result + arista.eos.eos_facts: + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_memtotal_mb > 10 + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_config is not defined + +- debug: msg="END cli/default_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/invalid_subset.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/invalid_subset.yaml new file mode 100644 index 00000000..ebd88253 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/invalid_subset.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/invalid_subset.yaml on connection={{ ansible_connection + }}" + +- name: test invalid subset (foobar) + become: true + register: result + ignore_errors: true + arista.eos.eos_facts: + gather_subset: + - foobar + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.failed == true + - "'Subset must be one of' in result.msg" + +- debug: msg="END cli/invalid_subset.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/not_hardware.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/not_hardware.yaml new file mode 100644 index 00000000..54ede8ab --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/cli/not_hardware.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START cli/not_hardware.yaml on connection={{ ansible_connection }}" + +- name: test not hardware + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - '!hardware' + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_filesystems is not defined + +- debug: msg="END cli/not_hardware.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/all_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/all_facts.yaml new file mode 100644 index 00000000..9d0b8728 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/all_facts.yaml @@ -0,0 +1,23 @@ +--- +- debug: msg="START eapi/all_facts.yaml on connection={{ ansible_connection }}" + +- name: test getting all facts + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - all + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_memfree_mb > 1 + - result.ansible_facts.ansible_net_memtotal_mb > 1 + +- debug: msg="END eapi/all_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/default_facts.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/default_facts.yaml new file mode 100644 index 00000000..b75edf9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/default_facts.yaml @@ -0,0 +1,24 @@ +--- +- debug: msg="START eapi/default_facts.yaml on connection={{ ansible_connection + }}" + +- name: test getting default facts + become: true + register: result + arista.eos.eos_facts: + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_memtotal_mb > 10 + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_config is not defined + +- debug: msg="END eapi/default_facts.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml new file mode 100644 index 00000000..361500ca --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START eapi/invalid_subset.yaml on connection={{ ansible_connection + }}" + +- name: test invalid subset (foobar) + become: true + register: result + ignore_errors: true + arista.eos.eos_facts: + gather_subset: + - foobar + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - result.failed == true + - "'Subset must be one of' in result.msg" + +- debug: msg="END eapi/invalid_subset.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/not_hardware.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/not_hardware.yaml new file mode 100644 index 00000000..eb136076 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_facts/tests/eapi/not_hardware.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START eapi/not_hardware.yaml on connection={{ ansible_connection }}" + +- name: test not hardware + become: true + register: result + arista.eos.eos_facts: + gather_subset: + - '!hardware' + provider: '{{ eapi }}' + +- assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_interfaces.Management1 + - result.ansible_facts.ansible_net_filesystems is not defined + +- debug: msg="END eapi/not_hardware.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..9a45cccc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/basic.yaml @@ -0,0 +1,255 @@ +--- +- debug: msg="START eos_interface cli/basic.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Configure interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface (idempotent) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == false + +- name: Confgure interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Change interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-1" in result.commands' + - '"mtu 1800" in result.commands' + +- name: Disable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: true + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: Confgure second interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_2 }}' + description: test-interface-initial + mtu: 1800 + state: present + +- name: Add interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"mtu 2000" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"description test-interface-2" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Add interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == false + +- name: Disable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: false + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: true + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: loopback interface setup + become: true + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- name: Create loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: present + +- assert: + that: + - result.changed == true + - '"interface loopback9" in result.commands' + - '"interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == true + - '"no interface loopback9" in result.commands' + - '"no interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_interface cli/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/intent.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/intent.yaml new file mode 100644 index 00000000..8ed69dcf --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/intent.yaml @@ -0,0 +1,162 @@ +--- +- debug: msg="START eos_interface cli/intent.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Check intent arguments + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: up + tx_rate: ge(0) + rx_rate: ge(0) + +- assert: + that: + - result.failed == false + +- name: Check intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: down + tx_rate: gt(0) + rx_rate: lt(0) + +- assert: + that: + - result.failed == true + - "'state eq(down)' in result.failed_conditions" + - "'tx_rate gt(0)' in result.failed_conditions" + - "'rx_rate lt(0)' in result.failed_conditions" + +- name: Config + intent + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: down + +- assert: + that: + - result.failed == false + +- name: Config + intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: up + +- assert: + that: + - result.failed == true + - "'state eq(up)' in result.failed_conditions" + +- name: Register show neighbors detail + become: true + register: show_lldp_neighbors_result + arista.eos.eos_command: + commands: + - show lldp neighbors management1 + +- block: + + - name: Check neighbors intent arguments + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Check neighbors intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: '"an-vyos-02" in show_lldp_neighbors_result.stdout[0]' + +- name: Aggregate config + intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + enabled: true + state: up + +- assert: + that: + - result.failed == false + +- block: + + - name: Aggregate neighbors intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Aggregate neighbors intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: "'an-vyos-02' in show_lldp_neighbors_result.stdout[0]" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/net_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/net_interface.yaml new file mode 100644 index 00000000..9064167a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/cli/net_interface.yaml @@ -0,0 +1,49 @@ +--- +- debug: msg="START eos cli/net_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Configure interface (setup) + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface description using platform agnostic module + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface parameters + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- debug: msg="END eos cli/net_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/basic.yaml new file mode 100644 index 00000000..aaafd973 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/basic.yaml @@ -0,0 +1,255 @@ +--- +- debug: msg="START eos_interface eapi/basic.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Configure interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface (idempotent) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == false + +- name: Confgure interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Change interface parameters + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-1" in result.commands' + - '"mtu 1800" in result.commands' + +- name: Disable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: true + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: Confgure second interface (setup) + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_2 }}' + description: test-interface-initial + mtu: 1800 + state: present + +- name: Add interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"mtu 2000" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"description test-interface-2" in result.commands' + - '"mtu 2000" in result.commands' + +- name: Add interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + mtu: 2000 + description: test-interface-1 + + - name: '{{ test_interface_2 }}' + mtu: 2000 + description: test-interface-2 + state: present + +- assert: + that: + - result.changed == false + +- name: Disable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: false + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"shutdown" in result.commands' + +- name: Enable interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + enabled: true + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no shutdown" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no shutdown" in result.commands' + +- name: loopback interface setup + become: true + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- name: Create loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: present + +- assert: + that: + - result.changed == true + - '"interface loopback9" in result.commands' + - '"interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == true + - '"no interface loopback9" in result.commands' + - '"no interface loopback10" in result.commands' + +- name: Delete loopback interface aggregate (idempotent) + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: loopback9 + + - name: loopback10 + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_interface eapi/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/intent.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/intent.yaml new file mode 100644 index 00000000..ffcab9e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/intent.yaml @@ -0,0 +1,167 @@ +--- +- debug: msg="START eos_interface eapi/intent.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + +- name: Make sure LLDP is running + become: true + arista.eos.eos_config: + lines: lldp run + +- name: Check intent arguments + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: up + tx_rate: ge(0) + rx_rate: ge(0) + +- assert: + that: + - result.failed == false + +- name: Check intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + state: down + tx_rate: gt(0) + rx_rate: lt(0) + +- assert: + that: + - result.failed == true + - "'state eq(down)' in result.failed_conditions" + - "'tx_rate gt(0)' in result.failed_conditions" + - "'rx_rate lt(0)' in result.failed_conditions" + +- name: Config + intent + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: down + +- assert: + that: + - result.failed == false + +- name: Config + intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: '{{ test_interface_1 }}' + enabled: false + state: up + +- assert: + that: + - result.failed == true + - "'state eq(up)' in result.failed_conditions" + +- name: Register show neighbors detail + become: true + register: show_lldp_neighbors_result + arista.eos.eos_command: + commands: + - show lldp neighbors management1 + +- block: + + - name: Check neighbors intent arguments + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Check neighbors intent arguments (failed condition) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + name: management1 + neighbors: + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: '"an-vyos-02" in show_lldp_neighbors_result.stdout[0]' + +- name: Aggregate config + intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + enabled: true + state: up + +- assert: + that: + - result.failed == false + +- block: + + - name: Aggregate neighbors intent (pass) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - assert: + that: + - result.failed == false + + - name: Aggregate neighbors intent (fail) + ignore_errors: true + become: true + register: result + arista.eos.eos_interface: + aggregate: + + - name: management1 + neighbors: + + - port: eth0 + host: an-vyos-02 + + - port: dummy_port + host: dummy_host + + - assert: + that: + - result.failed == true + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: "'an-vyos-02' in show_lldp_neighbors_result.stdout[0]" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/net_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/net_interface.yaml new file mode 100644 index 00000000..8bfb271e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interface/tests/eapi/net_interface.yaml @@ -0,0 +1,49 @@ +--- +- debug: msg="START eos eapi/net_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Configure interface (setup) + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-1 + mtu: 1800 + state: present + +- name: Configure interface description using platform agnostic module + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface-initial + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface-initial" in result.commands' + +- name: Confgure interface parameters + become: true + register: result + ansible.netcommon.net_interface: + name: '{{ test_interface_1 }}' + description: test-interface + mtu: 2000 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"description test-interface" in result.commands' + - '"mtu 2000" in result.commands' + +- debug: msg="END eos eapi/net_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/templates/reset.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/templates/reset.cfg new file mode 100644 index 00000000..8288812b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/templates/reset.cfg @@ -0,0 +1,12 @@ +interface Ethernet1 + description "Interface 1" + switchport + no shutdown + no mtu + speed forced 40gfull +interface Ethernet2 + no description + no shutdown + no switchport + mtu 3000 + speed auto diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..83b6cf71 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +interface Ethernet1 + description "this is interface for testing" +! +interface Ethernet2 + description "Configured by Ansible" + shutdown +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..04f9c181 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,5 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + src: reset.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..bf3283e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/deleted.yaml @@ -0,0 +1,31 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Returns interfaces to default parameters + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..eca1cc6e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..3502dddc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + + - assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.gathered)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..7d71274c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/merged.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + mode: layer3 + description: this is interface for testing + enabled: true + + - name: Ethernet2 + description: Configured by Ansible + speed: '10' + duplex: full + enabled: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..1061e7ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/overridden.yaml @@ -0,0 +1,43 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + duplex: auto + enabled: true + + - name: Ethernet2 + mode: layer2 + duplex: auto + description: Configured by Ansible + enabled: false + + - name: Management1 + enabled: true + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Overrides device configuration of all interfaces with provided configuration + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..5c27a4b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..21913323 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rendered.yaml @@ -0,0 +1,27 @@ +--- +- debug: + msg: START eos_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + enabled: true + - name: Ethernet2 + description: Configured by Ansible + speed: '10' + duplex: full + enabled: false + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..bcb37339 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/replaced.yaml @@ -0,0 +1,40 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + duplex: auto + enabled: true + + - name: Ethernet2 + description: Configured by Ansible + duplex: auto + mode: layer2 + enabled: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- name: Replaces device configuration of listed interfaces with provided configuration + register: result + become: true + arista.eos.eos_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..744985dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/tests/common/rtt.yaml @@ -0,0 +1,48 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + - name: Ethernet2 + description: Configured by Ansible + speed: '10' + duplex: full + enabled: false + config2: + - name: Ethernet1 + mode: layer3 + enabled: true + description: Config to be reverted + +- name: Merge provided configuration with device configuration( Base config ) + register: baseconfig + become: true + arista.eos.eos_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: interfaces + +- assert: + that: + - ansible_facts.network_resources.interfaces|symmetric_difference(baseconfig.after) == [] + +- name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_interfaces: + config: '{{ config2 }}' + state: merged + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_interfaces: + config: "{{ ansible_facts['network_resources']['interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig['after'] | symmetric_difference(revert['after']) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/vars/main.yaml new file mode 100644 index 00000000..bf23519b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_interfaces/vars/main.yaml @@ -0,0 +1,17 @@ +--- +parsed: + config: + - name: Ethernet1 + description: 'this is interface for testing' + enabled: true + - name: Ethernet2 + description: 'Configured by Ansible' + enabled: false + +rendered: + - "interface Ethernet2" + - "speed 10full" + - "description Configured by Ansible" + - "shutdown" + - "interface Ethernet1" + - "no shutdown" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..58b3bc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/basic.yaml @@ -0,0 +1,110 @@ +--- +- debug: + msg: START eos_l2_interface cli/basic.yaml on connection={{ ansible_connection + }} + +- name: Delete test interface switchports + become: true + arista.eos.eos_l2_interface: &id008 + name: Ethernet1 + state: absent + +- name: Set switchport mode to access on vlan 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: present + mode: access + access_vlan: 4000 + +- assert: &id002 + that: + - result.changed == true + +- name: Set switchport mode to access on vlan 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: &id004 + that: + - result.changed == false + +- name: Change access vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id003 + name: Ethernet1 + state: present + mode: access + access_vlan: 4001 + +- assert: *id002 + +- name: Change access vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id003 + +- assert: *id004 + +- name: Change switchport mode to trunk + become: true + register: result + arista.eos.eos_l2_interface: &id005 + name: Ethernet1 + state: present + mode: trunk + +- assert: *id002 + +- name: Change switchport mode to trunk (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id005 + +- assert: *id004 + +- name: Change switchport mode to trunk and set native vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id006 + name: Ethernet1 + state: present + mode: trunk + native_vlan: 4001 + +- assert: *id002 + +- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id006 + +- assert: *id004 + +- name: Set trunk allowed vlans to 20 and 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id007 + name: Ethernet1 + state: present + mode: trunk + trunk_allowed_vlans: 20,4000 + +- assert: *id002 + +- name: Set trunk allowed vlans to 20 and 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id007 + +- assert: *id004 + +- name: Tear down switchports + become: true + arista.eos.eos_l2_interface: *id008 + +- debug: msg="END eos_l2_interface cli/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml new file mode 100644 index 00000000..b9aa2577 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/cli/no_interface.yaml @@ -0,0 +1,39 @@ +--- +- debug: + msg: START eos_l2_interface/cli/no_interface.yaml on connection={{ ansible_connection + }} + +- name: Create fake interface + become: true + arista.eos.eos_interface: + name: Management0 + +- block: + + - name: eos_l2_interface shouldn't fail + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: absent + + - assert: + that: "'Interface does not exist' in result.warnings[0]" + always: + + - name: Cleanup fake interface + become: true + ansible.netcommon.cli_config: + config: no interface Management0 + +- name: eos_l2_interface should still not fail + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: + that: result.warnings is not defined + +- debug: + msg: END eos_l2_interface/cli/no_interface.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/basic.yaml new file mode 100644 index 00000000..a2ca7143 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/basic.yaml @@ -0,0 +1,110 @@ +--- +- debug: + msg: START eos_l2_interface eapi/basic.yaml on connection={{ ansible_connection + }} + +- name: Delete test interface switchports + become: true + arista.eos.eos_l2_interface: &id008 + name: Ethernet1 + state: absent + +- name: Set switchport mode to access on vlan 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: present + mode: access + access_vlan: 4000 + +- assert: &id002 + that: + - result.changed == true + +- name: Set switchport mode to access on vlan 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: &id004 + that: + - result.changed == false + +- name: Change access vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id003 + name: Ethernet1 + state: present + mode: access + access_vlan: 4001 + +- assert: *id002 + +- name: Change access vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id003 + +- assert: *id004 + +- name: Change switchport mode to trunk + become: true + register: result + arista.eos.eos_l2_interface: &id005 + name: Ethernet1 + state: present + mode: trunk + +- assert: *id002 + +- name: Change switchport mode to trunk (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id005 + +- assert: *id004 + +- name: Change switchport mode to trunk and set native vlan to 4001 + become: true + register: result + arista.eos.eos_l2_interface: &id006 + name: Ethernet1 + state: present + mode: trunk + native_vlan: 4001 + +- assert: *id002 + +- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id006 + +- assert: *id004 + +- name: Set trunk allowed vlans to 20 and 4000 + become: true + register: result + arista.eos.eos_l2_interface: &id007 + name: Ethernet1 + state: present + mode: trunk + trunk_allowed_vlans: 20,4000 + +- assert: *id002 + +- name: Set trunk allowed vlans to 20 and 4000 again (idempotent) + become: true + register: result + arista.eos.eos_l2_interface: *id007 + +- assert: *id004 + +- name: Tear down switchports + become: true + arista.eos.eos_l2_interface: *id008 + +- debug: msg="END eos_l2_interface eapi/basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml new file mode 100644 index 00000000..c94c2dda --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interface/tests/eapi/no_interface.yaml @@ -0,0 +1,40 @@ +--- +- debug: + msg: START eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection + }} + +- name: Create fake interface + become: true + arista.eos.eos_interface: + name: Management0 + +- block: + + - name: eos_l2_interface shouldn't fail + become: true + register: result + arista.eos.eos_l2_interface: &id001 + name: Ethernet1 + state: absent + + - assert: + that: "'Interface does not exist' in result.warnings[0]" + always: + + - name: Cleanup fake interface + become: true + arista.eos.eos_config: + lines: + - no interface Management0 + +- name: eos_l2_interface should still not fail + become: true + register: result + arista.eos.eos_l2_interface: *id001 + +- assert: + that: result.warnings is not defined + +- debug: + msg: END eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..de357afd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/cli.yaml @@ -0,0 +1,32 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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: Clean up test state + include: '{{ role_path }}/tests/common/_cleanup.yml ansible_connection=ansible.netcommon.network_cli' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..630e6be6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/eapi.yaml @@ -0,0 +1,32 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + +- name: Clean up test state + include: '{{ role_path }}/tests/common/_cleanup.yml ansible_connection=ansible.netcommon.network_cli' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_cleanup.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_cleanup.yml new file mode 100644 index 00000000..87412ed6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_cleanup.yml @@ -0,0 +1,14 @@ +--- +- name: Remove all vlans + become: true + ansible.netcommon.cli_config: + config: no vlan 1-4094 + +- name: Completely remove vlans from interfaces + with_items: + - Ethernet1 + - Ethernet2 + become: true + ansible.netcommon.cli_config: + config: "interface {{ item }}\n no switchport mode\n no switchport access\ + \ vlan\n no switchport trunk native vlan\n" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..5f6297e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +interface Ethernet1 + switchport trunk native vlan 10 + switchport mode trunk +! +interface Ethernet2 + switchport access vlan 30 +! diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..023c4cb7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,36 @@ +--- +- name: Reset state + become: true + arista.eos.eos_config: + lines: + - "interface Ethernet1" + - " switchport access vlan 20" + - " no switchport mode" + - " no switchport trunk native vlan" + - " no switchport trunk allowed vlan" + - "interface Ethernet2" + - " no switchport access vlan" + - " switchport trunk native vlan 20" + - " switchport mode trunk" + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + access: + vlan: 20 + + - mode: trunk + name: Ethernet2 + trunk: + native_vlan: 20 + + - name: Management1 + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..936a4f5c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml @@ -0,0 +1,42 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + + - name: Ethernet2 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Delete EOS L2 interfaces as in given arguments. + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Management1'}]" + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..398f8e2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_l2_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l2_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_l2_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..ca5af2df --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_l2_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_l2_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + + - assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.gathered)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..50fc8a29 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/merged.yaml @@ -0,0 +1,63 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + + - name: Ethernet2 + access: + vlan: 30 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - name: Ethernet1 + mode: trunk + access: + vlan: 20 + trunk: + native_vlan: 10 + + - name: Ethernet2 + mode: trunk + access: + vlan: 30 + trunk: + native_vlan: 20 + + - name: Management1 + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..1fa59e11 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml @@ -0,0 +1,43 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet2 + access: + vlan: 30 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Override device configuration of all L2 interfaces on device with provided + configuration. + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Ethernet1'}, {'name': 'Management1'}]" + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..6d040bcd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_l2_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..671e762a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rendered.yaml @@ -0,0 +1,31 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + + - name: Ethernet2 + access: + vlan: 30 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..a866f305 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + trunk: + native_vlan: 20 + trunk_allowed_vlans: + - 5-10 + - '15' + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- name: Replace device configuration of specified L2 interfaces with provided configuration. + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: "{{ config }} + [{'mode': 'trunk', 'name': 'Ethernet2', 'trunk':\ + \ {'native_vlan': 20}}, {'name': 'Management1'}]" + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..6819f5b1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/tests/common/rtt.yaml @@ -0,0 +1,75 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + + config2: + + - name: Ethernet2 + access: + vlan: 30 + +- name: Merge provided configuration with device configuration (base config) + register: baseconfig + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: l2_interfaces + +- assert: + that: + - ansible_facts.network_resources.l2_interfaces|symmetric_difference(baseconfig.after) + == [] + +- name: Apply the provided configuration (config to be reverted) + register: result + become: true + arista.eos.eos_l2_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + mode: trunk + access: + vlan: 20 + trunk: + native_vlan: 10 + + - name: Ethernet2 + mode: trunk + access: + vlan: 30 + trunk: + native_vlan: 20 + + - name: Management1 + +- assert: + that: + - result.after|symmetric_difference(expected_config) + == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_l2_interfaces: + config: "{{ ansible_facts['network_resources']['l2_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig['after'] | symmetric_difference(revert['after']) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/vars/main.yaml new file mode 100644 index 00000000..549dc8a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l2_interfaces/vars/main.yaml @@ -0,0 +1,17 @@ +--- +rendered: + - "interface Ethernet2" + - "switchport access vlan 30" + - "interface Ethernet1" + - "switchport mode trunk" + - "switchport trunk native vlan 10" + +parsed: + config: + - name: Ethernet1 + mode: trunk + trunk: + native_vlan: 10 + - name: Ethernet2 + access: + vlan: 30 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..7b241101 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/basic.yaml @@ -0,0 +1,209 @@ +--- +- debug: + msg: START eos_l3_interface cli/basic.yaml on connection={{ ansible_connection + }} + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + ipv4_addr_1: 192.0.2.5/24 + ipv4_addr_2: 198.51.100.15/24 + ipv4_addr_3: 203.0.113.25/28 + ipv4_addr_4: 203.0.113.225/28 + ipv6_addr_1: 2001:DB8:123::/64 + ipv6_addr_2: 2001:DB8:ABC::/64 + ipv6_addr_3: 2001:DB8::/48 + ipv6_addr_4: 2001:DB8:FFFF::/90 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + arista.eos.eos_l3_interface: &id004 + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: &id001 + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + +- name: Configure interface ipv4 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id001 + +- assert: &id003 + that: + - result.changed == false + +- name: Change interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + +- name: Configure interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: &id002 + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure interface ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id002 + +- assert: *id003 + +- name: Change interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + +- name: Delete interface ipv4 and ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete interface ipv4 and ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: *id003 + +- name: Delete second interface ipv4 and ipv6 address (setup) + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_2 }}' + state: absent + +- name: Configure ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id005 + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_3 }}' + ipv6: '{{ ipv6_addr_3 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_3 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_3 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id005 + +- assert: *id003 + +- name: Change ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + ipv6: '{{ ipv6_addr_2 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_4 }}' + ipv6: '{{ ipv6_addr_4 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_4 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_4 }}" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id006 + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + state: absent + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id006 + +- assert: *id003 + +- debug: + msg: END eos_l3_interface cli/basic.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/net_l3_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/net_l3_interface.yaml new file mode 100644 index 00000000..6f3fbde7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/cli/net_l3_interface.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START eos cli/net_l3_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address using platform agnostic module + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: 192.108.0.1/24 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address 192.108.0.1/24" in result.commands' + +- name: Delete interface ipv4 and ipv6 address(teardown) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- debug: msg="END eos cli/net_l3_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/basic.yaml new file mode 100644 index 00000000..2a3f2ec1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/basic.yaml @@ -0,0 +1,209 @@ +--- +- debug: + msg: START eos_l3_interface eapi/basic.yaml on connection={{ ansible_connection + }} + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + test_interface_2: ethernet2 + ipv4_addr_1: 192.0.2.5/24 + ipv4_addr_2: 198.51.100.15/24 + ipv4_addr_3: 203.0.113.25/28 + ipv4_addr_4: 203.0.113.225/28 + ipv6_addr_1: 2001:DB8:123::/64 + ipv6_addr_2: 2001:DB8:ABC::/64 + ipv6_addr_3: 2001:DB8::/48 + ipv6_addr_4: 2001:DB8:FFFF::/90 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + arista.eos.eos_l3_interface: &id004 + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: &id001 + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + +- name: Configure interface ipv4 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id001 + +- assert: &id003 + that: + - result.changed == false + +- name: Change interface ipv4 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + +- name: Configure interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: &id002 + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure interface ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id002 + +- assert: *id003 + +- name: Change interface ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_1 }}' + ipv6: '{{ ipv6_addr_2 }}' + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + +- name: Delete interface ipv4 and ipv6 address + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete interface ipv4 and ipv6 address (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id004 + +- assert: *id003 + +- name: Delete second interface ipv4 and ipv6 address (setup) + become: true + register: result + arista.eos.eos_l3_interface: + name: '{{ test_interface_2 }}' + state: absent + +- name: Configure ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id005 + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_3 }}' + ipv6: '{{ ipv6_addr_3 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_1 }}' + ipv6: '{{ ipv6_addr_1 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_3 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_3 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_1 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_1 }}" in result.commands' + +- name: Configure ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id005 + +- assert: *id003 + +- name: Change ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: + aggregate: + + - name: '{{ test_interface_1 }}' + ipv4: '{{ ipv4_addr_2 }}' + ipv6: '{{ ipv6_addr_2 }}' + + - name: '{{ test_interface_2 }}' + ipv4: '{{ ipv4_addr_4 }}' + ipv6: '{{ ipv6_addr_4 }}' + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address {{ ipv4_addr_2 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_2 }}" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"ip address {{ ipv4_addr_4 }}" in result.commands' + - '"ipv6 address {{ ipv6_addr_4 }}" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate + become: true + register: result + arista.eos.eos_l3_interface: &id006 + aggregate: + + - name: '{{ test_interface_1 }}' + + - name: '{{ test_interface_2 }}' + state: absent + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + - '"interface {{ test_interface_2 }}" in result.commands' + - '"no ip address" in result.commands' + - '"no ipv6 address" in result.commands' + +- name: Delete ipv4 and ipv6 address using aggregate (idempotent) + become: true + register: result + arista.eos.eos_l3_interface: *id006 + +- assert: *id003 + +- debug: + msg: END eos_l3_interface eapi/basic.yaml on connection={{ ansible_connection + }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/net_l3_interface.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/net_l3_interface.yaml new file mode 100644 index 00000000..b1c99d65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interface/tests/eapi/net_l3_interface.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START eos eapi/net_l3_interface.yaml on connection={{ ansible_connection + }}" + +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Delete interface ipv4 and ipv6 address(setup) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- name: Configure interface ipv4 address using platform agnostic module + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + ipv4: 192.108.0.1/24 + state: present + +- assert: + that: + - result.changed == true + - '"interface {{ test_interface_1 }}" in result.commands' + - '"ip address 192.108.0.1/24" in result.commands' + +- name: Delete interface ipv4 and ipv6 address(teardown) + become: true + register: result + ansible.netcommon.net_l3_interface: + name: '{{ test_interface_1 }}' + state: absent + +- debug: msg="END eos eapi/net_l3_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..47c54811 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/eapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/templates/reset.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/templates/reset.cfg new file mode 100644 index 00000000..08059b6e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/templates/reset.cfg @@ -0,0 +1,10 @@ +interface Ethernet1 + ip address 192.0.2.12/24 + ip address 203.0.113.27/31 secondary + no ipv6 address +interface Ethernet2 + no ip address + ipv6 address 2001:db8::1/64 +interface Management1 + ip address dhcp + no ipv6 address diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..85c42127 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +interface Ethernet1 + ip address 198.51.100.14/24 +! +interface Ethernet2 + ip address 203.0.113.27/24 +! + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..95779005 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,34 @@ +--- +- name: Reset state + become: true + arista.eos.eos_config: + src: reset.cfg + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + ipv4: + + - address: 192.0.2.12/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Ethernet2 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..0f944e75 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml @@ -0,0 +1,49 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + + - name: Ethernet2 + other_config: + + - name: Management1 + ipv4: + + - address: dhcp + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Delete EOS L3 interfaces as in given arguments. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..37e67b62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_l3_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..2d648b12 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_l3_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_l3_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + + - assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.gathered)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..034de19d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/merged.yaml @@ -0,0 +1,70 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Merge provided configuration with device configuration. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..71358a31 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml @@ -0,0 +1,55 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + ipv6: + + - address: 2001:db8:feed::1/96 + + - name: Ethernet2 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Override device configuration of all L3 interfaces on device with provided + configuration. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: '{{ config }}' + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..6f13973d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_l3_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..08e6f228 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rendered.yaml @@ -0,0 +1,24 @@ +--- +- set_fact: + config: + + - name: Ethernet1 + ipv4: + - address: 198.51.100.14/24 + + - name: Ethernet2 + ipv4: + - address: 203.0.113.27/24 + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..b61d99bf --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml @@ -0,0 +1,58 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.205/31 + other_config: + + - name: Ethernet1 + ipv4: + + - address: 192.0.2.12/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Management1 + ipv4: + + - address: dhcp + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- name: Replace device configuration of specified L3 interfaces with provided configuration. + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) + == [] + become: true + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..a97c5f82 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/tests/common/rtt.yaml @@ -0,0 +1,82 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + config2: + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + +- name: Merge provided configuration with device configuration (base config). + register: baseconfig + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: l3_interfaces + +- assert: + that: + - ansible_facts.network_resources.l3_interfaces|symmetric_difference(baseconfig.after) + == [] + become: true + +- name: Merge provided configuration with device configuration (config to be reverted). + register: result + become: true + arista.eos.eos_l3_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + ipv4: + + - address: 198.51.100.14/24 + + - address: 203.0.113.27/31 + secondary: true + + - name: Ethernet2 + ipv4: + + - address: 203.0.113.227/31 + ipv6: + + - address: 2001:db8::1/64 + + - name: Management1 + ipv4: + + - address: dhcp + +- assert: + that: + - result.after|symmetric_difference(expected_config) + == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_l3_interfaces: + config: "{{ ansible_facts['network_resources']['l3_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig['after'] | symmetric_difference(revert['after']) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/vars/main.yaml new file mode 100644 index 00000000..00f2a3c4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_l3_interfaces/vars/main.yaml @@ -0,0 +1,15 @@ +--- +parsed: + config: + - name: Ethernet1 + ipv4: + - address: 198.51.100.14/24 + - name: Ethernet2 + ipv4: + - address: 203.0.113.27/24 + +rendered: + - "interface Ethernet1" + - "ip address 198.51.100.14/24" + - "interface Ethernet2" + - "ip address 203.0.113.27/24" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_parsed.cfg new file mode 100644 index 00000000..5e87c055 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_parsed.cfg @@ -0,0 +1 @@ +lacp system-priority 20 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_reset_config.yaml new file mode 100644 index 00000000..d36c4d53 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/_reset_config.yaml @@ -0,0 +1,19 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "lacp system-priority 10" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- set_fact: + expected_config: + system: + priority: 10 + +- assert: + that: + - expected_config == ansible_facts.network_resources.lacp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/deleted.yaml new file mode 100644 index 00000000..166cadc0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/deleted.yaml @@ -0,0 +1,28 @@ +--- +- include_tasks: _reset_config.yaml + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- name: Returns lacp to default parameters + register: result + become: true + arista.eos.eos_lacp: + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lacp == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- assert: + that: + - ansible_facts.network_resources.lacp == result.after + +- assert: + that: + - ansible_facts.network_resources.lacp == {} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/empty_config.yaml new file mode 100644 index 00000000..a550d502 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/empty_config.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: START eos.eos_lacp empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lacp empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/gathered.yaml new file mode 100644 index 00000000..a9779917 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lacp gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lacp: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lacp + + - assert: + that: + - ansible_facts.network_resources.lacp == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/merged.yaml new file mode 100644 index 00000000..1469f286 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/merged.yaml @@ -0,0 +1,34 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + system: + priority: 20 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- name: Merge provided lacp configuration with device configuration + register: result + become: true + arista.eos.eos_lacp: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lacp == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- assert: + that: + - ansible_facts.network_resources.lacp == result.after + +- assert: + that: + - config == ansible_facts.network_resources.lacp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/parsed.yaml new file mode 100644 index 00000000..6549828f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/parsed.yaml @@ -0,0 +1,21 @@ +--- +- debug: + msg: START eos_lacp parsed integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + system: + priority: 20 + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lacp: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - config == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/rendered.yaml new file mode 100644 index 00000000..679cc997 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/rendered.yaml @@ -0,0 +1,26 @@ +--- +- debug: + msg: START eos_lacp rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + system: + priority: 20 + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lacp: + config: '{{ config }}' + state: rendered + +- set_fact: + rendered: + - "lacp system-priority 20" + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/replaced.yaml new file mode 100644 index 00000000..e5fee498 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp/tests/common/replaced.yaml @@ -0,0 +1,34 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + system: + priority: 20 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- name: Replaces device lacp configuration with provided configuration + register: result + become: true + arista.eos.eos_lacp: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lacp == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp + +- assert: + that: + - ansible_facts.network_resources.lacp == result.after + +- assert: + that: + - config == ansible_facts.network_resources.lacp diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..1db4d4d6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,4 @@ +interface Ethernet1 + lacp port-priority 30 + lacp rate fast +interface Ethernet2 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..653b0c49 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,29 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "interface Ethernet1" + - " lacp port-priority 30" + - " lacp rate normal" + - "interface Ethernet2" + - " no lacp port-priority" + - " lacp rate fast" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + port_priority: 30 + + - name: Ethernet2 + rate: fast + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..d9811a70 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + other_config: + + - name: Ethernet2 + rate: fast + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Returns vlans to default parameters + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..6de8fd2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_lacp_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lacp_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lacp_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..e4fec7bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lacp_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lacp_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + + - assert: + that: + - ansible_facts.network_resources.lacp_interfaces == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..f3d2a3e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml @@ -0,0 +1,48 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + rate: fast + + - name: Ethernet2 + rate: normal + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - name: Ethernet1 + port_priority: 30 + rate: fast + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..ca03f684 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + rate: fast + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Overrides device configuration of all vlans with provided configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..1de8011d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/parsed.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lacp_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + rate: fast + port_priority: 30 + - name: Ethernet2 + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lacp_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - config == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..43dc6a9d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rendered.yaml @@ -0,0 +1,31 @@ +--- +- debug: + msg: START eos_lacp_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + rate: fast + - name: Ethernet2 + rate: normal + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: rendered + +- set_fact: + rendered: + - "interface Ethernet1" + - "lacp rate fast" + - "interface Ethernet2" + - "lacp rate normal" + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..aa109de6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + rate: fast + port_priority: 45 + other_config: + + - name: Ethernet2 + rate: fast + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- name: Replaces device configuration of listed vlans with provided configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..a596c633 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lacp_interfaces/tests/common/rtt.yaml @@ -0,0 +1,64 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + rate: fast + + config2: + - name: Ethernet2 + port_priority: 20 + rate: fast + + +- name: Merge provided configuration with device configuration (base config) + register: baseconfig + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: lacp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lacp_interfaces|symmetric_difference(baseconfig.after) + == [] + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_lacp_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + port_priority: 30 + rate: fast + + - name: Ethernet2 + port_priority: 20 + rate: fast + +- assert: + that: + - expected_config|symmetric_difference(result.after) == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_lacp_interfaces: + config: "{{ ansible_facts['network_resources']['lacp_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: "{{ baseconfig.after | symmetric_difference(revert.after) == [] }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_parsed.cfg new file mode 100644 index 00000000..fdaa5444 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_parsed.cfg @@ -0,0 +1,4 @@ +interface Ethernet1 + channel-group 5 mode on +interface Ethernet2 + channel-group 5 mode on diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_reset_config.yaml new file mode 100644 index 00000000..dba69500 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/_reset_config.yaml @@ -0,0 +1,24 @@ +--- +- name: Reset state + become: true + ansible.netcommon.cli_config: + config: "interface Ethernet1\n channel-group 5 mode on\ninterface Ethernet2\n\ + \ no channel-group\nno interface Port-Channel10\n" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- set_fact: + expected_config: + + - name: Port-Channel5 + members: + + - member: Ethernet1 + mode: 'on' + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..863f560b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,31 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel5 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Delete EOS L3 interfaces as in given arguments. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..a1a42083 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lag_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..2c265100 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lag_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lag_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + + - assert: + that: + - ansible_facts.network_resources.lag_interfaces == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..389c8069 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml @@ -0,0 +1,74 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel5 + members: + + - member: Ethernet2 + mode: 'on' + + change_config: + - name: Port-Channel5 + members: + + - member: Ethernet2 + mode: 'passive' + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Merge provided configuration with device configuration. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length + == 0 + +- set_fact: + expected_config: + + - name: Port-Channel5 + members: + + - member: Ethernet1 + mode: 'on' + + - member: Ethernet2 + mode: 'on' + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length + == 0 + +- name: Merge provided configuration with device configuration, expect error. + become: true + ignore_errors: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ change_config }}' + state: merged + +- assert: + that: + - result.failed == true + - result.msg is defined + - '"Cannot change mode" in result.module_stderr' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..f7ca1ed2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel10 + members: + + - member: Ethernet2 + mode: 'on' + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Override device configuration of all LAGs on device with provided configuration. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length + == 0 + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(config)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..c694e5dc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lag_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result['parsed']) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..9fabbb6d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,22 @@ +--- +- set_fact: + config: + - name: 5 + members: + - member: Ethernet2 + mode: "on" + - member: Ethernet1 + mode: "on" + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered.sort() == result.rendered.sort() + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..cf7eac88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,51 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Port-Channel10 + members: + + - member: Ethernet2 + mode: 'on' + other_config: + + - name: Port-Channel5 + members: + + - member: Ethernet1 + mode: 'on' + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- name: Replace device configuration of specified LAGs with provided configuration. + become: true + register: result + arista.eos.eos_lag_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length + == 0 + +- become: true + arista.eos.eos_facts: + gather_network_resources: lag_interfaces + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length + == 0 + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length + == 0 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/vars/main.yaml new file mode 100644 index 00000000..01a7e807 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lag_interfaces/vars/main.yaml @@ -0,0 +1,15 @@ +--- +parsed: + config: + - name: "Port-Channel5" + members: + - member: Ethernet1 + mode: "on" + - member: Ethernet2 + mode: "on" + +rendered: + - "interface Ethernet1" + - "channel-group 5 mode on" + - "interface Ethernet2" + - "channel-group 5 mode on" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tests/cli/basic.yaml new file mode 100644 index 00000000..df2df8fd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_linkagg/tests/cli/basic.yaml @@ -0,0 +1,198 @@ +--- +- debug: msg="START cli/basic.yaml" + +- name: setup - remove config used in test(part1) + become: true + arista.eos.eos_config: + lines: + - no interface port-channel 20 + - no interface port-channel 100 + provider: '{{ cli }}' + +- name: setup - remove config used in test(part2) + loop: + - interface Ethernet1 + - interface Ethernet2 + become: true + arista.eos.eos_config: + lines: + - no channel-group 20 + provider: '{{ cli }}' + parents: '{{ item }}' + +- name: create linkagg + become: true + register: result + arista.eos.eos_linkagg: &id001 + group: 20 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface port-channel 20' in result.commands" + +- name: create linkagg(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id001 + +- assert: + that: + - result.changed == false + +- name: set link aggregation group to members + become: true + register: result + arista.eos.eos_linkagg: &id002 + group: 20 + mode: active + members: + - Ethernet1 + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface Ethernet1' in result.commands" + - "'channel-group 20 mode active' in result.commands" + - "'interface Ethernet2' in result.commands" + - "'channel-group 20 mode active' in result.commands" + +- name: set link aggregation group to members(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id002 + +- assert: + that: + - result.changed == false + +- name: remove link aggregation group from member + become: true + register: result + arista.eos.eos_linkagg: &id003 + group: 20 + mode: active + members: + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface Ethernet1' in result.commands" + - "'no channel-group 20' in result.commands" + +- name: remove link aggregation group from member(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id003 + +- assert: + that: + - result.changed == false + +- name: remove linkagg + become: true + register: result + arista.eos.eos_linkagg: &id004 + group: 20 + state: absent + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no interface port-channel 20' in result.commands" + +- name: remove linkagg(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id004 + +- assert: + that: + - result.changed == false + +- name: create aggregate of linkagg definitions + become: true + register: result + arista.eos.eos_linkagg: &id005 + aggregate: + + - group: 20 + min_links: 3 + + - group: 100 + min_links: 4 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface port-channel 20' in result.commands" + - "'port-channel min-links 3' in result.commands" + - "'interface port-channel 100' in result.commands" + - "'port-channel min-links 4' in result.commands" + +- name: create aggregate of linkagg definitions(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id005 + +- assert: + that: + - result.changed == false + +- name: remove aggregate of linkagg definitions + become: true + register: result + arista.eos.eos_linkagg: &id006 + aggregate: + + - group: 20 + min_links: 3 + + - group: 100 + min_links: 4 + provider: '{{ cli }}' + state: absent + +- assert: + that: + - result.changed == true + - "'no interface port-channel 20' in result.commands" + - "'no interface port-channel 100' in result.commands" + +- name: remove aggregate of linkagg definitions(Idempotence) + become: true + register: result + arista.eos.eos_linkagg: *id006 + +- assert: + that: + - result.changed == false + +- name: teardown(part1) + become: true + arista.eos.eos_config: + lines: + - no interface port-channel 20 + - no interface port-channel 100 + provider: '{{ cli }}' + +- name: teardown(part2) + become: true + loop: + - interface Ethernet1 + - interface Ethernet2 + arista.eos.eos_config: + lines: + - no channel-group 20 + provider: '{{ cli }}' + parents: '{{ item }}' + +- debug: msg="END cli/basic.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/cli/basic.yaml new file mode 100644 index 00000000..748ab308 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/cli/basic.yaml @@ -0,0 +1,52 @@ +--- +- debug: msg="START eos_lldp cli/basic.yaml on connection={{ ansible_connection + }}" + +- name: Make sure LLDP is not running before tests + become: true + arista.eos.eos_config: + lines: no lldp run + +- name: Enable LLDP service + register: result + become: true + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == true + - '"lldp run" in result.commands' + +- name: Enable LLDP service again (idempotent) + register: result + become: true + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == false + +- name: Disable LLDP service + register: result + become: true + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == true + - '"no lldp run" in result.commands' + +- name: Disable LLDP service (idempotent) + register: result + become: true + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_lldp cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/eapi/basic.yaml new file mode 100644 index 00000000..ea5f6b11 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp/tests/eapi/basic.yaml @@ -0,0 +1,52 @@ +--- +- debug: msg="START eos_lldp eapi/basic.yaml on connection={{ ansible_connection + }}" + +- name: Make sure LLDP is not running before tests + become: true + arista.eos.eos_config: + lines: no lldp run + +- name: Enable LLDP service + become: true + register: result + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == true + - '"lldp run" in result.commands' + +- name: Enable LLDP service again (idempotent) + become: true + register: result + arista.eos.eos_lldp: + state: present + +- assert: + that: + - result.changed == false + +- name: Disable LLDP service + become: true + register: result + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == true + - '"no lldp run" in result.commands' + +- name: Disable LLDP service (idempotent) + become: true + register: result + arista.eos.eos_lldp: + state: absent + +- assert: + that: + - result.changed == false + +- debug: msg="END eos_lldp eapi/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_parsed.cfg new file mode 100644 index 00000000..b507f3f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_parsed.cfg @@ -0,0 +1,6 @@ +lldp timer 3000 +lldp holdtime 100 +lldp reinit 5 +no lldp tlv-select management-address +no lldp tlv-select system-description + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_reset_config.yaml new file mode 100644 index 00000000..ca00bed6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/_reset_config.yaml @@ -0,0 +1,28 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "lldp timer 3000" + - "lldp holdtime 100" + - "lldp reinit 5" + - "no lldp tlv-select management-address" + - "no lldp tlv-select system-description" + - "lldp tlv-select port-description" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- set_fact: + expected_config: + timer: 3000 + holdtime: 100 + reinit: 5 + tlv_select: + management_address: false + system_description: false + +- assert: + that: + - expected_config == ansible_facts.network_resources.lldp_global diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/deleted.yaml new file mode 100644 index 00000000..fc8b8f88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/deleted.yaml @@ -0,0 +1,28 @@ +--- +- include_tasks: _reset_config.yaml + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- name: Returns LLDP configuration to default parameters + register: result + become: true + arista.eos.eos_lldp_global: + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + +- assert: + that: + - ansible_facts.network_resources.lldp_global == {} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/empty_config.yaml new file mode 100644 index 00000000..ea65cfd2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/empty_config.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: START eos.eos_lldp_global empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_global: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lldp_global empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/gathered.yaml new file mode 100644 index 00000000..1c33a2b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lldp_global gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lldp_global: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + + - assert: + that: + - ansible_facts.network_resources.lldp_global == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/merged.yaml new file mode 100644 index 00000000..0b3e414c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/merged.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + system_description: true + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- name: Merge provided LLDP configuration with device configuration + register: result + become: true + arista.eos.eos_lldp_global: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + +- set_fact: + expected_config: + timer: 3000 + holdtime: 100 + reinit: 5 + tlv_select: + management_address: false + port_description: false + +- assert: + that: + - ansible_facts.network_resources.lldp_global == expected_config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/parsed.yaml new file mode 100644 index 00000000..94f6bbea --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lldp_global: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/rendered.yaml new file mode 100644 index 00000000..80b90b57 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/rendered.yaml @@ -0,0 +1,21 @@ +--- +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + system_description: true + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lldp_global: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered.sort() == result.rendered.sort() + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/replaced.yaml new file mode 100644 index 00000000..eb209ecd --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/tests/common/replaced.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + system_description: true + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- name: Replaces device configuration with provided LLDP configuration + register: result + become: true + arista.eos.eos_lldp_global: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.before + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_global + +- assert: + that: + - ansible_facts.network_resources.lldp_global == result.after + +- set_fact: + expected_config: + holdtime: 100 + tlv_select: + management_address: false + port_description: false + +- assert: + that: + - ansible_facts.network_resources.lldp_global == expected_config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/vars/main.yaml new file mode 100644 index 00000000..e8ee687d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_global/vars/main.yaml @@ -0,0 +1,17 @@ +--- +parsed: + config: + holdtime: 100 + timer: 3000 + reinit: 5 + tlv_select: + management_address: false + system_description: false + +rendered: + - "lldp holdtime 100" + - "lldp timer None" + - "no lldp tlv-select port-description" + - "lldp tlv-select system-description" + - "no lldp tlv-select management-address" + - "lldp reinit None" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..022a212b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: cli_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..2862e7b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: test_cases + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + delegate_to: localhost + register: eapi_cases + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..0bc2f5f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,5 @@ +interface Ethernet1 + no lldp transmit +interface Ethernet2 + no lldp transmit + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_reset_config.yaml new file mode 100644 index 00000000..6cba9bf9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/_reset_config.yaml @@ -0,0 +1,29 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "interface Ethernet1" + - " no lldp receive" + - " lldp transmit" + - "interface Ethernet2" + - " lldp receive" + - " no lldp transmit" + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- set_fact: + expected_config: + + - name: Ethernet1 + receive: false + + - name: Ethernet2 + transmit: false + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..87f3aebe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml @@ -0,0 +1,40 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + expected_config: + + - name: Ethernet2 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Returns interface lldp parameterss to default parameters + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces == expected_config diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..2fae304c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_lldp_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..0f2fde22 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lldp_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_lldp_interfaces: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + + - assert: + that: + - ansible_facts.network_resources.lldp_interfaces == result.gathered diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..8e7375b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml @@ -0,0 +1,51 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + transmit: false + + - name: Ethernet2 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - name: Ethernet1 + transmit: false + receive: false + + - name: Ethernet2 + transmit: false + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..10fec735 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml @@ -0,0 +1,38 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Override the LLDP configuration of all interfaces with provided configuration + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- assert: + that: + - config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..1f235217 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/parsed.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_lldp_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + transmit: false + - name: Ethernet2 + transmit: false + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_lldp_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - config == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..8331802e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rendered.yaml @@ -0,0 +1,31 @@ +--- +- debug: + msg: START eos_lldp_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- set_fact: + config: + - name: Ethernet1 + transmit: false + - name: Ethernet2 + transmit: false + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: rendered + +- set_fact: + rendered: + - "interface Ethernet1" + - "no lldp transmit" + - "interface Ethernet2" + - "no lldp transmit" + +- name: Assert + assert: + that: + - rendered|symmetric_difference(result.rendered) == [] + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..1dc1b0ce --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - name: Ethernet1 + transmit: false + other_config: + + - name: Ethernet2 + transmit: false + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- name: Replace existing LLDP configuration of specified interfaces with provided + configuration + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..ce910f4b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_lldp_interfaces/tests/common/rtt.yaml @@ -0,0 +1,63 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - name: Ethernet1 + transmit: false + + config2: + + - name: Ethernet2 + receive: false + +- name: Merge provided configuration with device configuration(base config). + register: baseconfig + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: lldp_interfaces + +- assert: + that: + - ansible_facts.network_resources.lldp_interfaces|symmetric_difference(baseconfig.after) + == [] + +- name: Merge provided configuration with device configuration(config to be reverted). + register: result + become: true + arista.eos.eos_lldp_interfaces: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - name: Ethernet1 + transmit: false + receive: false + + - name: Ethernet2 + transmit: false + receive: false + +- assert: + that: + - expected_config|symmetric_difference(result.after) == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_lldp_interfaces: + config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/basic.yaml new file mode 100644 index 00000000..87d5a464 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/basic.yaml @@ -0,0 +1,155 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Set up host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Set up host logging again (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == false + +- name: Delete/disable host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Console logging with level warnings + become: true + register: result + arista.eos.eos_logging: + dest: console + level: warnings + state: present + +- assert: + that: + - result.changed == true + - '"logging console warnings" in result.commands' + +- name: Configure buffer size + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 480000 + +- assert: + that: + - result.changed == true + - '"logging buffered 480000" in result.commands' + +- name: Set up logging destination and facility at the same time + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 4096 + facility: local7 + level: informational + state: present + +- assert: + that: + - result.changed == true + - '"logging buffered 4096 informational" in result.commands' + - '"logging facility local7" in result.commands' + +- name: Set up logging destination and facility at the same time again (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 4096 + facility: local7 + level: informational + state: present + +- assert: + that: + - result.changed == false + +- name: Set up logging facility alone + become: true + register: result + arista.eos.eos_logging: + facility: local2 + state: present + +- assert: + that: + - result.changed == true + - '"logging facility local2" in result.commands' + +- name: Set up logging facility (idempotent) + become: true + register: result + arista.eos.eos_logging: + facility: local2 + state: present + +- assert: + that: + - result.changed == false + +- name: remove logging as collection tearDown + become: true + register: result + arista.eos.eos_logging: + aggregate: + + - dest: console + level: warnings + state: absent + + - dest: buffered + level: informational + size: 4096 + state: absent + + - facility: local2 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging console" in result.commands' + - '"no logging buffered" in result.commands' + - '"no logging facility local2" in result.commands' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/net_logging.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/net_logging.yaml new file mode 100644 index 00000000..947ab02c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/cli/net_logging.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_logging.yaml on connection={{ ansible_connection + }}" + +- name: Delete/disable host logging- setup + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- name: Set up host logging using platform agnostic module + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging- teardown + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- debug: msg="END eos cli/net_logging.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/basic.yaml new file mode 100644 index 00000000..afa2bea9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/basic.yaml @@ -0,0 +1,97 @@ +--- +- debug: msg="START eapi/basic.yaml on connection={{ ansible_connection }}" + +- name: Set up host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Set up host logging again (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == false + +- name: Delete/disable host logging + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging (idempotent) + become: true + register: result + arista.eos.eos_logging: + dest: host + name: 172.16.0.1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Console logging with level warnings + become: true + register: result + arista.eos.eos_logging: + dest: console + level: warnings + state: present + +- assert: + that: + - result.changed == true + - '"logging console warnings" in result.commands' + +- name: Configure buffer size + become: true + register: result + arista.eos.eos_logging: + dest: buffered + size: 480000 + +- assert: + that: + - result.changed == true + - '"logging buffered 480000" in result.commands' + +- name: remove logging as collection tearDown + become: true + register: result + arista.eos.eos_logging: + aggregate: + + - dest: console + level: warnings + state: absent + + - dest: buffered + size: 480000 + state: absent + +- assert: + that: + - result.changed == true + - '"no logging console" in result.commands' + - '"no logging buffered" in result.commands' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/net_logging.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/net_logging.yaml new file mode 100644 index 00000000..452728db --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_logging/tests/eapi/net_logging.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START eos eapi/net_logging.yaml on connection={{ ansible_connection + }}" + +- name: Delete/disable host logging- setup + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- name: Set up host logging using platform agnostic module + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: present + +- assert: + that: + - result.changed == true + - '"logging host 172.16.0.1" in result.commands' + +- name: Delete/disable host logging- teardown + become: true + register: result + ansible.netcommon.net_logging: + dest: host + name: 172.16.0.1 + state: absent + +- debug: msg="END eos eapi/net_logging.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/templates/populate.cfg new file mode 100644 index 00000000..3a4b518c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/templates/populate.cfg @@ -0,0 +1,17 @@ +interface Vlan2 + ospfv3 ipv4 area 0.0.0.6 + ospfv3 ipv4 hello-interval 45 + ospfv3 ipv4 retransmit-interval 100 +interface Vlan1 + ip ospf dead-interval 29 + ip ospf mtu-ignore + ip ospf hello-interval 66 + ospfv3 hello-interval 77 + ospfv3 cost 106 + ospfv3 transmit-delay 100 + ospfv3 ipv4 area 0.0.0.5 + ospfv3 ipv4 priority 45 + ospfv3 ipv6 retransmit-interval 115 + ospfv3 ipv6 dead-interval 56 + ospfv3 ipv6 passive-interface + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_parsed.cfg new file mode 100644 index 00000000..8043f970 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_parsed.cfg @@ -0,0 +1,17 @@ +interface Vlan1 + ip ospf dead-interval 29 + ip ospf mtu-ignore + ip ospf hello-interval 66 + ospfv3 hello-interval 77 + ospfv3 cost 106 + ospfv3 transmit-delay 100 + ospfv3 ipv4 area 0.0.0.5 + ospfv3 ipv4 priority 45 + ospfv3 ipv6 retransmit-interval 115 + ospfv3 ipv6 dead-interval 56 + ospfv3 ipv6 passive-interface +interface Vlan2 + ospfv3 ipv4 area 0.0.0.6 + ospfv3 ipv4 hello-interval 45 + ospfv3 ipv4 retransmit-interval 100 + diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_remove_config.yaml new file mode 100644 index 00000000..690eff73 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no interface Vlan1" + - "no interface Vlan2" + - "no interface Vlan3" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/deleted.yaml new file mode 100644 index 00000000..8a642e3f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/deleted.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: Start eos_ospf_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: delete given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + - afi: "ipv6" + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 12 + - result.changed == true + - result.commands|symmetric_difference(deleted.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/empty_config.yaml new file mode 100644 index 00000000..7024fae6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START eos_ospf_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospf_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/gathered.yaml new file mode 100644 index 00000000..abc1a841 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/gathered.yaml @@ -0,0 +1,29 @@ +--- +- debug: + msg: Start eos_ospf_interfaces gathered integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.changed == false + - result.gathered|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/merged.yaml new file mode 100644 index 00000000..56c773de --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/merged.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: Start eos_ospf_interfaces merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: merge given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + - afi: "ipv6" + hello_interval: 77 + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv6" + retransmit_interval: 115 + dead_interval: 56 + passive_interface: true + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 16 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/overridden.yaml new file mode 100644 index 00000000..3b483610 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/overridden.yaml @@ -0,0 +1,51 @@ +--- +- debug: + msg: Start eos_ospf_interfaces overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: overridde device ocnfiguration with given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv6" + cost: 44 + bfd: true + ip_params: + - afi: "ipv6" + mtu_ignore: true + network: "point-to-point" + dead_interval: 56 + state: overridden + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 18 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/parsed.yaml new file mode 100644 index 00000000..db22340a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_ospf_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_ospf_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result.parsed) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rendered.yaml new file mode 100644 index 00000000..04bcce8c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rendered.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: Start eos_ospf_interfaces rendered integration tests ansible_connection={{ + ansible_connection }} + + +- block: + + - name: render native config + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + - afi: "ipv6" + hello_interval: 77 + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv6" + retransmit_interval: 115 + dead_interval: 56 + passive_interface: true + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/replaced.yaml new file mode 100644 index 00000000..aff1c14d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/replaced.yaml @@ -0,0 +1,51 @@ +--- +- debug: + msg: Start eos_ospf_interfaces replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: replace device ocnfiguration with given ospf interfaces configuration + become: true + register: result + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv6" + cost: 44 + bfd: true + ip_params: + - afi: "ipv6" + mtu_ignore: true + network: "point-to-point" + dead_interval: 56 + state: replaced + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 14 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospf_interfaces: *id001 + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rtt.yaml new file mode 100644 index 00000000..e65ba878 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/tests/common/rtt.yaml @@ -0,0 +1,80 @@ +--- +- debug: + msg: Start eos_ospf_interfaces rtt integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: merge given ospf interfaces configuration + become: true + register: baseconfig + arista.eos.eos_ospf_interfaces: &id001 + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + - afi: "ipv6" + hello_interval: 77 + cost: 106 + transmit_delay: 100 + ip_params: + - afi: "ipv6" + retransmit_interval: 115 + dead_interval: 56 + passive_interface: true + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - baseconfig.commands|length == 16 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Apply the provided configuration (config to be reverted) check + become: true + register: result + arista.eos.eos_ospf_interfaces: + config: + - name: "Vlan2" + address_family: + - afi: "ipv4" + dead_interval: 29 + mtu_ignore: true + hello_interval: 66 + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_ospf_interfaces: + config: "{{ ansible_facts['network_resources']['ospf_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/vars/main.yaml new file mode 100644 index 00000000..801ddfe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospf_interfaces/vars/main.yaml @@ -0,0 +1,126 @@ +--- +deleted: + commands: + - interface Vlan1 + - no ip ospf dead-interval 29 + - no ip ospf hello-interval 66 + - no ip ospf mtu-ignore + - no ospfv3 cost 106 + - no ospfv3 hello-interval 77 + - no ospfv3 transmit-delay 100 + - no ospfv3 ipv4 priority 45 + - no ospfv3 ipv4 area 0.0.0.5 + - no ospfv3 ipv6 passive-interface + - no ospfv3 ipv6 dead-interval 56 + - no ospfv3 ipv6 retransmit-interval 115 +merged: + commands: + - interface Vlan1 + - ip ospf dead-interval 29 + - ip ospf mtu-ignore + - ip ospf hello-interval 66 + - ospfv3 hello-interval 77 + - ospfv3 cost 106 + - ospfv3 transmit-delay 100 + - ospfv3 ipv4 area 0.0.0.5 + - ospfv3 ipv4 priority 45 + - ospfv3 ipv6 retransmit-interval 115 + - ospfv3 ipv6 dead-interval 56 + - ospfv3 ipv6 passive-interface + - interface Vlan2 + - ospfv3 ipv4 area 0.0.0.6 + - ospfv3 ipv4 hello-interval 45 + - ospfv3 ipv4 retransmit-interval 100 +replaced: + commands: + - interface Vlan1 + - no ip ospf dead-interval 29 + - no ip ospf hello-interval 66 + - no ip ospf mtu-ignore + - ospfv3 cost 44 + - ospfv3 bfd + - no ospfv3 ipv4 priority 45 + - no ospfv3 ipv4 area 0.0.0.5 + - ospfv3 ipv6 mtu-ignore + - ospfv3 ipv6 network point-to-point + - no ospfv3 ipv6 passive-interface + - no ospfv3 ipv6 retransmit-interval 115 + - no ospfv3 hello-interval 77 + - no ospfv3 transmit-delay 100 +overridden: + commands: + - interface Vlan2 + - no ospfv3 ipv4 hello-interval 45 + - no ospfv3 ipv4 retransmit-interval 100 + - no ospfv3 ipv4 area 0.0.0.6 + - interface Vlan1 + - no ip ospf dead-interval 29 + - no ip ospf hello-interval 66 + - no ip ospf mtu-ignore + - ospfv3 cost 44 + - ospfv3 bfd + - no ospfv3 ipv4 priority 45 + - no ospfv3 ipv4 area 0.0.0.5 + - ospfv3 ipv6 mtu-ignore + - ospfv3 ipv6 network point-to-point + - no ospfv3 ipv6 passive-interface + - no ospfv3 ipv6 retransmit-interval 115 + - no ospfv3 hello-interval 77 + - no ospfv3 transmit-delay 100 +roundtrip: + commands: + - interface GigabitEthernet0/1 + - ip access-group aclv401 in +gathered: + config: + - name: Loopback888 + - access_groups: + - acls: + - direction: in + name: aclv401 + - direction: out + name: aclv402 + afi: ipv4 + - acls: + - direction: out + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/0 + - access_groups: + - acls: + - direction: in + name: aclv601 + afi: ipv6 + name: GigabitEthernet0/1 + - name: GigabitEthernet0/2 + - name: GigabitEthernet0/3 +parsed: + config: + - name: "Vlan1" + address_family: + - afi: "ipv4" + dead_interval: 29 + hello_interval: 66 + mtu_ignore: true + - afi: "ipv6" + cost: 106 + hello_interval: 77 + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.5" + priority: 45 + - afi: "ipv6" + dead_interval: 56 + passive_interface: true + retransmit_interval: 115 + transmit_delay: 100 + - name: "Vlan2" + address_family: + - afi: "ipv6" + ip_params: + - afi: "ipv4" + area: + area_id: "0.0.0.6" + hello_interval: 45 + retransmit_interval: 100 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/templates/populate.cfg new file mode 100644 index 00000000..7d40fa3a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/templates/populate.cfg @@ -0,0 +1,18 @@ +router ospf 1 + router-id 170.21.0.4 + distance ospf intra-area 85 + redistribute static + area 0.0.0.2 filter 10.1.1.0/24 + area 0.0.0.50 range 172.20.0.0/16 cost 34 + network 10.10.2.0/24 area 0.0.0.0 + network 10.10.3.0/24 area 0.0.0.0 + max-lsa 8000 40 ignore-count 3 ignore-time 6 reset-time 20 + adjacency exchange-start threshold 20045623 + default-information originate metric 100 metric-type 1 + exit +router ospf 2 vrf vrf01 + area 0.0.0.9 default-cost 20 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + exit +router ospf 3 vrf vrf02 + redistribute connected diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_parsed.cfg new file mode 100644 index 00000000..ffc94513 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_parsed.cfg @@ -0,0 +1,16 @@ +router ospf 1 + adjacency exchange-start threshold 20045623 + area 0.0.0.2 filter 10.1.1.0/24 + area 0.0.0.50 range 172.20.0.0/16 cost 34 + default-information originate metric 100 metric-type 1 + distance ospf intra-area 85 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + network 10.10.2.0/24 area 0.0.0.0 + network 10.10.3.0/24 area 0.0.0.0 + redistribute static + router-id 170.21.0.4 +router ospf 2 vrf vrf01 + area 0.0.0.9 default-cost 20 + max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 +router ospf 3 vrf vrf02 + redistribute connected diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_remove_config.yaml new file mode 100644 index 00000000..663ad5fc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router ospf 1" + - "no router ospf 2" + - "no router ospf 3" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/deleted.yaml new file mode 100644 index 00000000..e305ed6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/deleted.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_ospfv2 deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &deleted + config: + processes: + - process_id: 1 + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - "'no router ospf 1' in result.commands" + - ansible_facts.network_resources.ospfv2 == result.after + - result.after.processes|symmetric_difference(deleted.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/empty_config.yaml new file mode 100644 index 00000000..13f26211 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/empty_config.yaml @@ -0,0 +1,64 @@ +--- +- debug: + msg: START eos_ospfv2 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: overridden + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv2: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/gathered.yaml new file mode 100644 index 00000000..55193fa2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_ospfv2 gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_ospfv2: + config: + state: gathered + + - name: Assert + assert: + that: + - gathered.config == result.gathered + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/merged.yaml new file mode 100644 index 00000000..626a2d25 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/merged.yaml @@ -0,0 +1,75 @@ +--- +- debug: + msg: Start eos_ospfv2 merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &merged + config: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: 10.10.2.0/24 + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + + - assert: + that: + - result.commands|length == 18 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after.processes|symmetric_difference(merged.after.processes) == [] + - result.before == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/overridden.yaml new file mode 100644 index 00000000..7df9f820 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/overridden.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: Start eos_ospfv2 overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &overridden + config: + processes: + - process_id: 2 + vrf: "vrf01" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + redistribute: + - routes: "isis" + isis_level: "level-1" + state: overridden + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - ansible_facts.network_resources.ospfv2 == result.after + - result.after.processes|symmetric_difference(overridden.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *overridden + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/parsed.yaml new file mode 100644 index 00000000..69c0d34e --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_ospfv2_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_ospfv2: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/replaced.yaml new file mode 100644 index 00000000..06621a5d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/replaced.yaml @@ -0,0 +1,52 @@ +--- +- debug: + msg: Start eos_ospfv2 replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given ospfv2 configuration + become: true + register: result + arista.eos.eos_ospfv2: &replaced + config: + processes: + - process_id: 2 + vrf: "vrf01" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + redistribute: + - routes: "isis" + isis_level: "level-1" + state: replaced + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - result.commands|length == 4 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after.processes|symmetric_difference(replaced.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv2: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/rtt.yaml new file mode 100644 index 00000000..77402db9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/tests/common/rtt.yaml @@ -0,0 +1,100 @@ +--- +- debug: + msg: Start eos_ospfv2 round trip integration tests ansible_connection={{ ansible_connection + }} + +- block: + + - name: merge attributes of given ospfv2(apply base config). + become: true + register: base_config + arista.eos.eos_ospfv2: + config: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: 10.10.2.0/24 + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv2 + + - assert: + that: + - base_config.commands|length == 18 + - base_config.changed == true + - base_config.commands|symmetric_difference(merged.commands) == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_ospfv2: + config: + processes: + - process_id: 1 + areas: + - area_id: "0.0.0.9" + default_cost: 20 + redistribute: + - routes: "isis" + isis_level: "level-1" + - process_id: 3 + vrf: "vrf02" + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_ospfv2: + config: "{{ ansible_facts['network_resources']['ospfv2'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: base_config.after == revert.after + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/vars/main.yaml new file mode 100644 index 00000000..36862ab6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv2/vars/main.yaml @@ -0,0 +1,318 @@ +--- +merged: + commands: + - router ospf 1 + - adjacency exchange-start threshold 20045623 + - area 0.0.0.2 filter 10.1.1.0/24 + - area 0.0.0.50 range 172.20.0.0/16 cost 34 + - default-information originate metric 100 metric-type 1 + - distance ospf intra-area 85 + - max-lsa 80000 40 ignore-count 3 ignore-time 6 reset-time 20 + - network 10.10.2.0/24 area 0.0.0.0 + - network 10.10.3.0/24 area 0.0.0.0 + - redistribute static + - router-id 170.21.0.4 + - exit + - router ospf 2 vrf vrf01 + - area 0.0.0.9 default-cost 20 + - exit + - router ospf 3 vrf vrf02 + - redistribute connected + after: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 12000 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +deleted: + after: + processes: + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +replaced: + commands: + - router ospf 2 vrf vrf01 + - no area 0.0.0.9 default-cost 20 + - redistribute isis level-1 + - exit + before: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 8000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 + after: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 8000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + redistribute: + - routes: "isis" + isis_level: "level-1" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +overridden: + commands: + - router ospf 2 vrf vrf01 + - no area 0.0.0.9 default-cost 20 + - redistribute isis level-1 + - exit + - no router ospf 1 + - no router ospf 3 + after: + processes: + - process_id: 2 + vrf: "vrf01" + redistribute: + - routes: "isis" + isis_level: "level-1" + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 +gathered: + config: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 8000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +parsed: + config: + processes: + - adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + process_id: 1 + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/templates/populate.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/templates/populate.cfg new file mode 100644 index 00000000..6cc382d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/templates/populate.cfg @@ -0,0 +1,46 @@ +router ospfv3 + fips restrictions + area 0.0.0.20 stub + area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + area 0.0.0.40 default-cost 45 + area 0.0.0.40 stub + timers pacing flood 7 + adjacency exchange-start threshold 11 + address-family ipv4 + fips restrictions + redistribute connected + exit + address-family ipv6 + router-id 10.1.1.1 + fips restrictions + exit + exit +router ospfv3 vrf vrf01 + bfd all-interfaces + fips restrictions + area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + log-adjacency-changes detail + address-family ipv4 + passive-interface default + fips restrictions + redistribute connected route-map MAP01 + maximum-paths 100 + exit + address-family ipv6 + fips restrictions + area 0.0.0.10 nssa no-summary + default-information originate route-map DefaultRouteFilter + max-metric router-lsa external-lsa 25 summary-lsa + exit + exit +router ospfv3 vrf vrf02 + fips restrictions + address-family ipv6 + router-id 10.17.0.3 + distance ospf intra-area 200 + fips restrictions + area 0.0.0.1 stub + timers throttle spf 56 56 56 + timers out-delay 10 + exit + exit diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_parsed.cfg new file mode 100644 index 00000000..6cc382d9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_parsed.cfg @@ -0,0 +1,46 @@ +router ospfv3 + fips restrictions + area 0.0.0.20 stub + area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + area 0.0.0.40 default-cost 45 + area 0.0.0.40 stub + timers pacing flood 7 + adjacency exchange-start threshold 11 + address-family ipv4 + fips restrictions + redistribute connected + exit + address-family ipv6 + router-id 10.1.1.1 + fips restrictions + exit + exit +router ospfv3 vrf vrf01 + bfd all-interfaces + fips restrictions + area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + log-adjacency-changes detail + address-family ipv4 + passive-interface default + fips restrictions + redistribute connected route-map MAP01 + maximum-paths 100 + exit + address-family ipv6 + fips restrictions + area 0.0.0.10 nssa no-summary + default-information originate route-map DefaultRouteFilter + max-metric router-lsa external-lsa 25 summary-lsa + exit + exit +router ospfv3 vrf vrf02 + fips restrictions + address-family ipv6 + router-id 10.17.0.3 + distance ospf intra-area 200 + fips restrictions + area 0.0.0.1 stub + timers throttle spf 56 56 56 + timers out-delay 10 + exit + exit diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_populate.yaml new file mode 100644 index 00000000..fd50ed14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_populate.yaml @@ -0,0 +1,5 @@ +--- +- name: Setup + become: true + arista.eos.eos_config: + src: populate.cfg diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_remove_config.yaml new file mode 100644 index 00000000..9e3c3a05 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/_remove_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Cleanup + become: true + arista.eos.eos_config: + lines: + - "no router ospfv3" + - "no router ospfv3 vrf vrf01" + - "no router ospfv3 vrf vrf02" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/deleted.yaml new file mode 100644 index 00000000..3f908cb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/deleted.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: Start eos_ospfv3 deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &deleted + config: + processes: + - vrf: "vrf01" + state: deleted + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv3 + + - assert: + that: + - result.commands|length == 1 + - result.changed == true + - "'no router ospfv3 vrf vrf01' in result.commands" + - ansible_facts.network_resources.ospfv3 == result.after + - result.after.processes|symmetric_difference(deleted.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *deleted + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/empty_config.yaml new file mode 100644 index 00000000..6907b699 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/empty_config.yaml @@ -0,0 +1,64 @@ +--- +- debug: + msg: START eos_ospfv3 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: merged + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: replaced + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: overridden + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + config: + state: rendered + become: true + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty config should give appropriate error message + register: result + ignore_errors: true + arista.eos.eos_ospfv3: + running_config: + state: parsed + become: true + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/gathered.yaml new file mode 100644 index 00000000..e326aefa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START eos_ospfv3 gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_ospfv3: + config: + state: gathered + + - name: Assert + assert: + that: + - populate.before == result.gathered + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/merged.yaml new file mode 100644 index 00000000..80aefc63 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/merged.yaml @@ -0,0 +1,117 @@ +--- +- debug: + msg: Start eos_ospfv3 merged integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &merged + config: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + + - assert: + that: + - result.commands|length == 46 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after.processes|symmetric_difference(populate.before.processes) == [] + - result.before == {} + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *merged + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/overridden.yaml new file mode 100644 index 00000000..2014b5da --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/overridden.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: Start eos_ospfv3 overridden integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: override given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &overridden + state: overridden + config: + processes: + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: 60.1.0.0/16 + cost: 30 + timers: + lsa: 10 + vrf: "vrf02" + + - assert: + that: + - result.commands|length == 16 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after.processes|symmetric_difference(overridden.after.processes) == [] + - result.before.processes|symmetric_difference(populate.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *overridden + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/parsed.yaml new file mode 100644 index 00000000..58f18eba --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_ospfv3: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed.processes|symmetric_difference(populate.before.processes) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rendered.yaml new file mode 100644 index 00000000..8cf0656c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rendered.yaml @@ -0,0 +1,102 @@ +--- +- debug: + msg: START eos_ospfv3 rendered integration tests on connection={{ ansible_connection + }} + +- block: + + - name: Structure provided configuration into device specific commands + become: true + register: result + arista.eos.eos_ospfv3: + config: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/replaced.yaml new file mode 100644 index 00000000..61885a8c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/replaced.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: Start eos_ospfv3 replaced integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: replace given ospfv3 configuration + become: true + register: result + arista.eos.eos_ospfv3: &replaced + state: replaced + config: + processes: + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: 60.1.0.0/16 + cost: 30 + timers: + lsa: 10 + vrf: "vrf02" + + - assert: + that: + - result.commands|length == 14 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after.processes|symmetric_difference(replaced.after.processes) == [] + - result.before.processes|symmetric_difference(replaced.before.processes) == [] + + - name: Idempotency check + become: true + register: result + arista.eos.eos_ospfv3: *replaced + + - assert: + that: + - result.commands|length == 0 + - result.changed == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rtt.yaml new file mode 100644 index 00000000..553e71fc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/tests/common/rtt.yaml @@ -0,0 +1,148 @@ +--- +- debug: + msg: Start eos_ospfv3 rtt integration tests ansible_connection={{ + ansible_connection }} + +- block: + + - name: merge given ospfv3 configuration + become: true + register: baseconfig + arista.eos.eos_ospfv3: &merged + config: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + + - assert: + that: + - baseconfig.commands|length == 46 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after.processes|symmetric_difference(populate.before.processes) == [] + - baseconfig.before == {} + + - become: true + arista.eos.eos_facts: + gather_network_resources: ospfv3 + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_ospfv3: + config: + processes: + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: 60.1.0.0/16 + cost: 30 + timers: + lsa: 10 + vrf: "vrf02" + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_ospfv3: + config: "{{ ansible_facts['network_resources']['ospfv3'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/vars/main.yaml new file mode 100644 index 00000000..e1fe0fcc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_ospfv3/vars/main.yaml @@ -0,0 +1,449 @@ +--- +merged: + commands: + - router ospfv3 vrf vrf01 + - address-family ipv4 + - redistribute connected route-map MAP01 + - fips restrictions + - maximum-paths 100 + - passive-interface default + - exit + - address-family ipv6 + - area 0.0.0.10 nssa no-summary + - default-information originate route-map DefaultRouteFilter + - fips restrictions + - max-metric router-lsa external-lsa 25 summary-lsa + - exit + - area 0.0.0.0 encryption ipsec spi 44 esp null sha1 passphrase 7 7hl8FV3lZ6H1mAKpjL47hQ== + - bfd all-interfaces + - fips restrictions + - log-adjacency-changes detail + - exit + - router ospfv3 + - address-family ipv4 + - redistribute connected + - fips restrictions + - exit + - address-family ipv6 + - fips restrictions + - router-id 10.1.1.1 + - exit + - adjacency exchange-start threshold 11 + - area 0.0.0.20 authentication ipsec spi 33 sha1 passphrase 7 4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w + - area 0.0.0.20 stub + - area 0.0.0.40 default-cost 45 + - area 0.0.0.40 stub + - fips restrictions + - timers pacing flood 7 + - exit + - router ospfv3 vrf vrf02 + - address-family ipv6 + - area 0.0.0.1 stub + - distance ospf intra-area 200 + - fips restrictions + - router-id 10.17.0.3 + - timers out-delay 10 + - timers throttle spf 56 56 56 + - exit + - fips restrictions + - exit + after: + processes: + - process_id: 1 + adjacency: + exchange_start: + threshold: 20045623 + areas: + - filter: + address: "10.1.1.0/24" + area_id: "0.0.0.2" + - area_id: "0.0.0.50" + range: + address: "172.20.0.0/16" + cost: 34 + default_information: + metric: 100 + metric_type: 1 + originate: true + distance: + intra_area: 85 + max_lsa: + count: 80000 + ignore_count: 3 + ignore_time: 6 + reset_time: 20 + threshold: 40 + networks: + - area: "0.0.0.0" + prefix: "10.10.2.0/24" + - area: "0.0.0.0" + prefix: "10.10.3.0/24" + redistribute: + - routes: "static" + router_id: "170.21.0.4" + - process_id: 2 + vrf: "vrf01" + areas: + - area_id: "0.0.0.9" + default_cost: 20 + max_lsa: + count: 12000 + - process_id: 3 + vrf: "vrf02" + redistribute: + - routes: "connected" + max_lsa: + count: 12000 +deleted: + after: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" +replaced: + commands: + - router ospfv3 vrf vrf02 + - address-family ipv6 + - no fips restrictions + - no router-id + - no timers out-delay 10 + - no timers throttle spf 56 56 56 + - redistribute static + - exit + - address-family ipv4 + - area 0.0.0.3 range 60.1.0.0/16 cost 30 + - timers lsa arrival 10 + - exit + - no fips restrictions + - exit + before: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" + after: + processes: + - address_family: + - afi: "ipv4" + redistribute: + - routes: "connected" + - afi: "ipv6" + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: "60.1.0.0/16" + cost: 30 + timers: + lsa: 10 + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + vrf: "vrf02" +overridden: + commands: + - no router ospfv3 + - no router ospfv3 vrf vrf01 + - router ospfv3 vrf vrf02 + - address-family ipv6 + - no fips restrictions + - no router-id + - no timers out-delay 10 + - no timers throttle spf 56 56 56 + - redistribute static + - exit + - address-family ipv4 + - area 0.0.0.3 range 60.1.0.0/16 cost 30 + - timers lsa arrival 10 + - exit + - no fips restrictions + - exit + after: + processes: + - address_family: + - afi: "ipv4" + areas: + - area_id: "0.0.0.3" + ranges: + - address: "60.1.0.0/16" + cost: 30 + timers: + lsa: 10 + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + redistribute: + - routes: "static" + vrf: "vrf02" +populate: + before: + processes: + - address_family: + - afi: "ipv4" + fips_restrictions: true + redistribute: + - routes: "connected" + - afi: "ipv6" + fips_restrictions: true + router_id: "10.1.1.1" + adjacency: + exchange_start: + threshold: 11 + areas: + - area_id: "0.0.0.20" + authentication: + algorithm: "sha1" + hidden_key: true + passphrase: "4O8T3zo4xBdRWXBnsnK934o9SEb+jEhHUN6+xzZgCo2j9EnQBUvtwNxxLEmYmm6w" + spi: 33 + stub: + set: true + - area_id: "0.0.0.40" + default_cost: 45 + stub: + set: true + fips_restrictions: true + timers: + pacing: 7 + vrf: "default" + - address_family: + - afi: "ipv4" + fips_restrictions: true + maximum_paths: 100 + passive_interface: true + redistribute: + - route_map: "MAP01" + routes: "connected" + - afi: "ipv6" + areas: + - area_id: "0.0.0.10" + nssa: + no_summary: true + default_information: + originate: true + route_map: "DefaultRouteFilter" + fips_restrictions: true + max_metric: + router_lsa: + external_lsa: + max_metric_value: 25 + summary_lsa: + set: true + areas: + - area_id: "0.0.0.0" + encryption: + spi: 44 + algorithm: "sha1" + encryption: "null" + hidden_key: true + passphrase: "7hl8FV3lZ6H1mAKpjL47hQ==" + bfd: + all_interfaces: true + fips_restrictions: true + log_adjacency_changes: + detail: true + vrf: "vrf01" + - address_family: + - afi: "ipv6" + areas: + - area_id: "0.0.0.1" + stub: + set: true + distance: 200 + fips_restrictions: true + router_id: "10.17.0.3" + timers: + out_delay: 10 + throttle: + initial: 56 + max: 56 + min: 56 + spf: true + fips_restrictions: true + vrf: "vrf02" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/defaults/main.yaml new file mode 100644 index 00000000..5f709c5a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/cli.yaml new file mode 100644 index 00000000..477df469 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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 + tags: network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/eapi.yaml new file mode 100644 index 00000000..679a7144 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/eapi" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/main.yaml new file mode 100644 index 00000000..9806e592 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tasks/main.yaml @@ -0,0 +1,6 @@ +--- +- include: cli.yaml + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_config.yaml new file mode 100644 index 00000000..c16f7ca7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_config.yaml @@ -0,0 +1,109 @@ +--- +# arista.eos.eos_config -> NetworkConfig, dumps + +- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}" + +- name: setup + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ cli }}" + become: true + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ cli }}" + become: true + register: config + +- name: configure hostname + arista.eos.eos_config: + lines: hostname foo + config: "{{ config.stdout[0] }}" + provider: "{{ cli }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ cli }}" + become: true + register: config + +- name: teardown + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ cli }}" + become: true + +# hit block and diffs +- block: + - name: setup + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + provider: "{{ cli }}" + become: true + + - name: configure sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ cli }}" + match: line + become: true + register: result + + - assert: + that: + - "result.changed == true" + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + + - name: check sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ cli }}" + match: exact + become: true + register: result + + always: + - name: teardown + arista.eos.eos_config: + lines: no ip access-list test + match: none + provider: "{{ cli }}" + become: true + +- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_utils.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_utils.yaml new file mode 100644 index 00000000..1e7d30a7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/common_utils.yaml @@ -0,0 +1,66 @@ +--- +# eos_static_route -> remove_default_spec, validate_ip_address, validate_prefix +# eos_interface -> conditional +# eos_command -> ComplexList + +- debug: msg="START cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit remove_default_spec() validate_ip_address() validate_prefix() ComplexList +- name: setup - remove config used in test + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ cli }}" + become: true + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ cli }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/250 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ cli }}" + become: true + register: result + ignore_errors: true + +- assert: + that: + - "result.failed == true" + +- name: teardown + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ cli }}" + become: true + +- debug: msg="END cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit conditional() +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Check intent arguments + eos_interface: + name: "{{ test_interface_1 }}" + state: up + tx_rate: ge(0) + rx_rate: ge(0) + provider: "{{ cli }}" + become: true + register: result diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/misc_tests.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/misc_tests.yaml new file mode 100644 index 00000000..03841f28 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/misc_tests.yaml @@ -0,0 +1,29 @@ +--- +- debug: msg="START cli/misc_tests.yaml on connection={{ ansible_connection }}" + + +# test become and unbecome +- block: + - name: command that does require become (should fail) + arista.eos.eos_command: + commands: show running-config + become: false + ignore_errors: true + register: result + + - assert: + that: + - 'result.failed == true' + - '"privileged mode required" in result.msg' + + - name: command that doesn't require become + arista.eos.eos_command: + commands: show uptime + become: false + + - name: wrong transport specified in provider + arista.eos.eos_command: + commands: show version + provider: "{{ eapi }}" + + when: "ansible_connection != 'local'" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/reboot.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/reboot.yaml new file mode 100644 index 00000000..20f886fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/cli/reboot.yaml @@ -0,0 +1,20 @@ +--- +- block: + - cli_command: + command: reload power + prompt: + - "yes/no/cancel/diff]" + - "confirm]" + answer: + - "no" + - "" + check_all: true + become: true + + - wait_for_connection: + delay: 20 + sleep: 10 + + - cli_command: + command: show version + when: ansible_connection.endswith("network_cli") diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_config.yaml new file mode 100644 index 00000000..f5cceb55 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_config.yaml @@ -0,0 +1,109 @@ +--- +# arista.eos.eos_config -> NetworkConfig, dumps + +- debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}" + +- name: setup + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ eapi }}" + become: true + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ eapi }}" + become: true + register: config + +- name: configure hostname + arista.eos.eos_config: + lines: hostname foo + config: "{{ config.stdout[0] }}" + provider: "{{ eapi }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'hostname foo' in result.updates" + +- name: get current running-config + arista.eos.eos_command: + commands: show running-config + provider: "{{ eapi }}" + become: true + register: config + +- name: teardown + arista.eos.eos_config: + lines: hostname {{ inventory_hostname_short }} + match: none + provider: "{{ eapi }}" + become: true + +# hit block and diffs +- block: + - name: setup + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + parents: ip access-list test + before: no ip access-list test + after: exit + match: strict + provider: "{{ eapi }}" + become: true + + - name: configure sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ eapi }}" + match: line + become: true + register: result + + - assert: + that: + - "result.changed == true" + - "'ip access-list test' in result.updates" + - "'10 permit ip host 192.0.2.1 any log' in result.updates" + - "'20 permit ip host 192.0.2.2 any log' in result.updates" + - "'30 permit ip host 192.0.2.3 any log' in result.updates" + - "'40 permit ip host 192.0.2.4 any log' in result.updates" + + - name: check sub level command using block replace + arista.eos.eos_config: + lines: + - 10 permit ip host 192.0.2.1 any log + - 20 permit ip host 192.0.2.2 any log + - 30 permit ip host 192.0.2.3 any log + - 40 permit ip host 192.0.2.4 any log + parents: ip access-list test + replace: block + after: exit + provider: "{{ eapi }}" + match: exact + become: true + register: result + + always: + - name: teardown + arista.eos.eos_config: + lines: no ip access-list test + match: none + provider: "{{ eapi }}" + become: true + +- debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_utils.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_utils.yaml new file mode 100644 index 00000000..66f369f9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_smoke/tests/eapi/common_utils.yaml @@ -0,0 +1,66 @@ +--- +# arista.eos.eos_static_route -> remove_default_spec, validate_ip_address, validate_prefix +# arista.eos.eos_interface -> conditional +# arista.eos.eos_command -> ComplexList + +- debug: msg="START cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit remove_default_spec() validate_ip_address() validate_prefix() ComplexList +- name: setup - remove config used in test + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ eapi }}" + become: true + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ eapi }}" + become: true + register: result + +- assert: + that: + - "result.changed == true" + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: configure static route + arista.eos.eos_static_route: + address: 192.168.3.0/250 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: "{{ eapi }}" + become: true + register: result + ignore_errors: true + +- assert: + that: + - "result.failed == true" + +- name: teardown + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: "{{ eapi }}" + become: true + +- debug: msg="END cli/common_utils.yaml on connection={{ ansible_connection }}" + +# hit conditional() +- name: Set test interface + set_fact: + test_interface_1: ethernet1 + +- name: Check intent arguments + arista.eos.eos_interface: + name: "{{ test_interface_1 }}" + state: up + tx_rate: ge(0) + rx_rate: ge(0) + provider: "{{ eapi }}" + become: true + register: result diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/basic.yaml new file mode 100644 index 00000000..3b8bca3c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/basic.yaml @@ -0,0 +1,126 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup - remove config used in test + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + - no ip route 192.168.4.0/24 192.168.0.1 + - no ip route 192.168.5.0/24 192.168.0.1 + provider: '{{ cli }}' + +- name: configure static route + become: true + register: result + arista.eos.eos_static_route: &id001 + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: configure static route(Idempotence) + become: true + register: result + arista.eos.eos_static_route: *id001 + +- assert: + that: + - result.changed == false + +- name: delete static route + become: true + register: result + arista.eos.eos_static_route: &id002 + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: '{{ cli }}' + state: absent + +- assert: + that: + - result.changed == true + - "'no ip route 192.168.3.0/24 192.168.0.1' in result.commands" + +- name: delete static route + become: true + register: result + arista.eos.eos_static_route: *id002 + +- assert: + that: + - result.changed == false + +- name: configure static routes using aggregate + become: true + register: result + arista.eos.eos_static_route: &id003 + aggregate: + + - address: 192.168.4.0/24 + next_hop: 192.168.0.1 + + - address: 192.168.5.0/24 + next_hop: 192.168.0.1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'ip route 192.168.4.0/24 192.168.0.1 1' in result.commands" + - "'ip route 192.168.5.0/24 192.168.0.1 1' in result.commands" + +- name: configure static routes using aggregate(Idemporence) + become: true + register: result + arista.eos.eos_static_route: *id003 + +- assert: + that: + - result.changed == false + +- name: delete static routes using aggregate + become: true + register: result + arista.eos.eos_static_route: &id004 + aggregate: + + - address: 192.168.4.0/24 + next_hop: 192.168.0.1 + + - address: 192.168.5.0/24 + next_hop: 192.168.0.1 + state: absent + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no ip route 192.168.4.0/24 192.168.0.1' in result.commands" + - "'no ip route 192.168.5.0/24 192.168.0.1' in result.commands" + +- name: delete static routes using aggregate(Idempotence) + become: true + register: result + arista.eos.eos_static_route: *id004 + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + - no ip route 192.168.4.0/24 192.168.0.1 + - no ip route 192.168.5.0/24 192.168.0.1 + provider: '{{ cli }}' + +- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/net_static_route.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/net_static_route.yaml new file mode 100644 index 00000000..69e1bdff --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_route/tests/cli/net_static_route.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_static_route.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove config used in test + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: '{{ cli }}' + +- name: configure static route using platform agnostic module + become: true + register: result + ansible.netcommon.net_static_route: + address: 192.168.3.0/24 + next_hop: 192.168.0.1 + admin_distance: 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands" + +- name: teardown - remove config used in test + become: true + arista.eos.eos_config: + lines: + - no ip route 192.168.3.0/24 192.168.0.1 + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_static_route.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_parsed.cfg new file mode 100644 index 00000000..a4bb4d65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +ip route 10.1.1.0/24 Management1 +ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200 +ip route 10.50.0.0/16 Management1 +ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42 +ip route vrf testvrf 120.1.1.0/24 Ethernet1 23 +ip route vrf vrftest1 77.77.1.0/24 33.1.1.1 +ipv6 route 1000:10::/64 Ethernet1 67 tag 98 diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_populate.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_populate.yaml new file mode 100644 index 00000000..24c16dbb --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_populate.yaml @@ -0,0 +1,15 @@ +--- +- name: Setup + become: true + + arista.eos.eos_config: + lines: + - "vrf definition testvrf" + - "vrf definition vrftest1" + - "ip route 10.1.1.0/24 Management1" + - "ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" + - "ip route 10.50.0.0/16 Management1" + - "ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" + - "ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" + - "ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" + - "ipv6 route 1000:10::/64 Ethernet1 67 tag 98" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_remove_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_remove_config.yaml new file mode 100644 index 00000000..0377bcad --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/_remove_config.yaml @@ -0,0 +1,30 @@ +--- +- name: Remove routes + become: true + arista.eos.eos_config: + lines: + - "no ip route 10.1.1.0/24 Management1" + - "no ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" + - "no ip route 10.50.0.0/16 Management1" + - "no ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" + - "no ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100" + - "no ip route 122.1.19.0/24 Nexthop-Group testgrp 21" + - "no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" + - "no ipv6 route 1000:10::/64 Ethernet1 55" + +- name: Remove testvrf VRF + become: true + arista.eos.eos_config: + lines: + - "no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" + - "no ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" + - "no vrf definition testvrf" + ignore_errors: true + +- name: Remove vrftest1 VRF + become: true + arista.eos.eos_config: + lines: + - "no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" + - "no vrf definition vrftest1" + ignore_errors: true diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/deleted.yaml new file mode 100644 index 00000000..7b732d07 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/deleted.yaml @@ -0,0 +1,204 @@ +--- +- debug: + msg: Start eos_static_routes deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + +- set_fact: + config1: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - interface: Ethernet1 + admin_distance: 23 + vrf: testvrf + +- set_fact: + config2: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + vrf: testvrf + +- set_fact: + config3: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - interface: Ethernet1 + admin_distance: 23 + vrf: testvrf + +- include_tasks: _populate.yaml + +- name: Delete attributes of given static routes - afi specific. + become: true + register: result + arista.eos.eos_static_routes: + config: + + - address_families: + + - afi: ipv6 + state: deleted + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config1) + == [] + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + become: true + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/gathered.yaml new file mode 100644 index 00000000..3b134729 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/gathered.yaml @@ -0,0 +1,97 @@ +--- +- debug: + msg: START eos_static_routes gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + state: gathered + + - set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + vrf: testvrf + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - " config | symmetric_difference(result['gathered']) == []" + + - name: Gather the existing running configuration (IDEMPOTENT) + become: true + register: result + arista.eos.eos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/merged.yaml new file mode 100644 index 00000000..4bbffbc7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/merged.yaml @@ -0,0 +1,137 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- name: merge attributes of given static routes. + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + - '"ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" in result.commands' + - '"ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100" in result.commands' + become: true + +- name: Idempotency check + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result.changed == false + - result.commands|length == 0 + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/overridden.yaml new file mode 100644 index 00000000..2fe80c6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/overridden.yaml @@ -0,0 +1,71 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- name: Override attributes of given static routes. + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + state: overridden + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + - result.commands|length == 8 + - '"no ipv6 route 1000:10::/64 Ethernet1 67 tag 98" in result.commands' + - '"no ip route 23.1.0.0/16 Nexthop-Group testgrp tag 42" in result.commands' + - '"no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23" in result.commands' + - '"no ip route 10.50.0.0/16 Management1" in result.commands' + - '"no ip route 10.1.1.0/24 Management1" in result.commands' + - '"no ip route 10.1.1.0/24 Ethernet1 20.1.1.3 track bfd 200" in result.commands' + - '"no ip route vrf vrftest1 77.77.1.0/24 33.1.1.1" in result.commands' + - '"ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55" in result.commands' + become: true + +- name: Idempotency check + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result.changed == false + - result.commands|length == 0 + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/parsed.yaml new file mode 100644 index 00000000..d9ef9c65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/parsed.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START eos_static_routes parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- name: Gather static_routes facts + become: true + register: static_routes_facts + arista.eos.eos_facts: + gather_subset: + - default + gather_network_resources: + - static_routes + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_static_routes: &id001 + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed'])\ + \ |length == 0 }}" + +- name: Gather the existing running configuration (IDEMPOTENT) + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result['changed'] == false + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rendered.yaml new file mode 100644 index 00000000..bb947942 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rendered.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START eos_static_routes rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + state: rendered + + - name: Assert that correct set of commands were generated + vars: + lines: + - ipv6 route vrf testvrf 1120:10::/64 Ethernet1 55 + - ip route 155.55.1.0/24 Nexthop-Group testgrp tag 100 + assert: + that: + - "{{ lines | symmetric_difference(result['rendered']) |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + arista.eos.eos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/replaced.yaml new file mode 100644 index 00000000..181227e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/replaced.yaml @@ -0,0 +1,119 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- name: Replace attributes of given static routes. + become: true + register: result + arista.eos.eos_static_routes: &id001 + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + state: replaced + +- become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + +- assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + - '"ipv6 route vrf testvrf 1000:10::/64 Ethernet1 55" in result.commands' + become: true + +- name: Idempotency check + become: true + register: result + arista.eos.eos_static_routes: *id001 + +- assert: + that: + - result.changed == false + - result.commands|length == 0 + +- include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rtt.yaml new file mode 100644 index 00000000..5c7b3f37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_static_routes/tests/common/rtt.yaml @@ -0,0 +1,243 @@ +--- +- debug: + msg: Start eos_static_routes merged integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- set_fact: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + revert_config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 10.1.1.0/24 + next_hops: + + - interface: Management1 + + - admin_distance: 200 + forward_router_address: 20.1.1.3 + interface: Ethernet1 + track: bfd + + - dest: 10.50.0.0/16 + next_hops: + + - interface: Management1 + + - dest: 23.1.0.0/16 + next_hops: + + - nexthop_grp: testgrp + tag: 42 + + - dest: 122.1.19.0/24 + next_hops: + + - admin_distance: 21 + nexthop_grp: testgrp + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + + - afi: ipv6 + routes: + + - dest: 1000:10::/64 + next_hops: + + - admin_distance: 67 + interface: Ethernet1 + tag: 98 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 77.77.1.0/24 + next_hops: + + - interface: 33.1.1.1 + vrf: vrftest1 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 120.1.1.0/24 + next_hops: + + - admin_distance: 23 + interface: Ethernet1 + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - admin_distance: 55 + interface: Ethernet1 + vrf: testvrf + +- block: + + - name: merge attributes of given static routes. + become: true + register: base_config + arista.eos.eos_static_routes: + config: + + - vrf: testvrf + address_families: + + - afi: ipv6 + routes: + + - dest: 1120:10::/64 + next_hops: + + - interface: Ethernet1 + admin_distance: 55 + + - address_families: + + - afi: ipv4 + routes: + + - dest: 155.55.1.0/24 + next_hops: + + - nexthop_grp: testgrp + tag: 100 + state: merged + + - become: true + arista.eos.eos_facts: + gather_network_resources: static_routes + + - assert: + that: + - ansible_facts.network_resources.static_routes|symmetric_difference(config) + == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + arista.eos.eos_static_routes: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 122.1.19.0/24 + next_hops: + + - nexthop_grp: testgrp + admin_distance: 21 + state: merged + + - assert: + that: + - result.after|symmetric_difference(revert_config) == [] + + - name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_static_routes: + config: "{{ ansible_facts['network_resources']['static_routes'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: + - ansible_facts.network_resources.static_routes | symmetric_difference(revert.after) + == [] + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/net_system.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/net_system.yaml new file mode 100644 index 00000000..11ccb29f --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/net_system.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START eos cli/net_system.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list using platform agnostic module + become: true + register: result + ansible.netcommon.net_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- debug: msg="END eos cli/net_system.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_list.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_list.yaml new file mode 100644 index 00000000..99e283b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_list.yaml @@ -0,0 +1,123 @@ +--- +- debug: msg="START cli/set_domain_list.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: verify domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + +- name: verify remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == false + +- name: add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list redhat.com' in result.commands" + +- name: verify add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + - "'ip domain-list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + - no ip domain-list eng.ansible.com + match: none + +- debug: msg="END cli/set_domain_list.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_name.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_name.yaml new file mode 100644 index 00000000..5f1ad237 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_domain_name.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START cli/set_domain_name.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- name: configure domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == true + +- name: verify domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_hostname.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_hostname.yaml new file mode 100644 index 00000000..dd7547bb --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START cli/set_hostname.yaml on connection={{ ansible_connection }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname switch + match: none + +- name: configure hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == true + +- name: verify hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname }} + match: none + +- debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_lookup_source.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_lookup_source.yaml new file mode 100644 index 00000000..0340a02a --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_lookup_source.yaml @@ -0,0 +1,72 @@ +--- +- debug: msg="START cli/set_lookup_source.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + +- name: configure lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Management1' in result.commands" + +- name: verify lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == false + +- name: change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == true + - "'no ip domain lookup source-interface Management1' in result.commands" + - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" + - result.commands|length == 2 + +- name: verify change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END cli/set_lookup_source.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_name_servers.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_name_servers.yaml new file mode 100644 index 00000000..ea1a0a2d --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/cli/set_name_servers.yaml @@ -0,0 +1,66 @@ +--- +- debug: msg="START cli/set_name_servers.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip name-server + - vrf definition ansible + match: none + +- name: configure name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 192.0.2.1' in result.commands" + - "'ip name-server 192.0.2.2' in result.commands" + - "'ip name-server 192.0.2.3' in result.commands" + +- name: verify name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == false + +- name: remove one + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 192.0.2.3' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/net_system.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/net_system.yaml new file mode 100644 index 00000000..d7b43e88 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/net_system.yaml @@ -0,0 +1,35 @@ +--- +- debug: msg="START eos eapi/net_system.yaml on connection={{ ansible_connection + }}" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list using platform agnostic module + become: true + register: result + ansible.netcommon.net_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- debug: msg="END eos eapi/net_system.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_list.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_list.yaml new file mode 100644 index 00000000..b34eca82 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_list.yaml @@ -0,0 +1,122 @@ +--- +- debug: msg="START eapi/set_domain_list.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + +- name: configure domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: verify domain_list + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + +- name: verify remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + +- assert: + that: + - result.changed == false + +- name: add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == true + - "'ip domain-list redhat.com' in result.commands" + +- name: verify add one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - redhat.com + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + - "'ip domain-list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + become: true + register: result + arista.eos.eos_system: + domain_list: + - ansible.com + - eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + - no ip domain-list eng.ansible.com + match: none + +- debug: msg="END eapi/set_domain_list.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_name.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_name.yaml new file mode 100644 index 00000000..733c54e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_domain_name.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START eapi/set_domain_name.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- name: configure domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == true + +- name: verify domain_name + become: true + register: result + arista.eos.eos_system: + domain_name: eng.ansible.com + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: no ip domain-name + match: none + +- debug: msg="END eapi/set_domain_name.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_hostname.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_hostname.yaml new file mode 100644 index 00000000..fcf76662 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START eapi/set_hostname.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: hostname switch + match: none + +- name: configure hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == true + +- name: verify hostname + become: true + register: result + arista.eos.eos_system: + hostname: foo + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: hostname {{ inventory_hostname }} + match: none + +- debug: msg="END eapi/set_hostname.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_lookup_source.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_lookup_source.yaml new file mode 100644 index 00000000..676b9fef --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_lookup_source.yaml @@ -0,0 +1,70 @@ +--- +- debug: msg="START eapi/set_lookup_source.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + +- name: configure lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Management1' in result.commands" + +- name: verify lookup_source + become: true + register: result + arista.eos.eos_system: + lookup_source: Management1 + +- assert: + that: + - result.changed == false + +- name: change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == true + - "'no ip domain lookup source-interface Management1' in result.commands" + - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" + - result.commands|length == 2 + +- name: verify change to vrf + become: true + register: result + arista.eos.eos_system: + lookup_source: + + - interface: Management1 + vrf: ansible + +- assert: + that: + - result.changed == false + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END eapi/set_lookup_source.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_name_servers.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_name_servers.yaml new file mode 100644 index 00000000..3dba50fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_system/tests/eapi/set_name_servers.yaml @@ -0,0 +1,64 @@ +--- +- debug: msg="START eapi/set_name_servers.yaml" + +- name: setup + become: true + arista.eos.eos_config: + lines: + - no ip name-server + - vrf definition ansible + match: none + +- name: configure name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 192.0.2.1' in result.commands" + - "'ip name-server 192.0.2.2' in result.commands" + - "'ip name-server 192.0.2.3' in result.commands" + +- name: verify name_servers + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == false + +- name: remove one + become: true + register: result + arista.eos.eos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 192.0.2.3' in result.commands" + +- name: teardown + become: true + arista.eos.eos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + +- debug: msg="END eapi/set_name_servers.yaml" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/defaults/main.yaml new file mode 100644 index 00000000..10c0fabc --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: '*' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/meta/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/meta/main.yaml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/eapi.yaml new file mode 100644 index 00000000..5f76cdb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/eapi.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/auth.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/auth.yaml new file mode 100644 index 00000000..8ff7eba0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/auth.yaml @@ -0,0 +1,42 @@ +--- +- block: + + - name: Create user with password + become: true + arista.eos.eos_user: + name: auth_user + privilege: 15 + role: network-operator + state: present + provider: '{{ cli }}' + configured_password: pass123 + + - name: test login + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no show version + responses: + (?i)password: pass123 + + - name: test login with invalid password (should fail) + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no show version + responses: + (?i)password: badpass + ignore_errors: true + register: results + + - name: check that attempt failed + assert: + that: + - results.failed + always: + + - name: delete user + become: true + register: result + arista.eos.eos_user: + name: auth_user + state: absent + provider: '{{ cli }}' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/basic.yaml new file mode 100644 index 00000000..8a2ec87c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/basic.yaml @@ -0,0 +1,100 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Set Up + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + - no username ansibletest2 + - no username ansibletest3 + - no username ansibletest4 + provider: '{{ cli }}' + +- name: Create user with role + become: true + register: result + arista.eos.eos_user: + name: ansibletest1 + privilege: 15 + role: network-operator + state: present + configured_password: test1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"secret" in result.commands[0]' + - '"role network-operator" in result.commands[1]' + - '"privilege 15" in result.commands[2]' + +- name: Create user with priv level and update_password + become: true + register: result + arista.eos.eos_user: + name: ansibletest4 + privilege: 15 + state: present + configured_password: test1 + update_password: on_create + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"secret" in result.commands[0]' + - '"privilege 15" in result.commands[1]' + +- name: Collection of users + become: true + register: result + arista.eos.eos_user: + aggregate: + + - name: ansibletest2 + configured_password: test2 + + - name: ansibletest3 + configured_password: test3 + state: present + role: network-operator + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"role network-operator" in result.commands[1]' + - '"secret" in result.commands[0]' + - '"username" in result.commands[2]' + - '"role network-operator" in result.commands[3]' + - '"secret" in result.commands[2]' + +- name: Add user without password or nopassword arg(Should fail) + become: true + ignore_errors: true + register: result + arista.eos.eos_user: + name: faileduser1 + privilege: 15 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.failed == true + - result.msg == "configured_password, sshkey or nopassword should be provided" + +- name: tearDown + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + - no username ansibletest2 + - no username ansibletest3 + - no username ansibletest4 + provider: '{{ cli }}' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/net_user.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/net_user.yaml new file mode 100644 index 00000000..2a0a3e2c --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_user/tests/cli/net_user.yaml @@ -0,0 +1,37 @@ +--- +- debug: msg="START eos cli/net_user.yaml on connection={{ ansible_connection }}" + +- name: Set Up + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + provider: '{{ cli }}' + +- name: Create user with role using platform agnostic module + become: true + register: result + ansible.netcommon.net_user: + name: ansibletest1 + privilege: 15 + role: network-operator + state: present + configured_password: test1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - '"username" in result.commands[0]' + - '"secret" in result.commands[0]' + - '"role network-operator" in result.commands[1]' + - '"privilege 15" in result.commands[2]' + +- name: Teardown + become: true + arista.eos.eos_config: + lines: + - no username ansibletest1 + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_user.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/basic.yaml new file mode 100644 index 00000000..466a0556 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/basic.yaml @@ -0,0 +1,277 @@ +--- +- name: setup - remove vlans used in test + become: true + arista.eos.eos_config: + lines: + - no vlan 4000 + - no vlan 4001 + - no vlan 4002 + provider: '{{ cli }}' + +- name: setup - remove switchport settings on interface Ethernet1 used in test + become: true + arista.eos.eos_config: + lines: + - switchport + - no switchport access vlan 4000 + parents: interface Ethernet1 + provider: '{{ cli }}' + +- name: setup - remove switchport settings on interface Ethernet2 used in test + become: true + arista.eos.eos_config: + lines: + - switchport + - no switchport access vlan 4000 + parents: interface Ethernet2 + provider: '{{ cli }}' + +- name: Create vlan + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'name vlan-4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create vlan again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Change vlan name and state + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000-new + state: suspend + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'name vlan-4000-new' in result.commands" + - "'state suspend' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Change vlan name and state again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + name: vlan-4000-new + state: suspend + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Unsuspend vlan + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: active + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'state active' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add interfaces to vlan and check state + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet1 + - Ethernet2 + associated_interfaces: + - Ethernet1 + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'interface Ethernet1' in result.commands" + - "'switchport access vlan 4000' in result.commands" + - "'interface Ethernet2' in result.commands" + - "'switchport access vlan 4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add interfaces to vlan again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet 1 + - Ethernet 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: vlan interface intent fail + become: true + register: result + ignore_errors: true + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + associated_interfaces: + - test + provider: '{{ cli }}' + +- assert: + that: + - result.failed == True + +- name: Remove interface from vlan + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'interface Ethernet2' in result.commands" + - "'no switchport access vlan 4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Remove interface from vlan again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + vlan_id: 4000 + state: present + interfaces: + - Ethernet 1 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Create aggregate of vlans + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4000 + state: absent + + - vlan_id: 4001 + name: vlan-4001 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no vlan 4000' in result.commands" + - "'vlan 4001' in result.commands" + - "'name vlan-4001' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create aggregate of vlans again (idempotent) + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4000 + state: absent + + - vlan_id: 4001 + name: vlan-4001 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Create vlan with purge + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4002 + name: vlan-4002 + name: vlan-4002 + state: present + purge: true + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'no vlan 4001' in result.commands" + - "'vlan 4002' in result.commands" + - "'name vlan-4002' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create vlan with purge + become: true + register: result + arista.eos.eos_vlan: + aggregate: + + - vlan_id: 4002 + name: vlan-4002 + name: vlan-4002 + state: present + purge: true + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/net_vlan.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/net_vlan.yaml new file mode 100644 index 00000000..e91f9ca3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlan/tests/cli/net_vlan.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_vlan.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlans used in test + become: true + arista.eos.eos_config: + lines: + - no vlan 4000 + provider: '{{ cli }}' + +- name: Create vlan using platform agnostic vlan module + become: true + register: result + ansible.netcommon.net_vlan: + vlan_id: 4000 + name: vlan-4000 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vlan 4000' in result.commands" + - "'name vlan-4000' in result.commands" + - "'ansible_1' in result.session_name" + +- name: setup - remove vlans used in test + become: true + arista.eos.eos_config: + lines: + - no vlan 4000 + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_vlan.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/cli.yaml new file mode 100644 index 00000000..9dd1bf86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: cli_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ cli_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/eapi.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/eapi.yaml new file mode 100644 index 00000000..7bbc71c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/eapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all common test cases + find: + paths: '{{ role_path }}/tests/common' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: collect all eapi test cases + find: + paths: '{{ role_path }}/tests/eapi' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: eapi_cases + delegate_to: localhost + +- set_fact: + test_cases: + files: '{{ test_cases.files }} + {{ eapi_cases.files }}' + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=ansible.netcommon.httpapi) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.httpapi' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/main.yaml new file mode 100644 index 00000000..c8f87904 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: eapi.yaml + tags: + - httpapi diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_parsed.cfg b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_parsed.cfg new file mode 100644 index 00000000..f16ae504 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_parsed.cfg @@ -0,0 +1,7 @@ +vlan 10 + name ten + state active +! +vlan 20 + name twenty + state suspend diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_reset_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_reset_config.yaml new file mode 100644 index 00000000..68e96460 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/_reset_config.yaml @@ -0,0 +1,31 @@ +--- +- name: Reset initial config + become: true + arista.eos.eos_config: + lines: + - "no vlan 1-4094" + - "vlan 10" + - " name ten" + - "vlan 20" + - " name twenty" + match: none + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + + - vlan_id: 20 + name: twenty + state: active + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/deleted.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/deleted.yaml new file mode 100644 index 00000000..cc94e11b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/deleted.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Returns vlans to default parameters + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: deleted + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/empty_config.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/empty_config.yaml new file mode 100644 index 00000000..2d59a627 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/empty_config.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START eos.eos_vlans empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + + +- name: Parsed with empty config should give appropriate error message + register: result + become: true + ignore_errors: true + arista.eos.eos_vlans: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- debug: + msg: END eos.eos_vlans empty_config integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/gathered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/gathered.yaml new file mode 100644 index 00000000..c9c1ed57 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/gathered.yaml @@ -0,0 +1,23 @@ +--- +- debug: + msg: START eos_vlans gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _reset_config.yaml + +- block: + + - name: Gathered the provided configuration with the exisiting running configuration + become: true + register: result + arista.eos.eos_vlans: + config: + state: gathered + + - become: true + arista.eos.eos_facts: + gather_network_resources: vlans + + - assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.gathered) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/idempotent.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/idempotent.yaml new file mode 100644 index 00000000..9c7eb249 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/idempotent.yaml @@ -0,0 +1,24 @@ +--- +- include_tasks: _reset_config.yaml + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Ensures that facts are idempotent through replace + register: result + become: true + arista.eos.eos_vlans: + config: '{{ ansible_facts.network_resources.vlans }}' + state: replaced + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - result.changed == False + - result.commands == [] + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/merged.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/merged.yaml new file mode 100644 index 00000000..b4b53697 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/merged.yaml @@ -0,0 +1,49 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + state: suspend + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Merge provided configuration with device configuration + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: merged + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + + - vlan_id: 20 + name: twenty + state: suspend + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/overridden.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/overridden.yaml new file mode 100644 index 00000000..b06b25fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/overridden.yaml @@ -0,0 +1,45 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + state: suspend + + - vlan_id: 50 + name: fifty + state: active + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Overrides device configuration of all vlans with provided configuration + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: overridden + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/parsed.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/parsed.yaml new file mode 100644 index 00000000..9bdbbb87 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START eos_vlans parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + arista.eos.eos_vlans: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - parsed['config']|symmetric_difference(result['parsed']) == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rendered.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rendered.yaml new file mode 100644 index 00000000..fa987233 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rendered.yaml @@ -0,0 +1,20 @@ +--- +- set_fact: + config: + - vlan_id: 10 + name: ten + - vlan_id: 20 + state: suspend + +- name: Use rendered state to convert task input to device specific commands + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: rendered + +- name: Assert + assert: + that: + - rendered.sort() == result.rendered.sort() + - result['changed'] == false diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/replaced.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/replaced.yaml new file mode 100644 index 00000000..23ceba50 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/replaced.yaml @@ -0,0 +1,47 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config: + + - vlan_id: 20 + state: suspend + name: twentyreplaced + other_config: + + - vlan_id: 10 + name: ten + state: active + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- name: Replaces device configuration of listed vlans with provided configuration + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config }}' + state: replaced + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.before) + == [] + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(result.after) + == [] + +- set_fact: + expected_config: '{{ config }} + {{ other_config }}' + +- assert: + that: + - expected_config|symmetric_difference(ansible_facts.network_resources.vlans) + == [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rtt.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rtt.yaml new file mode 100644 index 00000000..58831e04 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/tests/common/rtt.yaml @@ -0,0 +1,67 @@ +--- +- include_tasks: _reset_config.yaml + +- set_fact: + config1: + + - vlan_id: 20 + state: suspend + + config2: + - vlan_id: 30 + name: thirty + +- name: Merge provided configuration with device configuration(base config). + register: baseconfig + become: true + arista.eos.eos_vlans: + config: '{{ config1 }}' + state: merged + +- become: true + arista.eos.eos_facts: + gather_network_resources: vlans + +- assert: + that: + - ansible_facts.network_resources.vlans|symmetric_difference(baseconfig.after) + == [] + +- name: Merge provided configuration with device configuration(config to be reverted). + register: result + become: true + arista.eos.eos_vlans: + config: '{{ config2 }}' + state: merged + + +- set_fact: + expected_config: + + - vlan_id: 10 + name: ten + state: active + + - vlan_id: 20 + name: twenty + state: suspend + + - vlan_id: 30 + name: thirty + state: active + +- assert: + that: + - expected_config|symmetric_difference(result.after) + == [] + +- name: Revert back to base config using facts round trip + become: true + register: revert + arista.eos.eos_vlans: + config: "{{ ansible_facts['network_resources']['vlans'] }}" + state: overridden + +- name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/vars/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/vars/main.yaml new file mode 100644 index 00000000..b6e27ebe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vlans/vars/main.yaml @@ -0,0 +1,16 @@ +--- +parsed: + config: + - vlan_id: 10 + name: ten + state: active + - vlan_id: 20 + state: suspend + name: twenty + + +rendered: + - "vlan 10" + - "name ten" + - "vlan 20" + - "state suspend" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/aliases b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/aliases new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/aliases diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/defaults/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/meta/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/meta/main.yml new file mode 100644 index 00000000..d29186fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_eos_tests diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/cli.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/cli.yaml new file mode 100644 index 00000000..ce5fdc46 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + 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 cases (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/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/main.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/basic.yaml new file mode 100644 index 00000000..2ac30d25 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/basic.yaml @@ -0,0 +1,315 @@ +--- +- name: setup - remove vrf + become: true + with_items: + - test + - test1 + - test2 + - test3 + - test4 + - test5 + arista.eos.eos_vrf: + name: '{{ item }}' + state: absent + provider: '{{ cli }}' + +- name: Create vrf + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:200 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test' in result.commands" + - "'rd 1:200' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create vrf again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:200 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Modify rd + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test' in result.commands" + - "'rd 1:201' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Modify rd again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Add Ethernet2 to vrf and check interface assigned state + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + interfaces: + - Ethernet2 + associated_interfaces: + - Ethernet2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface ethernet2' in result.commands" + - "'vrf forwarding test' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add Ethernet2 to vrf again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test + rd: 1:201 + state: present + interfaces: + - ethernet 2 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - "'session_name' not in result.commands" + +- name: vrf interface intent fail + become: true + register: result + ignore_errors: true + arista.eos.eos_vrf: + name: test + state: present + associated_interfaces: + - test + provider: '{{ cli }}' + +- assert: + that: + - result.failed == True + +- name: Add multiple interfaces to vrf + become: true + register: result + arista.eos.eos_vrf: + name: test1 + rd: 1:202 + state: present + interfaces: + - loopback10 + - loopback11 + - loopback12 + - loopback13 + - loopback14 + - loopback15 + - loopback1000 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'interface loopback10' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback11' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback12' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback13' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback14' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback15' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'interface loopback1000' in result.commands" + - "'vrf forwarding test1' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Add multiple interfaces to vrf (idempotent) + become: true + register: result + arista.eos.eos_vrf: + name: test1 + rd: 1:202 + state: present + interfaces: + - loopback10 + - loopback11 + - loopback12 + - loopback13 + - loopback14 + - loopback15 + - loopback1000 + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + +- name: setup - remove vrf + become: true + with_items: + - test1 + - test2 + - test3 + arista.eos.eos_vrf: + name: '{{ item }}' + state: absent + provider: '{{ cli }}' + +- name: Create aggregate of VRFs + become: true + register: result + arista.eos.eos_vrf: + aggregate: + + - name: test2 + rd: 1:202 + + - name: test3 + rd: 1:203 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test2' in result.commands" + - "'rd 1:202' in result.commands" + - "'vrf definition test3' in result.commands" + - "'rd 1:203' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Create aggregate of VRFs again (idempotent) + become: true + register: result + arista.eos.eos_vrf: + aggregate: + + - name: test2 + rd: 1:202 + + - name: test3 + rd: 1:203 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + - result.session_name is not defined + +- name: Create aggregate of VRFs with purge + become: true + register: result + arista.eos.eos_vrf: + aggregate: + + - name: test4 + rd: 1:204 + + - name: test5 + rd: 1:205 + state: present + purge: true + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test4' in result.commands" + - "'rd 1:204' in result.commands" + - "'vrf definition test5' in result.commands" + - "'rd 1:205' in result.commands" + - "'no vrf definition test' in result.commands" + - "'no vrf definition test2' in result.commands" + - "'no vrf definition test3' in result.commands" + - "'ansible_1' in result.session_name" + +- name: Delete VRFs + become: true + arista.eos.eos_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- name: Delete VRFs again (idempotent) + become: true + arista.eos.eos_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- name: Delete aggregate of VRFs + become: true + arista.eos.eos_vrf: + aggregate: + + - name: test1 + + - name: test2 + + - name: test3 + + - name: test4 + + - name: test5 + state: absent + provider: '{{ cli }}' + +- name: Delete VRFs again (idempotent) + become: true + arista.eos.eos_vrf: + aggregate: + + - name: test1 + + - name: test2 + + - name: test3 + + - name: test4 + + - name: test5 + state: absent + provider: '{{ cli }}' diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/net_vrf.yaml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/net_vrf.yaml new file mode 100644 index 00000000..cd06900b --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/eos_vrf/tests/cli/net_vrf.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START eos cli/net_vrf.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vrf + become: true + ansible.netcommon.net_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- name: Create vrf using platform agnostic vrf module + become: true + register: result + ansible.netcommon.net_vrf: + name: test + rd: 1:200 + state: present + provider: '{{ cli }}' + +- assert: + that: + - result.changed == true + - "'vrf definition test' in result.commands" + - "'rd 1:200' in result.commands" + - "'ansible_1' in result.session_name" + +- name: teardown - remove vrf + become: true + ansible.netcommon.net_vrf: + name: test + state: absent + provider: '{{ cli }}' + +- debug: msg="END eos cli/net_vrf.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/prepare_eos_tests/tasks/main.yml b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/prepare_eos_tests/tasks/main.yml new file mode 100644 index 00000000..a40e0d23 --- /dev/null +++ b/collections-debian-merged/ansible_collections/arista/eos/tests/integration/targets/prepare_eos_tests/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- name: Enable Ethernet1 interface and disable switchport + become: true + connection: ansible.netcommon.network_cli + arista.eos.eos_config: + lines: + - no shutdown + - no switchport + parents: int Ethernet1 + +- name: Enable Ethernet2 interface and disable switchport + become: true + connection: ansible.netcommon.network_cli + arista.eos.eos_config: + lines: + - no shutdown + - no switchport + parents: int Ethernet2 + +- name: enable eapi + become: true + connection: ansible.netcommon.network_cli + tags: eapi + arista.eos.eos_eapi: + http: true + https: true + local_http: false + enable_socket: true |