summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn R Barker <john@johnrbarker.com>2016-10-28 19:50:29 +0100
committerGitHub <noreply@github.com>2016-10-28 19:50:29 +0100
commite0cc7b34151def2ce0b08dbe3cb995107a2d6a0f (patch)
tree09df24fe1a91723d5fe716d8b9da843b383d5204 /test
parent4a067c3f502aa2254d8f35d8598895df8f3d1365 (diff)
downloadansible-e0cc7b34151def2ce0b08dbe3cb995107a2d6a0f.tar.gz
Migrate Network Tests into ansible/ansible (#18233)
* Docs Networking tests * Copy networking tests from test-network-modules * Networking transport settings - group_vars * Network playbooks * Debug should be off by default * Update nxos.yaml * Remove items from top level * Use dependencies, not pre-tasks * Remove trailing blank lines * Remove backup files * newlines
Diffstat (limited to 'test')
-rw-r--r--test/README.md2
-rw-r--r--test/integration/asa.yaml13
-rw-r--r--test/integration/dellos10.yaml13
-rw-r--r--test/integration/dellos6.yaml13
-rw-r--r--test/integration/dellos9.yaml13
-rw-r--r--test/integration/eos.yaml15
-rw-r--r--test/integration/group_vars/asa.yaml8
-rw-r--r--test/integration/group_vars/dellos10.yaml6
-rw-r--r--test/integration/group_vars/dellos6.yaml8
-rw-r--r--test/integration/group_vars/dellos9.yaml8
-rw-r--r--test/integration/group_vars/eos.yaml15
-rw-r--r--test/integration/group_vars/ios.yaml6
-rw-r--r--test/integration/group_vars/iosxr.yaml6
-rw-r--r--test/integration/group_vars/junos.yaml12
-rw-r--r--test/integration/group_vars/nxos.yaml13
-rw-r--r--test/integration/group_vars/vyos.yaml6
-rw-r--r--test/integration/ios.yaml14
-rw-r--r--test/integration/iosxr.yaml14
-rw-r--r--test/integration/junos.yaml14
-rw-r--r--test/integration/network-all.yaml10
-rw-r--r--test/integration/nxos.yaml15
-rw-r--r--test/integration/targets/asa_acl/defaults/main.yaml3
-rw-r--r--test/integration/targets/asa_acl/tasks/cli.yaml16
-rw-r--r--test/integration/targets/asa_acl/tasks/main.yaml3
-rw-r--r--test/integration/targets/asa_acl/tests/cli/basic.yaml41
-rw-r--r--test/integration/targets/asa_acl/tests/cli/full_name_match.yaml43
-rw-r--r--test/integration/targets/asa_acl/tests/cli/insert.yaml51
-rw-r--r--test/integration/targets/asa_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/asa_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/asa_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/asa_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/asa_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/asa_command/tests/cli/invalid.yaml30
-rw-r--r--test/integration/targets/asa_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/asa_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/asa_config/defaults/main.yaml3
-rw-r--r--test/integration/targets/asa_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/asa_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/asa_config/templates/basic/config.j23
-rw-r--r--test/integration/targets/asa_config/templates/defaults/config.j24
-rw-r--r--test/integration/targets/asa_config/tests/cli/backup.yaml53
-rw-r--r--test/integration/targets/asa_config/tests/cli/basic.yaml39
-rw-r--r--test/integration/targets/asa_config/tests/cli/defaults.yaml45
-rw-r--r--test/integration/targets/asa_config/tests/cli/force.yaml41
-rw-r--r--test/integration/targets/asa_config/tests/cli/more_system.yaml47
-rw-r--r--test/integration/targets/asa_config/tests/cli/sublevel.yaml40
-rw-r--r--test/integration/targets/asa_config/tests/cli/sublevel_block.yaml64
-rw-r--r--test/integration/targets/asa_config/tests/cli/sublevel_exact.yaml64
-rw-r--r--test/integration/targets/asa_config/tests/cli/sublevel_strict.yaml61
-rw-r--r--test/integration/targets/asa_config/tests/cli/toplevel.yaml35
-rw-r--r--test/integration/targets/asa_config/tests/cli/toplevel_after.yaml42
-rw-r--r--test/integration/targets/asa_config/tests/cli/toplevel_before.yaml42
-rw-r--r--test/integration/targets/asa_config/tests/cli/toplevel_nonidempotent.yaml38
-rw-r--r--test/integration/targets/dellos10_command/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos10_command/tasks/cli.yaml18
-rw-r--r--test/integration/targets/dellos10_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos10_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/dellos10_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/dellos10_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/dellos10_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/dellos10_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/dellos10_config/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos10_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/dellos10_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/sublevel.yaml42
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/sublevel_block.yaml62
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/sublevel_exact.yaml66
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/sublevel_strict.yaml63
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/toplevel_before.yaml44
-rw-r--r--test/integration/targets/dellos10_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/dellos10_facts/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos10_facts/tasks/cli.yaml18
-rw-r--r--test/integration/targets/dellos10_facts/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos10_facts/tests/cli/facts.yaml48
-rw-r--r--test/integration/targets/dellos6_command/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos6_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/dellos6_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos6_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/dellos6_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/dellos6_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/dellos6_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/dellos6_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/dellos6_config/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos6_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/dellos6_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/sublevel.yaml42
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/sublevel_block.yaml62
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/sublevel_exact.yaml66
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/sublevel_strict.yaml63
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/toplevel_before.yaml44
-rw-r--r--test/integration/targets/dellos6_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/dellos6_facts/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos6_facts/tasks/cli.yaml18
-rw-r--r--test/integration/targets/dellos6_facts/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos6_facts/tests/cli/facts.yaml42
-rw-r--r--test/integration/targets/dellos9_command/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos9_command/tasks/cli.yaml18
-rw-r--r--test/integration/targets/dellos9_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos9_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/dellos9_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/dellos9_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/dellos9_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/dellos9_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/dellos9_config/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos9_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/dellos9_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/sublevel.yaml43
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/sublevel_block.yaml62
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/sublevel_exact.yaml66
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/sublevel_strict.yaml63
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/toplevel_before.yaml44
-rw-r--r--test/integration/targets/dellos9_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/dellos9_facts/defaults/main.yaml2
-rw-r--r--test/integration/targets/dellos9_facts/tasks/cli.yaml18
-rw-r--r--test/integration/targets/dellos9_facts/tasks/main.yaml3
-rw-r--r--test/integration/targets/dellos9_facts/tests/cli/facts.yaml42
-rw-r--r--test/integration/targets/eos_command/defaults/main.yaml2
-rw-r--r--test/integration/targets/eos_command/meta/main.yml2
-rw-r--r--test/integration/targets/eos_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/eos_command/tasks/eapi.yaml17
-rw-r--r--test/integration/targets/eos_command/tasks/main.yaml4
-rw-r--r--test/integration/targets/eos_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/eos_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/eos_command/tests/cli/equal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/cli/greaterthan.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/cli/invalid.yaml30
-rw-r--r--test/integration/targets/eos_command/tests/cli/lessthan.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/cli/lessthanorequal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/cli/notequal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/cli/output.yaml28
-rw-r--r--test/integration/targets/eos_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/eos_command/tests/eapi/bad_operator.yaml20
-rw-r--r--test/integration/targets/eos_command/tests/eapi/contains.yaml20
-rw-r--r--test/integration/targets/eos_command/tests/eapi/equal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/eapi/greaterthan.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/eapi/invalid.yaml30
-rw-r--r--test/integration/targets/eos_command/tests/eapi/lessthan.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/eapi/notequal.yaml34
-rw-r--r--test/integration/targets/eos_command/tests/eapi/output.yaml28
-rw-r--r--test/integration/targets/eos_command/tests/eapi/timeout.yaml20
-rw-r--r--test/integration/targets/eos_config/config.txt31
-rw-r--r--test/integration/targets/eos_config/defaults/main.yaml3
-rw-r--r--test/integration/targets/eos_config/meta/main.yml2
-rw-r--r--test/integration/targets/eos_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/eos_config/tasks/eapi.yaml17
-rw-r--r--test/integration/targets/eos_config/tasks/main.yaml4
-rw-r--r--test/integration/targets/eos_config/templates/basic/config.j24
-rw-r--r--test/integration/targets/eos_config/templates/config.js4
-rw-r--r--test/integration/targets/eos_config/templates/defaults/config.j23
-rw-r--r--test/integration/targets/eos_config/templates/defaults/test.j24
-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
-rw-r--r--test/integration/targets/eos_config/tests/eapi/backup.yaml50
-rw-r--r--test/integration/targets/eos_config/tests/eapi/defaults.yaml42
-rw-r--r--test/integration/targets/eos_config/tests/eapi/save.yaml35
-rw-r--r--test/integration/targets/eos_config/tests/eapi/src_basic.yaml38
-rw-r--r--test/integration/targets/eos_config/tests/eapi/src_invalid.yaml19
-rw-r--r--test/integration/targets/eos_config/tests/eapi/src_match_none.yaml41
-rw-r--r--test/integration/targets/eos_config/tests/eapi/sublevel.yaml41
-rw-r--r--test/integration/targets/eos_config/tests/eapi/sublevel_block.yaml59
-rw-r--r--test/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml65
-rw-r--r--test/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml64
-rw-r--r--test/integration/targets/eos_config/tests/eapi/toplevel.yaml37
-rw-r--r--test/integration/targets/eos_config/tests/eapi/toplevel_after.yaml44
-rw-r--r--test/integration/targets/eos_config/tests/eapi/toplevel_before.yaml44
-rw-r--r--test/integration/targets/eos_eapi/defaults/main.yaml4
-rw-r--r--test/integration/targets/eos_eapi/meta/main.yml2
-rw-r--r--test/integration/targets/eos_eapi/tasks/cli.yaml17
-rw-r--r--test/integration/targets/eos_eapi/tasks/main.yaml2
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/badtransport.yaml16
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/config.yaml52
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/configure.yaml43
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/off.yaml50
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/on.yaml48
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/start.yaml39
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/stop.yaml39
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/vrf.yaml57
-rw-r--r--test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml36
-rw-r--r--test/integration/targets/eos_facts/defaults/main.yaml2
-rw-r--r--test/integration/targets/eos_facts/meta/main.yml2
-rw-r--r--test/integration/targets/eos_facts/tasks/cli.yaml17
-rw-r--r--test/integration/targets/eos_facts/tasks/eapi.yaml17
-rw-r--r--test/integration/targets/eos_facts/tasks/main.yaml4
-rw-r--r--test/integration/targets/eos_facts/tests/cli/all_facts.yaml31
-rw-r--r--test/integration/targets/eos_facts/tests/cli/default_facts.yaml31
-rw-r--r--test/integration/targets/eos_facts/tests/cli/invalid_subset.yaml48
-rw-r--r--test/integration/targets/eos_facts/tests/cli/not_hardware.yaml30
-rw-r--r--test/integration/targets/eos_facts/tests/eapi/all_facts.yaml31
-rw-r--r--test/integration/targets/eos_facts/tests/eapi/default_facts.yaml31
-rw-r--r--test/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml48
-rw-r--r--test/integration/targets/eos_facts/tests/eapi/not_hardware.yaml30
-rw-r--r--test/integration/targets/eos_template/defaults/main.yaml2
-rw-r--r--test/integration/targets/eos_template/meta/main.yml2
-rw-r--r--test/integration/targets/eos_template/tasks/cli.yaml17
-rw-r--r--test/integration/targets/eos_template/tasks/eapi.yaml17
-rw-r--r--test/integration/targets/eos_template/tasks/main.yaml4
-rw-r--r--test/integration/targets/eos_template/templates/basic/config.j24
-rw-r--r--test/integration/targets/eos_template/templates/config.js4
-rw-r--r--test/integration/targets/eos_template/templates/defaults/config.j23
-rw-r--r--test/integration/targets/eos_template/templates/defaults/test.j24
-rw-r--r--test/integration/targets/eos_template/tests/cli/backup.yaml50
-rw-r--r--test/integration/targets/eos_template/tests/cli/basic.yaml36
-rw-r--r--test/integration/targets/eos_template/tests/cli/defaults.yaml42
-rw-r--r--test/integration/targets/eos_template/tests/cli/force.yaml38
-rw-r--r--test/integration/targets/eos_template/tests/eapi/backup.yaml50
-rw-r--r--test/integration/targets/eos_template/tests/eapi/basic.yaml36
-rw-r--r--test/integration/targets/eos_template/tests/eapi/defaults.yaml42
-rw-r--r--test/integration/targets/eos_template/tests/eapi/force.yaml38
-rw-r--r--test/integration/targets/ios_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/ios_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/ios_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/ios_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/ios_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/ios_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/ios_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/ios_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/ios_config/defaults/main.yaml3
-rw-r--r--test/integration/targets/ios_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/ios_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/ios_config/templates/basic/config.j24
-rw-r--r--test/integration/targets/ios_config/templates/defaults/config.j24
-rw-r--r--test/integration/targets/ios_config/tests/cli/backup.yaml50
-rw-r--r--test/integration/targets/ios_config/tests/cli/defaults.yaml42
-rw-r--r--test/integration/targets/ios_config/tests/cli/save.yaml43
-rw-r--r--test/integration/targets/ios_config/tests/cli/src_basic.yaml38
-rw-r--r--test/integration/targets/ios_config/tests/cli/src_invalid.yaml19
-rw-r--r--test/integration/targets/ios_config/tests/cli/src_match_none.yaml40
-rw-r--r--test/integration/targets/ios_config/tests/cli/src_match_none.yaml.orig49
-rw-r--r--test/integration/targets/ios_config/tests/cli/sublevel.yaml43
-rw-r--r--test/integration/targets/ios_config/tests/cli/sublevel_block.yaml62
-rw-r--r--test/integration/targets/ios_config/tests/cli/sublevel_exact.yaml65
-rw-r--r--test/integration/targets/ios_config/tests/cli/sublevel_strict.yaml61
-rw-r--r--test/integration/targets/ios_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/ios_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/ios_config/tests/cli/toplevel_before.yaml44
-rw-r--r--test/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/ios_facts/defaults/main.yaml3
-rw-r--r--test/integration/targets/ios_facts/tasks/cli.yaml17
-rw-r--r--test/integration/targets/ios_facts/tasks/main.yaml3
-rw-r--r--test/integration/targets/ios_facts/tests/cli/all_facts.yaml31
-rw-r--r--test/integration/targets/ios_facts/tests/cli/default_facts.yaml31
-rw-r--r--test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml48
-rw-r--r--test/integration/targets/ios_facts/tests/cli/not_hardware.yaml30
-rw-r--r--test/integration/targets/ios_template/defaults/main.yaml3
-rw-r--r--test/integration/targets/ios_template/tasks/cli.yaml17
-rw-r--r--test/integration/targets/ios_template/tasks/main.yaml3
-rw-r--r--test/integration/targets/ios_template/templates/basic/config.j24
-rw-r--r--test/integration/targets/ios_template/templates/defaults/config.j24
-rw-r--r--test/integration/targets/ios_template/tests/cli/backup.yaml55
-rw-r--r--test/integration/targets/ios_template/tests/cli/basic.yaml41
-rw-r--r--test/integration/targets/ios_template/tests/cli/defaults.yaml41
-rw-r--r--test/integration/targets/ios_template/tests/cli/force.yaml43
-rw-r--r--test/integration/targets/iosxr_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/iosxr_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/iosxr_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/iosxr_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/iosxr_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/iosxr_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/iosxr_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/iosxr_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/iosxr_config/defaults/main.yaml3
-rw-r--r--test/integration/targets/iosxr_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/iosxr_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/iosxr_config/templates/basic/config.j24
-rw-r--r--test/integration/targets/iosxr_config/templates/defaults/config.j24
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/backup.yaml50
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml32
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/comment.yaml37
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/src_basic.yaml38
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/src_invalid.yaml19
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/src_match_none.yaml40
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/sublevel.yaml41
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/sublevel_block.yaml61
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/sublevel_exact.yaml65
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/sublevel_strict.yaml66
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/toplevel_before.yaml44
-rw-r--r--test/integration/targets/iosxr_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/iosxr_facts/defaults/main.yaml3
-rw-r--r--test/integration/targets/iosxr_facts/tasks/cli.yaml17
-rw-r--r--test/integration/targets/iosxr_facts/tasks/main.yaml3
-rw-r--r--test/integration/targets/iosxr_facts/tests/cli/all_facts.yaml28
-rw-r--r--test/integration/targets/iosxr_facts/tests/cli/default_facts.yaml30
-rw-r--r--test/integration/targets/iosxr_facts/tests/cli/invalid_subset.yaml48
-rw-r--r--test/integration/targets/iosxr_facts/tests/cli/not_hardware.yaml30
-rw-r--r--test/integration/targets/iosxr_template/defaults/main.yaml3
-rw-r--r--test/integration/targets/iosxr_template/tasks/cli.yaml17
-rw-r--r--test/integration/targets/iosxr_template/tasks/main.yaml3
-rw-r--r--test/integration/targets/iosxr_template/templates/basic/config.j25
-rw-r--r--test/integration/targets/iosxr_template/tests/cli/backup.yaml55
-rw-r--r--test/integration/targets/iosxr_template/tests/cli/basic.yaml40
-rw-r--r--test/integration/targets/iosxr_template/tests/cli/force.yaml42
-rw-r--r--test/integration/targets/junos_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/junos_command/tasks/main.yaml4
-rw-r--r--test/integration/targets/junos_command/tasks/netconf_text.yaml17
-rw-r--r--test/integration/targets/junos_command/tasks/netconf_xml.yaml17
-rw-r--r--test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml21
-rw-r--r--test/integration/targets/junos_command/tests/netconf_text/contains.yaml22
-rw-r--r--test/integration/targets/junos_command/tests/netconf_text/invalid.yaml34
-rw-r--r--test/integration/targets/junos_command/tests/netconf_text/output.yaml32
-rw-r--r--test/integration/targets/junos_command/tests/netconf_text/timeout.yaml20
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml21
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/contains.yaml22
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/equal.yaml40
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml38
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml38
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml31
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml38
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml38
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml38
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/output.yaml32
-rw-r--r--test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml19
-rw-r--r--test/integration/targets/junos_config/defaults/main.yaml3
-rw-r--r--test/integration/targets/junos_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/junos_config/tasks/netconf.yaml17
-rw-r--r--test/integration/targets/junos_config/templates/basic/config.j210
-rw-r--r--test/integration/targets/junos_config/tests/netconf/backup.yaml47
-rw-r--r--test/integration/targets/junos_config/tests/netconf/bad_action.yaml16
-rw-r--r--test/integration/targets/junos_config/tests/netconf/invalid.yaml29
-rw-r--r--test/integration/targets/junos_config/tests/netconf/multiple.yaml49
-rw-r--r--test/integration/targets/junos_config/tests/netconf/single.yaml41
-rw-r--r--test/integration/targets/junos_config/tests/netconf/src_basic.yaml35
-rw-r--r--test/integration/targets/junos_config/tests/netconf/src_invalid.yaml19
-rw-r--r--test/integration/targets/junos_netconf/defaults/main.yaml3
-rw-r--r--test/integration/targets/junos_netconf/tasks/cli.yaml17
-rw-r--r--test/integration/targets/junos_netconf/tasks/main.yaml3
-rw-r--r--test/integration/targets/junos_netconf/tests/cli/changeport.yaml68
-rw-r--r--test/integration/targets/junos_netconf/tests/cli/netconf.yaml72
-rw-r--r--test/integration/targets/junos_template/defaults/main.yaml4
-rw-r--r--test/integration/targets/junos_template/tasks/main.yaml3
-rw-r--r--test/integration/targets/junos_template/tasks/netconf.yaml17
-rw-r--r--test/integration/targets/junos_template/templates/basic/config.j210
-rw-r--r--test/integration/targets/junos_template/tests/netconf/backup.yaml54
-rw-r--r--test/integration/targets/junos_template/tests/netconf/basic.yaml39
-rw-r--r--test/integration/targets/junos_template/tests/netconf/force.yaml43
-rw-r--r--test/integration/targets/nxos_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/nxos_command/meta/main.yml2
-rw-r--r--test/integration/targets/nxos_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/nxos_command/tasks/main.yaml5
-rw-r--r--test/integration/targets/nxos_command/tasks/nxapi.yaml30
-rw-r--r--test/integration/targets/nxos_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/nxos_command/tests/cli/contains.yaml19
-rw-r--r--test/integration/targets/nxos_command/tests/cli/equal.yaml32
-rw-r--r--test/integration/targets/nxos_command/tests/cli/greaterthan.yaml32
-rw-r--r--test/integration/targets/nxos_command/tests/cli/greaterthanorequal.yaml32
-rw-r--r--test/integration/targets/nxos_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/nxos_command/tests/cli/lessthan.yaml32
-rw-r--r--test/integration/targets/nxos_command/tests/cli/lessthanorequal.yaml32
-rw-r--r--test/integration/targets/nxos_command/tests/cli/negative.yaml27
-rw-r--r--test/integration/targets/nxos_command/tests/cli/notequal.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/cli/output.yaml26
-rw-r--r--test/integration/targets/nxos_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/bad_operator.yaml20
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/contains.yaml20
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/equal.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/greaterthan.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/greaterthanorequal.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/invalid.yaml30
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/lessthan.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/lessthanorequal.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/negative.yaml27
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/notequal.yaml34
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/output.yaml28
-rw-r--r--test/integration/targets/nxos_command/tests/nxapi/timeout.yaml20
-rw-r--r--test/integration/targets/nxos_config/defaults/main.yaml4
-rw-r--r--test/integration/targets/nxos_config/meta/main.yml2
-rw-r--r--test/integration/targets/nxos_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/nxos_config/tasks/main.yaml4
-rw-r--r--test/integration/targets/nxos_config/tasks/nxapi.yaml30
-rw-r--r--test/integration/targets/nxos_config/templates/basic/config.j24
-rw-r--r--test/integration/targets/nxos_config/templates/config.js4
-rw-r--r--test/integration/targets/nxos_config/templates/defaults/config.j24
-rw-r--r--test/integration/targets/nxos_config/templates/defaults/test.j24
-rw-r--r--test/integration/targets/nxos_config/tests/cli/backup.yaml50
-rw-r--r--test/integration/targets/nxos_config/tests/cli/defaults.yaml42
-rw-r--r--test/integration/targets/nxos_config/tests/cli/multilevel.yaml58
-rw-r--r--test/integration/targets/nxos_config/tests/cli/save.yaml35
-rw-r--r--test/integration/targets/nxos_config/tests/cli/src_basic.yaml38
-rw-r--r--test/integration/targets/nxos_config/tests/cli/src_invalid.yaml19
-rw-r--r--test/integration/targets/nxos_config/tests/cli/src_match_none.yaml40
-rw-r--r--test/integration/targets/nxos_config/tests/cli/sublevel.yaml40
-rw-r--r--test/integration/targets/nxos_config/tests/cli/sublevel_block.yaml57
-rw-r--r--test/integration/targets/nxos_config/tests/cli/sublevel_exact.yaml62
-rw-r--r--test/integration/targets/nxos_config/tests/cli/sublevel_strict.yaml63
-rw-r--r--test/integration/targets/nxos_config/tests/cli/toplevel.yaml37
-rw-r--r--test/integration/targets/nxos_config/tests/cli/toplevel_after.yaml44
-rw-r--r--test/integration/targets/nxos_config/tests/cli/toplevel_before.yaml44
-rw-r--r--test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/backup.yaml50
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/defaults.yaml42
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/multilevel.yaml44
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/save.yaml35
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml38
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml19
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/src_match_none.yaml41
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/sublevel.yaml41
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/sublevel_block.yaml59
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/sublevel_exact.yaml63
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/sublevel_strict.yaml62
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml37
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/toplevel_after.yaml44
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/toplevel_before.yaml44
-rw-r--r--test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml39
-rw-r--r--test/integration/targets/nxos_facts/defaults/main.yaml2
-rw-r--r--test/integration/targets/nxos_facts/meta/main.yml2
-rw-r--r--test/integration/targets/nxos_facts/tasks/cli.yaml17
-rw-r--r--test/integration/targets/nxos_facts/tasks/main.yaml4
-rw-r--r--test/integration/targets/nxos_facts/tasks/nxapi.yaml17
-rw-r--r--test/integration/targets/nxos_facts/tests/cli/all_facts.yaml31
-rw-r--r--test/integration/targets/nxos_facts/tests/cli/default_facts.yaml32
-rw-r--r--test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml48
-rw-r--r--test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml31
-rw-r--r--test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml31
-rw-r--r--test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml32
-rw-r--r--test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml48
-rw-r--r--test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml31
-rw-r--r--test/integration/targets/nxos_nxapi/defaults/main.yaml3
-rw-r--r--test/integration/targets/nxos_nxapi/meta/main.yml2
-rw-r--r--test/integration/targets/nxos_nxapi/tasks/cli.yaml17
-rw-r--r--test/integration/targets/nxos_nxapi/tasks/main.yaml4
-rw-r--r--test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml17
-rw-r--r--test/integration/targets/nxos_nxapi/tests/cli/config.yaml87
-rw-r--r--test/integration/targets/nxos_nxapi/tests/cli/configure.yaml45
-rw-r--r--test/integration/targets/nxos_nxapi/tests/cli/disable.yaml46
-rw-r--r--test/integration/targets/nxos_nxapi/tests/cli/enable.yaml39
-rw-r--r--test/integration/targets/nxos_template/defaults/main.yaml4
-rw-r--r--test/integration/targets/nxos_template/meta/main.yml2
-rw-r--r--test/integration/targets/nxos_template/tasks/cli.yaml17
-rw-r--r--test/integration/targets/nxos_template/tasks/main.yaml4
-rw-r--r--test/integration/targets/nxos_template/tasks/nxapi.yaml29
-rw-r--r--test/integration/targets/nxos_template/templates/basic/config.j24
-rw-r--r--test/integration/targets/nxos_template/templates/config.js4
-rw-r--r--test/integration/targets/nxos_template/templates/defaults/config.j24
-rw-r--r--test/integration/targets/nxos_template/templates/defaults/test.j24
-rw-r--r--test/integration/targets/nxos_template/tests/cli/backup.yaml50
-rw-r--r--test/integration/targets/nxos_template/tests/cli/basic.yaml36
-rw-r--r--test/integration/targets/nxos_template/tests/cli/defaults.yaml42
-rw-r--r--test/integration/targets/nxos_template/tests/cli/force.yaml38
-rw-r--r--test/integration/targets/nxos_template/tests/nxapi/backup.yaml50
-rw-r--r--test/integration/targets/nxos_template/tests/nxapi/basic.yaml36
-rw-r--r--test/integration/targets/nxos_template/tests/nxapi/defaults.yaml42
-rw-r--r--test/integration/targets/nxos_template/tests/nxapi/force.yaml38
-rw-r--r--test/integration/targets/ops_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/ops_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/ops_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/ops_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/ops_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/ops_command/tests/cli/invalid.yaml28
-rw-r--r--test/integration/targets/ops_command/tests/cli/output.yaml29
-rw-r--r--test/integration/targets/ops_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/prepare_eos_tests/tasks/main.yml9
-rw-r--r--test/integration/targets/prepare_nxos_tests/tasks/main.yml5
-rw-r--r--test/integration/targets/vyos_command/defaults/main.yaml3
-rw-r--r--test/integration/targets/vyos_command/tasks/cli.yaml17
-rw-r--r--test/integration/targets/vyos_command/tasks/main.yaml3
-rw-r--r--test/integration/targets/vyos_command/tests/cli/bad_operator.yaml20
-rw-r--r--test/integration/targets/vyos_command/tests/cli/contains.yaml21
-rw-r--r--test/integration/targets/vyos_command/tests/cli/invalid.yaml24
-rw-r--r--test/integration/targets/vyos_command/tests/cli/output.yaml30
-rw-r--r--test/integration/targets/vyos_command/tests/cli/timeout.yaml19
-rw-r--r--test/integration/targets/vyos_config/defaults/main.yaml3
-rw-r--r--test/integration/targets/vyos_config/tasks/cli.yaml17
-rw-r--r--test/integration/targets/vyos_config/tasks/main.yaml3
-rw-r--r--test/integration/targets/vyos_config/tests/cli/check_config.yaml29
-rw-r--r--test/integration/targets/vyos_config/tests/cli/comment.yaml38
-rw-r--r--test/integration/targets/vyos_config/tests/cli/simple.yaml37
-rw-r--r--test/integration/vyos.yaml12
489 files changed, 13144 insertions, 2 deletions
diff --git a/test/README.md b/test/README.md
index c7f5e92c37..fb541818ae 100644
--- a/test/README.md
+++ b/test/README.md
@@ -22,8 +22,6 @@ Integration test layer, constructed using playbooks.
Some tests may require cloud credentials, others will not, and destructive tests are separated from non-destructive so a subset
can be run on development machines.
-Tests for network modules can be found in https://github.com/ansible/test-network-modules/
-
learn more
----------
diff --git a/test/integration/asa.yaml b/test/integration/asa.yaml
new file mode 100644
index 0000000000..62fef0d4c7
--- /dev/null
+++ b/test/integration/asa.yaml
@@ -0,0 +1,13 @@
+---
+- hosts: asa
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: asa_command, when: "limit_to in ['*', 'asa_command']" }
+ - { role: asa_config, when: "limit_to in ['*', 'asa_config']" }
+ - { role: asa_acl, when: "limit_to in ['*', 'asa_acl']" }
diff --git a/test/integration/dellos10.yaml b/test/integration/dellos10.yaml
new file mode 100644
index 0000000000..9052c43301
--- /dev/null
+++ b/test/integration/dellos10.yaml
@@ -0,0 +1,13 @@
+---
+- hosts: dellos10
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: dellos10_command, when: "limit_to in ['*', 'dellos10_command']" }
+ - { role: dellos10_config, when: "limit_to in ['*', 'dellos10_config']" }
+ - { role: dellos10_facts, when: "limit_to in ['*', 'dellos10_facts']" }
diff --git a/test/integration/dellos6.yaml b/test/integration/dellos6.yaml
new file mode 100644
index 0000000000..1d110f944e
--- /dev/null
+++ b/test/integration/dellos6.yaml
@@ -0,0 +1,13 @@
+---
+- hosts: dellos6
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: dellos6_command, when: "limit_to in ['*', 'dellos6_command']" }
+ - { role: dellos6_config, when: "limit_to in ['*', 'dellos6_config']" }
+ - { role: dellos6_facts, when: "limit_to in ['*', 'dellos6_facts']" }
diff --git a/test/integration/dellos9.yaml b/test/integration/dellos9.yaml
new file mode 100644
index 0000000000..5a8f780efd
--- /dev/null
+++ b/test/integration/dellos9.yaml
@@ -0,0 +1,13 @@
+---
+- hosts: dellos9
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: dellos9_command, when: "limit_to in ['*', 'dellos9_command']" }
+ - { role: dellos9_config, when: "limit_to in ['*', 'dellos9_config']" }
+ - { role: dellos9_facts, when: "limit_to in ['*', 'dellos9_facts']" }
diff --git a/test/integration/eos.yaml b/test/integration/eos.yaml
new file mode 100644
index 0000000000..9658a853d4
--- /dev/null
+++ b/test/integration/eos.yaml
@@ -0,0 +1,15 @@
+---
+- hosts: eos
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: eos_command, when: "limit_to in ['*', 'eos_command']" }
+ - { role: eos_config, when: "limit_to in ['*', 'eos_config']" }
+ - { role: eos_template, when: "limit_to in ['*', 'eos_template']" }
+ - { role: eos_facts, when: "limit_to in ['*', 'eos_facts']" }
+ - { role: eos_eapi, debug: yes, when: "limit_to in ['*', 'eos_eapi']" }
diff --git a/test/integration/group_vars/asa.yaml b/test/integration/group_vars/asa.yaml
new file mode 100644
index 0000000000..b6316e57ac
--- /dev/null
+++ b/test/integration/group_vars/asa.yaml
@@ -0,0 +1,8 @@
+---
+cli:
+ host: "{{ inventory_hostname }}"
+ username: "{{ asa_cli_user | default('cisco') }}"
+ password: "{{ asa_cli_pass | default('cisco') }}"
+ transport: cli
+ authorize: yes
+ auth_pass: "{{ asa_auth_pass | default('cisco') }}"
diff --git a/test/integration/group_vars/dellos10.yaml b/test/integration/group_vars/dellos10.yaml
new file mode 100644
index 0000000000..48a3d59a07
--- /dev/null
+++ b/test/integration/group_vars/dellos10.yaml
@@ -0,0 +1,6 @@
+---
+cli:
+ host: "{{ ansible_host }}"
+ username: "{{ dellos10_cli_user | default('admin') }}"
+ password: "{{ dellos10_cli_pass | default('admin') }}"
+ transport: cli
diff --git a/test/integration/group_vars/dellos6.yaml b/test/integration/group_vars/dellos6.yaml
new file mode 100644
index 0000000000..668f287c07
--- /dev/null
+++ b/test/integration/group_vars/dellos6.yaml
@@ -0,0 +1,8 @@
+---
+cli:
+ host: "{{ ansible_host }}"
+ username: "{{ dellos_cli_user | default('admin') }}"
+ password: "{{ dellos_cli_pass | default('admin') }}"
+ authorize: true
+ auth_pass: "{{ dellos_cli_auth_pass | default('calvin') }}"
+ transport: cli
diff --git a/test/integration/group_vars/dellos9.yaml b/test/integration/group_vars/dellos9.yaml
new file mode 100644
index 0000000000..3b3bb6bd39
--- /dev/null
+++ b/test/integration/group_vars/dellos9.yaml
@@ -0,0 +1,8 @@
+---
+cli:
+ host: "{{ ansible_host }}"
+ username: "{{ dellos9_cli_user | default('admin') }}"
+ password: "{{ dellos9_cli_pass | default('admin') }}"
+ authorize: true
+ auth_pass: "{{ dellos9_cli_en_pass | default('calvin') }}"
+ transport: cli
diff --git a/test/integration/group_vars/eos.yaml b/test/integration/group_vars/eos.yaml
new file mode 100644
index 0000000000..67e6675ae7
--- /dev/null
+++ b/test/integration/group_vars/eos.yaml
@@ -0,0 +1,15 @@
+---
+cli:
+ host: "{{ ansible_host }}"
+ username: "{{ eos_cli_user | default('admin') }}"
+ password: "{{ eos_cli_pass | default('admin') }}"
+ transport: cli
+ authorize: yes
+
+eapi:
+ host: "{{ ansible_host }}"
+ username: "{{ eos_eapi_user | default('admin') }}"
+ password: "{{ eos_eapi_pass | default('admin') }}"
+ transport: eapi
+ use_ssl: no
+ authorize: yes
diff --git a/test/integration/group_vars/ios.yaml b/test/integration/group_vars/ios.yaml
new file mode 100644
index 0000000000..21b55f5621
--- /dev/null
+++ b/test/integration/group_vars/ios.yaml
@@ -0,0 +1,6 @@
+---
+cli:
+ host: "{{ inventory_hostname }}"
+ username: "{{ ios_cli_user | default('cisco') }}"
+ password: "{{ ios_cli_pass | default('cisco') }}"
+ transport: cli
diff --git a/test/integration/group_vars/iosxr.yaml b/test/integration/group_vars/iosxr.yaml
new file mode 100644
index 0000000000..878b47b366
--- /dev/null
+++ b/test/integration/group_vars/iosxr.yaml
@@ -0,0 +1,6 @@
+---
+cli:
+ host: "{{ inventory_hostname }}"
+ username: "{{ iosxr_cli_user | default('root') }}"
+ password: "{{ iosxr_cli_pass | default('root') }}"
+ transport: cli
diff --git a/test/integration/group_vars/junos.yaml b/test/integration/group_vars/junos.yaml
new file mode 100644
index 0000000000..1216ba9a61
--- /dev/null
+++ b/test/integration/group_vars/junos.yaml
@@ -0,0 +1,12 @@
+---
+netconf:
+ host: "{{ ansible_ssh_host }}"
+ username: "{{ junos_cli_user | default('ansible') }}"
+ password: "{{ junos_cli_pass | default('Ansible') }}"
+ transport: netconf
+
+cli:
+ host: "{{ ansible_ssh_host }}"
+ username: "{{ junos_cli_user | default('ansible') }}"
+ password: "{{ junos_cli_pass | default('Ansible') }}"
+ transport: cli
diff --git a/test/integration/group_vars/nxos.yaml b/test/integration/group_vars/nxos.yaml
new file mode 100644
index 0000000000..2c3f1a288d
--- /dev/null
+++ b/test/integration/group_vars/nxos.yaml
@@ -0,0 +1,13 @@
+---
+cli:
+ host: "{{ inventory_hostname }}"
+ username: "{{ nxos_cli_user | default('admin') }}"
+ password: "{{ nxos_cli_pass | default('admin') }}"
+ transport: cli
+
+nxapi:
+ host: "{{ inventory_hostname }}"
+ username: "{{ nxos_nxapi_user | default('admin') }}"
+ password: "{{ nxos_nxapi_pass | default('admin') }}"
+ transport: nxapi
+ use_ssl: no
diff --git a/test/integration/group_vars/vyos.yaml b/test/integration/group_vars/vyos.yaml
new file mode 100644
index 0000000000..64b24dcd56
--- /dev/null
+++ b/test/integration/group_vars/vyos.yaml
@@ -0,0 +1,6 @@
+---
+cli:
+ host: "{{ ansible_ssh_host }}"
+ username: vyos
+ password: vyos
+ transport: cli
diff --git a/test/integration/ios.yaml b/test/integration/ios.yaml
new file mode 100644
index 0000000000..2010d29b62
--- /dev/null
+++ b/test/integration/ios.yaml
@@ -0,0 +1,14 @@
+---
+- hosts: ios
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: ios_command, when: "limit_to in ['*', 'ios_command']" }
+ - { role: ios_config, when: "limit_to in ['*', 'ios_config']" }
+ - { role: ios_facts, when: "limit_to in ['*', 'ios_facts']" }
+ - { role: ios_template, when: "limit_to in ['*', 'ios_template']" }
diff --git a/test/integration/iosxr.yaml b/test/integration/iosxr.yaml
new file mode 100644
index 0000000000..117d3aec30
--- /dev/null
+++ b/test/integration/iosxr.yaml
@@ -0,0 +1,14 @@
+---
+- hosts: iosxr
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: iosxr_command, when: "limit_to in ['*', 'iosxr_command']" }
+ - { role: iosxr_config, when: "limit_to in ['*', 'iosxr_config']" }
+ - { role: iosxr_facts, when: "limit_to in ['*', 'iosxr_facts']" }
+ - { role: iosxr_template, when: "limit_to in ['*', 'iosxr_template']" }
diff --git a/test/integration/junos.yaml b/test/integration/junos.yaml
new file mode 100644
index 0000000000..b0e02b5736
--- /dev/null
+++ b/test/integration/junos.yaml
@@ -0,0 +1,14 @@
+---
+- hosts: junos
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: junos_command, when: "limit_to in ['*', 'junos_command']" }
+ - { role: junos_config, when: "limit_to in ['*', 'junos_config']" }
+ - { role: junos_netconf, when: "limit_to in ['*', 'junos_netconf']" }
+ - { role: junos_template, when: "limit_to in ['*', 'junos_template']" }
diff --git a/test/integration/network-all.yaml b/test/integration/network-all.yaml
new file mode 100644
index 0000000000..f75c24b20d
--- /dev/null
+++ b/test/integration/network-all.yaml
@@ -0,0 +1,10 @@
+---
+- { include: asa.yaml }
+- { include: eos.yaml }
+- { include: ios.yaml }
+- { include: iosxr.yaml }
+- { include: nxos.yaml }
+- { include: junos.yaml }
+- { include: dellos10.yaml }
+- { include: dellos9.yaml }
+- { include: dellos6.yaml }
diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml
new file mode 100644
index 0000000000..3dcbe5e112
--- /dev/null
+++ b/test/integration/nxos.yaml
@@ -0,0 +1,15 @@
+---
+- hosts: nxos
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: nxos_command, when: "limit_to in ['*', 'nxos_command']" }
+ - { role: nxos_config, when: "limit_to in ['*', 'nxos_config']" }
+ - { role: nxos_facts, when: "limit_to in ['*', 'nxos_facts']" }
+ - { role: nxos_template, when: "limit_to in ['*', 'nxos_template']" }
+ - { role: nxos_nxapi, when: "limit_to in ['*', 'nxos_nxapi']" }
diff --git a/test/integration/targets/asa_acl/defaults/main.yaml b/test/integration/targets/asa_acl/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/asa_acl/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/asa_acl/tasks/cli.yaml b/test/integration/targets/asa_acl/tasks/cli.yaml
new file mode 100644
index 0000000000..9a32dbe643
--- /dev/null
+++ b/test/integration/targets/asa_acl/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
+
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/asa_acl/tasks/main.yaml b/test/integration/targets/asa_acl/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/asa_acl/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/asa_acl/tests/cli/basic.yaml b/test/integration/targets/asa_acl/tests/cli/basic.yaml
new file mode 100644
index 0000000000..f9b7541691
--- /dev/null
+++ b/test/integration/targets/asa_acl/tests/cli/basic.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - clear configure access-list ACL-BASIC
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: Basic ACL
+ asa_acl:
+ provider: "{{ cli }}"
+ lines:
+ - access-list ACL-BASIC extended permit tcp any any eq www
+ - access-list ACL-BASIC extended permit tcp any any eq https
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: Basic ACL idempotency
+ asa_acl:
+ provider: "{{ cli }}"
+ lines:
+ - access-list ACL-BASIC extended permit tcp any any eq www
+ - access-list ACL-BASIC extended permit tcp any any eq https
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ commands:
+ - clear configure access-list ACL-BASIC
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/asa_acl/tests/cli/full_name_match.yaml b/test/integration/targets/asa_acl/tests/cli/full_name_match.yaml
new file mode 100644
index 0000000000..0761aa53cf
--- /dev/null
+++ b/test/integration/targets/asa_acl/tests/cli/full_name_match.yaml
@@ -0,0 +1,43 @@
+---
+- debug: msg="START cli/full_name_match.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - clear configure access-list ACL-BASIC
+ - clear configure access-list ACL-BASIC2
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: Basic ACL
+ asa_acl:
+ provider: "{{ cli }}"
+ lines:
+ - access-list ACL-BASIC2 extended permit tcp any any eq www
+ - access-list ACL-BASIC2 extended permit tcp any any eq https
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: Should not match for ACL-BASIC2
+ asa_acl:
+ provider: "{{ cli }}"
+ lines:
+ - access-list ACL-BASIC extended permit tcp any any eq www
+ - access-list ACL-BASIC extended permit tcp any any eq https
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ asa_config:
+ commands:
+ - clear configure access-list ACL-BASIC
+ - clear configure access-list ACL-BASIC2
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/full_name_match.yaml"
diff --git a/test/integration/targets/asa_acl/tests/cli/insert.yaml b/test/integration/targets/asa_acl/tests/cli/insert.yaml
new file mode 100644
index 0000000000..4ae7b54492
--- /dev/null
+++ b/test/integration/targets/asa_acl/tests/cli/insert.yaml
@@ -0,0 +1,51 @@
+---
+- debug: msg="START cli/insert.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - clear configure access-list ACL-INSERT
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: Create ACL
+ asa_acl:
+ provider: "{{ cli }}"
+ lines:
+ - access-list ACL-INSERT extended permit tcp any any eq www
+ - access-list ACL-INSERT extended permit tcp any any eq https
+ register: result
+
+- name: Insert on first line
+ asa_acl:
+ provider: "{{ cli }}"
+ lines:
+ - access-list ACL-INSERT extended permit tcp any any eq www
+ - access-list ACL-INSERT extended permit tcp any any eq https
+ - access-list ACL-INSERT line 1 extended permit tcp any any eq ssh
+ register: result
+
+- name: Show ACL
+ asa_command:
+ provider: "{{ cli }}"
+ commands: "show run access-list ACL-INSERT"
+ register: result
+
+- name: Show me
+ debug:
+ var: result
+
+- name:
+ assert:
+ that:
+ - result.stdout_lines[0][0].rstrip() == 'access-list ACL-INSERT extended permit tcp any any eq ssh'
+
+
+
+- name: teardown
+ asa_config:
+ commands:
+ - clear configure access-list ACL-INSERT
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/insert.yaml"
diff --git a/test/integration/targets/asa_command/defaults/main.yaml b/test/integration/targets/asa_command/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/asa_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/asa_command/tasks/cli.yaml b/test/integration/targets/asa_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/asa_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/asa_command/tasks/main.yaml b/test/integration/targets/asa_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/asa_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/asa_command/tests/cli/bad_operator.yaml b/test/integration/targets/asa_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..bcbe8bb592
--- /dev/null
+++ b/test/integration/targets/asa_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ asa_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet 0/0
+ wait_for:
+ - result[0] contains 'Description: Foo'
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/asa_command/tests/cli/contains.yaml b/test/integration/targets/asa_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..c08d89c273
--- /dev/null
+++ b/test/integration/targets/asa_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ asa_command:
+ commands:
+ - show version
+ - show interface
+ wait_for:
+ - "result[0] contains 'Cisco Adaptive Security Appliance Software Version'"
+ - "result[1] contains 'Hardware'"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/asa_command/tests/cli/invalid.yaml b/test/integration/targets/asa_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..67730968d4
--- /dev/null
+++ b/test/integration/targets/asa_command/tests/cli/invalid.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ asa_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- name: run commands that include invalid command
+ asa_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+# FIXME bug https://github.com/ansible/ansible-modules-extras/issues/3048
+ ignore_errors: true
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/asa_command/tests/cli/output.yaml b/test/integration/targets/asa_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..ccfb75375f
--- /dev/null
+++ b/test/integration/targets/asa_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ asa_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ asa_command:
+ commands:
+ - show version
+ - show interface
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/asa_command/tests/cli/timeout.yaml b/test/integration/targets/asa_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..2387058a86
--- /dev/null
+++ b/test/integration/targets/asa_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ asa_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/asa_config/defaults/main.yaml b/test/integration/targets/asa_config/defaults/main.yaml
new file mode 100644
index 0000000000..ebf6ffc903
--- /dev/null
+++ b/test/integration/targets/asa_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: [] \ No newline at end of file
diff --git a/test/integration/targets/asa_config/tasks/cli.yaml b/test/integration/targets/asa_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/asa_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/asa_config/tasks/main.yaml b/test/integration/targets/asa_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/asa_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/asa_config/templates/basic/config.j2 b/test/integration/targets/asa_config/templates/basic/config.j2
new file mode 100644
index 0000000000..779b731e13
--- /dev/null
+++ b/test/integration/targets/asa_config/templates/basic/config.j2
@@ -0,0 +1,3 @@
+object-group network OG-ANSIBLE-TEMPLATE
+ description this is a test
+ network-object host 192.168.99.12
diff --git a/test/integration/targets/asa_config/templates/defaults/config.j2 b/test/integration/targets/asa_config/templates/defaults/config.j2
new file mode 100644
index 0000000000..762e73dea0
--- /dev/null
+++ b/test/integration/targets/asa_config/templates/defaults/config.j2
@@ -0,0 +1,4 @@
+object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
+ description this is a test
+ network-object 10.0.0.0 255.255.255.0
+ network-object 10.1.0.0 255.255.255.0
diff --git a/test/integration/targets/asa_config/tests/cli/backup.yaml b/test/integration/targets/asa_config/tests/cli/backup.yaml
new file mode 100644
index 0000000000..eea8a94cd3
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/backup.yaml
@@ -0,0 +1,53 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- 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
+ asa_config:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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"
+
+- name: teardown
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/backup.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/basic.yaml b/test/integration/targets/asa_config/tests/cli/basic.yaml
new file mode 100644
index 0000000000..2c7450f3d2
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/basic.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: configure device with config
+ asa_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ asa_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- name: teardown
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/defaults.yaml b/test/integration/targets/asa_config/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..184c2c404b
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/defaults.yaml
@@ -0,0 +1,45 @@
+---
+- debug: msg="START cli/defaults.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: configure device with defaults included
+ asa_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with defaults included
+ asa_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- name: teardown
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/defaults.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/force.yaml b/test/integration/targets/asa_config/tests/cli/force.yaml
new file mode 100644
index 0000000000..c151cb6a0c
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/force.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/force.yaml"
+
+- name: setup
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: configure device with config
+ asa_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ asa_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: teardown
+ asa_config:
+ commands:
+ - no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/force.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/more_system.yaml b/test/integration/targets/asa_config/tests/cli/more_system.yaml
new file mode 100644
index 0000000000..a84fde29e3
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/more_system.yaml
@@ -0,0 +1,47 @@
+---
+- debug: msg="START cli/more_system.yaml"
+
+- name: setup
+ asa_config:
+ lines:
+ - "clear configure tunnel-group 1.1.1.1"
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+
+- name: Prepare tunnel-group
+ asa_config:
+ before: tunnel-group 1.1.1.1 type ipsec-l2l
+ lines:
+ - "tunnel-group 1.1.1.1 ipsec-attributes"
+ provider: "{{ cli }}"
+
+- name: Setup tunnel-group
+ asa_config:
+ parents: tunnel-group 1.1.1.1 ipsec-attributes
+ lines:
+ - "ikev1 pre-shared-key abc123"
+ passwords: yes
+ provider: "{{ cli }}"
+
+- name: Test idempotency
+ asa_config:
+ parents: tunnel-group 1.1.1.1 ipsec-attributes
+ lines:
+ - "ikev1 pre-shared-key abc123"
+ passwords: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines:
+ - "clear configure tunnel-group 1.1.1.1"
+ provider: "{{ cli }}"
+
+
+- debug: msg="END cli/more_system.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/sublevel.yaml b/test/integration/targets/asa_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..2435d9f32c
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/sublevel.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup test
+ asa_config:
+ lines:
+ - 'no object-group network OG-ANSIBLE-SUBLEVEL'
+ provider: "{{ cli }}"
+
+- name: configure sub level command
+ asa_config:
+ lines: ['network-object host 192.168.10.1']
+ parents: ['object-group network OG-ANSIBLE-SUBLEVEL']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'object-group network OG-ANSIBLE-SUBLEVEL' in result.updates"
+ - "'network-object host 192.168.10.1' in result.updates"
+
+- name: configure sub level command idempotent check
+ asa_config:
+ lines: ['network-object host 192.168.10.1']
+ parents: ['object-group network OG-ANSIBLE-SUBLEVEL']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines:
+ - 'no object-group network OG-ANSIBLE-SUBLEVEL'
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/sublevel_block.yaml b/test/integration/targets/asa_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..303eb4abf1
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,64 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ asa_command:
+ commands:
+ - show run object-group
+ provider: "{{ cli }}"
+ register: object_group
+
+- name: setup
+ asa_config:
+ lines:
+ - no object-group network OG-ANSIBLE
+ match: none
+ provider: "{{ cli }}"
+ #when: "'object-group network OG-ANSIBLE\n' in {{ object_group.stdout }}"
+
+- name: configure sub level command using block replace
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'object-group network OG-ANSIBLE' in result.updates"
+ - "'network-object 192.168.10.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.20.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.30.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.40.0 255.255.255.0' in result.updates"
+
+- name: check sub level command using block replace
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines:
+ - no object-group network OG-ANSIBLE
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/asa_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..c2748caf4c
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,64 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ - network-object 192.168.50.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE-EXACT']
+ before: ['no object-group network OG-ANSIBLE-EXACT']
+ after: ['exit']
+ provider: "{{ cli }}"
+
+- name: configure sub level command using exact match
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE-EXACT']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'object-group network OG-ANSIBLE-EXACT' in result.updates"
+ - "'network-object 192.168.10.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.20.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.30.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.40.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.50.0 255.255.255.0' not in result.updates"
+
+- name: check sub level command using exact match
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ - network-object 192.168.50.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE-EXACT']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines:
+ - no object-group network OG-ANSIBLE-EXACT
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/asa_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..44ea7f8c2a
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,61 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ - network-object 192.168.50.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE-STRICT']
+ before: ['no object-group network OG-ANSIBLE-STRICT']
+ after: ['exit']
+ provider: "{{ cli }}"
+
+- name: configure sub level command using strict match
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.20.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.40.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE-STRICT']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: check sub level command using strict match
+ asa_config:
+ lines:
+ - network-object 192.168.10.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ - network-object 192.168.30.0 255.255.255.0
+ parents: ['object-group network OG-ANSIBLE-STRICT']
+ after: ['exit']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'object-group network OG-ANSIBLE-STRICT' in result.updates"
+ - "'network-object 192.168.10.0 255.255.255.0' not in result.updates"
+ - "'network-object 192.168.30.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.30.0 255.255.255.0' in result.updates"
+ - "'network-object 192.168.40.0 255.255.255.0' not in result.updates"
+ - "'network-object 192.168.50.0 255.255.255.0' not in result.updates"
+
+- name: teardown
+ asa_config:
+ lines:
+ - no object-group network OG-ANSIBLE-STRICT
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/toplevel.yaml b/test/integration/targets/asa_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..870dd42b2e
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/toplevel.yaml
@@ -0,0 +1,35 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ asa_config:
+ lines: ['hostname firewall']
+ provider: "{{ cli }}"
+
+- name: configure top level command
+ asa_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
+ asa_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/toplevel_after.yaml b/test/integration/targets/asa_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..3fbe745237
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ asa_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname firewall"
+ provider: "{{ cli }}"
+
+- name: configure top level command with before
+ asa_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
+ asa_config:
+ lines: ['hostname foo']
+ after: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/toplevel_before.yaml b/test/integration/targets/asa_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..c326bc5f2d
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ asa_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname firewall"
+ provider: "{{ cli }}"
+
+- name: configure top level command with before
+ asa_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
+ asa_config:
+ lines: ['hostname foo']
+ before: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ asa_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel_before.yaml"
diff --git a/test/integration/targets/asa_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/asa_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..9e8eafdcf0
--- /dev/null
+++ b/test/integration/targets/asa_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/toplevel_nonidempotent.yaml"
+
+- name: setup
+ asa_config:
+ backup: true
+ # lines: ['hostname firewall']
+ provider: "{{ cli }}"
+
+- name: configure top level command
+ asa_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ asa_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ asa_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/toplevel_nonidempotent.yaml"
diff --git a/test/integration/targets/dellos10_command/defaults/main.yaml b/test/integration/targets/dellos10_command/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos10_command/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos10_command/tasks/cli.yaml b/test/integration/targets/dellos10_command/tasks/cli.yaml
new file mode 100644
index 0000000000..d648420ae7
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos10_command/tasks/main.yaml b/test/integration/targets/dellos10_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos10_command/tests/cli/bad_operator.yaml b/test/integration/targets/dellos10_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..ae77680b41
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ dellos10_command:
+ commands:
+ - show version
+ - show interface ethernet 1/1/1
+ wait_for:
+ - "result[0] contains 'Description : blah'"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/dellos10_command/tests/cli/contains.yaml b/test/integration/targets/dellos10_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..c62488b904
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ dellos10_command:
+ commands:
+ - show version
+ - show interface ethernet 1/1/1
+ wait_for:
+ - "result[0] contains OS10-Premium"
+ - "result[1] contains Ethernet "
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/dellos10_command/tests/cli/invalid.yaml b/test/integration/targets/dellos10_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..14b24b4cbc
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ dellos10_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "'Error: Unrecognized command' in result.stdout"
+
+- name: run commands that include invalid command
+ dellos10_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "'Error: Unrecognized command' in result.stdout"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/dellos10_command/tests/cli/output.yaml b/test/integration/targets/dellos10_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..4df528a711
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ dellos10_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ dellos10_command:
+ commands:
+ - show version
+ - show interface Eth 1/1/1
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/dellos10_command/tests/cli/timeout.yaml b/test/integration/targets/dellos10_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..50d870a0e5
--- /dev/null
+++ b/test/integration/targets/dellos10_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ dellos10_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/dellos10_config/defaults/main.yaml b/test/integration/targets/dellos10_config/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos10_config/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos10_config/tasks/cli.yaml b/test/integration/targets/dellos10_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/dellos10_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos10_config/tasks/main.yaml b/test/integration/targets/dellos10_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos10_config/tests/cli/sublevel.yaml b/test/integration/targets/dellos10_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..b465108d61
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/sublevel.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup test
+ dellos10_config:
+ lines:
+ - 'no ip access-list test'
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command
+ dellos10_config:
+ lines: ['seq 5 permit ip any any count byte']
+ parents: ['ip access-list test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'seq 5 permit ip any any count byte' in result.updates"
+
+- name: configure sub level command idempotent check
+ dellos10_config:
+ lines: ['seq 5 permit ip any any count byte']
+ parents: ['ip access-list test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos10_config:
+ lines:
+ - 'no ip access-list test'
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/sublevel_block.yaml b/test/integration/targets/dellos10_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..9df119a439
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,62 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ parents: ['ip access-list test']
+ before: ['no ip access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using block resplace
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ 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"
+ - "'seq 5 permit ip host 1.1.1.1 any count byte' in result.updates"
+ - "'seq 10 permit ip host 2.2.2.2 any count byte' in result.updates"
+ - "'seq 15 permit ip host 3.3.3.3 any count byte' in result.updates"
+ - "'seq 20 permit ip host 4.4.4.4 any count byte' in result.updates"
+
+- name: check sub level command using block replace
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ parents: ['ip access-list test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos10_config:
+ lines:
+ - no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/dellos10_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..ad68ed1d1a
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,66 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ - seq 25 permit ip host 5.5.5.5 any count byte
+ parents: ['ip access-list test']
+ before: ['no ip access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using exact match
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ parents: ['ip access-list test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'seq 5 permit ip host 1.1.1.1 any count byte' in result.updates"
+ - "'seq 10 permit ip host 2.2.2.2 any count byte' in result.updates"
+ - "'seq 15 permit ip host 3.3.3.3 any count byte' in result.updates"
+ - "'seq 20 permit ip host 4.4.4.4 any count byte' in result.updates"
+ - "'seq 25 permit ip host 5.5.5.5 any count byte' not in result.updates"
+
+- name: check sub level command using exact match
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ - seq 25 permit ip host 5.5.5.5 any count byte
+ parents: ['ip access-list test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos10_config:
+ lines:
+ - no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/dellos10_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..5ce7d7ccba
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,63 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ - seq 25 permit ip host 5.5.5.5 any count byte
+ parents: ['ip access-list test']
+ before: ['no ip access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using strict match
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 20 permit ip host 4.4.4.4 any count byte
+ parents: ['ip access-list test']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: check sub level command using strict match
+ dellos10_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any count byte
+ - seq 15 permit ip host 3.3.3.3 any count byte
+ - seq 10 permit ip host 2.2.2.2 any count byte
+ parents: ['ip access-list test']
+ after: ['exit']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'seq 5 permit ip host 1.1.1.1 any count byte' not in result.updates"
+ - "'seq 10 permit ip host 2.2.2.2 any count byte' in result.updates"
+ - "'seq 15 permit ip host 3.3.3.3 any count byte' in result.updates"
+ - "'seq 20 permit ip host 4.4.4.4 any count byte' not in result.updates"
+ - "'seq 25 permit ip host 5.5.5.5 any count byte' not in result.updates"
+
+- name: teardown
+ dellos10_config:
+ lines:
+ - no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/toplevel.yaml b/test/integration/targets/dellos10_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..df5435f3f8
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ dellos10_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ dellos10_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
+ dellos10_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos10_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/toplevel_after.yaml b/test/integration/targets/dellos10_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..57948bcfc6
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ dellos10_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ dellos10_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
+ dellos10_config:
+ lines: ['hostname foo']
+ after: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos10_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/toplevel_before.yaml b/test/integration/targets/dellos10_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..4e0acf604f
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ dellos10_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ dellos10_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
+ dellos10_config:
+ lines: ['hostname foo']
+ before: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos10_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_before.yaml"
diff --git a/test/integration/targets/dellos10_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/dellos10_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..ad285718ba
--- /dev/null
+++ b/test/integration/targets/dellos10_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/toplevel_nonidempotent.yaml"
+
+- name: setup
+ dellos10_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ dellos10_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ dellos10_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ dellos10_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_nonidempotent.yaml"
diff --git a/test/integration/targets/dellos10_facts/defaults/main.yaml b/test/integration/targets/dellos10_facts/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos10_facts/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos10_facts/tasks/cli.yaml b/test/integration/targets/dellos10_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..d648420ae7
--- /dev/null
+++ b/test/integration/targets/dellos10_facts/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos10_facts/tasks/main.yaml b/test/integration/targets/dellos10_facts/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos10_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos10_facts/tests/cli/facts.yaml b/test/integration/targets/dellos10_facts/tests/cli/facts.yaml
new file mode 100644
index 0000000000..9f2d763de0
--- /dev/null
+++ b/test/integration/targets/dellos10_facts/tests/cli/facts.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START cli/facts.yaml"
+
+- name: test all facts
+ dellos10_facts:
+ gather_subset:
+ - all
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts is defined"
+ - "result.ansible_facts.ansible_net_interfaces is defined"
+ - "result.ansible_facts.ansible_net_memfree_mb is defined"
+ - "result.ansible_facts.ansible_net_model is defined"
+ - "result.ansible_facts.ansible_net_servicetag is defined"
+ - "result.ansible_facts.ansible_net_version is defined"
+
+- name: test all facts except hardware
+ dellos10_facts:
+ gather_subset:
+ - "!hardware"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts.ansible_net_interfaces is defined"
+ - "result.ansible_facts.ansible_net_memfree_mb is not defined"
+
+- name: test interface facts
+ dellos10_facts:
+ gather_subset:
+ - interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts.ansible_net_interfaces is defined"
+ - "result.ansible_facts.ansible_net_memfree_mb is not defined"
+
+
+- debug: msg="END cli/facts.yaml"
diff --git a/test/integration/targets/dellos6_command/defaults/main.yaml b/test/integration/targets/dellos6_command/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos6_command/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos6_command/tasks/cli.yaml b/test/integration/targets/dellos6_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/dellos6_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos6_command/tasks/main.yaml b/test/integration/targets/dellos6_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos6_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos6_command/tests/cli/bad_operator.yaml b/test/integration/targets/dellos6_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..1a8f6a2826
--- /dev/null
+++ b/test/integration/targets/dellos6_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ dellos6_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet 1/0/1
+ wait_for:
+ - "result[0] contains 'Description: Foo'"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/dellos6_command/tests/cli/contains.yaml b/test/integration/targets/dellos6_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..b9978ea867
--- /dev/null
+++ b/test/integration/targets/dellos6_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ dellos6_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet 1/0/1
+ wait_for:
+ - "result[0] contains 5"
+ - "result[1] contains Access"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/dellos6_command/tests/cli/invalid.yaml b/test/integration/targets/dellos6_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..036e54d6e5
--- /dev/null
+++ b/test/integration/targets/dellos6_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ dellos6_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- name: run commands that include invalid command
+ dellos6_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/dellos6_command/tests/cli/output.yaml b/test/integration/targets/dellos6_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..5d0ea281de
--- /dev/null
+++ b/test/integration/targets/dellos6_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ dellos6_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ dellos6_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/dellos6_command/tests/cli/timeout.yaml b/test/integration/targets/dellos6_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..046a759abe
--- /dev/null
+++ b/test/integration/targets/dellos6_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ dellos6_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/dellos6_config/defaults/main.yaml b/test/integration/targets/dellos6_config/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos6_config/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos6_config/tasks/cli.yaml b/test/integration/targets/dellos6_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/dellos6_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos6_config/tasks/main.yaml b/test/integration/targets/dellos6_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos6_config/tests/cli/sublevel.yaml b/test/integration/targets/dellos6_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..44af7c5e0f
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/sublevel.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup test
+ dellos6_config:
+ lines:
+ - 'no ip access-list test'
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command
+ dellos6_config:
+ lines: ['1000 permit every log']
+ parents: ['ip access-list test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'1000 permit every log' in result.updates"
+
+- name: configure sub level command idempotent check
+ dellos6_config:
+ lines: ['1000 permit every log']
+ parents: ['ip access-list test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos6_config:
+ lines:
+ - 'no ip access-list test'
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/sublevel_block.yaml b/test/integration/targets/dellos6_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..2b5a495fcf
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,62 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ dellos6_config:
+ lines:
+ - permit ip 1.1.1.1 0.0.0.0 any log
+ - permit ip 2.2.2.2 0.0.0.0 any log
+ - permit ip 3.3.3.3 0.0.0.0 any log
+ parents: ['ip access-list test']
+ before: ['no ip access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using block resplace
+ dellos6_config:
+ lines:
+ - 1000 permit ip 1.1.1.1 0.0.0.0 any log
+ - 1010 permit ip 2.2.2.2 0.0.0.0 any log
+ - 1020 permit ip 3.3.3.3 0.0.0.0 any log
+ - 1030 permit ip 4.4.4.4 0.0.0.0 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"
+ - "'1000 permit ip 1.1.1.1 0.0.0.0 any log' in result.updates"
+ - "'1010 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
+ - "'1020 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
+ - "'1030 permit ip 4.4.4.4 0.0.0.0 any log' in result.updates"
+
+- name: check sub level command using block replace
+ dellos6_config:
+ lines:
+ - 1000 permit ip 1.1.1.1 0.0.0.0 any log
+ - 1010 permit ip 2.2.2.2 0.0.0.0 any log
+ - 1020 permit ip 3.3.3.3 0.0.0.0 any log
+ - 1030 permit ip 4.4.4.4 0.0.0.0 any log
+ parents: ['ip access-list test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos6_config:
+ lines:
+ - no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/dellos6_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..72f7334e43
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,66 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ dellos6_config:
+ lines:
+ - permit ip 1.1.1.1 0.0.0.0 any log
+ - permit ip 2.2.2.2 0.0.0.0 any log
+ - permit ip 3.3.3.3 0.0.0.0 any log
+ - permit ip 4.4.4.4 0.0.0.0 any log
+ - permit ip 5.5.5.5 0.0.0.0 any log
+ parents: ['ip access-list test']
+ before: ['no ip access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using exact match
+ dellos6_config:
+ lines:
+ - 1000 permit ip 1.1.1.1 0.0.0.0 any log
+ - 1010 permit ip 2.2.2.2 0.0.0.0 any log
+ - 1020 permit ip 3.3.3.3 0.0.0.0 any log
+ - 1030 permit ip 4.4.4.4 0.0.0.0 any log
+ parents: ['ip access-list test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'1000 permit ip 1.1.1.1 0.0.0.0 any log' in result.updates"
+ - "'1010 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
+ - "'1020 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
+ - "'1030 permit ip 4.4.4.4 0.0.0.0 any log' in result.updates"
+ - "'1040 permit ip 5.5.5.5 0.0.0.0 any log' not in result.updates"
+
+- name: check sub level command using exact match
+ dellos6_config:
+ lines:
+ - 1000 permit ip 1.1.1.1 0.0.0.0 any log
+ - 1010 permit ip 2.2.2.2 0.0.0.0 any log
+ - 1020 permit ip 3.3.3.3 0.0.0.0 any log
+ - 1030 permit ip 4.4.4.4 0.0.0.0 any log
+ - 1040 permit ip 5.5.5.5 0.0.0.0 any log
+ parents: ['ip access-list test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos6_config:
+ lines:
+ - no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/dellos6_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..cba9943ec5
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,63 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ dellos6_config:
+ lines:
+ - permit ip 1.1.1.1 0.0.0.0 any log
+ - permit ip 2.2.2.2 0.0.0.0 any log
+ - permit ip 3.3.3.3 0.0.0.0 any log
+ - permit ip 4.4.4.4 0.0.0.0 any log
+ - permit ip 5.5.5.5 0.0.0.0 any log
+ parents: ['ip access-list test']
+ before: ['no ip access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using strict match
+ dellos6_config:
+ lines:
+ - 1000 permit ip 1.1.1.1 0.0.0.0 any log
+ - 1010 permit ip 2.2.2.2 0.0.0.0 any log
+ - 1020 permit ip 3.3.3.3 0.0.0.0 any log
+ - 1030 permit ip 4.4.4.4 0.0.0.0 any log
+ parents: ['ip access-list test']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: check sub level command using strict match
+ dellos6_config:
+ lines:
+ - 1000 permit ip 1.1.1.1 0.0.0.0 any log
+ - 1010 permit ip 3.3.3.3 0.0.0.0 any log
+ - 1020 permit ip 2.2.2.2 0.0.0.0 any log
+ parents: ['ip access-list test']
+ after: ['exit']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'1000 permit ip 1.1.1.1 0.0.0.0 any log' not in result.updates"
+ - "'1020 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
+ - "'1010 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
+ - "'1030 permit ip 4.4.4.4 0.0.0.0 any log' not in result.updates"
+ - "'1040 permit ip 5.5.5.5 0.0.0.0 any log' not in result.updates"
+
+- name: teardown
+ dellos6_config:
+ lines:
+ - no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/toplevel.yaml b/test/integration/targets/dellos6_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..42ccda1b92
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ dellos6_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ dellos6_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
+ dellos6_config:
+ lines: ['hostname "foo"']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos6_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/toplevel_after.yaml b/test/integration/targets/dellos6_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..c3048c1dce
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ dellos6_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ dellos6_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
+ dellos6_config:
+ lines: ['hostname "foo"']
+ after: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos6_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/toplevel_before.yaml b/test/integration/targets/dellos6_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..5c110da010
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ dellos6_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ dellos6_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
+ dellos6_config:
+ lines: ['hostname "foo"']
+ before: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos6_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_before.yaml"
diff --git a/test/integration/targets/dellos6_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/dellos6_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..0694c836d6
--- /dev/null
+++ b/test/integration/targets/dellos6_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/toplevel_nonidempotent.yaml"
+
+- name: setup
+ dellos6_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ dellos6_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ dellos6_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ dellos6_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_nonidempotent.yaml"
diff --git a/test/integration/targets/dellos6_facts/defaults/main.yaml b/test/integration/targets/dellos6_facts/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos6_facts/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos6_facts/tasks/cli.yaml b/test/integration/targets/dellos6_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..d648420ae7
--- /dev/null
+++ b/test/integration/targets/dellos6_facts/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos6_facts/tasks/main.yaml b/test/integration/targets/dellos6_facts/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos6_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos6_facts/tests/cli/facts.yaml b/test/integration/targets/dellos6_facts/tests/cli/facts.yaml
new file mode 100644
index 0000000000..f6b19ddb56
--- /dev/null
+++ b/test/integration/targets/dellos6_facts/tests/cli/facts.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/facts.yaml"
+
+- name: test all facts
+ dellos6_facts:
+ gather_subset:
+ - all
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts is defined"
+
+- name: test all facts except hardware
+ dellos6_facts:
+ gather_subset:
+ - "!hardware"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts.ansible_net_memfree_mb is not defined"
+
+- name: test interface facts
+ dellos6_facts:
+ gather_subset:
+ - interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts.ansible_net_interfaces is defined"
+ - "result.ansible_facts.ansible_net_memfree_mb is not defined"
+
+
+- debug: msg="END cli/facts.yaml"
diff --git a/test/integration/targets/dellos9_command/defaults/main.yaml b/test/integration/targets/dellos9_command/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos9_command/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos9_command/tasks/cli.yaml b/test/integration/targets/dellos9_command/tasks/cli.yaml
new file mode 100644
index 0000000000..d648420ae7
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos9_command/tasks/main.yaml b/test/integration/targets/dellos9_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos9_command/tests/cli/bad_operator.yaml b/test/integration/targets/dellos9_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..0ec627f55b
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ dellos9_command:
+ commands:
+ - show version
+ - show interfaces TenGigabitEthernet 0/0
+ wait_for:
+ - "result[0] contains 'Description : blah'"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/dellos9_command/tests/cli/contains.yaml b/test/integration/targets/dellos9_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..4082cddf60
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ dellos9_command:
+ commands:
+ - show version
+ - show interface TenGigabitEthernet 0/0
+ wait_for:
+ - "result[0] contains 2.0"
+ - "result[1] contains TenGigabitEthernet "
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/dellos9_command/tests/cli/invalid.yaml b/test/integration/targets/dellos9_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..6e9e8e3c93
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ dellos9_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- name: run commands that include invalid command
+ dellos9_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/dellos9_command/tests/cli/output.yaml b/test/integration/targets/dellos9_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..151c1b8805
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ dellos9_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ dellos9_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/dellos9_command/tests/cli/timeout.yaml b/test/integration/targets/dellos9_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..530ca6789b
--- /dev/null
+++ b/test/integration/targets/dellos9_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ dellos9_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/dellos9_config/defaults/main.yaml b/test/integration/targets/dellos9_config/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos9_config/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos9_config/tasks/cli.yaml b/test/integration/targets/dellos9_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/dellos9_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos9_config/tasks/main.yaml b/test/integration/targets/dellos9_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos9_config/tests/cli/sublevel.yaml b/test/integration/targets/dellos9_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..b8e95d3b5e
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/sublevel.yaml
@@ -0,0 +1,43 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup test
+ dellos9_config:
+ lines:
+ - 'no ip access-list extended test'
+ - 'no ip access-list standard test'
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command
+ dellos9_config:
+ lines: ['seq 5 permit ip any any log threshold-in-msgs 10 interval 5']
+ parents: ['ip access-list extended test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'seq 5 permit ip any any log threshold-in-msgs 10 interval 5' in result.updates"
+
+- name: configure sub level command idempotent check
+ dellos9_config:
+ lines: ['seq 5 permit ip any any log threshold-in-msgs 10 interval 5']
+ parents: ['ip access-list extended test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos9_config:
+ lines:
+ - 'no ip access-list extended test'
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/sublevel_block.yaml b/test/integration/targets/dellos9_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..267ec5bd35
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,62 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ before: ['no ip access-list extended test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using block replace
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5' in result.updates"
+
+- name: check sub level command using block replace
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos9_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/dellos9_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..d8797253c7
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,66 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ - seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ before: ['no ip access-list extended test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using exact match
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5' not in result.updates"
+
+- name: check sub level command using exact match
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ - seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos9_config:
+ lines:
+ - no ip access-list extended test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/dellos9_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..929f2b07ff
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,63 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ - seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ before: ['no ip access-list extended test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using strict match
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: check sub level command using strict match
+ dellos9_config:
+ lines:
+ - seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
+ - seq 10 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
+ - seq 15 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
+ parents: ['ip access-list extended test']
+ after: ['exit']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5' not in result.updates"
+ - "'seq 15 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 10 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5' in result.updates"
+ - "'seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5' not in result.updates"
+ - "'seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5' not in result.updates"
+
+- name: teardown
+ dellos9_config:
+ lines:
+ - no ip access-list extended test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/toplevel.yaml b/test/integration/targets/dellos9_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..8ce5666356
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ dellos9_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ dellos9_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
+ dellos9_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos9_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/toplevel_after.yaml b/test/integration/targets/dellos9_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..9ac39e1056
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ dellos9_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with after
+ dellos9_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 after idempotent check
+ dellos9_config:
+ lines: ['hostname foo']
+ after: ['snmp-server contact bar']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos9_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/toplevel_before.yaml b/test/integration/targets/dellos9_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..5b3390fbb3
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ dellos9_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ dellos9_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
+ dellos9_config:
+ lines: ['hostname foo']
+ before: ['snmp-server contact bar']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ dellos9_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_before.yaml"
diff --git a/test/integration/targets/dellos9_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/dellos9_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..fed627bae2
--- /dev/null
+++ b/test/integration/targets/dellos9_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/toplevel_nonidempotent.yaml"
+
+- name: setup
+ dellos9_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ dellos9_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ dellos9_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ dellos9_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_nonidempotent.yaml"
diff --git a/test/integration/targets/dellos9_facts/defaults/main.yaml b/test/integration/targets/dellos9_facts/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/dellos9_facts/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/dellos9_facts/tasks/cli.yaml b/test/integration/targets/dellos9_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..d648420ae7
--- /dev/null
+++ b/test/integration/targets/dellos9_facts/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/dellos9_facts/tasks/main.yaml b/test/integration/targets/dellos9_facts/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/dellos9_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/dellos9_facts/tests/cli/facts.yaml b/test/integration/targets/dellos9_facts/tests/cli/facts.yaml
new file mode 100644
index 0000000000..acea51ced6
--- /dev/null
+++ b/test/integration/targets/dellos9_facts/tests/cli/facts.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/facts.yaml"
+
+- name: test all facts
+ dellos9_facts:
+ gather_subset:
+ - all
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts is defined"
+
+- name: test all facts except hardware
+ dellos9_facts:
+ gather_subset:
+ - "!hardware"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- name: test interface facts
+ dellos9_facts:
+ gather_subset:
+ - interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.ansible_facts.ansible_net_interfaces is defined"
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+
+- debug: msg="END cli/facts.yaml"
diff --git a/test/integration/targets/eos_command/defaults/main.yaml b/test/integration/targets/eos_command/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/eos_command/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/eos_command/meta/main.yml b/test/integration/targets/eos_command/meta/main.yml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_command/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_command/tasks/cli.yaml b/test/integration/targets/eos_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/eos_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_command/tasks/eapi.yaml b/test/integration/targets/eos_command/tasks/eapi.yaml
new file mode 100644
index 0000000000..0b01334bff
--- /dev/null
+++ b/test/integration/targets/eos_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_command/tasks/main.yaml b/test/integration/targets/eos_command/tasks/main.yaml
new file mode 100644
index 0000000000..db05cb6233
--- /dev/null
+++ b/test/integration/targets/eos_command/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: eapi.yaml, tags: ['eapi'] }
+
diff --git a/test/integration/targets/eos_command/tests/cli/bad_operator.yaml b/test/integration/targets/eos_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..3e40a3ba7e
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.name foo Management"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/contains.yaml b/test/integration/targets/eos_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..5ce87ce893
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ eos_command:
+ commands:
+ - show version
+ - show interface Management1 | json
+ wait_for:
+ - "result[0] contains EOS"
+ - "result[1].interfaces.Management1.name contains Manage"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/equal.yaml b/test/integration/targets/eos_command/tests/cli/equal.yaml
new file mode 100644
index 0000000000..7041e767d3
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/equal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/equal.yaml"
+
+- name: test eq operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.name eq Management1"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test == operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.name == Management1"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/equal.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/greaterthan.yaml b/test/integration/targets/eos_command/tests/cli/greaterthan.yaml
new file mode 100644
index 0000000000..18b5a0af65
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/greaterthan.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/greaterthan.yaml"
+
+- name: test gt operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu gt 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test > operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu > 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/greaterthan.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml b/test/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml
new file mode 100644
index 0000000000..a258a4ef0c
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/greaterthanorequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/greaterthanorequal.yaml"
+
+- name: test ge operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu ge 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test >= operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu >= 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/greaterthanorequal.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/invalid.yaml b/test/integration/targets/eos_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..ed01459aaa
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/invalid.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ eos_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- name: run commands that include invalid command
+ eos_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/lessthan.yaml b/test/integration/targets/eos_command/tests/cli/lessthan.yaml
new file mode 100644
index 0000000000..b0ed69ea8b
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/lessthan.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/lessthan.yaml"
+
+- name: test lt operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu lt 1600"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test < operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu < 1600"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/lessthan.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/lessthanorequal.yaml b/test/integration/targets/eos_command/tests/cli/lessthanorequal.yaml
new file mode 100644
index 0000000000..35085e62ee
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/lessthanorequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/lessthanorequal.yaml"
+
+- name: test le operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu le 1600"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test <= operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.mtu <= 1600"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/lessthanorequal.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/notequal.yaml b/test/integration/targets/eos_command/tests/cli/notequal.yaml
new file mode 100644
index 0000000000..beab4c0ed0
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/notequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/notequal.yaml"
+
+- name: test neq operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.name neq Ethernet"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test != operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1 | json
+ wait_for:
+ - "result[1].interfaces.Management1.name != Ethernet"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/notequal.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/output.yaml b/test/integration/targets/eos_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..43e7eb1236
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/output.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ eos_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ eos_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/eos_command/tests/cli/timeout.yaml b/test/integration/targets/eos_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..02d49ea9cb
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ eos_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/bad_operator.yaml b/test/integration/targets/eos_command/tests/eapi/bad_operator.yaml
new file mode 100644
index 0000000000..f184adf2f3
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START eapi/bad_operator.yaml"
+
+- name: test bad operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.name foo Management"
+ provider: "{{ eapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END eapi/bad_operator.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/contains.yaml b/test/integration/targets/eos_command/tests/eapi/contains.yaml
new file mode 100644
index 0000000000..7f928ddd84
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START eapi/contains.yaml"
+
+- name: test contains operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[0].modelName contains EOS"
+ - "result[1].interfaces.Management1.name contains Management"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/contains.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/equal.yaml b/test/integration/targets/eos_command/tests/eapi/equal.yaml
new file mode 100644
index 0000000000..5ff5f0c224
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/equal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START eapi/equal.yaml"
+
+- name: test eq operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.name eq Management1"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test == operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.name == Management1"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/equal.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/greaterthan.yaml b/test/integration/targets/eos_command/tests/eapi/greaterthan.yaml
new file mode 100644
index 0000000000..37837d815a
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/greaterthan.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START eapi/greaterthan.yaml"
+
+- name: test gt operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu gt 0"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test > operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu >= 0"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/greaterthan.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml b/test/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml
new file mode 100644
index 0000000000..78d4bca916
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/greaterthanorequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START eapi/greaterthanorequal.yaml"
+
+- name: test ge operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu ge 0"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test >= operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu >= 0"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/greaterthanorequal.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/invalid.yaml b/test/integration/targets/eos_command/tests/eapi/invalid.yaml
new file mode 100644
index 0000000000..6c797b2088
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/invalid.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START eapi/invalid.yaml"
+
+- name: run invalid command
+ eos_command:
+ commands: ['show foo']
+ provider: "{{ eapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- name: run commands that include invalid command
+ eos_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ eapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END eapi/invalid.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/lessthan.yaml b/test/integration/targets/eos_command/tests/eapi/lessthan.yaml
new file mode 100644
index 0000000000..e157974791
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/lessthan.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START eapi/lessthan.yaml"
+
+- name: test lt operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu lt 9100"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test < operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu < 9100"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/lessthan.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml b/test/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml
new file mode 100644
index 0000000000..5bc2218295
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/lessthanorequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START eapi/lessthanorequal.yaml"
+
+- name: test le operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu le 9100"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test <= operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.mtu <= 9100"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/lessthanorequal.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/notequal.yaml b/test/integration/targets/eos_command/tests/eapi/notequal.yaml
new file mode 100644
index 0000000000..1af8a8963a
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/notequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START eapi/notequal.yaml"
+
+- name: test neq operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.name neq Ethernet"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test != operator
+ eos_command:
+ commands:
+ - show version
+ - show interfaces Management1
+ wait_for:
+ - "result[1].interfaces.Management1.name != Ethernet"
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/notequal.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/output.yaml b/test/integration/targets/eos_command/tests/eapi/output.yaml
new file mode 100644
index 0000000000..8e48e127a9
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/output.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START eapi/output.yaml"
+
+- name: get output for single command
+ eos_command:
+ commands: ['show version']
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ eos_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END eapi/output.yaml"
diff --git a/test/integration/targets/eos_command/tests/eapi/timeout.yaml b/test/integration/targets/eos_command/tests/eapi/timeout.yaml
new file mode 100644
index 0000000000..8665276d22
--- /dev/null
+++ b/test/integration/targets/eos_command/tests/eapi/timeout.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START eapi/timeout.yaml"
+
+- name: test bad condition
+ eos_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0].version foo 4.15"
+ retries: 1
+ provider: "{{ eapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END eapi/timeout.yaml"
diff --git a/test/integration/targets/eos_config/config.txt b/test/integration/targets/eos_config/config.txt
new file mode 100644
index 0000000000..e9c84cd14b
--- /dev/null
+++ b/test/integration/targets/eos_config/config.txt
@@ -0,0 +1,31 @@
+!
+! boot system flash:/vEOS-lab.swi
+!
+transceiver qsfp default-mode 4x10G
+!
+hostname localhost
+!
+spanning-tree mode mstp
+!
+no aaa root
+!
+interface Ethernet1
+!
+interface Ethernet2
+!
+interface Ethernet3
+!
+interface Ethernet4
+!
+interface Ethernet5
+!
+interface Ethernet6
+!
+interface Ethernet7
+!
+!
+no ip routing
+!
+!
+end
+
diff --git a/test/integration/targets/eos_config/defaults/main.yaml b/test/integration/targets/eos_config/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/eos_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/eos_config/meta/main.yml b/test/integration/targets/eos_config/meta/main.yml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_config/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_config/tasks/cli.yaml b/test/integration/targets/eos_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/eos_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_config/tasks/eapi.yaml b/test/integration/targets/eos_config/tasks/eapi.yaml
new file mode 100644
index 0000000000..0b01334bff
--- /dev/null
+++ b/test/integration/targets/eos_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_config/tasks/main.yaml b/test/integration/targets/eos_config/tasks/main.yaml
new file mode 100644
index 0000000000..db05cb6233
--- /dev/null
+++ b/test/integration/targets/eos_config/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: eapi.yaml, tags: ['eapi'] }
+
diff --git a/test/integration/targets/eos_config/templates/basic/config.j2 b/test/integration/targets/eos_config/templates/basic/config.j2
new file mode 100644
index 0000000000..f6a410eece
--- /dev/null
+++ b/test/integration/targets/eos_config/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Ethernet5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/eos_config/templates/config.js b/test/integration/targets/eos_config/templates/config.js
new file mode 100644
index 0000000000..931baf48e4
--- /dev/null
+++ b/test/integration/targets/eos_config/templates/config.js
@@ -0,0 +1,4 @@
+interface Ethernet5
+ description test description from ansible
+ shutdown
+
diff --git a/test/integration/targets/eos_config/templates/defaults/config.j2 b/test/integration/targets/eos_config/templates/defaults/config.j2
new file mode 100644
index 0000000000..aec2515cb9
--- /dev/null
+++ b/test/integration/targets/eos_config/templates/defaults/config.j2
@@ -0,0 +1,3 @@
+interface Ethernet5
+ description this is a test
+ no shutdown
diff --git a/test/integration/targets/eos_config/templates/defaults/test.j2 b/test/integration/targets/eos_config/templates/defaults/test.j2
new file mode 100644
index 0000000000..f6a410eece
--- /dev/null
+++ b/test/integration/targets/eos_config/templates/defaults/test.j2
@@ -0,0 +1,4 @@
+interface Ethernet5
+ description this is a test
+ shutdown
+
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"
diff --git a/test/integration/targets/eos_config/tests/eapi/backup.yaml b/test/integration/targets/eos_config/tests/eapi/backup.yaml
new file mode 100644
index 0000000000..e37001ec86
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START eapi/backup.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- 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: "{{ eapi }}"
+ 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 eapi/backup.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/defaults.yaml b/test/integration/targets/eos_config/tests/eapi/defaults.yaml
new file mode 100644
index 0000000000..9b08c15ffa
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START eapi/defaults.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure device with defaults included
+ eos_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- debug: msg="END eapi/defaults.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/save.yaml b/test/integration/targets/eos_config/tests/eapi/save.yaml
new file mode 100644
index 0000000000..1cbd4f8026
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/save.yaml
@@ -0,0 +1,35 @@
+---
+- debug: msg="START eapi/save.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+
+- name: save config
+ eos_config:
+ save: true
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: save should always run
+ eos_config:
+ save: true
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- debug: msg="END eapi/save.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/src_basic.yaml b/test/integration/targets/eos_config/tests/eapi/src_basic.yaml
new file mode 100644
index 0000000000..f4703fde51
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/src_basic.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START eapi/src_basic.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure device with config
+ eos_config:
+ src: basic/config.j2
+ provider: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- debug: msg="END eapi/src_basic.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/src_invalid.yaml b/test/integration/targets/eos_config/tests/eapi/src_invalid.yaml
new file mode 100644
index 0000000000..25745b5eac
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/src_invalid.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START eapi/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: "{{ eapi }}"
+ register: result
+ ignore_errors: yes
+
+- 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/test/integration/targets/eos_config/tests/eapi/src_match_none.yaml b/test/integration/targets/eos_config/tests/eapi/src_match_none.yaml
new file mode 100644
index 0000000000..c845b1ccd1
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/src_match_none.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START eapi/src_match_none.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure device with config
+ eos_config:
+ src: basic/config.j2
+ provider: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ 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 eapi/src_match_none.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/sublevel.yaml b/test/integration/targets/eos_config/tests/eapi/sublevel.yaml
new file mode 100644
index 0000000000..7f3d3d5e59
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/sublevel.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START eapi/sublevel.yaml"
+
+- name: setup
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure sub level command
+ eos_config:
+ lines: 10 permit ip any any log
+ parents: ip access-list test
+ after: exit
+ provider: "{{ eapi }}"
+ register: result
+
+- 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
+ eos_config:
+ lines: 10 permit ip any any log
+ parents: ip access-list test
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END eapi/sublevel.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/sublevel_block.yaml b/test/integration/targets/eos_config/tests/eapi/sublevel_block.yaml
new file mode 100644
index 0000000000..d634020291
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/sublevel_block.yaml
@@ -0,0 +1,59 @@
+---
+- debug: msg="START eapi/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
+ match: none
+ provider: "{{ eapi }}"
+
+- 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
+ after: end
+ replace: block
+ provider: "{{ eapi }}"
+ 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
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END eapi/sublevel_block.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml b/test/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml
new file mode 100644
index 0000000000..7da723644a
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/sublevel_exact.yaml
@@ -0,0 +1,65 @@
+---
+- debug: msg="START eapi/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: "{{ eapi }}"
+
+- 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
+ before: no ip access-list test
+ parents: ip access-list test
+ after: exit
+ match: exact
+ provider: "{{ eapi }}"
+ 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
+ before: no ip access-list test
+ parents: ip access-list test
+ match: exact
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END eapi/sublevel_exact.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml b/test/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml
new file mode 100644
index 0000000000..dbd16184c1
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/sublevel_strict.yaml
@@ -0,0 +1,64 @@
+---
+- debug: msg="START eapi/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
+ provider: "{{ eapi }}"
+ match: none
+
+- 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: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: no ip access-list test
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END eapi/sublevel_strict.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/toplevel.yaml b/test/integration/targets/eos_config/tests/eapi/toplevel.yaml
new file mode 100644
index 0000000000..4507c45adb
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START eapi/toplevel.yaml"
+
+- name: setup
+ eos_config:
+ lines: hostname {{ inventory_hostname }}
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure top level command
+ eos_config:
+ lines: hostname foo
+ provider: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines: hostname {{ inventory_hostname }}
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END eapi/toplevel.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/toplevel_after.yaml b/test/integration/targets/eos_config/tests/eapi/toplevel_after.yaml
new file mode 100644
index 0000000000..a7f69bec15
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START eapi/toplevel_after.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure top level command with before
+ eos_config:
+ lines: hostname foo
+ after: snmp-server contact bar
+ provider: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines:
+ - no snmp-server contact
+ - hostname {{ inventory_hostname }}
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END eapi/toplevel_after.yaml"
diff --git a/test/integration/targets/eos_config/tests/eapi/toplevel_before.yaml b/test/integration/targets/eos_config/tests/eapi/toplevel_before.yaml
new file mode 100644
index 0000000000..8ce04f56d7
--- /dev/null
+++ b/test/integration/targets/eos_config/tests/eapi/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START eapi/toplevel_before.yaml"
+
+- name: setup
+ eos_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure top level command with before
+ eos_config:
+ lines: hostname foo
+ before: snmp-server contact bar
+ provider: "{{ eapi }}"
+ 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: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines:
+ - no snmp-server contact ansible
+ - hostname {{ inventory_hostname }}
+ match: none
+ provider: "{{ eapi }}"
+
+- debug: msg="END eapi/toplevel_before.yaml"
diff --git a/test/integration/targets/eos_eapi/defaults/main.yaml b/test/integration/targets/eos_eapi/defaults/main.yaml
new file mode 100644
index 0000000000..2a4e223ff0
--- /dev/null
+++ b/test/integration/targets/eos_eapi/defaults/main.yaml
@@ -0,0 +1,4 @@
+---
+testcase: "*"
+test_items: []
+
diff --git a/test/integration/targets/eos_eapi/meta/main.yml b/test/integration/targets/eos_eapi/meta/main.yml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_eapi/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_eapi/tasks/cli.yaml b/test/integration/targets/eos_eapi/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/eos_eapi/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_eapi/tasks/main.yaml b/test/integration/targets/eos_eapi/tasks/main.yaml
new file mode 100644
index 0000000000..415c99d8b1
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/eos_eapi/tests/cli/badtransport.yaml b/test/integration/targets/eos_eapi/tests/cli/badtransport.yaml
new file mode 100644
index 0000000000..32b51555d7
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/badtransport.yaml
@@ -0,0 +1,16 @@
+- debug: msg="START CLI/BADTRANSPORT.YAML"
+
+- name: Expect transport other than cli to fail
+ eos_eapi:
+ provider: "{{ eapi }}"
+ register: eos_eapi_output
+ connection: local
+ ignore_errors: yes
+
+- debug: var=eos_eapi_output
+ when: debug
+
+- assert:
+ that: eos_eapi_output.failed and eos_eapi_output.msg |search('transport')
+
+- debug: msg="START CLI/BADTRANSPORT.YAML"
diff --git a/test/integration/targets/eos_eapi/tests/cli/config.yaml b/test/integration/targets/eos_eapi/tests/cli/config.yaml
new file mode 100644
index 0000000000..15cebd9518
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/config.yaml
@@ -0,0 +1,52 @@
+- debug: msg="START cli/config.yaml"
+
+
+#----
+- name: Setup
+ eos_config:
+ lines: no management api http-commands
+ match: none
+ provider: "{{ cli }}"
+ connection: local
+
+- name: Get running-config
+ eos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+- name: Set config
+ eos_eapi:
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+- name: Ensure that this triggered a change
+ assert:
+ that:
+ - "config.changed == true"
+
+#---
+- name: Get running-config again
+ eos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+- name: Set config
+ eos_eapi:
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+
+- name: Idempotency check
+ assert:
+ that:
+ - "config.changed == false"
+
+- debug: msg="END cli/config.yaml"
diff --git a/test/integration/targets/eos_eapi/tests/cli/configure.yaml b/test/integration/targets/eos_eapi/tests/cli/configure.yaml
new file mode 100644
index 0000000000..27c29f1190
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/configure.yaml
@@ -0,0 +1,43 @@
+- debug: msg="START CLI/CONFIGURE.YAML"
+
+- name: Change endpoint ports
+ eos_eapi:
+ enable_http: false
+ http_port: 81
+ https_port: 4443
+ enable_local_http: yes
+ local_http_port: 8181
+ 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 be set
+ assert:
+ that:
+ - http_config.stdout[0].httpServer.port == 81
+ - http_config.stdout[0].httpsServer.port == 4443
+ - http_config.stdout[0].localHttpServer.port == 8181
+
+- name: Change endpoint ports again
+ eos_eapi:
+ http_port: 81
+ https_port: 4443
+ enable_local_http: yes
+ local_http_port: 8181
+ 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/CONFIGURE.YAML"
diff --git a/test/integration/targets/eos_eapi/tests/cli/off.yaml b/test/integration/targets/eos_eapi/tests/cli/off.yaml
new file mode 100644
index 0000000000..68e73fa047
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/off.yaml
@@ -0,0 +1,50 @@
+- debug: msg="START CLI/OFF.YAML"
+
+- name: Turn all endpoints off
+ eos_eapi:
+ enable_http: no
+ enable_https: no
+ enable_local_http: no
+ enable_socket: no
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- debug: var=eos_eapi_output
+
+- eos_command:
+ commands:
+ - show management api http-commands | json
+ provider: "{{ cli }}"
+ register: http_config
+ connection: local
+
+- 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
+ eos_eapi:
+ enable_http: no
+ enable_https: no
+ enable_local_http: no
+ enable_socket: no
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- 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/test/integration/targets/eos_eapi/tests/cli/on.yaml b/test/integration/targets/eos_eapi/tests/cli/on.yaml
new file mode 100644
index 0000000000..ec8e8ba467
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/on.yaml
@@ -0,0 +1,48 @@
+- debug: msg="START CLI/ON.YAML"
+
+- name: Turn on all endpoints
+ eos_eapi:
+ enable_http: yes
+ enable_https: yes
+ enable_local_http: yes
+ enable_socket: yes
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- eos_command:
+ commands:
+ - show management api http-commands | json
+ provider: "{{ cli }}"
+ register: http_config
+ connection: local
+
+- 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
+ eos_eapi:
+ enable_http: yes
+ enable_https: yes
+ enable_local_http: yes
+ enable_socket: yes
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- 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/test/integration/targets/eos_eapi/tests/cli/start.yaml b/test/integration/targets/eos_eapi/tests/cli/start.yaml
new file mode 100644
index 0000000000..e7ac7e46cd
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/start.yaml
@@ -0,0 +1,39 @@
+- debug: msg="START CLI/START.YAML"
+
+- name: Set state to started
+ eos_eapi:
+ state: started
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- eos_command:
+ commands:
+ - show management api http-commands | json
+ provider: "{{ cli }}"
+ register: http_config
+ connection: local
+
+- 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
+ eos_eapi:
+ state: started
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- 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/test/integration/targets/eos_eapi/tests/cli/stop.yaml b/test/integration/targets/eos_eapi/tests/cli/stop.yaml
new file mode 100644
index 0000000000..1b380fa940
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/stop.yaml
@@ -0,0 +1,39 @@
+- debug: msg="START CLI/STOP.YAML"
+
+- name: Set state to stopped
+ eos_eapi:
+ state: stopped
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- eos_command:
+ commands:
+ - show management api http-commands | json
+ provider: "{{ cli }}"
+ register: http_config
+ connection: local
+
+- 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
+ eos_eapi:
+ state: stopped
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- 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/test/integration/targets/eos_eapi/tests/cli/vrf.yaml b/test/integration/targets/eos_eapi/tests/cli/vrf.yaml
new file mode 100644
index 0000000000..b21387fb2d
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/vrf.yaml
@@ -0,0 +1,57 @@
+- debug: msg="START cli/vrf.yaml"
+
+
+#----
+- name: Set invalid VRF
+ eos_eapi:
+ vrf: foobar
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+ ignore_errors: true
+
+- 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"
+
+#----
+- name: Set VRF to default
+ eos_eapi:
+ vrf: default
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+ ignore_errors: true
+
+
+- name: Set VRF to default again (idempotent)
+ eos_eapi:
+ vrf: default
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+
+- name: Ensure idempotent
+ assert:
+ that:
+ - "eos_eapi_output.changed == false"
+
+
+# -----
+# FIXME Future: Idempotent test
+# Add in an extra vrt and swap between that and default to ensure idempotency
+- name: DEBUG show vrf
+ eos_command:
+ commands: show vrf
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
+ when: false
+
+#- debug:
+# msg: "{{ eos_eapi_output }}"
+
+- debug: msg="END cli/vrf.yaml"
diff --git a/test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml b/test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml
new file mode 100644
index 0000000000..a11afef7c2
--- /dev/null
+++ b/test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml
@@ -0,0 +1,36 @@
+- debug: msg="START CLI/RESET.YAML"
+
+- name: Change endpoint ports back to default values
+ eos_eapi:
+ enable_local_http: yes
+ 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_eapi:
+ enable_local_http: yes
+ 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/test/integration/targets/eos_facts/defaults/main.yaml b/test/integration/targets/eos_facts/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/eos_facts/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/eos_facts/meta/main.yml b/test/integration/targets/eos_facts/meta/main.yml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_facts/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_facts/tasks/cli.yaml b/test/integration/targets/eos_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_facts/tasks/eapi.yaml b/test/integration/targets/eos_facts/tasks/eapi.yaml
new file mode 100644
index 0000000000..0b01334bff
--- /dev/null
+++ b/test/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_facts/tasks/main.yaml b/test/integration/targets/eos_facts/tasks/main.yaml
new file mode 100644
index 0000000000..db05cb6233
--- /dev/null
+++ b/test/integration/targets/eos_facts/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: eapi.yaml, tags: ['eapi'] }
+
diff --git a/test/integration/targets/eos_facts/tests/cli/all_facts.yaml b/test/integration/targets/eos_facts/tests/cli/all_facts.yaml
new file mode 100644
index 0000000000..1f107f99f2
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/cli/all_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/all_facts.yaml"
+
+
+- name: test getting all facts
+ eos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # Check that these facts not only are present, but are valid (positive integers)
+ - "result.ansible_facts.ansible_net_memfree_mb > 1"
+ - "result.ansible_facts.ansible_net_memtotal_mb > 1"
+
+- debug: msg="END cli/all_facts.yaml"
diff --git a/test/integration/targets/eos_facts/tests/cli/default_facts.yaml b/test/integration/targets/eos_facts/tests/cli/default_facts.yaml
new file mode 100644
index 0000000000..70909a5665
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/cli/default_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/default_facts.yaml"
+
+
+- name: test getting default facts
+ eos_facts:
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" #hw
+ - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
+ - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END cli/default.yaml"
diff --git a/test/integration/targets/eos_facts/tests/cli/invalid_subset.yaml b/test/integration/targets/eos_facts/tests/cli/invalid_subset.yaml
new file mode 100644
index 0000000000..a232bc1aaf
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/cli/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START cli/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ eos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "'Subset must be one of' in result.msg"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ eos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ #- "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END cli/invalid_subset.yaml"
diff --git a/test/integration/targets/eos_facts/tests/cli/not_hardware.yaml b/test/integration/targets/eos_facts/tests/cli/not_hardware.yaml
new file mode 100644
index 0000000000..734f6048e8
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/cli/not_hardware.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ eos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END cli/not_hardware_facts.yaml"
diff --git a/test/integration/targets/eos_facts/tests/eapi/all_facts.yaml b/test/integration/targets/eos_facts/tests/eapi/all_facts.yaml
new file mode 100644
index 0000000000..4a993bc9b1
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/eapi/all_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START eapi/all_facts.yaml"
+
+
+- name: test getting all facts
+ eos_facts:
+ provider: "{{ eapi }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # Check that these facts not only are present, but are valid (positive integers)
+ - "result.ansible_facts.ansible_net_memfree_mb > 1"
+ - "result.ansible_facts.ansible_net_memtotal_mb > 1"
+
+- debug: msg="END eapi/all_facts.yaml"
diff --git a/test/integration/targets/eos_facts/tests/eapi/default_facts.yaml b/test/integration/targets/eos_facts/tests/eapi/default_facts.yaml
new file mode 100644
index 0000000000..04e4986225
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/eapi/default_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START eapi/default_facts.yaml"
+
+
+- name: test getting default facts
+ eos_facts:
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" #hw
+ - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
+ - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END eapi/default.yaml"
diff --git a/test/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml b/test/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml
new file mode 100644
index 0000000000..e6fba87181
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/eapi/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START eapi/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ eos_facts:
+ provider: "{{ eapi }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "'Subset must be one of' in result.msg"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ eos_facts:
+ provider: "{{ eapi }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ #- "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END eapi/invalid_subset.yaml"
diff --git a/test/integration/targets/eos_facts/tests/eapi/not_hardware.yaml b/test/integration/targets/eos_facts/tests/eapi/not_hardware.yaml
new file mode 100644
index 0000000000..7be0fcdc60
--- /dev/null
+++ b/test/integration/targets/eos_facts/tests/eapi/not_hardware.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START eapi/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ eos_facts:
+ provider: "{{ eapi }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END eapi/not_hardware_facts.yaml"
diff --git a/test/integration/targets/eos_template/defaults/main.yaml b/test/integration/targets/eos_template/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/eos_template/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/eos_template/meta/main.yml b/test/integration/targets/eos_template/meta/main.yml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_template/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_template/tasks/cli.yaml b/test/integration/targets/eos_template/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/eos_template/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_template/tasks/eapi.yaml b/test/integration/targets/eos_template/tasks/eapi.yaml
new file mode 100644
index 0000000000..0b01334bff
--- /dev/null
+++ b/test/integration/targets/eos_template/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/eos_template/tasks/main.yaml b/test/integration/targets/eos_template/tasks/main.yaml
new file mode 100644
index 0000000000..db05cb6233
--- /dev/null
+++ b/test/integration/targets/eos_template/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: eapi.yaml, tags: ['eapi'] }
+
diff --git a/test/integration/targets/eos_template/templates/basic/config.j2 b/test/integration/targets/eos_template/templates/basic/config.j2
new file mode 100644
index 0000000000..f6a410eece
--- /dev/null
+++ b/test/integration/targets/eos_template/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Ethernet5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/eos_template/templates/config.js b/test/integration/targets/eos_template/templates/config.js
new file mode 100644
index 0000000000..931baf48e4
--- /dev/null
+++ b/test/integration/targets/eos_template/templates/config.js
@@ -0,0 +1,4 @@
+interface Ethernet5
+ description test description from ansible
+ shutdown
+
diff --git a/test/integration/targets/eos_template/templates/defaults/config.j2 b/test/integration/targets/eos_template/templates/defaults/config.j2
new file mode 100644
index 0000000000..aec2515cb9
--- /dev/null
+++ b/test/integration/targets/eos_template/templates/defaults/config.j2
@@ -0,0 +1,3 @@
+interface Ethernet5
+ description this is a test
+ no shutdown
diff --git a/test/integration/targets/eos_template/templates/defaults/test.j2 b/test/integration/targets/eos_template/templates/defaults/test.j2
new file mode 100644
index 0000000000..f6a410eece
--- /dev/null
+++ b/test/integration/targets/eos_template/templates/defaults/test.j2
@@ -0,0 +1,4 @@
+interface Ethernet5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/eos_template/tests/cli/backup.yaml b/test/integration/targets/eos_template/tests/cli/backup.yaml
new file mode 100644
index 0000000000..c3d9491888
--- /dev/null
+++ b/test/integration/targets/eos_template/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_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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_template/tests/cli/basic.yaml b/test/integration/targets/eos_template/tests/cli/basic.yaml
new file mode 100644
index 0000000000..c698928b41
--- /dev/null
+++ b/test/integration/targets/eos_template/tests/cli/basic.yaml
@@ -0,0 +1,36 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/eos_template/tests/cli/defaults.yaml b/test/integration/targets/eos_template/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..9eb6423138
--- /dev/null
+++ b/test/integration/targets/eos_template/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_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with defaults included
+ eos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END cli/defaults.yaml"
diff --git a/test/integration/targets/eos_template/tests/cli/force.yaml b/test/integration/targets/eos_template/tests/cli/force.yaml
new file mode 100644
index 0000000000..9a929a83fa
--- /dev/null
+++ b/test/integration/targets/eos_template/tests/cli/force.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/force.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- debug: msg="END cli/force.yaml"
diff --git a/test/integration/targets/eos_template/tests/eapi/backup.yaml b/test/integration/targets/eos_template/tests/eapi/backup.yaml
new file mode 100644
index 0000000000..e39efb476e
--- /dev/null
+++ b/test/integration/targets/eos_template/tests/eapi/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START eapi/backup.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- 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_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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 eapi/backup.yaml"
diff --git a/test/integration/targets/eos_template/tests/eapi/basic.yaml b/test/integration/targets/eos_template/tests/eapi/basic.yaml
new file mode 100644
index 0000000000..22d1085581
--- /dev/null
+++ b/test/integration/targets/eos_template/tests/eapi/basic.yaml
@@ -0,0 +1,36 @@
+---
+- debug: msg="START eapi/basic.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ eapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END eapi/basic.yaml"
diff --git a/test/integration/targets/eos_template/tests/eapi/defaults.yaml b/test/integration/targets/eos_template/tests/eapi/defaults.yaml
new file mode 100644
index 0000000000..74e423299c
--- /dev/null
+++ b/test/integration/targets/eos_template/tests/eapi/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START eapi/defaults.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure device with defaults included
+ eos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ eapi }}"
+ register: result
+
+#- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with defaults included
+ eos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ eapi }}"
+ register: result
+
+#- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END eapi/defaults.yaml"
diff --git a/test/integration/targets/eos_template/tests/eapi/force.yaml b/test/integration/targets/eos_template/tests/eapi/force.yaml
new file mode 100644
index 0000000000..de2c051137
--- /dev/null
+++ b/test/integration/targets/eos_template/tests/eapi/force.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START eapi/force.yaml"
+
+- name: setup
+ eos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet5
+ match: none
+ provider: "{{ eapi }}"
+
+- name: configure device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ eapi }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ eos_template:
+ src: basic/config.j2
+ provider: "{{ eapi }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- debug: msg="END eapi/force.yaml"
diff --git a/test/integration/targets/ios_command/defaults/main.yaml b/test/integration/targets/ios_command/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/ios_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/ios_command/tasks/cli.yaml b/test/integration/targets/ios_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/ios_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/ios_command/tasks/main.yaml b/test/integration/targets/ios_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/ios_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/ios_command/tests/cli/bad_operator.yaml b/test/integration/targets/ios_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..38885b1488
--- /dev/null
+++ b/test/integration/targets/ios_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ ios_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet 0/0
+ wait_for:
+ - "result[0] contains 'Description: Foo'"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/ios_command/tests/cli/contains.yaml b/test/integration/targets/ios_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..2777d887bd
--- /dev/null
+++ b/test/integration/targets/ios_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ ios_command:
+ commands:
+ - show version
+ - show interface GigabitEthernet0/0
+ wait_for:
+ - "result[0] contains 15.6"
+ - "result[1] contains GigabitEthernet0/0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/ios_command/tests/cli/invalid.yaml b/test/integration/targets/ios_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..597d50746e
--- /dev/null
+++ b/test/integration/targets/ios_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ ios_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- name: run commands that include invalid command
+ ios_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/ios_command/tests/cli/output.yaml b/test/integration/targets/ios_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..827349765c
--- /dev/null
+++ b/test/integration/targets/ios_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ ios_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ ios_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/ios_command/tests/cli/timeout.yaml b/test/integration/targets/ios_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..6b43fee973
--- /dev/null
+++ b/test/integration/targets/ios_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ ios_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/ios_config/defaults/main.yaml b/test/integration/targets/ios_config/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/ios_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/ios_config/tasks/cli.yaml b/test/integration/targets/ios_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/ios_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/ios_config/tasks/main.yaml b/test/integration/targets/ios_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/ios_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/ios_config/templates/basic/config.j2 b/test/integration/targets/ios_config/templates/basic/config.j2
new file mode 100644
index 0000000000..06f9848883
--- /dev/null
+++ b/test/integration/targets/ios_config/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Loopback999
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/ios_config/templates/defaults/config.j2 b/test/integration/targets/ios_config/templates/defaults/config.j2
new file mode 100644
index 0000000000..1d4d9da8d4
--- /dev/null
+++ b/test/integration/targets/ios_config/templates/defaults/config.j2
@@ -0,0 +1,4 @@
+interface Loopback999
+ description this is a test
+ no shutdown
+
diff --git a/test/integration/targets/ios_config/tests/cli/backup.yaml b/test/integration/targets/ios_config/tests/cli/backup.yaml
new file mode 100644
index 0000000000..a34586a3cb
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ 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
+ ios_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/ios_config/tests/cli/defaults.yaml b/test/integration/targets/ios_config/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..b78b589d45
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/defaults.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with defaults included
+ ios_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
+ ios_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/ios_config/tests/cli/save.yaml b/test/integration/targets/ios_config/tests/cli/save.yaml
new file mode 100644
index 0000000000..a886210e61
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/save.yaml
@@ -0,0 +1,43 @@
+---
+- debug: msg="START cli/save.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+
+- name: save config
+ ios_config:
+ save: true
+ provider: "{{ cli }}"
+ register: result
+# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
+ ignore_errors: true
+
+- assert:
+ that:
+ - "result.changed == true"
+# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
+ ignore_errors: true
+
+- name: save should always run
+ ios_config:
+ save: true
+ provider: "{{ cli }}"
+ register: result
+# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
+ ignore_errors: true
+
+- assert:
+ that:
+ - "result.changed == true"
+# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
+ ignore_errors: true
+
+- debug: msg="END cli/save.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/src_basic.yaml b/test/integration/targets/ios_config/tests/cli/src_basic.yaml
new file mode 100644
index 0000000000..177d19f926
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/src_basic.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/src_basic.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ ios_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
+ ios_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/ios_config/tests/cli/src_invalid.yaml b/test/integration/targets/ios_config/tests/cli/src_invalid.yaml
new file mode 100644
index 0000000000..5081f1a736
--- /dev/null
+++ b/test/integration/targets/ios_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
+ ios_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/ios_config/tests/cli/src_match_none.yaml b/test/integration/targets/ios_config/tests/cli/src_match_none.yaml
new file mode 100644
index 0000000000..b55d7a545b
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/src_match_none.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START cli/src_match_none.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ ios_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
+ ios_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ 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/ios_config/tests/cli/src_match_none.yaml.orig b/test/integration/targets/ios_config/tests/cli/src_match_none.yaml.orig
new file mode 100644
index 0000000000..1e063d5ef7
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/src_match_none.yaml.orig
@@ -0,0 +1,49 @@
+---
+- debug: msg="START cli/src_match_none.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ ios_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
+ ios_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+<<<<<<< f84b1d496e52b69dab38894e7ec7b90b63857331
+=======
+ match: none
+>>>>>>> Tests for ios_config
+ register: result
+
+- assert:
+ that:
+ # Idempotent test
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.changed == false"
+ - "result.updates is not defined"
+<<<<<<< f84b1d496e52b69dab38894e7ec7b90b63857331
+=======
+# FIXME bug https://github.com/ansible/ansible-modules-core/issues/5003
+ ignore_errors: true
+>>>>>>> Tests for ios_config
+
+- debug: msg="END cli/src_match_none.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/sublevel.yaml b/test/integration/targets/ios_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..a5b13a3a66
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/sublevel.yaml
@@ -0,0 +1,43 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup test
+ ios_config:
+ lines:
+ - 'no ip access-list extended test'
+ - 'no ip access-list standard test'
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command
+ ios_config:
+ lines: ['permit ip any any log']
+ parents: ['ip access-list extended test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip any any log' in result.updates"
+
+- name: configure sub level command idempotent check
+ ios_config:
+ lines: ['permit ip any any log']
+ parents: ['ip access-list extended test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ios_config:
+ lines:
+ - 'no ip access-list extended test'
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/sublevel_block.yaml b/test/integration/targets/ios_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..142ed6ee86
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,62 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ parents: ['ip access-list extended test']
+ before: ['no ip access-list extended test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using block resplace
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ parents: ['ip access-list extended test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip host 1.1.1.1 any log' in result.updates"
+ - "'permit ip host 2.2.2.2 any log' in result.updates"
+ - "'permit ip host 3.3.3.3 any log' in result.updates"
+ - "'permit ip host 4.4.4.4 any log' in result.updates"
+
+- name: check sub level command using block replace
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ parents: ['ip access-list extended test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ios_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/ios_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..0ef170ffcb
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,65 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ - permit ip host 5.5.5.5 any log
+ parents: ip access-list extended test
+ before: no ip access-list extended test
+ after: exit
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using exact match
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ parents: ip access-list extended test
+ before: no ip access-list extended test
+ after: exit
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip host 1.1.1.1 any log' in result.updates"
+ - "'permit ip host 2.2.2.2 any log' in result.updates"
+ - "'permit ip host 3.3.3.3 any log' in result.updates"
+ - "'permit ip host 4.4.4.4 any log' in result.updates"
+ - "'permit ip host 5.5.5.5 any log' not in result.updates"
+
+- name: check sub level command using exact match
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ parents: ip access-list extended test
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ios_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/ios_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..f626b94f2d
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,61 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ - permit ip host 5.5.5.5 any log
+ parents: ip access-list extended test
+ before: no ip access-list extended test
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using strict match
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 2.2.2.2 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 4.4.4.4 any log
+ parents: ip access-list extended test
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: check sub level command using strict match
+ ios_config:
+ lines:
+ - permit ip host 1.1.1.1 any log
+ - permit ip host 3.3.3.3 any log
+ - permit ip host 2.2.2.2 any log
+ parents: ip access-list extended test
+ after: exit
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip host 1.1.1.1 any log' not in result.updates"
+ - "'permit ip host 2.2.2.2 any log' in result.updates"
+ - "'permit ip host 3.3.3.3 any log' in result.updates"
+ - "'permit ip host 4.4.4.4 any log' not in result.updates"
+ - "'permit ip host 5.5.5.5 any log' not in result.updates"
+
+- name: teardown
+ ios_config:
+ lines: no ip access-list extended test
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/toplevel.yaml b/test/integration/targets/ios_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..13e34f2b69
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ ios_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ ios_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
+ ios_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ios_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/toplevel_after.yaml b/test/integration/targets/ios_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..c308ecc5e7
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ ios_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ ios_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
+ ios_config:
+ lines: ['hostname foo']
+ after: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ios_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/toplevel_before.yaml b/test/integration/targets/ios_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..9707f41a0a
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ ios_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ ios_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
+ ios_config:
+ lines: ['hostname foo']
+ before: ['snmp-server contact foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ ios_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_before.yaml"
diff --git a/test/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..99bac13ebb
--- /dev/null
+++ b/test/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/toplevel_nonidempotent.yaml"
+
+- name: setup
+ ios_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ ios_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ ios_config:
+ lines: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ ios_config:
+ lines: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_nonidempotent.yaml"
diff --git a/test/integration/targets/ios_facts/defaults/main.yaml b/test/integration/targets/ios_facts/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/ios_facts/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/ios_facts/tasks/cli.yaml b/test/integration/targets/ios_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/ios_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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/ios_facts/tasks/main.yaml b/test/integration/targets/ios_facts/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/ios_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/ios_facts/tests/cli/all_facts.yaml b/test/integration/targets/ios_facts/tests/cli/all_facts.yaml
new file mode 100644
index 0000000000..c6e9219e7a
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/all_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/all_facts.yaml"
+
+
+- name: test getting all facts
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # Check that these facts not only are present, but are valid (positive integers)
+ - "result.ansible_facts.ansible_net_memfree_mb > 1"
+ - "result.ansible_facts.ansible_net_memtotal_mb > 1"
+
+- debug: msg="END cli/all_facts.yaml"
diff --git a/test/integration/targets/ios_facts/tests/cli/default_facts.yaml b/test/integration/targets/ios_facts/tests/cli/default_facts.yaml
new file mode 100644
index 0000000000..2218fc6860
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/default_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/default_facts.yaml"
+
+
+- name: test getting default facts
+ ios_facts:
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" #hw
+ - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
+ - "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END cli/default.yaml"
diff --git a/test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml b/test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml
new file mode 100644
index 0000000000..b0c2799254
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START cli/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END cli/invalid_subset.yaml"
diff --git a/test/integration/targets/ios_facts/tests/cli/not_hardware.yaml b/test/integration/targets/ios_facts/tests/cli/not_hardware.yaml
new file mode 100644
index 0000000000..319e4bcc2c
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/not_hardware.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END cli/not_hardware_facts.yaml"
diff --git a/test/integration/targets/ios_template/defaults/main.yaml b/test/integration/targets/ios_template/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/ios_template/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/ios_template/tasks/cli.yaml b/test/integration/targets/ios_template/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/ios_template/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/ios_template/tasks/main.yaml b/test/integration/targets/ios_template/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/ios_template/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/ios_template/templates/basic/config.j2 b/test/integration/targets/ios_template/templates/basic/config.j2
new file mode 100644
index 0000000000..06f9848883
--- /dev/null
+++ b/test/integration/targets/ios_template/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Loopback999
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/ios_template/templates/defaults/config.j2 b/test/integration/targets/ios_template/templates/defaults/config.j2
new file mode 100644
index 0000000000..1d4d9da8d4
--- /dev/null
+++ b/test/integration/targets/ios_template/templates/defaults/config.j2
@@ -0,0 +1,4 @@
+interface Loopback999
+ description this is a test
+ no shutdown
+
diff --git a/test/integration/targets/ios_template/tests/cli/backup.yaml b/test/integration/targets/ios_template/tests/cli/backup.yaml
new file mode 100644
index 0000000000..87c37c9d00
--- /dev/null
+++ b/test/integration/targets/ios_template/tests/cli/backup.yaml
@@ -0,0 +1,55 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- 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
+ ios_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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"
+
+- name: teardown
+ ios_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/backup.yaml"
diff --git a/test/integration/targets/ios_template/tests/cli/basic.yaml b/test/integration/targets/ios_template/tests/cli/basic.yaml
new file mode 100644
index 0000000000..2fd9ef0423
--- /dev/null
+++ b/test/integration/targets/ios_template/tests/cli/basic.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: configure device with config
+ ios_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ ios_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- name: teardown
+ ios_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/ios_template/tests/cli/defaults.yaml b/test/integration/targets/ios_template/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..95015568cd
--- /dev/null
+++ b/test/integration/targets/ios_template/tests/cli/defaults.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/defaults.yaml"
+
+- name: setup
+ ios_config:
+ commands: no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: configure device with defaults included
+ ios_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with defaults included
+ ios_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- name: teardown
+ ios_config:
+ commands: no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/defaults.yaml"
diff --git a/test/integration/targets/ios_template/tests/cli/force.yaml b/test/integration/targets/ios_template/tests/cli/force.yaml
new file mode 100644
index 0000000000..d784fd0f1c
--- /dev/null
+++ b/test/integration/targets/ios_template/tests/cli/force.yaml
@@ -0,0 +1,43 @@
+---
+- debug: msg="START cli/force.yaml"
+
+- name: setup
+ ios_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- name: configure device with config
+ ios_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ ios_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: teardown
+ ios_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/force.yaml"
diff --git a/test/integration/targets/iosxr_command/defaults/main.yaml b/test/integration/targets/iosxr_command/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/iosxr_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/iosxr_command/tasks/cli.yaml b/test/integration/targets/iosxr_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/iosxr_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/iosxr_command/tasks/main.yaml b/test/integration/targets/iosxr_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/iosxr_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/iosxr_command/tests/cli/bad_operator.yaml b/test/integration/targets/iosxr_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..cc345ddcb6
--- /dev/null
+++ b/test/integration/targets/iosxr_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ iosxr_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet 0/0
+ wait_for:
+ - "result[0] contains 'Description: Foo'"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/iosxr_command/tests/cli/contains.yaml b/test/integration/targets/iosxr_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..5491cc19c3
--- /dev/null
+++ b/test/integration/targets/iosxr_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ iosxr_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet0/0/0/1
+ wait_for:
+ - "result[0] contains 6.0.0"
+ - "result[1] contains GigabitEthernet0/0/0/1"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/iosxr_command/tests/cli/invalid.yaml b/test/integration/targets/iosxr_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..ce18444a93
--- /dev/null
+++ b/test/integration/targets/iosxr_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ iosxr_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- name: run commands that include invalid command
+ iosxr_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/iosxr_command/tests/cli/output.yaml b/test/integration/targets/iosxr_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..36ee04981a
--- /dev/null
+++ b/test/integration/targets/iosxr_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ iosxr_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ iosxr_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/iosxr_command/tests/cli/timeout.yaml b/test/integration/targets/iosxr_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..ef787b077c
--- /dev/null
+++ b/test/integration/targets/iosxr_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ iosxr_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/iosxr_config/defaults/main.yaml b/test/integration/targets/iosxr_config/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/iosxr_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/iosxr_config/tasks/cli.yaml b/test/integration/targets/iosxr_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/iosxr_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/iosxr_config/tasks/main.yaml b/test/integration/targets/iosxr_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/iosxr_config/templates/basic/config.j2 b/test/integration/targets/iosxr_config/templates/basic/config.j2
new file mode 100644
index 0000000000..06f9848883
--- /dev/null
+++ b/test/integration/targets/iosxr_config/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Loopback999
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/iosxr_config/templates/defaults/config.j2 b/test/integration/targets/iosxr_config/templates/defaults/config.j2
new file mode 100644
index 0000000000..1d4d9da8d4
--- /dev/null
+++ b/test/integration/targets/iosxr_config/templates/defaults/config.j2
@@ -0,0 +1,4 @@
+interface Loopback999
+ description this is a test
+ no shutdown
+
diff --git a/test/integration/targets/iosxr_config/tests/cli/backup.yaml b/test/integration/targets/iosxr_config/tests/cli/backup.yaml
new file mode 100644
index 0000000000..6782fd1de9
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ 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
+ iosxr_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/iosxr_config/tests/cli/comment-too-long.yaml b/test/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml
new file mode 100644
index 0000000000..97b79cdf82
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/comment-too-long.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+# Defend against https://github.com/ansible/ansible-modules-core/issues/5146
+- name: Commit message too long
+ iosxr_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ comment: "this is a really long message aaaaabbbbbbcdde end-of-message"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+# Defend https://github.com/ansible/ansible-modules-core/issues/5146
+ - "'comment argument cannot be more than 60 characters' in result.msg"
+# Check for the correct error message (and not a generic "Invalid input detected") once fixed
+
+
+- debug: msg="END cli/comment-too-long.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/comment.yaml b/test/integration/targets/iosxr_config/tests/cli/comment.yaml
new file mode 100644
index 0000000000..cd43e9cd7c
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/comment.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/comment.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with comment
+ iosxr_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ comment: "this is sensible commit message"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is not defined"
+
+- name: check device with config
+ iosxr_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- debug: msg="END cli/comment.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/src_basic.yaml b/test/integration/targets/iosxr_config/tests/cli/src_basic.yaml
new file mode 100644
index 0000000000..4d86af8b24
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/src_basic.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/src_basic.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ iosxr_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
+ iosxr_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/iosxr_config/tests/cli/src_invalid.yaml b/test/integration/targets/iosxr_config/tests/cli/src_invalid.yaml
new file mode 100644
index 0000000000..c5bb287724
--- /dev/null
+++ b/test/integration/targets/iosxr_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
+ iosxr_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/iosxr_config/tests/cli/src_match_none.yaml b/test/integration/targets/iosxr_config/tests/cli/src_match_none.yaml
new file mode 100644
index 0000000000..1340c6a83f
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/src_match_none.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START cli/src_match_none.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ iosxr_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
+ iosxr_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ 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/iosxr_config/tests/cli/sublevel.yaml b/test/integration/targets/iosxr_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..c292e9e536
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/sublevel.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START cli/sublevel.yaml"
+
+- name: setup
+ iosxr_config:
+ commands: ['no ipv4 access-list test']
+ provider: "{{ cli }}"
+ match: none
+ ignore_errors: yes
+
+- name: configure sub level command
+ iosxr_config:
+ commands: ['10 permit ipv4 any any log']
+ parents: ['ipv4 access-list test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ipv4 access-list test' in result.updates"
+ - "'10 permit ipv4 any any log' in result.updates"
+
+- name: configure sub level command idempotent check
+ iosxr_config:
+ commands: ['10 permit ipv4 any any log']
+ parents: ['ipv4 access-list test']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands: ['no ipv4 access-list test']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/sublevel_block.yaml b/test/integration/targets/iosxr_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..0e49ed9ee2
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,61 @@
+---
+- debug: msg="START cli/sublevel_block.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ parents: ['ipv4 access-list test']
+ before: ['no ipv4 access-list test']
+ after: ['exit']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using block resplace
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ parents: ['ipv4 access-list test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ipv4 access-list test' in result.updates"
+ - "'10 permit ipv4 host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ipv4 host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ipv4 host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ipv4 host 4.4.4.4 any log' in result.updates"
+
+- name: check sub level command using block replace
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ parents: ['ipv4 access-list test']
+ replace: block
+ after: ['exit']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands: ['no ipv4 access-list test']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_block.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/iosxr_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..5b3db3f0da
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,65 @@
+---
+- debug: msg="START cli/sublevel_exact.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ - 50 permit ipv4 host 5.5.5.5 any log
+ parents: ['ipv4 access-list test']
+ before: ['no ipv4 access-list test']
+ after: ['exit']
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using exact match
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ parents: ['ipv4 access-list test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ipv4 access-list test' in result.updates"
+ - "'10 permit ipv4 host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ipv4 host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ipv4 host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ipv4 host 4.4.4.4 any log' in result.updates"
+ - "'50 permit ipv4 host 5.5.5.5 any log' not in result.updates"
+
+- name: check sub level command using exact match
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ - 50 permit ipv4 host 5.5.5.5 any log
+ parents: ['ipv4 access-list test']
+ after: ['exit']
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands: ['no ipv4 access-list test']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/sublevel_exact.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/iosxr_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..2ce0bc7c9d
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,66 @@
+---
+- debug: msg="START cli/sublevel_strict.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 3.3.3.3 any log
+ - 30 permit ipv4 host 2.2.2.2 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ - 50 permit ipv4 host 5.5.5.5 any log
+ parents: ['ipv4 access-list test']
+ before: ['no ipv4 access-list test']
+ after: ['exit']
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure sub level command using strict match
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ parents: ['ipv4 access-list test']
+ before: ['no ipv4 access-list test']
+ after: ['exit']
+ match: strict
+ replace: block
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ipv4 access-list test' in result.updates"
+ - "'10 permit ipv4 host 1.1.1.1 any log' in result.updates"
+ - "'20 permit ipv4 host 2.2.2.2 any log' in result.updates"
+ - "'30 permit ipv4 host 3.3.3.3 any log' in result.updates"
+ - "'40 permit ipv4 host 4.4.4.4 any log' in result.updates"
+ - "'50 permit ipv4 host 5.5.5.5 any log' not in result.updates"
+
+- name: check sub level command using strict match
+ iosxr_config:
+ commands:
+ - 10 permit ipv4 host 1.1.1.1 any log
+ - 20 permit ipv4 host 2.2.2.2 any log
+ - 30 permit ipv4 host 3.3.3.3 any log
+ - 40 permit ipv4 host 4.4.4.4 any log
+ parents: ['ipv4 access-list test']
+ after: ['exit']
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands: ['no ipv4 access-list test']
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/sublevel_strict.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/toplevel.yaml b/test/integration/targets/iosxr_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..07e645e938
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/toplevel.yaml"
+
+- name: setup
+ iosxr_config:
+ commands: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ iosxr_config:
+ commands: ['hostname foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ iosxr_config:
+ commands: ['hostname foo']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/toplevel_after.yaml b/test/integration/targets/iosxr_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..3755529f84
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_after.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - "no cdp"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ iosxr_config:
+ commands: ['hostname foo']
+ after: ['cdp']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+ - "'cdp' in result.updates"
+
+- name: configure top level command with before idempotent check
+ iosxr_config:
+ commands: ['hostname foo']
+ after: ['no cdp']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands:
+ - "no cdp"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_after.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/toplevel_before.yaml b/test/integration/targets/iosxr_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..b795417848
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/toplevel_before.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - "no cdp"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ iosxr_config:
+ commands: ['hostname foo']
+ before: ['cdp']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+ - "'cdp' in result.updates"
+
+- name: configure top level command with before idempotent check
+ iosxr_config:
+ commands: ['hostname foo']
+ before: ['cdp']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ iosxr_config:
+ commands:
+ - "no cdp"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_before.yaml"
diff --git a/test/integration/targets/iosxr_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/iosxr_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..227509e300
--- /dev/null
+++ b/test/integration/targets/iosxr_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/toplevel_nonidempotent.yaml"
+
+- name: setup
+ iosxr_config:
+ commands: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ iosxr_config:
+ commands: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ iosxr_config:
+ commands: ['hostname foo']
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ iosxr_config:
+ commands: ['hostname {{ inventory_hostname }}']
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/toplevel_nonidempotent.yaml"
diff --git a/test/integration/targets/iosxr_facts/defaults/main.yaml b/test/integration/targets/iosxr_facts/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/iosxr_facts/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/iosxr_facts/tasks/cli.yaml b/test/integration/targets/iosxr_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/iosxr_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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/iosxr_facts/tasks/main.yaml b/test/integration/targets/iosxr_facts/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/iosxr_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/iosxr_facts/tests/cli/all_facts.yaml b/test/integration/targets/iosxr_facts/tests/cli/all_facts.yaml
new file mode 100644
index 0000000000..7fe30225d3
--- /dev/null
+++ b/test/integration/targets/iosxr_facts/tests/cli/all_facts.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/all_facts.yaml"
+
+
+- name: test getting all facts
+ iosxr_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+
+- debug: msg="END cli/all_facts.yaml"
diff --git a/test/integration/targets/iosxr_facts/tests/cli/default_facts.yaml b/test/integration/targets/iosxr_facts/tests/cli/default_facts.yaml
new file mode 100644
index 0000000000..ebf9aa2652
--- /dev/null
+++ b/test/integration/targets/iosxr_facts/tests/cli/default_facts.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/default_facts.yaml"
+
+
+- name: test getting default facts
+ iosxr_facts:
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" # hardware
+ - "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END cli/default.yaml"
diff --git a/test/integration/targets/iosxr_facts/tests/cli/invalid_subset.yaml b/test/integration/targets/iosxr_facts/tests/cli/invalid_subset.yaml
new file mode 100644
index 0000000000..1c2d28ca27
--- /dev/null
+++ b/test/integration/targets/iosxr_facts/tests/cli/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START cli/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ iosxr_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ iosxr_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END cli/invalid_subset.yaml"
diff --git a/test/integration/targets/iosxr_facts/tests/cli/not_hardware.yaml b/test/integration/targets/iosxr_facts/tests/cli/not_hardware.yaml
new file mode 100644
index 0000000000..626d4e832b
--- /dev/null
+++ b/test/integration/targets/iosxr_facts/tests/cli/not_hardware.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ iosxr_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END cli/not_hardware_facts.yaml"
diff --git a/test/integration/targets/iosxr_template/defaults/main.yaml b/test/integration/targets/iosxr_template/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/iosxr_template/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/iosxr_template/tasks/cli.yaml b/test/integration/targets/iosxr_template/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/iosxr_template/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/iosxr_template/tasks/main.yaml b/test/integration/targets/iosxr_template/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/iosxr_template/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/iosxr_template/templates/basic/config.j2 b/test/integration/targets/iosxr_template/templates/basic/config.j2
new file mode 100644
index 0000000000..7c9c4f7e63
--- /dev/null
+++ b/test/integration/targets/iosxr_template/templates/basic/config.j2
@@ -0,0 +1,5 @@
+hostname {{ inventory_hostname }}
+!
+interface Loopback999
+ description this is a test
+ shutdown
diff --git a/test/integration/targets/iosxr_template/tests/cli/backup.yaml b/test/integration/targets/iosxr_template/tests/cli/backup.yaml
new file mode 100644
index 0000000000..4ef1ab01b0
--- /dev/null
+++ b/test/integration/targets/iosxr_template/tests/cli/backup.yaml
@@ -0,0 +1,55 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+ ignore_errors: yes
+
+- 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
+ iosxr_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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"
+
+- name: teardown
+ iosxr_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/backup.yaml"
diff --git a/test/integration/targets/iosxr_template/tests/cli/basic.yaml b/test/integration/targets/iosxr_template/tests/cli/basic.yaml
new file mode 100644
index 0000000000..6e3ac11fec
--- /dev/null
+++ b/test/integration/targets/iosxr_template/tests/cli/basic.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ iosxr_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ iosxr_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- name: teardown
+ iosxr_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/iosxr_template/tests/cli/force.yaml b/test/integration/targets/iosxr_template/tests/cli/force.yaml
new file mode 100644
index 0000000000..ccd373471e
--- /dev/null
+++ b/test/integration/targets/iosxr_template/tests/cli/force.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/force.yaml"
+
+- name: setup
+ iosxr_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ iosxr_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ iosxr_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: teardown
+ iosxr_config:
+ commands:
+ - no interface Loopback999
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/force.yaml"
diff --git a/test/integration/targets/junos_command/defaults/main.yaml b/test/integration/targets/junos_command/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/junos_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/junos_command/tasks/main.yaml b/test/integration/targets/junos_command/tasks/main.yaml
new file mode 100644
index 0000000000..9924bd301d
--- /dev/null
+++ b/test/integration/targets/junos_command/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: netconf_xml.yaml, tags: ['netconf', 'xml'] }
+- { include: netconf_text.yaml, tags: ['netconf', 'text'] }
+
diff --git a/test/integration/targets/junos_command/tasks/netconf_text.yaml b/test/integration/targets/junos_command/tasks/netconf_text.yaml
new file mode 100644
index 0000000000..3f123c1284
--- /dev/null
+++ b/test/integration/targets/junos_command/tasks/netconf_text.yaml
@@ -0,0 +1,17 @@
+---
+- name: collect netconf_text test cases with xml encoding
+ find:
+ paths: "{{ role_path }}/tests/netconf_text"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/junos_command/tasks/netconf_xml.yaml b/test/integration/targets/junos_command/tasks/netconf_xml.yaml
new file mode 100644
index 0000000000..93b6def35f
--- /dev/null
+++ b/test/integration/targets/junos_command/tasks/netconf_xml.yaml
@@ -0,0 +1,17 @@
+---
+- name: collect netconf_xml test cases with xml encoding
+ find:
+ paths: "{{ role_path }}/tests/netconf_xml"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml b/test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml
new file mode 100644
index 0000000000..91aac25edc
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml
@@ -0,0 +1,21 @@
+---
+- debug: msg="START netconf_text/bad_operator.yaml"
+
+- name: test bad operator with text encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[1].interface-information[0].physical-interface[0].name[0].data foo fxp0"
+ encoding: text
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_text/bad_operator.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_text/contains.yaml b/test/integration/targets/junos_command/tests/netconf_text/contains.yaml
new file mode 100644
index 0000000000..30a3d1fd18
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_text/contains.yaml
@@ -0,0 +1,22 @@
+---
+- debug: msg="START netconf_text/contains.yaml"
+
+- name: test contains operator with text encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ display: text
+ wait_for:
+ - "result[0] contains vsrx01"
+ - "result[1] contains fxp0"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_text/contains.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_text/invalid.yaml b/test/integration/targets/junos_command/tests/netconf_text/invalid.yaml
new file mode 100644
index 0000000000..cab272e9cc
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_text/invalid.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START netconf_text/invalid.yaml"
+
+- name: run invalid command
+ junos_command:
+ commands: show foo
+ display: text
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- name: run commands that include invalid command
+ junos_command:
+ commands:
+ - show version
+ - show foo
+ display: text
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_text/invalid.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_text/output.yaml b/test/integration/targets/junos_command/tests/netconf_text/output.yaml
new file mode 100644
index 0000000000..cf1308d86f
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_text/output.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START netconf_text/output.yaml"
+
+- name: get output for single command
+ junos_command:
+ commands: show version
+ display: text
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: get output for multiple commands
+ junos_command:
+ commands:
+ - show version
+ - show route
+ display: text
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_text/output.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_text/timeout.yaml b/test/integration/targets/junos_command/tests/netconf_text/timeout.yaml
new file mode 100644
index 0000000000..d72d5e5c06
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_text/timeout.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START netconf_text/timeout.yaml"
+
+- name: test bad condition
+ junos_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ display: text
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_text/timeout.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml b/test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml
new file mode 100644
index 0000000000..bc97b14d37
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml
@@ -0,0 +1,21 @@
+---
+- debug: msg="START netconf_xml/bad_operator.yaml"
+
+- name: test bad operator with xml encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[1].interface-information[0].physical-interface[0].name[0].data foo fxp0"
+ format: xml
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_xml/bad_operator.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/contains.yaml b/test/integration/targets/junos_command/tests/netconf_xml/contains.yaml
new file mode 100644
index 0000000000..fa79d8957d
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/contains.yaml
@@ -0,0 +1,22 @@
+---
+- debug: msg="START netconf_xml/contains.yaml"
+
+- name: test contains operator with xml encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[0].software-information.host-name contains vsrx01"
+ - "result[1].interface-information.physical-interface.name contains fxp0"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/contains.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml
new file mode 100644
index 0000000000..3240488cb3
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/equal.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START netconf_xml/equal.yaml"
+
+- name: test == operator with xml encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[0].software-information.host-name == vsrx01"
+ - "result[1].interface-information.physical-interface.name == fxp0"
+ format: xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test eq operator with json encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[0].software-information.host-name eq vsrx01"
+ - "result[1].interface-information.physical-interface.name eq fxp0"
+ format: xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/equal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml b/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml
new file mode 100644
index 0000000000..65c306429b
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_xml/greaterthan.yaml"
+
+- name: test gt operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu gt 1500"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test > operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu > 1500"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/greaterthan.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml
new file mode 100644
index 0000000000..d6a2ae7102
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_xml/greaterthanorequal.yaml"
+
+- name: test ge operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu ge 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test >= operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu >= 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/greaterthanorequal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml b/test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml
new file mode 100644
index 0000000000..3f541f2944
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/invalid.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START netconf_xml/invalid.yaml"
+
+- name: run invalid command
+ junos_command:
+ commands: ['show foo']
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+- debug: var=result
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- name: run commands that include invalid command
+ junos_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_xml/invalid.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml b/test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml
new file mode 100644
index 0000000000..f487c2b3ab
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_xml/lessthan.yaml"
+
+- name: test lt operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu lt 9000"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test < operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu lt 9000"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/lessthan.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml
new file mode 100644
index 0000000000..d3c571e90b
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_xml/lessthanorequal.yaml"
+
+- name: test le operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu le 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test <= operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[1].interface-information.physical-interface.mtu <= 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/lessthanorequal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml b/test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml
new file mode 100644
index 0000000000..191161d4a3
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/notequal.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_xml/notequal.yaml"
+
+- name: test neq operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[0].software-information.host-name neq localhost"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test != operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: xml
+ wait_for:
+ - "result[0].software-information.host-name != localhost"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/notequal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/output.yaml b/test/integration/targets/junos_command/tests/netconf_xml/output.yaml
new file mode 100644
index 0000000000..1043ff9f67
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/output.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START netconf_xml/output.yaml"
+
+- name: get output for single command
+ junos_command:
+ commands: ['show version']
+ format: xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: get output for multiple commands
+ junos_command:
+ commands:
+ - show version
+ - show route
+ format: xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_xml/output.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml b/test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml
new file mode 100644
index 0000000000..ff6b93275d
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_xml/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START netconf_xml/timeout.yaml"
+
+- name: test bad condition
+ junos_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_xml/timeout.yaml"
diff --git a/test/integration/targets/junos_config/defaults/main.yaml b/test/integration/targets/junos_config/defaults/main.yaml
new file mode 100644
index 0000000000..72860d74e5
--- /dev/null
+++ b/test/integration/targets/junos_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+
diff --git a/test/integration/targets/junos_config/tasks/main.yaml b/test/integration/targets/junos_config/tasks/main.yaml
new file mode 100644
index 0000000000..40d799545c
--- /dev/null
+++ b/test/integration/targets/junos_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: netconf.yaml, tags: ['netconf'] }
+
diff --git a/test/integration/targets/junos_config/tasks/netconf.yaml b/test/integration/targets/junos_config/tasks/netconf.yaml
new file mode 100644
index 0000000000..46debc247c
--- /dev/null
+++ b/test/integration/targets/junos_config/tasks/netconf.yaml
@@ -0,0 +1,17 @@
+---
+- name: collect netconf test cases
+ find:
+ paths: "{{ role_path }}/tests/netconf"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/junos_config/templates/basic/config.j2 b/test/integration/targets/junos_config/templates/basic/config.j2
new file mode 100644
index 0000000000..baa2d83833
--- /dev/null
+++ b/test/integration/targets/junos_config/templates/basic/config.j2
@@ -0,0 +1,10 @@
+interfaces {
+ lo0 {
+ unit 0 {
+ family inet {
+ address 1.1.1.1/32;
+ }
+ }
+ }
+}
+
diff --git a/test/integration/targets/junos_config/tests/netconf/backup.yaml b/test/integration/targets/junos_config/tests/netconf/backup.yaml
new file mode 100644
index 0000000000..58975df5d1
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/backup.yaml
@@ -0,0 +1,47 @@
+---
+- debug: msg="START netconf/backup.yaml"
+
+- name: setup
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- 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
+ junos_config:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ netconf }}"
+ 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 netconf/backup.yaml"
diff --git a/test/integration/targets/junos_config/tests/netconf/bad_action.yaml b/test/integration/targets/junos_config/tests/netconf/bad_action.yaml
new file mode 100644
index 0000000000..6c1e9ec975
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/bad_action.yaml
@@ -0,0 +1,16 @@
+---
+- debug: msg="START netconf/bad_action.yaml"
+
+- name: configure single bad_action command
+ junos_config:
+ lines:
+ - 'invalid system foo'
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- debug: msg="END netconf/bad_action.yaml"
diff --git a/test/integration/targets/junos_config/tests/netconf/invalid.yaml b/test/integration/targets/junos_config/tests/netconf/invalid.yaml
new file mode 100644
index 0000000000..d9b9d86593
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/invalid.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START netconf/invalid.yaml"
+
+- name: configure single invalid command
+ junos_config:
+ lines:
+ - 'set system foo'
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- name: configure multiple invalid command
+ junos_config:
+ lines:
+ - 'set system host-name {{ inventory_hostname }}'
+ - 'set system foo'
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- debug: msg="END netconf/invalid.yaml"
diff --git a/test/integration/targets/junos_config/tests/netconf/multiple.yaml b/test/integration/targets/junos_config/tests/netconf/multiple.yaml
new file mode 100644
index 0000000000..69e4592eba
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/multiple.yaml
@@ -0,0 +1,49 @@
+---
+- debug: msg="START netconf/multiple.yaml"
+
+- name: setup
+ junos_config:
+ lines:
+ - "set system host-name {{ inventory_hostname }}"
+ - "delete interfaces lo0"
+ provider: "{{ netconf }}"
+ register: test
+
+- name: configure multiple commands
+ junos_config:
+ lines:
+ - 'set system host-name {{ inventory_hostname }}'
+ - 'set interfaces lo0 unit 0 family inet address 1.1.1.1/32'
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ # Ensure host-name *hasn't* been updated
+ - "'host-name;' not in result.diff.prepared"
+ # Ensure interface has *been* updated
+ - "'address 1.1.1.1/32' in result.diff.prepared"
+
+- name: check multiple commands idempotent
+ junos_config:
+ lines:
+ - 'set system host-name {{ inventory_hostname }}'
+ - 'set interfaces lo0 unit 0 family inet address 1.1.1.1/32'
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.diff is not defined"
+
+- name: teardown
+ junos_config:
+ lines:
+ - "set system host-name {{ inventory_hostname }}"
+ - "delete interfaces lo0"
+ provider: "{{ netconf }}"
+ register: test
+
+- debug: msg="END netconf/multiple.yaml"
diff --git a/test/integration/targets/junos_config/tests/netconf/single.yaml b/test/integration/targets/junos_config/tests/netconf/single.yaml
new file mode 100644
index 0000000000..f0d78c71fa
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/single.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START netconf/single.yaml"
+
+# Ensure that when we change the hostname to `localhost` we cause a change
+- name: setup
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+
+- name: configure single command
+ junos_config:
+ lines:
+ - set system host-name localhost
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'+ host-name localhost;' in result.diff.prepared"
+
+- name: check single command idempotent
+ junos_config:
+ lines:
+ - set system host-name localhost
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+
+
+- debug: msg="END netconf/single.yaml"
diff --git a/test/integration/targets/junos_config/tests/netconf/src_basic.yaml b/test/integration/targets/junos_config/tests/netconf/src_basic.yaml
new file mode 100644
index 0000000000..4508abcf9a
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/src_basic.yaml
@@ -0,0 +1,35 @@
+---
+- debug: msg="START netconf/src_basic.yaml"
+
+- name: setup
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- name: configure device with config
+ junos_config:
+ src: basic/config.j2
+ provider: "{{ netconf }}"
+ 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
+ junos_config:
+ src: basic/config.j2
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- debug: msg="END netconf/src_basic.yaml"
diff --git a/test/integration/targets/junos_config/tests/netconf/src_invalid.yaml b/test/integration/targets/junos_config/tests/netconf/src_invalid.yaml
new file mode 100644
index 0000000000..6238acb474
--- /dev/null
+++ b/test/integration/targets/junos_config/tests/netconf/src_invalid.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START netconf/src_invalid.yaml"
+
+
+# Defend https://github.com/ansible/ansible-modules-core/issues/4797
+- name: configure with invalid src
+ junos_config:
+ src: basic/foobar.j2
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.failed == true"
+ - "result.msg == 'path specified in src not found'"
+
+- debug: msg="END netconf/src_invalid.yaml"
diff --git a/test/integration/targets/junos_netconf/defaults/main.yaml b/test/integration/targets/junos_netconf/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/junos_netconf/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/junos_netconf/tasks/cli.yaml b/test/integration/targets/junos_netconf/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/junos_netconf/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/junos_netconf/tasks/main.yaml b/test/integration/targets/junos_netconf/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/junos_netconf/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/junos_netconf/tests/cli/changeport.yaml b/test/integration/targets/junos_netconf/tests/cli/changeport.yaml
new file mode 100644
index 0000000000..a2fc25a27e
--- /dev/null
+++ b/test/integration/targets/junos_netconf/tests/cli/changeport.yaml
@@ -0,0 +1,68 @@
+---
+- debug: msg="START netconf/changeport.yaml"
+
+
+- name: Setup
+ junos_netconf:
+ state: present
+ provider: "{{ cli }}"
+ register: result
+
+
+###################################
+- name: Change port
+ junos_netconf:
+ state: present
+ netconf_port: 8080
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: idempotent tests
+ junos_netconf:
+ state: present
+ netconf_port: 8080
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: Ensure we can communicate over 8080
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+ port: 8080
+
+# This protects against the port override above not being honoured and a bug setting the port
+- name: Ensure we can NOT communicate over default port
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "'unable to connect to' in result.msg"
+
+- name: Set back netconf to default port
+ junos_netconf:
+ state: present
+ provider: "{{ cli }}"
+ register: result
+
+- name: Ensure we can communicate over netconf
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+
+- debug: msg="END netconf/changeport.yaml"
diff --git a/test/integration/targets/junos_netconf/tests/cli/netconf.yaml b/test/integration/targets/junos_netconf/tests/cli/netconf.yaml
new file mode 100644
index 0000000000..3e03eb74a2
--- /dev/null
+++ b/test/integration/targets/junos_netconf/tests/cli/netconf.yaml
@@ -0,0 +1,72 @@
+---
+- debug: msg="START netconf/netconf.yaml"
+
+
+- name: Ensure netconf is enabled
+ junos_netconf:
+ state: present
+ provider: "{{ cli }}"
+ register: result
+
+- name: idempotent tests
+ junos_netconf:
+ state: present
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+###################################
+
+- name: Ensure we can communicate over netconf
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+
+# Disable netconf
+
+- name: Disable netconf
+ junos_netconf:
+ state: absent
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: idempotent tests
+ junos_netconf:
+ state: absent
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+
+- name: Ensure we can NOT talk via netconf
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "'unable to connect to' in result.msg"
+
+- name: re-enable netconf
+ junos_netconf:
+ state: present
+ provider: "{{ cli }}"
+ register: result
+
+
+- debug: msg="END netconf/netconfg.yaml"
diff --git a/test/integration/targets/junos_template/defaults/main.yaml b/test/integration/targets/junos_template/defaults/main.yaml
new file mode 100644
index 0000000000..4f2a9a84ec
--- /dev/null
+++ b/test/integration/targets/junos_template/defaults/main.yaml
@@ -0,0 +1,4 @@
+---
+testcase: "*"
+test_cases: []
+
diff --git a/test/integration/targets/junos_template/tasks/main.yaml b/test/integration/targets/junos_template/tasks/main.yaml
new file mode 100644
index 0000000000..40d799545c
--- /dev/null
+++ b/test/integration/targets/junos_template/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: netconf.yaml, tags: ['netconf'] }
+
diff --git a/test/integration/targets/junos_template/tasks/netconf.yaml b/test/integration/targets/junos_template/tasks/netconf.yaml
new file mode 100644
index 0000000000..46debc247c
--- /dev/null
+++ b/test/integration/targets/junos_template/tasks/netconf.yaml
@@ -0,0 +1,17 @@
+---
+- name: collect netconf test cases
+ find:
+ paths: "{{ role_path }}/tests/netconf"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/junos_template/templates/basic/config.j2 b/test/integration/targets/junos_template/templates/basic/config.j2
new file mode 100644
index 0000000000..baa2d83833
--- /dev/null
+++ b/test/integration/targets/junos_template/templates/basic/config.j2
@@ -0,0 +1,10 @@
+interfaces {
+ lo0 {
+ unit 0 {
+ family inet {
+ address 1.1.1.1/32;
+ }
+ }
+ }
+}
+
diff --git a/test/integration/targets/junos_template/tests/netconf/backup.yaml b/test/integration/targets/junos_template/tests/netconf/backup.yaml
new file mode 100644
index 0000000000..85231660ed
--- /dev/null
+++ b/test/integration/targets/junos_template/tests/netconf/backup.yaml
@@ -0,0 +1,54 @@
+---
+- debug: msg="START netconf/backup.yaml"
+
+- name: setup
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- 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 using template with backup
+ junos_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'1.1.1.1/32' in result.diff.prepared"
+
+- 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"
+
+- name: teardown
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- debug: msg="END netconf/backup.yaml"
diff --git a/test/integration/targets/junos_template/tests/netconf/basic.yaml b/test/integration/targets/junos_template/tests/netconf/basic.yaml
new file mode 100644
index 0000000000..41320efb41
--- /dev/null
+++ b/test/integration/targets/junos_template/tests/netconf/basic.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START netconf/basic.yaml"
+
+- name: setup
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- name: configure basic config template
+ junos_template:
+ src: basic/config.j2
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'1.1.1.1/32' in result.diff.prepared"
+
+- name: check basic config template idempotent
+ junos_template:
+ src: basic/config.j2
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- debug: msg="END netconf/basic.yaml"
diff --git a/test/integration/targets/junos_template/tests/netconf/force.yaml b/test/integration/targets/junos_template/tests/netconf/force.yaml
new file mode 100644
index 0000000000..c65686481b
--- /dev/null
+++ b/test/integration/targets/junos_template/tests/netconf/force.yaml
@@ -0,0 +1,43 @@
+---
+- debug: msg="START netconf/force.yaml"
+
+- name: setup
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+
+- name: configure basic config template
+ junos_template:
+ src: basic/config.j2
+ provider: "{{ netconf }}"
+ action: replace
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'1.1.1.1/32' in result.diff.prepared"
+
+- name: check basic config template idempotent
+ junos_template:
+ src: basic/config.j2
+ action: replace
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'1.1.1.1/32' in result.diff.prepared"
+
+- name: teardown
+ junos_config:
+ lines:
+ - set system host-name {{ inventory_hostname }}
+ - delete interfaces lo0
+ action: replace
+ provider: "{{ netconf }}"
+
+- debug: msg="END netconf/force.yaml"
diff --git a/test/integration/targets/nxos_command/defaults/main.yaml b/test/integration/targets/nxos_command/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/nxos_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/nxos_command/meta/main.yml b/test/integration/targets/nxos_command/meta/main.yml
new file mode 100644
index 0000000000..ae741cbdc7
--- /dev/null
+++ b/test/integration/targets/nxos_command/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_command/tasks/cli.yaml b/test/integration/targets/nxos_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/nxos_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/nxos_command/tasks/main.yaml b/test/integration/targets/nxos_command/tasks/main.yaml
new file mode 100644
index 0000000000..c4f8226584
--- /dev/null
+++ b/test/integration/targets/nxos_command/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: nxapi.yaml, tags: ['nxapi'] }
+
+
diff --git a/test/integration/targets/nxos_command/tasks/nxapi.yaml b/test/integration/targets/nxos_command/tasks/nxapi.yaml
new file mode 100644
index 0000000000..1f5dc70f2d
--- /dev/null
+++ b/test/integration/targets/nxos_command/tasks/nxapi.yaml
@@ -0,0 +1,30 @@
+---
+- name: collect all nxapi test cases
+ find:
+ paths: "{{ role_path }}/tests/nxapi"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: enable nxapi
+ nxos_config:
+ lines:
+ - feature nxapi
+ - nxapi http port 80
+ provider: "{{ cli }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+- name: disable nxapi
+ nxos_config:
+ lines:
+ - no feature nxapi
+ provider: "{{ cli }}"
+
+
diff --git a/test/integration/targets/nxos_command/tests/cli/bad_operator.yaml b/test/integration/targets/nxos_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..17996efe2e
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state foo up"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/contains.yaml b/test/integration/targets/nxos_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..f5ada4e66d
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/contains.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[0] contains NX-OS"
+ - "result[1].TABLE_interface.ROW_interface.interface contains mgmt"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/equal.yaml b/test/integration/targets/nxos_command/tests/cli/equal.yaml
new file mode 100644
index 0000000000..fe80f8f049
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/equal.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/equal.yaml"
+
+- name: test eq operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state eq up"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: test == operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state == up"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/equal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/greaterthan.yaml b/test/integration/targets/nxos_command/tests/cli/greaterthan.yaml
new file mode 100644
index 0000000000..9ba3635fb3
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/greaterthan.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/greaterthan.yaml"
+
+- name: test gt operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask gt 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: test > operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask > 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/greaterthan.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/greaterthanorequal.yaml b/test/integration/targets/nxos_command/tests/cli/greaterthanorequal.yaml
new file mode 100644
index 0000000000..d8db151e37
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/greaterthanorequal.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/greaterthanorequal.yaml"
+
+- name: test ge operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask ge 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: test >= operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask >= 0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/greaterthanorequal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/invalid.yaml b/test/integration/targets/nxos_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..6f5fb5a3ab
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ nxos_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- name: run commands that include invalid command
+ nxos_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/lessthan.yaml b/test/integration/targets/nxos_command/tests/cli/lessthan.yaml
new file mode 100644
index 0000000000..abf09324e8
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/lessthan.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/lessthan.yaml"
+
+- name: test lt operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask lt 33"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: test < operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask lt 33"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/lessthan.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/lessthanorequal.yaml b/test/integration/targets/nxos_command/tests/cli/lessthanorequal.yaml
new file mode 100644
index 0000000000..2576fc11bd
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/lessthanorequal.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/lesstahnorequal.yaml"
+
+- name: test le operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask le 32"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: test <= operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask <= 32"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/lesstahnorequal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/negative.yaml b/test/integration/targets/nxos_command/tests/cli/negative.yaml
new file mode 100644
index 0000000000..2d37457745
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/negative.yaml
@@ -0,0 +1,27 @@
+---
+- debug: msg="START cli/negative.yaml"
+
+- name: run 11 commands
+ nxos_command:
+ commands:
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ provier: "{{ cli }}"
+ ignore_errors: yes
+ register: result
+
+- assert:
+ that:
+ - result.failed
+
+
+- debug: msg="END cli/negative.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/notequal.yaml b/test/integration/targets/nxos_command/tests/cli/notequal.yaml
new file mode 100644
index 0000000000..52e3b2e61e
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/notequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START cli/notequal.yaml"
+
+- name: test neq operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state neq down"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test != operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0 | json
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state != down"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/notequal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/output.yaml b/test/integration/targets/nxos_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..9b5cae64da
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/output.yaml
@@ -0,0 +1,26 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ nxos_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: get output for multiple commands
+ nxos_command:
+ commands:
+ - show version
+ - show interface
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/nxos_command/tests/cli/timeout.yaml b/test/integration/targets/nxos_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..0b2d9f00db
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ nxos_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/bad_operator.yaml b/test/integration/targets/nxos_command/tests/nxapi/bad_operator.yaml
new file mode 100644
index 0000000000..5d6ba8e907
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START nxapi/bad_operator.yaml"
+
+- name: test bad operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state foo up"
+ provider: "{{ nxapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END nxapi/bad_operator.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/contains.yaml b/test/integration/targets/nxos_command/tests/nxapi/contains.yaml
new file mode 100644
index 0000000000..3f3bdccc36
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START nxapi/contains.yaml"
+
+- name: test contains operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[0].header_str contains NX-OS"
+ - "result[1].TABLE_interface.ROW_interface.interface contains mgmt"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/contains.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/equal.yaml b/test/integration/targets/nxos_command/tests/nxapi/equal.yaml
new file mode 100644
index 0000000000..50ea63d1ad
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/equal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START nxapi/equal.yaml"
+
+- name: test eq operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state eq up"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test == operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state == up"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/equal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/greaterthan.yaml b/test/integration/targets/nxos_command/tests/nxapi/greaterthan.yaml
new file mode 100644
index 0000000000..f4fdc6797d
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/greaterthan.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START nxapi/greaterthan.yaml"
+
+- name: test gt operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask gt 0"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test > operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask gt 0"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/greaterthan.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/greaterthanorequal.yaml b/test/integration/targets/nxos_command/tests/nxapi/greaterthanorequal.yaml
new file mode 100644
index 0000000000..e8e22c3644
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/greaterthanorequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START nxapi/greaterthanorequal.yaml"
+
+- name: test ge operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask ge 0"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test >= operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask >= 0"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/greaterthanorequal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/invalid.yaml b/test/integration/targets/nxos_command/tests/nxapi/invalid.yaml
new file mode 100644
index 0000000000..93cd31a5fd
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/invalid.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START nxapi/invalid.yaml"
+
+- name: run invalid command
+ nxos_command:
+ commands: ['show foo']
+ provider: "{{ nxapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- name: run commands that include invalid command
+ nxos_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ nxapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END nxapi/invalid.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/lessthan.yaml b/test/integration/targets/nxos_command/tests/nxapi/lessthan.yaml
new file mode 100644
index 0000000000..724c3d1fc5
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/lessthan.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START nxapi/lessthan.yaml"
+
+- name: test lt operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask lt 33"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test < operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask lt 33"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/lessthan.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/lessthanorequal.yaml b/test/integration/targets/nxos_command/tests/nxapi/lessthanorequal.yaml
new file mode 100644
index 0000000000..7b9efb85b9
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/lessthanorequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START nxapi/lessthanorequal.yaml"
+
+- name: test le operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask le 32"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test <= operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.eth_ip_mask <= 32"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/lessthanorequal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/negative.yaml b/test/integration/targets/nxos_command/tests/nxapi/negative.yaml
new file mode 100644
index 0000000000..3763f958e6
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/negative.yaml
@@ -0,0 +1,27 @@
+---
+- debug: msg="START nxapi/negative.yaml"
+
+- name: run 11 commands
+ nxos_command:
+ commands:
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ - show version
+ provier: "{{ nxapi }}"
+ ignore_errors: yes
+ register: result
+
+- assert:
+ that:
+ - result.failed
+
+
+- debug: msg="END nxapi/negative.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/notequal.yaml b/test/integration/targets/nxos_command/tests/nxapi/notequal.yaml
new file mode 100644
index 0000000000..768e64a2f2
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/notequal.yaml
@@ -0,0 +1,34 @@
+---
+- debug: msg="START nxapi/notequal.yaml"
+
+- name: test neq operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state neq down"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: test != operator
+ nxos_command:
+ commands:
+ - show version
+ - show interface mgmt0
+ wait_for:
+ - "result[1].TABLE_interface.ROW_interface.state != down"
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="START nxapi/notequal.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/output.yaml b/test/integration/targets/nxos_command/tests/nxapi/output.yaml
new file mode 100644
index 0000000000..9eae4e515d
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/output.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START nxapi/output.yaml"
+
+- name: get output for single command
+ nxos_command:
+ commands: ['show version']
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ nxos_command:
+ commands:
+ - show version
+ - show interface
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END nxapi/output.yaml"
diff --git a/test/integration/targets/nxos_command/tests/nxapi/timeout.yaml b/test/integration/targets/nxos_command/tests/nxapi/timeout.yaml
new file mode 100644
index 0000000000..2ad1763ddf
--- /dev/null
+++ b/test/integration/targets/nxos_command/tests/nxapi/timeout.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START nxapi/timeout.yaml"
+
+- name: test bad condition
+ nxos_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0].header_str contains foo"
+ retries: 1
+ provider: "{{ nxapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END nxapi/timeout.yaml"
diff --git a/test/integration/targets/nxos_config/defaults/main.yaml b/test/integration/targets/nxos_config/defaults/main.yaml
new file mode 100644
index 0000000000..2a4e223ff0
--- /dev/null
+++ b/test/integration/targets/nxos_config/defaults/main.yaml
@@ -0,0 +1,4 @@
+---
+testcase: "*"
+test_items: []
+
diff --git a/test/integration/targets/nxos_config/meta/main.yml b/test/integration/targets/nxos_config/meta/main.yml
new file mode 100644
index 0000000000..ae741cbdc7
--- /dev/null
+++ b/test/integration/targets/nxos_config/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_config/tasks/cli.yaml b/test/integration/targets/nxos_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/nxos_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/nxos_config/tasks/main.yaml b/test/integration/targets/nxos_config/tasks/main.yaml
new file mode 100644
index 0000000000..a2f4b2415a
--- /dev/null
+++ b/test/integration/targets/nxos_config/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: nxapi.yaml, tags: ['nxapi'] }
+
diff --git a/test/integration/targets/nxos_config/tasks/nxapi.yaml b/test/integration/targets/nxos_config/tasks/nxapi.yaml
new file mode 100644
index 0000000000..1f5dc70f2d
--- /dev/null
+++ b/test/integration/targets/nxos_config/tasks/nxapi.yaml
@@ -0,0 +1,30 @@
+---
+- name: collect all nxapi test cases
+ find:
+ paths: "{{ role_path }}/tests/nxapi"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: enable nxapi
+ nxos_config:
+ lines:
+ - feature nxapi
+ - nxapi http port 80
+ provider: "{{ cli }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+- name: disable nxapi
+ nxos_config:
+ lines:
+ - no feature nxapi
+ provider: "{{ cli }}"
+
+
diff --git a/test/integration/targets/nxos_config/templates/basic/config.j2 b/test/integration/targets/nxos_config/templates/basic/config.j2
new file mode 100644
index 0000000000..9705ee1494
--- /dev/null
+++ b/test/integration/targets/nxos_config/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/nxos_config/templates/config.js b/test/integration/targets/nxos_config/templates/config.js
new file mode 100644
index 0000000000..d2ec0c0c71
--- /dev/null
+++ b/test/integration/targets/nxos_config/templates/config.js
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description test description from ansible
+ shutdown
+
diff --git a/test/integration/targets/nxos_config/templates/defaults/config.j2 b/test/integration/targets/nxos_config/templates/defaults/config.j2
new file mode 100644
index 0000000000..df0cac701c
--- /dev/null
+++ b/test/integration/targets/nxos_config/templates/defaults/config.j2
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description this is a test
+ no shutdown
+
diff --git a/test/integration/targets/nxos_config/templates/defaults/test.j2 b/test/integration/targets/nxos_config/templates/defaults/test.j2
new file mode 100644
index 0000000000..9705ee1494
--- /dev/null
+++ b/test/integration/targets/nxos_config/templates/defaults/test.j2
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/nxos_config/tests/cli/backup.yaml b/test/integration/targets/nxos_config/tests/cli/backup.yaml
new file mode 100644
index 0000000000..e3f9e14d17
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ 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
+ nxos_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/nxos_config/tests/cli/defaults.yaml b/test/integration/targets/nxos_config/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..59f2c5f76d
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/defaults.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with defaults included
+ nxos_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
+ nxos_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/nxos_config/tests/cli/multilevel.yaml b/test/integration/targets/nxos_config/tests/cli/multilevel.yaml
new file mode 100644
index 0000000000..648df5064c
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/multilevel.yaml
@@ -0,0 +1,58 @@
+---
+- debug: msg="START cli/mulitlevel.yaml"
+
+- name: get config
+ nxos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ register: config
+
+- name: enable feature bgp
+ nxos_config:
+ lines: feature bgp
+ provider: "{{ cli }}"
+ when: "'feature bgp' not in config.stdout[0]"
+
+- name: remove bgp
+ nxos_config:
+ lines: no router bgp 1
+ provider: "{{ cli }}"
+ when: "'router bgp 1' in config.stdout[0]"
+
+- name: configure multi level command
+ nxos_config:
+ lines: maximum-paths 14
+ parents:
+ - router bgp 1
+ - address-family ipv4 unicast
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'router bgp 1' in result.updates"
+ - "'address-family ipv4 unicast' in result.updates"
+ - "'maximum-paths 14' in result.updates"
+
+- name: check multi level command
+ nxos_config:
+ lines: maximum-paths 14
+ parents:
+ - router bgp 1
+ - address-family ipv4 unicast
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines:
+ - no feature bgp
+ match: none
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/mulitlevel.yaml"
diff --git a/test/integration/targets/nxos_config/tests/cli/save.yaml b/test/integration/targets/nxos_config/tests/cli/save.yaml
new file mode 100644
index 0000000000..4c87a822fa
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/save.yaml
@@ -0,0 +1,35 @@
+---
+- debug: msg="START cli/save.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+
+- name: save config
+ nxos_config:
+ save: true
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: save should always run
+ nxos_config:
+ save: true
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- debug: msg="END cli/save.yaml"
diff --git a/test/integration/targets/nxos_config/tests/cli/src_basic.yaml b/test/integration/targets/nxos_config/tests/cli/src_basic.yaml
new file mode 100644
index 0000000000..814f560af9
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/src_basic.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/src_basic.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ nxos_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
+ nxos_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/nxos_config/tests/cli/src_invalid.yaml b/test/integration/targets/nxos_config/tests/cli/src_invalid.yaml
new file mode 100644
index 0000000000..32931f8ab1
--- /dev/null
+++ b/test/integration/targets/nxos_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
+ nxos_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/nxos_config/tests/cli/src_match_none.yaml b/test/integration/targets/nxos_config/tests/cli/src_match_none.yaml
new file mode 100644
index 0000000000..0c9773d0d8
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/src_match_none.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START cli/src_match_none.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ nxos_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+# Defend https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- name: check device with config
+ nxos_config:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ # Idempotent test
+# Defend 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/nxos_config/tests/cli/sublevel.yaml b/test/integration/targets/nxos_config/tests/cli/sublevel.yaml
new file mode 100644
index 0000000000..ce017097d7
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/sublevel.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg='START cli/sublevel.yaml'
+
+- name: setup
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command
+ nxos_config:
+ lines: 10 permit ip any any log
+ parents: ip access-list test
+ provider: "{{ cli }}"
+ register: result
+
+- 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
+ nxos_config:
+ lines: 10 permit ip any any log
+ parents: ip access-list test
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/sublevel.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/sublevel_block.yaml b/test/integration/targets/nxos_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 0000000000..fc53543da3
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,57 @@
+---
+- debug: msg='START cli/sublevel_block.yaml'
+
+- name: setup
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ parents: ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using block resplace
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ replace: block
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip 1.1.1.1/32 any log' in result.updates"
+ - "'20 permit ip 2.2.2.2/32 any log' in result.updates"
+ - "'30 permit ip 3.3.3.3/32 any log' in result.updates"
+ - "'40 permit ip 4.4.4.4/32 any log' in result.updates"
+
+- name: check sub level command using block replace
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ replace: block
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/sublevel_block.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/sublevel_exact.yaml b/test/integration/targets/nxos_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 0000000000..29e517dbe9
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,62 @@
+---
+- debug: msg='START cli/sublevel_exact.yaml'
+
+- name: setup
+ nxos_config:
+ commands:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ - 50 permit ip 5.5.5.5/32 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using exact match
+ nxos_config:
+ commands:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip 1.1.1.1/32 any log' in result.updates"
+ - "'20 permit ip 2.2.2.2/32 any log' in result.updates"
+ - "'30 permit ip 3.3.3.3/32 any log' in result.updates"
+ - "'40 permit ip 4.4.4.4/32 any log' in result.updates"
+ - "'50 permit ip 5.5.5.5/32 any log' not in result.updates"
+
+- name: check sub level command using exact match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ - 50 permit ip 5.5.5.5/32 any log
+ parents: ip access-list test
+ match: exact
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/sublevel_exact.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/sublevel_strict.yaml b/test/integration/targets/nxos_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 0000000000..a14413d6e8
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,63 @@
+---
+- debug: msg='START cli/sublevel_strict.yaml'
+
+- name: setup
+ nxos_config:
+ commands:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ - 50 permit ip 5.5.5.5/32 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure sub level command using strict match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ match: strict
+ replace: block
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip 1.1.1.1/32 any log' in result.updates"
+ - "'20 permit ip 2.2.2.2/32 any log' in result.updates"
+ - "'30 permit ip 3.3.3.3/32 any log' in result.updates"
+ - "'40 permit ip 4.4.4.4/32 any log' in result.updates"
+ - "'50 permit ip 5.5.5.5/32 any log' not in result.updates"
+
+- name: check sub level command using strict match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ match: strict
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ commands: no ip access-list test
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/sublevel_strict.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/toplevel.yaml b/test/integration/targets/nxos_config/tests/cli/toplevel.yaml
new file mode 100644
index 0000000000..f66e41e68d
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg='START cli/toplevel.yaml'
+
+- name: setup
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ nxos_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
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/toplevel.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/toplevel_after.yaml b/test/integration/targets/nxos_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 0000000000..d8e5dc549a
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg='START cli/toplevel_after.yaml'
+
+- name: setup
+ nxos_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ nxos_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
+ nxos_config:
+ lines: hostname foo
+ after: snmp-server contact foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/toplevel_after.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/toplevel_before.yaml b/test/integration/targets/nxos_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 0000000000..ef64b7ce9d
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg='START cli/toplevel_before.yaml'
+
+- name: setup
+ nxos_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command with before
+ nxos_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
+ nxos_config:
+ lines: hostname foo
+ before: snmp-server contact foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines:
+ - "no snmp-server contact"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg='END cli/toplevel_before.yaml'
diff --git a/test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml b/test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..049eac7b6c
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/nonidempotent.yaml"
+
+- name: setup
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure top level command
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ cli }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: teardown
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/nonidempotent.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/backup.yaml b/test/integration/targets/nxos_config/tests/nxapi/backup.yaml
new file mode 100644
index 0000000000..9b063d0238
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START nxapi/backup.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- 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
+ nxos_config:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ nxapi }}"
+ 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 nxapi/backup.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/defaults.yaml b/test/integration/targets/nxos_config/tests/nxapi/defaults.yaml
new file mode 100644
index 0000000000..39c53846b3
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START nxapi/defaults.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- name: configure device with defaults included
+ nxos_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ nxapi }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is not defined"
+
+- name: check device with defaults included
+ nxos_config:
+ src: defaults/config.j2
+ defaults: yes
+ provider: "{{ nxapi }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is not defined"
+
+- debug: msg="END nxapi/defaults.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/multilevel.yaml b/test/integration/targets/nxos_config/tests/nxapi/multilevel.yaml
new file mode 100644
index 0000000000..f1524fa76a
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/multilevel.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START nxapi/mulitlevel.yaml"
+
+- name: setup
+ nxos_config:
+ lines: feature bgp
+ provider: "{{ nxapi }}"
+
+- name: configure multi level command
+ nxos_config:
+ lines: maximum-paths 14
+ parents:
+ - router bgp 1
+ - address-family ipv4 unicast
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'router bgp 1' in result.updates"
+ - "'address-family ipv4 unicast' in result.updates"
+ - "'maximum-paths 14' in result.updates"
+
+- name: test multi level command
+ nxos_config:
+ lines: maximum-paths 14
+ parents:
+ - router bgp 1
+ - address-family ipv4 unicast
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no feature bgp
+ match: none
+ provider: "{{ nxapi }}"
+
+- debug: msg="END nxapi/mulitlevel.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/save.yaml b/test/integration/targets/nxos_config/tests/nxapi/save.yaml
new file mode 100644
index 0000000000..bd14176b05
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/save.yaml
@@ -0,0 +1,35 @@
+---
+- debug: msg="START nxapi/save.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+
+- name: save config
+ nxos_config:
+ save: true
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: save should always run
+ nxos_config:
+ save: true
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- debug: msg="END nxapi/save.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml b/test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml
new file mode 100644
index 0000000000..d76e01107f
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/src_basic.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START nxapi/src_basic.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- name: configure device with config
+ nxos_config:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ 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
+ nxos_config:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+# https://github.com/ansible/ansible-modules-core/issues/4807
+ - "result.updates is not defined"
+
+- debug: msg="END nxapi/src_basic.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml b/test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml
new file mode 100644
index 0000000000..e670e4ef5b
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/src_invalid.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START nxapi/src_invalid.yaml"
+
+
+# Defend https://github.com/ansible/ansible-modules-core/issues/4797
+- name: configure with invalid src
+ nxos_config:
+ src: basic/foobar.j2
+ provider: "{{ nxapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.failed == true"
+ - "result.msg == 'path specified in src not found'"
+
+- debug: msg="END nxapi/src_invalid.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/src_match_none.yaml b/test/integration/targets/nxos_config/tests/nxapi/src_match_none.yaml
new file mode 100644
index 0000000000..a0855ff270
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/src_match_none.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START nxapi/src_match_none.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- name: configure device with config
+ nxos_config:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ 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
+ nxos_config:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ 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 nxapi/src_match_none.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/sublevel.yaml b/test/integration/targets/nxos_config/tests/nxapi/sublevel.yaml
new file mode 100644
index 0000000000..ceba5d36a9
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/sublevel.yaml
@@ -0,0 +1,41 @@
+---
+- debug: msg="START nxapi/sublevel.yaml"
+
+- name: setup
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+ ignore_errors: yes
+
+- name: configure sub level command
+ nxos_config:
+ lines: 10 permit ip any any log
+ parents: ip access-list test
+ provider: "{{ nxapi }}"
+ register: result
+
+- 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
+ nxos_config:
+ lines: 10 permit ip any any log
+ parents: ip access-list test
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/sublevel.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/sublevel_block.yaml b/test/integration/targets/nxos_config/tests/nxapi/sublevel_block.yaml
new file mode 100644
index 0000000000..b247c38712
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/sublevel_block.yaml
@@ -0,0 +1,59 @@
+---
+- debug: msg="START nxapi/sublevel_block.yaml"
+
+- name: setup
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+ ignore_errors: yes
+
+- name: configure sub level command using block resplace
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ replace: block
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip 1.1.1.1/32 any log' in result.updates"
+ - "'20 permit ip 2.2.2.2/32 any log' in result.updates"
+ - "'30 permit ip 3.3.3.3/32 any log' in result.updates"
+ - "'40 permit ip 4.4.4.4/32 any log' in result.updates"
+
+- name: check sub level command using block replace
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ replace: block
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/sublevel_block.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/sublevel_exact.yaml b/test/integration/targets/nxos_config/tests/nxapi/sublevel_exact.yaml
new file mode 100644
index 0000000000..3dd89dac1d
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/sublevel_exact.yaml
@@ -0,0 +1,63 @@
+---
+- debug: msg="START nxapi/sublevel_exact.yaml"
+
+- name: setup
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ - 50 permit ip 5.5.5.5/32 any log
+ parents: ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+ ignore_errors: yes
+
+- name: configure sub level command using exact match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ match: exact
+ replace: block
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip 1.1.1.1/32 any log' in result.updates"
+ - "'20 permit ip 2.2.2.2/32 any log' in result.updates"
+ - "'30 permit ip 3.3.3.3/32 any log' in result.updates"
+ - "'40 permit ip 4.4.4.4/32 any log' in result.updates"
+ - "'50 permit ip 5.5.5.5/32 any log' not in result.updates"
+
+- name: check sub level command using exact match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ match: exact
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/sublevel_exact.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/sublevel_strict.yaml b/test/integration/targets/nxos_config/tests/nxapi/sublevel_strict.yaml
new file mode 100644
index 0000000000..8fb56c0398
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/sublevel_strict.yaml
@@ -0,0 +1,62 @@
+---
+- debug: msg="START nxapi/sublevel_strict.yaml"
+
+- name: setup
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 2.2.2.2/32 any log
+ - 30 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ - 50 permit ip 5.5.5.5/32 any log
+ parents: ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+
+- name: configure sub level command using strict match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 30 permit ip 2.2.2.2/32 any log
+ - 20 permit ip 3.3.3.3/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ before: no ip access-list test
+ match: strict
+ replace: block
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list test' in result.updates"
+ - "'10 permit ip 1.1.1.1/32 any log' in result.updates"
+ - "'30 permit ip 2.2.2.2/32 any log' in result.updates"
+ - "'20 permit ip 3.3.3.3/32 any log' in result.updates"
+ - "'40 permit ip 4.4.4.4/32 any log' in result.updates"
+ - "'50 permit ip 5.5.5.5/32 any log' not in result.updates"
+
+- name: check sub level command using strict match
+ nxos_config:
+ lines:
+ - 10 permit ip 1.1.1.1/32 any log
+ - 20 permit ip 3.3.3.3/32 any log
+ - 30 permit ip 2.2.2.2/32 any log
+ - 40 permit ip 4.4.4.4/32 any log
+ parents: ip access-list test
+ match: strict
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: no ip access-list test
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/sublevel_strict.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml b/test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml
new file mode 100644
index 0000000000..7485f61c3b
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START nxapi/toplevel.yaml"
+
+- name: setup
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ nxapi }}"
+ match: none
+
+- name: configure top level command
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/toplevel.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/toplevel_after.yaml b/test/integration/targets/nxos_config/tests/nxapi/toplevel_after.yaml
new file mode 100644
index 0000000000..05b251edc1
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START nxapi/toplevel_after.yaml"
+
+- name: setup
+ nxos_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ nxapi }}"
+ match: none
+
+- name: configure top level command with before
+ nxos_config:
+ lines: hostname foo
+ after: snmp-server contact bar
+ provider: "{{ nxapi }}"
+ 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
+ nxos_config:
+ lines: hostname foo
+ after: snmp-server contact foo
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines:
+ - "no snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/toplevel_after.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/toplevel_before.yaml b/test/integration/targets/nxos_config/tests/nxapi/toplevel_before.yaml
new file mode 100644
index 0000000000..7f2ff373bf
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START nxapi/toplevel_before.yaml"
+
+- name: setup
+ nxos_config:
+ lines:
+ - "snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ nxapi }}"
+ match: none
+
+- name: configure top level command with before
+ nxos_config:
+ lines: hostname foo
+ before: snmp-server contact bar
+ provider: "{{ nxapi }}"
+ 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
+ nxos_config:
+ lines: hostname foo
+ before: snmp-server contact foo
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ nxos_config:
+ lines:
+ - "no snmp-server contact ansible"
+ - "hostname {{ inventory_hostname }}"
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/toplevel_before.yaml"
diff --git a/test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml b/test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml
new file mode 100644
index 0000000000..52089616df
--- /dev/null
+++ b/test/integration/targets/nxos_config/tests/nxapi/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START nxapi/toplevel_nonidempontent"
+
+- name: setup
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ nxapi }}"
+ match: none
+
+- name: configure top level command
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ nxapi }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'hostname foo' in result.updates"
+
+- name: configure top level command idempotent check
+ nxos_config:
+ lines: hostname foo
+ provider: "{{ nxapi }}"
+ match: strict
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: setup
+ nxos_config:
+ lines: hostname {{ inventory_hostname }}
+ provider: "{{ nxapi }}"
+ match: none
+
+- debug: msg="END nxapi/toplevel_nonidempontent"
diff --git a/test/integration/targets/nxos_facts/defaults/main.yaml b/test/integration/targets/nxos_facts/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/nxos_facts/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/nxos_facts/meta/main.yml b/test/integration/targets/nxos_facts/meta/main.yml
new file mode 100644
index 0000000000..ae741cbdc7
--- /dev/null
+++ b/test/integration/targets/nxos_facts/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_facts/tasks/cli.yaml b/test/integration/targets/nxos_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/nxos_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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/nxos_facts/tasks/main.yaml b/test/integration/targets/nxos_facts/tasks/main.yaml
new file mode 100644
index 0000000000..a2f4b2415a
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: nxapi.yaml, tags: ['nxapi'] }
+
diff --git a/test/integration/targets/nxos_facts/tasks/nxapi.yaml b/test/integration/targets/nxos_facts/tasks/nxapi.yaml
new file mode 100644
index 0000000000..2dc93a0769
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tasks/nxapi.yaml
@@ -0,0 +1,17 @@
+---
+- name: collect all nxapi test cases
+ find:
+ paths: "{{ role_path }}/tests/nxapi"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml b/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml
new file mode 100644
index 0000000000..5595f61d18
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/cli/all_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/all_facts.yaml"
+
+
+- name: test getting all facts
+ nxos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # Check that these facts not only are present, but are valid (positive integers)
+ - "result.ansible_facts.ansible_net_memfree_mb > 1"
+ - "result.ansible_facts.ansible_net_memtotal_mb > 1"
+
+- debug: msg="END cli/all_facts.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml b/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml
new file mode 100644
index 0000000000..111b779932
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/cli/default_facts.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START cli/default_facts.yaml"
+
+
+- name: test getting default facts
+ nxos_facts:
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" #hw
+ - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
+ # FIXME
+# - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END cli/default.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml b/test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml
new file mode 100644
index 0000000000..baf183eec3
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/cli/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START cli/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ nxos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ nxos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END cli/invalid_subset.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml b/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml
new file mode 100644
index 0000000000..11a7af1c61
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/cli/not_hardware.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ nxos_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ # FIXME
+ # - "result.ansible_facts.ansible_net_interfaces.['Ethernet2/15'].mtu > 1" # interfaces
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END cli/not_hardware_facts.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml b/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml
new file mode 100644
index 0000000000..45a8eba10e
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/nxapi/all_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START nxapi/all_facts.yaml"
+
+
+- name: test getting all facts
+ nxos_facts:
+ provider: "{{ nxapi }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # Check that these facts not only are present, but are valid (positive integers)
+ - "result.ansible_facts.ansible_net_memfree_mb > 1"
+ - "result.ansible_facts.ansible_net_memtotal_mb > 1"
+
+- debug: msg="END nxapi/all_facts.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml b/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml
new file mode 100644
index 0000000000..857f53ea8c
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/nxapi/default_facts.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START nxapi/default_facts.yaml"
+
+
+- name: test getting default facts
+ nxos_facts:
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" #hw
+ - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
+ # FIXME
+# - "result.ansible_facts.ansible_net_interfaces.Ethernet1.ipv4.masklen > 1" # interfaces
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END nxapi/default.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml b/test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml
new file mode 100644
index 0000000000..6b108c3dbf
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/nxapi/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START nxapi/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ nxos_facts:
+ provider: "{{ nxapi }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ nxos_facts:
+ provider: "{{ nxapi }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END nxapi/invalid_subset.yaml"
diff --git a/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml b/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml
new file mode 100644
index 0000000000..0daf6bc25a
--- /dev/null
+++ b/test/integration/targets/nxos_facts/tests/nxapi/not_hardware.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START nxapi/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ nxos_facts:
+ provider: "{{ nxapi }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'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"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ # FIXME
+ # - "result.ansible_facts.ansible_net_interfaces.['Ethernet2/15'].mtu > 1" # interfaces
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END nxapi/not_hardware_facts.yaml"
diff --git a/test/integration/targets/nxos_nxapi/defaults/main.yaml b/test/integration/targets/nxos_nxapi/defaults/main.yaml
new file mode 100644
index 0000000000..72860d74e5
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+
diff --git a/test/integration/targets/nxos_nxapi/meta/main.yml b/test/integration/targets/nxos_nxapi/meta/main.yml
new file mode 100644
index 0000000000..ae741cbdc7
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_nxapi/tasks/cli.yaml b/test/integration/targets/nxos_nxapi/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/nxos_nxapi/tasks/main.yaml b/test/integration/targets/nxos_nxapi/tasks/main.yaml
new file mode 100644
index 0000000000..97b1cee1ea
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
+
diff --git a/test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml b/test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml
new file mode 100644
index 0000000000..a56ac9ad90
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tests/cli/badtransport.yaml
@@ -0,0 +1,17 @@
+---
+- debug: msg="START cli/badtransport.yaml"
+
+- name: Sending transport other than cli should fail
+ nxos_nxapi:
+ enable_http: no
+ enable_sandbox: no
+ https_port: 9443
+ provider: "{{ nxapi }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - result.failed and result.msg | search('transport')
+
+- debug: msg="END cli/badtransport.yaml"
diff --git a/test/integration/targets/nxos_nxapi/tests/cli/config.yaml b/test/integration/targets/nxos_nxapi/tests/cli/config.yaml
new file mode 100644
index 0000000000..6dd9f9d1ca
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tests/cli/config.yaml
@@ -0,0 +1,87 @@
+- debug: msg="START cli/config.yaml"
+
+
+#----
+- name: Setup
+ nxos_config:
+ lines: no feature nxapi
+ match: none
+ provider: "{{ cli }}"
+ connection: local
+
+- name: Get running-config
+ nxos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+- name: Set config
+ nxos_nxapi:
+ config: "{{ config.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+# Triggers the following changes:
+# "updates": [
+# "feature nxapi",
+# "nxapi http port 80",
+# "no nxapi https",
+# "no nxapi sandbox"
+# ],
+
+- name: Ensure that this triggered a change
+ assert:
+ that:
+ - "config.changed == true"
+
+#---
+- name: Get running-config again
+ nxos_command:
+ commands: show running-config
+ provider: "{{ cli }}"
+ register: runningconfig
+ connection: local
+
+- name: Set config
+ nxos_nxapi:
+ config: "{{ runningconfig.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+# BUG: The above shouldn't trigger the following updates
+# Triggers the following changes:
+# "updates": [
+# "nxapi http port 80",
+# "no nxapi https",
+# "no nxapi sandbox"
+# ],
+
+
+
+# DEBUG: Try another time
+- name: Set config - FIXME, shouldn't need this
+ nxos_nxapi:
+ config: "{{ runningconfig.stdout[0] }}"
+ provider: "{{ cli }}"
+ register: config
+ connection: local
+
+# BUG: We are still getting changes
+# Triggers the following changes:
+# "updates": [
+# "nxapi http port 80",
+# "no nxapi https",
+# "no nxapi sandbox"
+# ],
+
+- name: Idempotency check
+ assert:
+ that:
+ - "config.changed == false"
+# FIXME: https://github.com/ansible/ansible-modules-core/issues/4955
+ ignore_erros: yes
+
+- debug: msg="END cli/config.yaml"
diff --git a/test/integration/targets/nxos_nxapi/tests/cli/configure.yaml b/test/integration/targets/nxos_nxapi/tests/cli/configure.yaml
new file mode 100644
index 0000000000..0b53a7a46f
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tests/cli/configure.yaml
@@ -0,0 +1,45 @@
+---
+- debug: msg="START cli/configure.yaml"
+
+- name: Setup - put NXAPI in stopped state
+ nxos_nxapi:
+ state: absent
+ provider: "{{ cli }}"
+
+- name: Configure NXAPI
+ nxos_nxapi:
+ enable_http: no
+ enable_sandbox: no
+ enable_https: yes
+ https_port: 9443
+ provider: "{{ cli }}"
+ register: result
+
+- nxos_command:
+ commands:
+ - show nxapi | json
+ provider: "{{ cli }}"
+ register: result
+
+- name: Assert configuration changes
+ assert:
+ that:
+ - result.stdout[0].http_port is not defined
+ - result.stdout[0].https_port == 9443
+ - result.stdout[0].sandbox_status == 'Disabled'
+
+- name: Configure NXAPI again
+ nxos_nxapi:
+ enable_http: no
+ enable_sandbox: no
+ enable_https: yes
+ https_port: 9443
+ provider: "{{ cli }}"
+ register: result
+
+- name: Assert configuration is idempotent
+ assert:
+ that:
+ - result.changed == false
+
+- debug: msg="END cli/configure.yaml"
diff --git a/test/integration/targets/nxos_nxapi/tests/cli/disable.yaml b/test/integration/targets/nxos_nxapi/tests/cli/disable.yaml
new file mode 100644
index 0000000000..7d3df6e40f
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tests/cli/disable.yaml
@@ -0,0 +1,46 @@
+---
+- debug: msg="START cli/disable.yaml"
+
+- name: Disable NXAPI
+ nxos_nxapi:
+ state: absent
+ provider: "{{ cli }}"
+ register: result
+ # delegate_to: "{{ delegate_to }}"
+
+- debug: var=result
+ when: debug
+
+- name: Check NXAPI state
+ nxos_command:
+ commands:
+ - show feature | grep nxapi
+ provider: "{{ cli }}"
+ register: result
+ # delegate_to: "{{ delegate_to }}"
+
+- debug: var=result
+ when: debug
+
+- name: Assert NXAPI is disabled
+ assert:
+ that:
+ result.stdout[0] | search('disabled')
+
+- name: Disable NXAPI again
+ nxos_nxapi:
+ state:
+ absent
+ provider: "{{ cli }}"
+ register: result
+ # delegate_to: "{{ delegate_to }}"
+
+
+- name: Assert idempotence
+ assert:
+ that:
+ result.changed == false
+# FIXME https://github.com/ansible/ansible-modules-core/issues/4955
+ ignore_errors: yes
+
+- debug: msg="END cli/disable.yaml"
diff --git a/test/integration/targets/nxos_nxapi/tests/cli/enable.yaml b/test/integration/targets/nxos_nxapi/tests/cli/enable.yaml
new file mode 100644
index 0000000000..57c2236727
--- /dev/null
+++ b/test/integration/targets/nxos_nxapi/tests/cli/enable.yaml
@@ -0,0 +1,39 @@
+---
+- debug: msg="START cli/enable.yaml"
+
+- name: Setup - put NXAPI in stopped state
+ nxos_nxapi:
+ state: absent
+ provider: "{{ cli }}"
+ register: result
+
+- name: Enable NXAPI
+ nxos_nxapi:
+ state: started
+ provider: "{{ cli }}"
+ register: result
+
+- name: Check NXAPI state
+ nxos_command:
+ commands:
+ - show feature | grep nxapi
+ provider: "{{ cli }}"
+ register: result
+
+- name: Assert NXAPI is enabled
+ assert:
+ that: result.result[0] | search('enabled')
+
+- name: Enable NXAPI again
+ nxos_nxapi:
+ provider: "{{ cli }}"
+ register: result
+
+- name: Assert idempotence
+ assert:
+ that:
+ result.changed == false
+
+
+- debug: msg="END cli/enable.yaml"
+
diff --git a/test/integration/targets/nxos_template/defaults/main.yaml b/test/integration/targets/nxos_template/defaults/main.yaml
new file mode 100644
index 0000000000..2a4e223ff0
--- /dev/null
+++ b/test/integration/targets/nxos_template/defaults/main.yaml
@@ -0,0 +1,4 @@
+---
+testcase: "*"
+test_items: []
+
diff --git a/test/integration/targets/nxos_template/meta/main.yml b/test/integration/targets/nxos_template/meta/main.yml
new file mode 100644
index 0000000000..ae741cbdc7
--- /dev/null
+++ b/test/integration/targets/nxos_template/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_template/tasks/cli.yaml b/test/integration/targets/nxos_template/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/nxos_template/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/nxos_template/tasks/main.yaml b/test/integration/targets/nxos_template/tasks/main.yaml
new file mode 100644
index 0000000000..a2f4b2415a
--- /dev/null
+++ b/test/integration/targets/nxos_template/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+- { include: nxapi.yaml, tags: ['nxapi'] }
+
diff --git a/test/integration/targets/nxos_template/tasks/nxapi.yaml b/test/integration/targets/nxos_template/tasks/nxapi.yaml
new file mode 100644
index 0000000000..7c69bbc92c
--- /dev/null
+++ b/test/integration/targets/nxos_template/tasks/nxapi.yaml
@@ -0,0 +1,29 @@
+---
+- name: collect all nxapi test cases
+ find:
+ paths: "{{ role_path }}/tests/nxapi"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: enable nxapi
+ nxos_config:
+ lines:
+ - feature nxapi
+ - nxapi http port 80
+ provider: "{{ cli }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+- name: disable nxapi
+ nxos_config:
+ lines:
+ - no feature nxapi
+ provider: "{{ cli }}"
+
diff --git a/test/integration/targets/nxos_template/templates/basic/config.j2 b/test/integration/targets/nxos_template/templates/basic/config.j2
new file mode 100644
index 0000000000..9705ee1494
--- /dev/null
+++ b/test/integration/targets/nxos_template/templates/basic/config.j2
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/nxos_template/templates/config.js b/test/integration/targets/nxos_template/templates/config.js
new file mode 100644
index 0000000000..d2ec0c0c71
--- /dev/null
+++ b/test/integration/targets/nxos_template/templates/config.js
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description test description from ansible
+ shutdown
+
diff --git a/test/integration/targets/nxos_template/templates/defaults/config.j2 b/test/integration/targets/nxos_template/templates/defaults/config.j2
new file mode 100644
index 0000000000..df0cac701c
--- /dev/null
+++ b/test/integration/targets/nxos_template/templates/defaults/config.j2
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description this is a test
+ no shutdown
+
diff --git a/test/integration/targets/nxos_template/templates/defaults/test.j2 b/test/integration/targets/nxos_template/templates/defaults/test.j2
new file mode 100644
index 0000000000..9705ee1494
--- /dev/null
+++ b/test/integration/targets/nxos_template/templates/defaults/test.j2
@@ -0,0 +1,4 @@
+interface Ethernet2/5
+ description this is a test
+ shutdown
+
diff --git a/test/integration/targets/nxos_template/tests/cli/backup.yaml b/test/integration/targets/nxos_template/tests/cli/backup.yaml
new file mode 100644
index 0000000000..3760dabe53
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/cli/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START cli/backup.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ 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
+ nxos_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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/nxos_template/tests/cli/basic.yaml b/test/integration/targets/nxos_template/tests/cli/basic.yaml
new file mode 100644
index 0000000000..17625e4173
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/cli/basic.yaml
@@ -0,0 +1,36 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/nxos_template/tests/cli/defaults.yaml b/test/integration/targets/nxos_template/tests/cli/defaults.yaml
new file mode 100644
index 0000000000..a98b958258
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/cli/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START cli/defaults.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with defaults included
+ nxos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with defaults included
+ nxos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ cli }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END cli/defaults.yaml"
diff --git a/test/integration/targets/nxos_template/tests/cli/force.yaml b/test/integration/targets/nxos_template/tests/cli/force.yaml
new file mode 100644
index 0000000000..8bfc398fdb
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/cli/force.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/force.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ cli }}"
+
+- name: configure device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ cli }}"
+ force: yes
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- debug: msg="END cli/force.yaml"
diff --git a/test/integration/targets/nxos_template/tests/nxapi/backup.yaml b/test/integration/targets/nxos_template/tests/nxapi/backup.yaml
new file mode 100644
index 0000000000..f42f1b2fbd
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/nxapi/backup.yaml
@@ -0,0 +1,50 @@
+---
+- debug: msg="START nxapi/backup.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- 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
+ nxos_template:
+ src: basic/config.j2
+ backup: yes
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is 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 nxapi/backup.yaml"
diff --git a/test/integration/targets/nxos_template/tests/nxapi/basic.yaml b/test/integration/targets/nxos_template/tests/nxapi/basic.yaml
new file mode 100644
index 0000000000..481447719a
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/nxapi/basic.yaml
@@ -0,0 +1,36 @@
+---
+- debug: msg="START nxapi/basic.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- name: configure device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END nxapi/basic.yaml"
diff --git a/test/integration/targets/nxos_template/tests/nxapi/defaults.yaml b/test/integration/targets/nxos_template/tests/nxapi/defaults.yaml
new file mode 100644
index 0000000000..83cdf3bb37
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/nxapi/defaults.yaml
@@ -0,0 +1,42 @@
+---
+- debug: msg="START nxapi/defaults.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- name: configure device with defaults included
+ nxos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ nxapi }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with defaults included
+ nxos_template:
+ src: defaults/config.j2
+ include_defaults: yes
+ provider: "{{ nxapi }}"
+ register: result
+
+- debug: var=result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.updates is defined"
+
+- debug: msg="END nxapi/defaults.yaml"
diff --git a/test/integration/targets/nxos_template/tests/nxapi/force.yaml b/test/integration/targets/nxos_template/tests/nxapi/force.yaml
new file mode 100644
index 0000000000..9afbab2577
--- /dev/null
+++ b/test/integration/targets/nxos_template/tests/nxapi/force.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START nxapi/force.yaml"
+
+- name: setup
+ nxos_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Ethernet2/5
+ match: none
+ provider: "{{ nxapi }}"
+
+- name: configure device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- name: check device with config
+ nxos_template:
+ src: basic/config.j2
+ provider: "{{ nxapi }}"
+ match: none
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "result.updates is defined"
+
+- debug: msg="END nxapi/force.yaml"
diff --git a/test/integration/targets/ops_command/defaults/main.yaml b/test/integration/targets/ops_command/defaults/main.yaml
new file mode 100644
index 0000000000..822f2213a4
--- /dev/null
+++ b/test/integration/targets/ops_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_cases: []
diff --git a/test/integration/targets/ops_command/tasks/cli.yaml b/test/integration/targets/ops_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/ops_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/ops_command/tasks/main.yaml b/test/integration/targets/ops_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/ops_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/ops_command/tests/cli/bad_operator.yaml b/test/integration/targets/ops_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..c3e48f0c6c
--- /dev/null
+++ b/test/integration/targets/ops_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ ops_command:
+ commands:
+ - show version
+ - show interfaces
+ wait_for:
+ - result[0] contains 'Description: Foo'
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/ops_command/tests/cli/contains.yaml b/test/integration/targets/ops_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..37c01a5193
--- /dev/null
+++ b/test/integration/targets/ops_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ ops_command:
+ commands:
+ - show version
+ - show interface GigabitEthernet0/0
+ wait_for:
+ - "result[0] contains 15.6"
+ - "result[1] contains GigabitEthernet0/0"
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/ops_command/tests/cli/invalid.yaml b/test/integration/targets/ops_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..7be4dd6611
--- /dev/null
+++ b/test/integration/targets/ops_command/tests/cli/invalid.yaml
@@ -0,0 +1,28 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ ops_command:
+ commands: ['show foo']
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- name: run commands that include invalid command
+ ops_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed"
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/ops_command/tests/cli/output.yaml b/test/integration/targets/ops_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..3292d1b2e8
--- /dev/null
+++ b/test/integration/targets/ops_command/tests/cli/output.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ ops_command:
+ commands: ['show version']
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+- name: get output for multiple commands
+ ops_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout | length == 2"
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/ops_command/tests/cli/timeout.yaml b/test/integration/targets/ops_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..a55b56fde1
--- /dev/null
+++ b/test/integration/targets/ops_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ ops_command:
+ commands:
+ - show version
+ wait_for:
+ - "result[0] contains bad_value_string"
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/prepare_eos_tests/tasks/main.yml b/test/integration/targets/prepare_eos_tests/tasks/main.yml
new file mode 100644
index 0000000000..0e9f36e49f
--- /dev/null
+++ b/test/integration/targets/prepare_eos_tests/tasks/main.yml
@@ -0,0 +1,9 @@
+ - name: enable cli on remote device
+ eos_eapi:
+ enable_http: yes
+ enable_https: yes
+ enable_local_http: yes
+ enable_socket: yes
+ provider: "{{ cli }}"
+ register: eos_eapi_output
+ connection: local
diff --git a/test/integration/targets/prepare_nxos_tests/tasks/main.yml b/test/integration/targets/prepare_nxos_tests/tasks/main.yml
new file mode 100644
index 0000000000..429ee68c5a
--- /dev/null
+++ b/test/integration/targets/prepare_nxos_tests/tasks/main.yml
@@ -0,0 +1,5 @@
+- name: enable nxapi on remote device
+ nxos_config:
+ lines:
+ - feature nxapi
+ provider: "{{ cli }}"
diff --git a/test/integration/targets/vyos_command/defaults/main.yaml b/test/integration/targets/vyos_command/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/vyos_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/vyos_command/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/vyos_command/tasks/main.yaml b/test/integration/targets/vyos_command/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/vyos_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml
new file mode 100644
index 0000000000..bff9b5cedd
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/bad_operator.yaml"
+
+- name: test bad operator
+ vyos_command:
+ commands:
+ - show version
+ - show interfaces
+ wait_for:
+ - result[0] is 'VyOS'
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+
+- debug: msg="END cli/bad_operator.yaml"
diff --git a/test/integration/targets/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/tests/cli/contains.yaml
new file mode 100644
index 0000000000..957004936e
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/contains.yaml
@@ -0,0 +1,21 @@
+---
+- debug: msg="START cli/contains.yaml"
+
+- name: test contains operator
+ vyos_command:
+ commands:
+ - show version
+ - show interface
+ wait_for:
+ - result[0] contains VyOS
+ - result[1] contains eth0
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout_lines is defined
+
+- debug: msg="END cli/contains.yaml"
diff --git a/test/integration/targets/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/tests/cli/invalid.yaml
new file mode 100644
index 0000000000..4987b503f3
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/invalid.yaml
@@ -0,0 +1,24 @@
+---
+- debug: msg="START cli/invalid.yaml"
+
+- name: run invalid command
+ vyos_command:
+ commands: show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert: { that: result.failed }
+
+- name: run commands that include invalid command
+ vyos_command:
+ commands:
+ - show version
+ - show foo
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert: { that: result.failed }
+
+- debug: msg="END cli/invalid.yaml"
diff --git a/test/integration/targets/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/tests/cli/output.yaml
new file mode 100644
index 0000000000..ba2a38aacf
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/output.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/output.yaml"
+
+- name: get output for single command
+ vyos_command:
+ commands: show version
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout_lines is defined
+
+- name: get output for multiple commands
+ vyos_command:
+ commands:
+ - show version
+ - show interfaces
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout | length == 2
+
+- debug: msg="END cli/output.yaml"
diff --git a/test/integration/targets/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/tests/cli/timeout.yaml
new file mode 100644
index 0000000000..b567df2e5c
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/timeout.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/timeout.yaml"
+
+- name: test bad condition
+ vyos_command:
+ commands:
+ - show version
+ wait_for:
+ - result[0] contains bad_value_string
+ provider: "{{ cli }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+
+- debug: msg="END cli/timeout.yaml"
diff --git a/test/integration/targets/vyos_config/defaults/main.yaml b/test/integration/targets/vyos_config/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/vyos_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/vyos_config/tasks/cli.yaml b/test/integration/targets/vyos_config/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/vyos_config/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
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+
diff --git a/test/integration/targets/vyos_config/tasks/main.yaml b/test/integration/targets/vyos_config/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/vyos_config/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/vyos_config/tests/cli/check_config.yaml b/test/integration/targets/vyos_config/tests/cli/check_config.yaml
new file mode 100644
index 0000000000..88a84de97b
--- /dev/null
+++ b/test/integration/targets/vyos_config/tests/cli/check_config.yaml
@@ -0,0 +1,29 @@
+---
+- debug: msg="START cli/config_check.yaml"
+
+- name: setup
+ vyos_config:
+ lines: set interfaces loopback lo description test
+ provider: "{{ cli }}"
+
+- name: configure config_check config command
+ vyos_config:
+ lines: delete interfaces loopback lo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: check config_check config command idempontent
+ vyos_config:
+ lines: delete interfaces loopback lo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- debug: msg="END cli/config_check.yaml"
diff --git a/test/integration/targets/vyos_config/tests/cli/comment.yaml b/test/integration/targets/vyos_config/tests/cli/comment.yaml
new file mode 100644
index 0000000000..91cc729770
--- /dev/null
+++ b/test/integration/targets/vyos_config/tests/cli/comment.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START cli/comment.yaml"
+
+- name: setup
+ vyos_config:
+ lines: set system host-name {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure using comment
+ vyos_config:
+ lines: set system host-name foo
+ comment: this is a test
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'set system host-name foo' in result.updates"
+
+- name: collect system commits
+ vyos_command:
+ commands: show system commit
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "'this is a test' in result.stdout_lines[0][1]"
+
+- name: teardown
+ vyos_config:
+ lines: set system host-name {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/comment.yaml"
diff --git a/test/integration/targets/vyos_config/tests/cli/simple.yaml b/test/integration/targets/vyos_config/tests/cli/simple.yaml
new file mode 100644
index 0000000000..957b91224d
--- /dev/null
+++ b/test/integration/targets/vyos_config/tests/cli/simple.yaml
@@ -0,0 +1,37 @@
+---
+- debug: msg="START cli/simple.yaml"
+
+- name: setup
+ vyos_config:
+ lines: set system host-name {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- name: configure simple config command
+ vyos_config:
+ lines: set system host-name foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'set system host-name foo' in result.updates"
+
+- name: check simple config command idempontent
+ vyos_config:
+ lines: set system host-name foo
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ vyos_config:
+ lines: set system host-name {{ inventory_hostname }}
+ provider: "{{ cli }}"
+ match: none
+
+- debug: msg="END cli/simple.yaml"
diff --git a/test/integration/vyos.yaml b/test/integration/vyos.yaml
new file mode 100644
index 0000000000..53130baace
--- /dev/null
+++ b/test/integration/vyos.yaml
@@ -0,0 +1,12 @@
+---
+- hosts: vyos
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: vyos_command, when: "limit_to in ['*', 'vyos_command']" }
+ - { role: vyos_config, when: "limit_to in ['*', 'vyos_config']" }