summaryrefslogtreecommitdiff
path: root/test/integration/targets/eos_config/tests/cli
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/eos_config/tests/cli')
-rw-r--r--test/integration/targets/eos_config/tests/cli/backup.yaml50
-rw-r--r--test/integration/targets/eos_config/tests/cli/config.yaml46
-rw-r--r--test/integration/targets/eos_config/tests/cli/defaults.yaml42
-rw-r--r--test/integration/targets/eos_config/tests/cli/save.yaml35
-rw-r--r--test/integration/targets/eos_config/tests/cli/src_basic.yaml38
-rw-r--r--test/integration/targets/eos_config/tests/cli/src_invalid.yaml19
-rw-r--r--test/integration/targets/eos_config/tests/cli/src_match_none.yaml41
-rw-r--r--test/integration/targets/eos_config/tests/cli/sublevel.yaml41
-rw-r--r--test/integration/targets/eos_config/tests/cli/sublevel_block.yaml61
-rw-r--r--test/integration/targets/eos_config/tests/cli/sublevel_exact.yaml65
-rw-r--r--test/integration/targets/eos_config/tests/cli/sublevel_strict.yaml65
-rw-r--r--test/integration/targets/eos_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/eos_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/eos_config/tests/cli/toplevel_before.yaml44
14 files changed, 628 insertions, 0 deletions
diff --git a/test/integration/targets/eos_config/tests/cli/backup.yaml b/test/integration/targets/eos_config/tests/cli/backup.yaml
new file mode 100644
index 0000000000..282ded948e
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+- name: collect any backup files
+ find:
+ paths: "{{ role_path }}/backup"
+ pattern: "{{ inventory_hostname }}_config*"
+ register: backup_files
+ delegate_to: localhost
+
+- name: delete backup files
+ file:
+ path: "{{ item.path }}"
+ state: absent
+ with_items: "{{backup_files.files|default([])}}"
+
+- name: configure device with config
+ eos_config:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is not defined"
+
+- name: collect any backup files
+ find:
+ paths: "{{ role_path }}/backup"
+ pattern: "{{ inventory_hostname }}_config*"
+ register: backup_files
+ delegate_to: localhost
+
+- assert:
+ that:
+ - "backup_files.files is defined"
+
+- debug: msg="END cli/backup.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/config.yaml b/test/integration/targets/eos_config/tests/cli/config.yaml
new file mode 100644
index 0000000000..d95a491a4b
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/config.yaml
@@ -0,0 +1,46 @@
+---
+- debug: msg="START cli/config.yaml"
+
+- name: setup
+ eos_config:
+ lines: hostname {{ inventory_hostname }}
+ match: none
+ provider: "{{ cli }}"
+
+- name: get current running-config
+ eos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ register: config
+
+- name: configure hostname
+ eos_config:
+ lines: hostname foo
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure hostname again
+ eos_config:
+ lines: hostname foo
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'hostname foo' in result.updates"
+
+- name: teardown
+ eos_config:
+ lines: hostname {{ inventory_hostname }}
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/config.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/defaults.yaml b/test/integration/targets/eos_config/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..751becf7d1
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/defaults.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with defaults included
+ eos_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is not defined"
+
+- name: check device with defaults included
+ eos_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- debug: msg="END cli/defaults.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/save.yaml b/test/integration/targets/eos_config/tests/cli/save.yaml
new file mode 100644
index 0000000000..b6e6ce6938
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/save.yaml
@@ -0,0 +1,35 @@
+---
+- debug: msg="START cli/save.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+
+- name: save config
+ eos_config:
+ save: true
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: save should always run
+ eos_config:
+ save: true
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- debug: msg="END cli/save.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/src_basic.yaml b/test/integration/targets/eos_config/tests/cli/src_basic.yaml
new file mode 100644
index 0000000000..757aeaecc5
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/src_basic.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/src_basic.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ eos_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- name: check device with config
+ eos_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- debug: msg="END cli/src_basic.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/src_invalid.yaml b/test/integration/targets/eos_config/tests/cli/src_invalid.yaml
new file mode 100644
index 0000000000..53f7be8bca
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/src_invalid.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/src_invalid.yaml"
+
+
+# Defend https://github.com/ansible/ansible-modules-core/issues/4797
+- name: configure with invalid src
+ eos_config:
+ src: basic/foobar.j2
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.failed == true"
+ - "result.msg == 'path specified in src not found'"
+
+- debug: msg="END cli/src_invalid.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/src_match_none.yaml b/test/integration/targets/eos_config/tests/cli/src_match_none.yaml
new file mode 100644
index 0000000000..400cf1eff1
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/src_match_none.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/src_match_none.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ eos_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- name: check device with config
+ eos_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ # Idempotent test
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- debug: msg="END cli/src_match_none.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/sublevel.yaml b/test/integration/targets/eos_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..dd4eb74d75
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/sublevel.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup
+ eos_config:
+ lines: no vlan 10
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command
+ eos_config:
+ lines: name test
+ parents: vlan 10
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'vlan 10' in result.updates"
+ - "'name test' in result.updates"
+
+- name: configure sub level command idempotent check
+ eos_config:
+ lines: name test
+ parents: vlan 10
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no vlan 10
+ match: none
+ provider: "{{ cli }}"
+
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/sublevel_block.yaml b/test/integration/targets/eos_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..00dd249a52
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,61 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using block resplace
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ replace: block
+ after: exit
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ip host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ip host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ip host 4.4.4.4 any log' in result.updates"
+
+- name: check sub level command using block replace
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ replace: block
+ after: exit
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/eos_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..45c72135ad
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,65 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ - 50 permit ip host 5.5.5.5 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using exact match
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: exact
+ replace: block
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ip host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ip host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ip host 4.4.4.4 any log' in result.updates"
+ - "'50 permit ip host 5.5.5.5 any log' not in result.updates"
+
+- name: check sub level command using exact match
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/eos_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..c389aab947
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,65 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 2.2.2.2 any log
+ - 30 permit ip host 3.3.3.3 any log
+ - 40 permit ip host 4.4.4.4 any log
+ - 50 permit ip host 5.5.5.5 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using strict match
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 3.3.3.3 any log
+ - 30 permit ip host 2.2.2.2 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ after: exit
+ match: strict
+ replace: block
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip host 1.1.1.1 any log' in result.updates"
+ - "'30 permit ip host 2.2.2.2 any log' in result.updates"
+ - "'20 permit ip host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ip host 4.4.4.4 any log' in result.updates"
+ - "'50 permit ip host 5.5.5.5 any log' not in result.updates"
+
+- name: check sub level command using strict match
+ eos_config:
+ lines:
+ - 10 permit ip host 1.1.1.1 any log
+ - 20 permit ip host 3.3.3.3 any log
+ - 30 permit ip host 2.2.2.2 any log
+ - 40 permit ip host 4.4.4.4 any log
+ parents: ip access-list test
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/toplevel.yaml b/test/integration/targets/eos_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..fa294ea27f
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ eos_config:
+ lines: hostname veos01
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure top level command
+ eos_config:
+ lines: hostname foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ eos_config:
+ lines: hostname foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: hostname veos01
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/toplevel_after.yaml b/test/integration/targets/eos_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..dacf461a8a
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - snmp-server contact ansible
+ - hostname veos01
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure top level command with before
+ eos_config:
+ lines: hostname foo
+ after: snmp-server contact bar
+ provider: "{{ cli }}"
+ register: result
+
+- 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
+ eos_config:
+ lines: hostname foo
+ after: snmp-server contact foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines:
+ - no snmp-server contact
+ - hostname veos01
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/eos_config/tests/cli/toplevel_before.yaml b/test/integration/targets/eos_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..b133e7f766
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - snmp-server contact ansible
+ - hostname veos01
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure top level command with before
+ eos_config:
+ lines: hostname foo
+ before: snmp-server contact bar
+ provider: "{{ cli }}"
+ register: result
+
+- 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
+ eos_config:
+ lines: hostname foo
+ before: snmp-server contact foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines:
+ - hostname veos01
+ - no snmp-server contact
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel_before.yaml"