diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/vyos | |
parent | Initial commit. (diff) | |
download | ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/vyos')
562 files changed, 78797 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/.gitignore b/collections-debian-merged/ansible_collections/vyos/vyos/.gitignore new file mode 100644 index 00000000..894a44cc --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/.gitignore @@ -0,0 +1,104 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/.yamllint b/collections-debian-merged/ansible_collections/vyos/vyos/.yamllint new file mode 100644 index 00000000..3adaf90c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/.yamllint @@ -0,0 +1,15 @@ +--- +extends: default + +ignore: | + .tox + changelogs/* + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/FILES.json b/collections-debian-merged/ansible_collections/vyos/vyos/FILES.json new file mode 100644 index 00000000..031acc70 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/FILES.json @@ -0,0 +1,5661 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a2ebfecdb6c1b58267fbe97e6e2ac02c2b963df7673fc1047270f0f0cff16732", + "format": 1 + }, + { + "name": "test-requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bc2b6f6c80ae681585b1c632137b80ce95c5bbb0a5e15fc49aeaf260cf91245a", + "format": 1 + }, + { + "name": "changelogs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/changelog.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "791ef285bb9e0903fb82712f74f3e1bebed982631f15e1a834420f3ff6a23686", + "format": 1 + }, + { + "name": "changelogs/CHANGELOG.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3619e33b2b748993927d83a20672514a8c6077e9457f68fff6ae02c54a030a77", + "format": 1 + }, + { + "name": "changelogs/config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0de35d0244fd604f9af1e56379c5a9ddc64252d485fba56d5f384ac5a40ddbbe", + "format": 1 + }, + { + "name": "LICENSE", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/filter", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/filter/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/terminal", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/terminal/vyos.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "64d4e21aad4712ccf9d7cc60559bb05503ccdfd6340af45d86b784a0c05a2730", + "format": 1 + }, + { + "name": "plugins/terminal/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules/vyos_lag_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c7c4b80ca462243bed5ad71f563f813465008b8c2dab75d410f389e64b21739e", + "format": 1 + }, + { + "name": "plugins/modules/vyos_config.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6ca6d71cee2c9d502da53df1348e19aa13d507c987c919201f92360d2e285b6c", + "format": 1 + }, + { + "name": "plugins/modules/vyos_logging.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7bde1a2705986862032a563e889c077a745878f4dcc7c532ddb1f9fcd948b1f8", + "format": 1 + }, + { + "name": "plugins/modules/vyos_static_route.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8e8e0e97e7dc88798fb37c7e63d74d8ca587ddec7d69ec8b45a8a4b58cab32db", + "format": 1 + }, + { + "name": "plugins/modules/vyos_firewall_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c34f1dfdbb50f981cca9655cf5402a9ac7df6fab2df00379809dfdb29ede0d91", + "format": 1 + }, + { + "name": "plugins/modules/vyos_lldp.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e64a85527f2fb6bf33b35043f7b4672faac43d1fdd0b4e643879dcfb12cb38e0", + "format": 1 + }, + { + "name": "plugins/modules/vyos_ping.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1821c68cd0d602c771956fa51b119cd26109855cadb9b9b4d2fb324e98d427fd", + "format": 1 + }, + { + "name": "plugins/modules/vyos_user.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9373bf674766ab6a213efedb918dbf27094720cf82047c75c4659a9cdbbe3b36", + "format": 1 + }, + { + "name": "plugins/modules/vyos_lldp_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "128c1d2fa3fdbbced4741d4493f4acf2a5ee1730f5532f8f824bcebe9b66fa24", + "format": 1 + }, + { + "name": "plugins/modules/vyos_vlan.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "771f6ca6b29c5e0fd3e30e9381f70fd200601d2e7be2a95985a2e0c63c46327b", + "format": 1 + }, + { + "name": "plugins/modules/vyos_banner.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a2e3e15e18f3ab1bf10c2f5cf11348e6a70acb4dfc1c515dee68d4322219ad18", + "format": 1 + }, + { + "name": "plugins/modules/vyos_l3_interface.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e88721384dd4b31d4129c4354cd017529e22c07a928bb2223535179267241d1c", + "format": 1 + }, + { + "name": "plugins/modules/vyos_firewall_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b6d1a549afebf7c94f9972801d7bd39e9111067b26f75ff5a845bf55640b4fa9", + "format": 1 + }, + { + "name": "plugins/modules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/modules/vyos_ospf_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1352e5b1196f0721665881a8763e38a8dc9ebb7ce66151e269edfd5a22e1528a", + "format": 1 + }, + { + "name": "plugins/modules/vyos_lldp_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "89715625cd7bb08b708b4fc9c579dec74f6b27e17bb9fb70f82e0049521f2865", + "format": 1 + }, + { + "name": "plugins/modules/vyos_interface.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e946bee49b922ae95e70d6f36404f196ba6f8b129c09028c606afe0dec6421cc", + "format": 1 + }, + { + "name": "plugins/modules/vyos_linkagg.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "99d1ba8046651677e44fbd9f88c11ce2a34d2fd79b7d32cc238cadcba4703a2e", + "format": 1 + }, + { + "name": "plugins/modules/vyos_static_routes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "56076c78ab61d16ef44a3a33a4fc8bb59454dc0dd6e8758689fa1eedbc4f625b", + "format": 1 + }, + { + "name": "plugins/modules/vyos_firewall_rules.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9e5a0dc39a785e7dd296458bb767dd8709c0988bbb60353a992d88ee3f28c929", + "format": 1 + }, + { + "name": "plugins/modules/vyos_ospfv3.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "877752b2313648d754b3f93725fe337faf5745afd89b42d7ab7e224ac7246e73", + "format": 1 + }, + { + "name": "plugins/modules/vyos_l3_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f5a04d8f6b625167ea631ff5b59261898f95ad5cc166fe05dadc57ea9ab03cc1", + "format": 1 + }, + { + "name": "plugins/modules/vyos_system.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9d1c919508a337dfd52462d493fd0609a9b58e32b68b9a901a5e43b43ba99c76", + "format": 1 + }, + { + "name": "plugins/modules/vyos_lldp_interface.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "14357dff03a4bbffac0c215bc85686146b2446e404bbf507d0dc3432b4786b37", + "format": 1 + }, + { + "name": "plugins/modules/vyos_command.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "401e5b51619e1a82a7902e8815e72393f7a31e4de66b775435f2b5e6bff1a70c", + "format": 1 + }, + { + "name": "plugins/modules/vyos_facts.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "afc31c78a8f70f43c521f181029bd039d5cfbbec1e96d33794d3529635ab881e", + "format": 1 + }, + { + "name": "plugins/modules/vyos_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5a7e0df4ba49bb12979506b55648cbf9332244a451bdb5b1e568f7bdbc175d7", + "format": 1 + }, + { + "name": "plugins/modules/vyos_ospfv2.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b69e0d11e457fa8e2330c58b57878c88928cf4022501bf9d43ce702661a439d3", + "format": 1 + }, + { + "name": "plugins/doc_fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments/vyos.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "485e06c4ee3eafc02550cc6968b23c637ebc76ef960cf41c23e3b65f10cfc4b2", + "format": 1 + }, + { + "name": "plugins/doc_fragments/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/facts.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddafff7998cfc208259d51372230a37f05cbe8a64df8cfbcdf1730b646db2237", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lldp_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eb269e5d61c429dbfdae7747a5fba2b428a9f70c7b56a5bfbe28cbce4c034c22", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lldp_global/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lldp_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4ffd23ca60c0445f5bb1657a270a1d8f19ee74faa15c097b211b8793db4a9251", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lldp_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospf_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4ff55a997f18073c46ef02c13ca3bd6dd944975bc213cc20aa33da8ac0f24d47", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospf_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospfv3", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospfv3/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d7c58b0b6023be1f8a58eab59ba017f8428e534911a81bb0b70f8072ff98d37f", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospfv2", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fba5918eeed4cbd6e823aeaa9245af72a76dbc0bcb21a90ad5b1afe8ed226a1d", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/ospfv2/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/legacy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/legacy/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/legacy/base.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ff9b627b4e171366b2c0bd3be1a6d6f6da192ac7948cf5d67438e6c317ee3129", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7c7c70b9ee2a803b0d74d5e9563541a82b23bf664c474919108b7d89bbbac75a", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/interfaces/interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "753eb5fcf74c82ab43cbdfa01de6586d326dafcc54712ee38b2a81ebad6b7ca0", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/l3_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba9b841360e54a993f1a04d50127c16602c4199c2e1b5ada345cf51f6095b267", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/l3_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4abd9643ac6e76e33621460b96db8c299a1623ce7288394ce9f2273f1bd36273", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_global/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lag_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lag_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "23784a6bfedc389e5bd0cae91d0ddce03068f1de7407f972cd90d18d3d4429b9", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/static_routes", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/static_routes/static_routes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b887be5b5e3efa32fa5a5f046433b8e7a9dd370e8ac6d48205de2b61c7144a21", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/static_routes/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_rules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5a4d733ea269c19e33a5e26319177991a626c08020e8387a760f321ece8ad772", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/facts/firewall_rules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/rm_templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f2ccbb95cef5b85b87fbd601eaf80e42012e9cabe6b562fea3d29894f8a64127", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/rm_templates/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/vyos.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "61cd638e4b247969e3eda62293cb2c858cccbeda52e09b2ddc52147089a0f7b4", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/utils/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/utils/utils.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5bd673d6968c4d8e57b56226acee72606f5670b611cb886d50c35c3dd1fa33ae", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lldp_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "60a67727208e39bd2089170d7ba6558003c38ace708ca8e57ea464d00385e2c5", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lldp_global/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lldp_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f15854b32f87874695d42ab8e86a490fd5c9a4030019afdadc1fc50c6831276d", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lldp_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospf_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "75abd44c30765eaeb71811490651676d34f381ad3d963e0d1f8f8eb1bcca4ce7", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospf_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospfv3", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospfv3/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5f3c72b221f74bcae31743edc93f08dda4a920eeeb0b9f94a1f226f0caa8b52", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospfv2", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "884f375307f4284fdcf5e0804d66396f82e63ec106de9f7f9bc7418fcf3f4fe1", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/ospfv2/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cee399382c3743d2fd5d5bd8d43e38bfa1ca8ab41c9f6c0fa6e52f711e11683e", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/interfaces/interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3465d58f09864a13501734878122272baf2ef4af9dc82943f632fa123fc2834f", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/l3_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9e8660154f1f48a60231df743ce7692f0d7953dfb62d6f0b5158092e0181d8f8", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/l3_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3e5bb9f7ab2cd98f521c1ce76dc5d75f847f3537c445ba450d5f1770b49a9058", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_global/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lag_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lag_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a21bbdde67eb7266dd73b07ad4c699bded8f652e6d915611f0ecbd470ed6176a", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/static_routes", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/static_routes/static_routes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9a69318a4836ba9ffc3fe28f9626b00a806242a213598d05185cf0897b106c76", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/static_routes/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_rules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0e5e10ead77d6bab013e4befce4029d2b355918a192e73dcc923ce098034100d", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/config/firewall_rules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lldp_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8648d14d12aa79a556a8053e86b683fff7f25c1daae82518d36799466a944253", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lldp_global/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/facts", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/facts/facts.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3c5ffcfc60161de1f5205e4ec3791f57994590f5086ed3ff28ae07e0c28283bc", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/facts/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lldp_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1d5131cfe51ad27dec6abfe4d9be53cb08e6d39bab404be8104a7fd05713c548", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lldp_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospf_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdf9465a43e877d9ed8903efd9eb742e0ce9424bcf8c8824af26603a91072ccf", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospf_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospfv3", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospfv3/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba75705133bd7ee87c570d9be378274bc6904f40734b4d89b46ff298f32d288d", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospfv2", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3193f9e931229ace21951539855f07ad196ef62c6176f1e3f22c1d44a1ea1f4e", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/ospfv2/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b7423b32879a3b432fa8c1b30781426f729ef910c582d1f85b45280dfb45a5ed", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "351b094add731ffc2ef9528956b0e45f1f814342576f45d9e0b04b5298a90ddb", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/l3_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "72e7a468cfbd64fbf809953969e173e8e0295463b4634b886fb8ae68a4bc8dab", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/l3_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "95b6a627275fc759af0f300d1984b12f8d1197cfef993053d3821cf4702a584c", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_global/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lag_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lag_interfaces/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "09a5b28691b0b8c0fcd4dc896168cc9e33ce41788b21dea4786a4e9321e735a0", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/static_routes", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "32fe20a7d3e4ab4df26bca351df62b0eb69b947b5aa6464b9f45801bf7afb4ff", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/static_routes/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_rules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fc13fd67286349da1a0873b147aaa15edfa0f7e4b97919e0e23815f27fb202a9", + "format": 1 + }, + { + "name": "plugins/module_utils/network/vyos/argspec/firewall_rules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/network/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/module_utils/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/cliconf", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/cliconf/vyos.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8e15182629a209ec40a16c39309f0e19226d37b58139e268c5ac3f0f293f5f88", + "format": 1 + }, + { + "name": "plugins/cliconf/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/action", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/action/vyos.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "945a8e3ac714137a24febfa76cffd4feb7a2f0617c57ba089e3dabf6b8a7285d", + "format": 1 + }, + { + "name": "plugins/action/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "plugins/inventory", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/inventory/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/sanity", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.9.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0601d1470a13bdc6e93e053fd970b2b6f46db034e411a61feaa86833465161e9", + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.10.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a7532854f0a69cbd1d48ff6f093c835debc6bd15c577dd440f1edcbcfafc803e", + "format": 1 + }, + { + "name": "tests/sanity/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c8a4ac4bfdef88e75d6e748e35a42fb4915947dfa2b7dd788626fd829600e014", + "format": 1 + }, + { + "name": "tests/.gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5726d3ec9335a09c124469eca039523847a6b0f08a083efaefd002b83326600", + "format": 1 + }, + { + "name": "tests/unit", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/modules/network", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_firewall_rules.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "974957ab91ba6eab06bf915d9637e84b1c57d089a18ca7683152640a17183a9b", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_static_route.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c26fe4bf75e7e611d3203c3ac14cf78bbff8dc3f2ed7a9dddfb9df0cd4f4ae64", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_interface.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8b505ee070f761c33143b6cceace3886bd923fb1e382f9eca9666d5dae01e9c2", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6a923d5d9b7da91c945e81a28602e115a3cfc781d593db9f746d5aceca590e16", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_facts.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "dd3bd53c6e1deed5e71575afa80f1b16b78b60e92d8fd8109c105cd339398dc5", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "546e5cc4390940d0a0ac76c35d145ac647ba2f52df630b6c8f2f194541f8b236", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_interface_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bee1003d72d534eff81258fc10eac84b6754a82a7f88055d167e9a5686223b5c", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/show_version", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7596dbf5fcd0e83c165d46e12dba97253425e24b97f3662a9b96ef6eb89a9422", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "738423a3ccd98905161a6d15a3f5a44ab4f71a1ba6eaec552555057ccf370c7e", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_static_routes_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "24e264207e3c76be328a0eef20c984c6937c77c230a6740676e48bcbf204b7a4", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_config_src.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "11edf901dee62b3e1fe4611e9a7d93aa7c7b9f18aa31ba7a64759c405d4ad326", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_config_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "43e42e158d44261c20c343c1b71b0640e819d94c7d132a4ecc3cebd56a20f89d", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_ospf_interfaces_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7479b26ab0e0238d347a808ca88bf15cbbc58f2d2505fb01624c5627e1f26302", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a8388234a268b6f3e162c6b059f2a65fb00c426dc7e5613421e7846ac55785a", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "49d6b325868eeb8905618eff9843cb1d5c5127f230af80a5face945fdc3611a9", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/show_host_name", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5e4b850450b895fc729138183b9e29684063ca09a493b4c60e5810547cd6af3", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d1e9fd5c49c7619d783536cfb58307ad520ea675c68d7a5f9c6608a80cdfca23", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "954f56d871468b9273975b48ca5048020082cfb2baa7661359f41e7a92859c63", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "834d9e934949e49f3a87629930de86004f9b8eba5faed4dedb0ac0cc722d1db7", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1c9b5b99cd0fb20ca46f006d111afb4a208d1d56271daefb37291d9efc6d74fe", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_ospfv3_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7d28369d4b497a36e65524a684415eeee46c0a5ac060dcc6b7be4a682191128e", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_ospfv2_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbdf1f1197c560b690b9154a03be06c84064fe8fa954c512e7235c477fa42c10", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_user_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ef00b7f9f6c30bdd1a1bd4e28b02a6d98faee62f6fc199d989e7af4d3ea56ae1", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/fixtures/vyos_lldp_neighbor_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e74e122ef6c9389a68c65c2b1da21505ed098a464982dab62b7934c14c883561", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "56a6b243e9285a2e8917689b818af170343cd591369659f1bbfd990fe087c507", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_command.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "05cf9fef1e96fd5154f035f5fc0d8de5780c1834cc8c4ab829e503d28cc257ec", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_ospfv3.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f8437ad4520159cc99f189c9efff7872f526772861066eec4283270bdd89e27b", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cb7b677dce533b53bd6ffff272798651cccf719e540e91111ee30959c97ec03d", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_ping.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "09ab31b60605e7520809a82bed73ad1453a7c20f3f7feba335bbb47b4d0c7a62", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/vyos_module.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "343dc8a757db195746506b2bc68e3f8026e801f81f06ea98d6fa141c4a395f80", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_user.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f9a2fb9aec4c7014197d0dce18eb09767a7018d20c1664fe31d035f3312488eb", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_banner.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9032f312be5574c048b127530a30571573c41002101633673f26e35034314504", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_config.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6035206161be6e7fbb705f03369e75d45a06bf94b9c2b6a10eeaf0aad5b79e20", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_ospfv2.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "be4db45ded682737d38fc9930b69a76062bfb6c11d54ddd010f299cd7afa9855", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_system.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "71ba1e9ec8f4ce4b255033186df7cee46adff12f014ddea913a277b520a5f18e", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_static_routes.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ca1e7ab17287803aaca0f21f5449b06d7c1b6cbcc02a6595ea18c73800445ea7", + "format": 1 + }, + { + "name": "tests/unit/modules/network/vyos/test_vyos_firewall_global.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "dbfaf9ee1239a1a497e1b46d559209a5f8efd15d283bac988e160a6427a695b2", + "format": 1 + }, + { + "name": "tests/unit/modules/network/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/modules/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/modules/conftest.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2af4846e50d461a131ad3edfb609fbb39a9eb1796048c62e4ead8234bcf5c6a1", + "format": 1 + }, + { + "name": "tests/unit/modules/utils.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ac0e108b4d864fb3f335372e92536ed2378c72345e024bfe587c577f9f914f28", + "format": 1 + }, + { + "name": "tests/unit/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/compat", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/compat/unittest.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3ed698b1faec43d87a2c1ebcb15a2aae48b09ff355bb9a598e5f5a1c928dbb30", + "format": 1 + }, + { + "name": "tests/unit/compat/mock.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "19729d817c5060fe2714834b549d18ab803e248882a83129849d170a42b0ec9f", + "format": 1 + }, + { + "name": "tests/unit/compat/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/compat/builtins.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba13a350ade8ef804336f888d5883b8e54f8bddfb9d0fadc10277a8ca6540f4e", + "format": 1 + }, + { + "name": "tests/unit/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "49ba996dc4735c3463e9af561344346dfae14bcc1a68096ce78364b377f0df1f", + "format": 1 + }, + { + "name": "tests/unit/mock", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/unit/mock/yaml_helper.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "94e2f3c867d2582c9f7a0e99e544718e355025c4a51c9925e70158fa89b3609e", + "format": 1 + }, + { + "name": "tests/unit/mock/loader.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0cfbf4c710a5d5725f84d5f34ab76ec1a0e853397cd945c90fd97769f89dddc5", + "format": 1 + }, + { + "name": "tests/unit/mock/vault_helper.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "feae23166b6eb502f7d9b77c314970516c9a99aaad7de01295b4dfdad53c5c09", + "format": 1 + }, + { + "name": "tests/unit/mock/path.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "396b0a5972d1f016f3d28cc06a093d85aa71da1ae7e3aa13866ec9dd6cc958b9", + "format": 1 + }, + { + "name": "tests/unit/mock/__init__.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/unit/mock/procenv.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "695c4c1184c4d1bf87a836bfd6099cb0a53e6e6fba68c19430df44a77f2aacbe", + "format": 1 + }, + { + "name": "tests/integration", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/network-integration.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d67b11263a8f50b30bf43c7c2b4bdd8dc4f173f0b5dd22761311360dfbd56a1d", + "format": 1 + }, + { + "name": "tests/integration/target-prefixes.network", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8f5d6e9c5feefc0545a2c53f7405093b3f87135d2e87858a754532a4a1d4745e", + "format": 1 + }, + { + "name": "tests/integration/targets", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "720ec3cc69d0f054aaeccc6af91b70f1b0a7f1ed3feeb9919908e016e786f07a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "91c97575f17a890151d4369d4db8eac238065ac12d599ef653d71cd101f283fa", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_logging/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "34b333f698292015410bd882a4d51a90cc13a646c700e73eb147d38879c01fc0", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "62f5433f8d3768f6e5e47dcec5619ca6845b1f81e7713fd76a38b2a48d60e1f8", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e8acfa9923185a068ef01baf2eb44741ad8389eaba27ea4c7bd84cff77f88398", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1c8dd2914c0b158591608b89de65f9265d934b1b1e33bf57fc04d512539779e7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "93b3da41594bc121ae3c6b87fe1f754c7f5fd26d668e7e3686d1b86940e20709", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e01669b9f13511b087b2ad51e50f5ee86938ed61670a5558387eadb0cb4baffd", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f0246f4f95d07aabbf6b7d4cb63456c09a9dfb6ceaddf0e05fda7c89cd22ad23", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "635300d142fab4e09d4dde8ea90e315692ec651273954fb52c89cd845a523d43", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e05cfeebef6891e1a65d019af0ebb7ca954028ced9a54ea140eecf5d347ec83b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "251a5f3ac213ca3d75c420d1e3b830503e508d165299f4b182a248e53e1c0a20", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e642bafad1788ffa61c8604388a081ef73876d0a5e8509c6b4d5ededbe17cbd7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1702b4ff681d4c6def8b1d92cae49ef9f9e21b532dd37f4d0528365cd46ecae4", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6f9ad9c72f39ea8dae16fe03ce61f00eeed5fd66db19a6cfc97cd2e6c82e199a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b6d5e2a1bf4ab6643d482445246c483a5a1f233d58a3e519ab3d1e4e5f1c7f54", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "42b1ec8189889366c7683f5f53e5bb56773cd327f03a1f83881d8534922a331b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ac9318c93d45957c10152cfc6b6839cd878a4302b64ec826eb179762af3987ac", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "213b8cdff1a5eda24b21ffaf4aa71274804cbd202a068568a77eb14c4386696e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "31e1e090904f8375e906d65e0b4820fe5eb6701f3ab73acc5a9d0a7d81390ac5", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4dfe2434c4813417c87b759aaff819e903d3c63b5e46fba41463fa50e495b231", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "05af6b196f878e90415a5295351ade47b1ef8b2aa76aa0e6c215df87c1086ea3", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8f282bb563863de720f60a5e986b9f1b4e990aedfb791122d95c36907e1305ab", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/1", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "630e92488d76f1bda35b6e9d721ad8ff531579f4d63ec48f8ddf83ad211e3730", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a2ed6e2e9ba3726d6661ba7938c2a5bb607cce4e616fc0edb05e1e43d365e5a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2918b60cc15e5e96e5a47d8d62b5f232c9f1e5902cc94b5ff40912f9df134f4f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tests/cli/intent.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0ed0bda07bed6c6ef4dacedbbafca27a08f8c159d72791865988e0b106f6791c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0dbdf5fe860ce05a57488ed6b13376f22d5f42e2b7ce74c1f8984b970f1dcb68", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_vlan/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/templates", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/templates/config.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1af3e1f05d0e4cff24108d0b0ff02b3f323d843cd074d578128b2528e1fc445f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli/comment.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5f936a88a3aedd7e2993ed89ed6a95a2bf74dde1ea5065ca12b59295c2e79d0", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli/config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8e3c10773d2da12e06e21c1d84116620a6723a531f9723b8636f15cf79e525f4", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli/check_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f9f26d231409e78accee8377f346b8cada56c967cb346d1170a3be26a2d82507", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli/simple.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2147d964ad9ad848aacbd45eaf2004f710a4f575a08c9e99f7035e919867f015", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli/backup.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0d59389759725b69fad8d074b46169b6d6ba1dd449d00adf36e5f0ea3a9e71cb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli/save.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2a5450d1fd4c02d0487a12fd583711343c78489ff5c2e4203cfb493a70e255aa", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli_config", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4ff0285771a46551ca06270ebabec26c0def234a9ef731f64033a3e7eef75d5c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8e3dc4e968e2149e65f78bf511fd56927fb8a0deb33233b24f6205f38bd5d3d8", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c7ab56eab29c00cbac70193c2d3aa6ffa89ef863bb179383c9f9d80538e97122", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "34c53a74169c387d5f916913a0c89838197052ea46452bf090fdb45524864e74", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "563e54eb47da89dd3372811bb375782b08538bd778cfaed6abe80c0393ab33f2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_config/tasks/cli_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "85cf134edf2a993adbf49b5058b0f58ef2469b24252aec88e7769bf50e014357", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "385875e35231b20014cfd942c5f43e650af017c2e645b5228ca02c42f53cf89e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "34fc054682d6da4102230b30c0b5ad2ca2be81d765647818b9c19765c88ee2fc", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1bdd5dc5387a76923bb4e03f999c31169a1cd706fbef5628278be0c5d11210d9", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b92b23de0a589524e6fd4352cdfeefaefd78dde748612d8e2a907009b94a6aef", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bec70f5c7a2a933f69136fdb7aec0864f41bc63669d0a0c2caacfe4c8204e5d8", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bd6d03811124544a568cba38cff3a765afa39d91a49a24a9cec66c94b69cb169", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d6e0f6f93447e330e0ef054e4c265165631cfd6934d441e421d23dd3b579f644", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e803c42458226f83f70043dede2e6c164b3e6a3477214dd58b415fb12e15423c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "68b164f3112ab0e2c76bf95580e944c076fd57f5d78a5bfcebf7c9f5a1bf277b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bead8b03b8cd8da640df7d1bc47389119cdc775161e08aae5ee10955955213c6", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c3c6809526ddde7c894216f7a79c0c78d659b54abb0d87d74ac5fcafd33b09cc", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ec6f205d7cea4c28fe23a3663bdd05f9ff5fac22406a4ba6a255950ad7735c4d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ced7f174d58c382e01fb9029630b69773b19369b1e5aab8a21c466d59c3413a7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "aa8565a8b8cc003c3a12f977c0e7e544cbcb4bf9ae674ccf32191c43efafdf7d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interfaces/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b7e6ec08fc517764d24a30e68ff33ae6498f076ff31c54fcbab942f6b6d51da7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27f80695b4b2c45944d6e63e52b68248fef98c7a529e91f023ab482d0820d4f1", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d763aa81ca680074ecb27b6baca8ac3f1c5921b8bba2f3b86bc2cc697ad40a5b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7b1c098dcc79e52f5cb1b92467f4d0fbf25116132f527a5927397b5907d0d020", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5ede8994550ca83c94be9a58efed9488d07ea035a8e3a90741576a6b428f067", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8dcfb0a5543d81a32d210a83239e97f646ddfab05b51654b0e7244b44bbdef84", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eda7d7544427821b30bd24bf1775aab0ba3d204756911eeb23d8b263c6a15592", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c04a2ea1273d4425cb27d4e5e04ab82ce60f1ecbb70a62e19bc246fa88d58a7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7d0e6b8a457f22fc1324d02d452a934c3d6f528656490600dc649ea3d7e32e0b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d009aa8f722d7708d17f868558c75ff33f68c735d193c8beda1213988af7b61c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "774f9a26bc52555b607e81227923b6eee3541f9f5fbf0a4912d9c67dd76d93e5", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e7eabfc7ac634a3cf2fdc5d754d23dba7be7844803561d5e0a858a6ad145c2ad", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5a5f4637a62124f8b170b543ffdc2ba3878973e785af3ed6ede394ff5844dd1f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b7f9ef6e404eba9b0b19c078c0dbcf6f5b450b9de07d0fbe92a560fdfd417e90", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv2/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e8acfa9923185a068ef01baf2eb44741ad8389eaba27ea4c7bd84cff77f88398", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eee04e25d9a4eef83ceeaefeb26665e96c3a0e7430b478318d3345bcf60f0f6f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "67378c660ff17115bc81566c00186bdf351dc2930c11f56863ea1a8a1130be3c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c4064d2d5a49ce1135eb2384f6500013e99360b3a77e7628c9696e3224b5a26f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c32039c7ae7211bae2a299a73d0d04ed18a338dde9d33839d6ed3d22bf289306", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6a7996f74d231e38c4ff59fbc35d45855dd3e48cf16e6c585b92faff8a633669", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4f2d7f68df100ad9a627dde1e7d36aa36b832b8635a54f7ef1bcb90ab5ef2663", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8508b306a7eaaaf167f30fd0c93b1ca63b96a3a6f3bebe0dd1d4d01f508b3406", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8b8bde54396f615629746ea18304097b84a5a292df3a0a43a9d9310ed05ef4cf", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "252988309c7e447e0a77b5ab2a0ab267a3fe824fb85dab60b129726143b2924d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eeb71127052d4175e52c1e232f885842efa9db6aa492ee290144ef494e2ffb4e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "412dd2fa8979e049424ca876a01cd81b717872d073af1ff688d0d116775afc50", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "05884bde7e8abddc2015ff9165858cf27f0daf323429c0f517fde4a152f23b90", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f10ad8afa2beb685b3e68d8409f5a0e5c0bd004581c7f5f8592ee5a9e1f20a85", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a2ed6e2e9ba3726d6661ba7938c2a5bb607cce4e616fc0edb05e1e43d365e5a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7188e3020c0f3343a9936308f2be5271e758c5407de7818265c26ce1338d5884", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tests/cli/net_system.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "88daf0094eb3678edb0b75944efd7e03bbde5230068805818ff659adebada9eb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_system/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d4cd0c2e9cb86a31d79f26b83555f3c1cbcfdad0431a842bb09e918b2efa93f1", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6f0df337323b9cc96c002e46563a026559dfcbf9b78b1f7b76428870cd50314f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ae8f6501636e2b2a1d45615068784da4e319f80a16ee3e79a4a3019111aebb3b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c4f79e779b0dc5f86df652d8ed664c2a05934cbfecf2e543a2055b2cbc14ff5f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "18597981d66eb42ee34916fbd8f05c47b07b824ebca67b8f52b3a1b1f0ea9a7b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8a75d64c1253d907944562ed76c0d1e4ca0aa21ecb97de97dc556b8c7b908b18", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "59ac0817529e5e28c172399077913c684719aa616d21e6a10e65121d9915052c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a8faf5674a91e0bf9727d918bd1fd1a1322f2fe483ed6786ae8faf6e869a8f47", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a9b36b7be26ea88d103609d69c1a051f2d25ea84b1335a931a346d2622392d6", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1c30311e76c51e59a27c298f5a8461c17c51b478e6461ccd592aa19658eed470", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d50b0b272492592e72a81cd2c832ac474f3b75a10aa9e22f46aaae447a3f805f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "403b25c08f94a477ba272cdc365e46c73052ce1e1b41afe97c90beb0d4454e59", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "864608785841033c7ab9d77d18480cfdde1de4707f64a86fbc413f7521da064c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/meta/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "90528688ff4d0b98df05918adb9b9740dfcc14e9c9a544c2f7507613d21e98a0", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interfaces/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "edce6da6784dcac1ebda51e551bc4d2a3fa3fef06a66f157a46bc7244de34d23", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "99c0b62a623a050298b525bdaca0620b8db3ea3d031a1511251db57a02b6d54d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0092eeb7be043cea4b610a19b624d89112fac90220401f793e2496c7558a702a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "22a09a8f2c8b80c5c6ee64dbc833925ed4a094e46eb3e7ef493bf74372279741", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d1aa21a1783c5f2a572b2cd7694e8b5e178358d02ab2b5fe4353e203bcec9cd0", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e382618b83493fa29dbdae5764dfebad3650020c840677e07a7e3d52a8c349ec", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f76b0b49707f1f0b5d5e911252081d8fab4e9d354f0c815d3d9ae285c0985590", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "34650122cf1f1af4b9644f62475214a475026b629ccdadcd558cfa68494bd2f7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "002fc15caa87b1c38fb7be1b418929eaec0b78894768f4bc0694dfec5ec31673", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27a7a06d0bcc81b578e9d34bbe11904018859e7605f3db37abd39d07b1c40a52", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3ce33ce1a527f427b43adcdcd12ae40a770555ed988fff5ce2189d19d37a12a5", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ccbd324d31e6a9218f25f74cbe953b00b9aca35ab06dcf4679539599832c77df", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a256fc9f3edc6c5c3bfdb779cc06173548affee2bce3e6676e6ccbca162a5e70", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6435b83e1812dc2fad30e5857584de7788f0e540cb2cf551e6ef5a5aebce7607", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a947fe698399871b45e3d5b8202a2721d4ba6a7dc9ed58ef7681e72aab21a098", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_interfaces/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8b5909b8643b5b5ac6bd072c383b4f760b381a0af4477c1afae2d0b19d854cab", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "109b8111963b6958d08d479736cb3444f0fad2e561bf26e9ff7c752b680c42e7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a98e867f78f0a9ee7eacd8b463c469ac3c676a18af0dd3509dc52a49c194ad53", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "686c8cfd6f00fee1383a8dd185cba8bd4f0809cb9926b69cf975e2ba0f28a8b0", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddad905e6e266d216cc14a6a72c385db6a2ba496f18805c879625902a9078fbc", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f561ffdb8a927af1fadce120d727add3316f60e65d2fe5429d5c1bb86838fd74", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f3a83be6ef6b00a93a6c4fcb910fd0af8741eea9f7296d3249edcfc668464678", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5d6535ce0d97277e8f7c56411aef9b1dd850eb7dd3c823d7d01f2b882a85017b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "11257cf00428207d8b309964030959ed92746d0b9fc571d7ee2e7d308fe3c206", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5b2f1e922086c1ee292afc009d4b16ae11ddc724daf86b9901f8c63710e42e1", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1e2d5a2060929bbfb176d5dd3d71132ebf8e994730851d7acf784218efea91ad", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "34708b4f383f2f9c2051c2e0743c5941aaf77fdaf527046b3c88577d70e310a9", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "71c1264780ed68bc3fb03241b473500f4f829f7b2df73a8fa1631e6ec132699b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "66a59c87d57b71ddf4b74ffc88eb4ee0af16132d9d3e72c16388263d262c9135", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d5a7be540e04782bcca4808dff3d29752f743ce7e2e5da79d62a695a66bb8270", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "175aea4e5364bd95aac0c41e974aa6af2662d9901525a1beae12fa7adc0f14cb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lag_interfaces/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "59612db65b1ab7ccf74c9ae6e32b39a692e7f83732d588b1fec6b52c58e55e2e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a29684f6009d9ea14e39435c7b39b9c28762580ad1d698169d08cce5da32b1e2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_route/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2925c3c928ae98807e2b75e73da4a20e9fa1ef7ceab3e2e6f8045c21daa37cb1", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5ba767d9b814faa9db8451d8719a7f835fe1f0817e4575f8b005c2a6f02a93d6", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6b1d91a33c59bb91193ac9b2835d4aba0608429b1f8b984750362a0a5dbac679", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_banner/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cc5c48b5d0ef0cc685394c9ad9ebb78056ef6c95e11cff81a70ee0678c31890c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a045c087931eea0e74153d8773230641d3fe3988685e2a915bfd28396c8bac83", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_linkagg/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "36a1aaece12e47beb5a2741deaad6e68c94ebfc7401d37609e0fb071ffa19fc2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0c4f5455fec2c4d8451835d05f341e889ac7c16fb98640a198b7c0c4ea5ad4a8", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_interface/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_vyos_tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_vyos_tests/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/prepare_vyos_tests/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a4f9a85ad709d3a4b872439adf4aca95a87ae1adfb0c7923b89fce3461b44d5b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c6ee716708e59182c8420ea78ab1298551e365ae950dc43464564fbd26a6bcc", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_l3_interface/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9256c3a880eb0f71684a208f0d369169996303fbbc9cb19f5122fc7da10e8169", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d7fa686a0cc3b72a4e78b3b1f21fd5d5ab558f8f8bf99a5ebb11772abbf1dd2d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "871797cd77c8dce388ff49623211e81a0f5ab04f5b0de991cc6fd4c025596a57", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "540964c919dbecfeccc02e23035356cf49ee2e1f1b95773b04ddde193810a416", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f3b45eed7cf392affb2981bbc0503a83221e3d70ab123a45b3b04ed42b6cf5d9", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "53f58f36a0cc51659c43c847ec699b06f0fdc9e91e9015d5d958b86ad7fc14f2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a756bf3f4a14d8497073748c6a0e9ff59cfe68bcea9a1f86090692449a5a86fc", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5ea2ae90a2496e16c3bd986c078fad6e5616d5e0bf2b247922401a64dc70b2cc", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "30fe26774ed94a3d6957298e2ac9ca557b9dabf9b93da6290f2668a99c55203e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "47c3d13e48c890c9adaeaa7d12285f474a1ec782b83f80de1b0eb0380d23907a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "24bda94462eeef10a1b55ac9accd80d5bde111037204db31e044a03956623e2e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6c8f0c2d9a227ecc45ddfe914a8e838fd22d627ec7968b46533f3b51f5b396a7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a2ed6e2e9ba3726d6661ba7938c2a5bb607cce4e616fc0edb05e1e43d365e5a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp_global/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "21b5328e5f160094f9f38dc52c7442e65ad325de7681f45234211c1326f47f80", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4641a606312b273553e473343ad4e0a346fb73699efecde119b8289ba836ce41", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "de1b2c7626375f902f3b8ed8734a0da6eca639dcbf06f4e92e3fc11b8187d305", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e16560f9b431ede3c27fb23f784e82db64dfa5952e77f6b6e0696231244f2ad2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5d724dfcab79dce098f8fc0de2769d86573d9fab285add3601c57f690fd30440", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0938b70cd293751b54cba1f1019e2e91788da20f705d3fc7f175eb63988618e5", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e0ee1c7a9a42e4c73107a0723381b562a45b1bd260063a7fc5c23fc9f7128ad3", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e5f657c42a38d5169f05450c606393dd1fc783a75d16e8cfebb6c1141648fc89", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3ed61ca7a947d04744101771b27ef21b13c6fca9e45ff6ef2af0eef1347bcfb0", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "06bce329ef76fff5da65e5bc0c72f71714698d9cba3edbfb76c1ec599fa8bef7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "70d716a4ca93aa89cc7acc63251b25bb5aa28459ae374f549ba617b9fe8642f9", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6932d677de57140432ce894eb0f585b14189a12147c3d70f86ca14450339629b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e2183348f557548902494e62c03c625fb8deba37213d41c4f3f4fb2a489ab77b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7106b82b54fa4b494bff367d6b21dbd79df31ba0c1ef89f6d8ed9bac18dafeaf", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_ospfv3/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5cfd90e0dca23370c46fa3dc53616810de2021f882848c3af6e107dab50a5f7b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1c6ca1721b0ab2aed6b832dbd7f3edec86f4e5fe8e4ccfff831f8638e6e1310c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbc6fe6fd7cbe9f01ee34cfb0a08bcbd0a0dc22b7d54d6285ac89f417a31e1ad", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_facts/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3a1ddfaa0116c374ab2f902270e6862a1bf565b0282fe4208c5425ccac94b16a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "40c05ab6a006612357b7899089adbb780edca6320ef7e0e869932ef6b3470980", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d93454f8ce3ef3397542d87cf5d57bede759ab2834fb343c5ac4de43ec146395", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6e9c32b4b823aee215007da91529f8a61fd3786939747d2e26842ce45b12504a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "de9e51518d631db285e6c03b6b95ae657e9a9597914835695deb356a629ccd26", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f03ba864eaac5d355f58cc423c6ef1c67ea162bd80d413e5a094adcb5def4f52", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e548c0397aa54b111ed9f4e5a50c3488cda267dd94ad81541a59a52b1954a66", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9cf2965c53afa86db7915281a598de7e891de5a68438a3ec3681c3de60931467", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0783889d0fc52cbac755fb2e7adde7e8813243549b82391e725e550610de1870", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "acb7ca6a73d7e1402e17a58981bd7098505fdded2074756a89096bc26804656b", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a8ab120e5bd9294e99936490342488632b1609c10f374997a3e8b187f08dc0a6", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "da1a829a7daa65cf7e785ed8d07de4fc70509da335c8573288b562f5d00cc34c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0f74e0f84512fdbfd63305609e1d0d3c47ee89eb02bff585427bf9378cf93533", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8ce6337664b7baca8e7366f2d3f56c8b9ce2648c8378b9caf407568ad319bd81", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bc92bf097a7c145ed31cdf00bcfe22842855df0da9820b0283283f949cc27394", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a2ed6e2e9ba3726d6661ba7938c2a5bb607cce4e616fc0edb05e1e43d365e5a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_rules/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b9098b2df992cc04fe3de98d5d4b1c972e8258f11639062dd8ae94954c602a93", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f6876cfb6ef092feae9859f52e9c6c92aa642b0b080f531f65db8b696052f609", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_lldp/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "61247bf1b2d932b7a26d94b578243d5a13a0becb01ca224a0a5708ac157b00dd", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "30242d60a89851b07a7a02567262cc5915c6ee02b533a9529f2de7ec46c01b8c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6ae8d1bc5fdaa3ed481dbaf3c68616ef45d1edfeabe89650e44f3a375f71515c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9eed03819bc034f6199f03f41b58f89ce7da91cb80350a041ac77a4374bf98fe", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "05649fbcec72bb023295e844a4f4efe214e7cf415058bbc4633678e862d3df65", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bd7cfadb2806c48bc726c4b8963478b1edd52dba78d3b728b3d0ab83d7a90e67", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9437f66dbd18283bf716ff325f2990fcabf8518aac00266d1cfd622926589a44", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7d7585f2c0910617ab40c3920e55d73c8e54f2b8894f43b2ff566939d8dd9b75", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b8b4071964db02d28353cafba273779cc27ddd4907f6fd073c34a73a8ffd5a1a", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ff8a4ed6bbeadfc6d9e05b89f5b37562a19389628483609d6c0c0099b7e96728", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f2f35f1858add024d250e435ef9ff779f285354f14fd23d706c6d08cea4ac2ce", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "aef6061f0775993d318c064440f87a214e812687255a6fce43e6d8c7668f8b30", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7aeab591c30ecc37f7cd1b9d7151640811daf4cb922d8f190c3c68ef84e5d7d7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "27b07d86cdd3068f41e5435bbd7baf4f664db35af1f26c498c08dce6703b2334", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_firewall_global/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli/cli_command.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b6e82d0dea2aac35a289975f88bb5bff3bdcea02ed4bb1364d86afdaa5382c84", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli/output.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "be7ce5467615bdf4dee0260b4442ed24619d36f22f9bb0035920054d956ccbf2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli/invalid.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "74d19397938de2fece4d693bf7534d6a0bdd2e3c88c22fecbc165728e68caa08", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli/timeout.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c8a934cff26c1d1ec8d30e41660cc6694b63a60ee061a5c649a9f540cbc3247e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cc73de3aa5078a86d81e045017eddac900374c8de0a5108d8c3fddda9a9e91d2", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/cli/contains.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ab62b27c0fc3126c9acc3d4b7b245ebd0f5c584056e7ef0f717fd7f6f1017d90", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c46f60dd3031700517b85c954db4277a59feaa8d29ef4649197e40bfc6ed8a19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbc6fe6fd7cbe9f01ee34cfb0a08bcbd0a0dc22b7d54d6285ac89f417a31e1ad", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_command/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9be8fe05117c68e2469329964d07b8cd6054ee1a8898c95b02980e63f22d9b23", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "da22a3c5e19dea15b219e0ac3f548c3daa03bda65126394bef7160538bd25877", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "253c10e9951cc4cf1f2c8fbf954faa6d5cb04637fbb4fdc0dc3474e87a3dadf8", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8a0193f8a346eadc1799ca949cc3539743659d4a2ea1bb6d4af01c6f7db25562", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4fdeadd0e296502b3990195091abb59bc830b0d0f7a06b756de5eb28352b995f", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "486def34fd1521aa45cbf9eb51478b8582e251e11d4d2d795f04ea8c38d6420c", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "20e6d0db32a4d7aa621a9b22f3c6310765fa8eb4d2c42cadc5588bec0d68a3db", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6e04c4ef3996f517c90f79ad7b4c3688dd2c3fb508e2e75f2f782ef6b80c9908", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ecbb6ccb3b1e5ef2e3f7da9c05f6d81ccf284359d3ed5cc6024923d7c775b151", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "62a5ec5fc949f34451d72a86ed2bcc325381e666bddbb9d388e3a8ce02e15014", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "73bbb2f2ba7fcf49d3b8122479d6ee8b533289c946f4610af570ca896e13b0ed", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5fd156b278185c274b6b579e938e099f338ed13ad04782c0f17675b11a465451", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fd6181c54f718909ec021ae9b02e0564f6fc0c3121e8826ec0a3bd755e4141e1", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/redirection", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/redirection/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "229b8976ae4954d01be29e1586365ae2809378accf2334eda42bad0ae69987d3", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "10065b058aa0b1471103d86b79c083cae0603eb6dda9b38c07af77c6cf22ef19", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/vars", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/vars/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "186029afc4df1670db6c7b4a539cfe2f674955614639c06291dd444881fb7022", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/meta/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "37bb266ed396b0deedfadc54a835f15862266232e9148bbebf537367a72fbba7", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9c7a04f67f78ee48d4cd68a3fc7ec07e8736cf82ecdca0f9600eb2fbb621d390", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cdaff5f4b4b2ca8ba06898e9bdcc3fdd454f5e29309f6ea9261714ac30a8b528", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13850d7e7fbc194e2031c3c03a2736113fbb9099b6f5c0d26dddf71cce53c62d", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_static_routes/tasks/redirection.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7503f7c9f1756901e21cb39314a797b73217348e39e0911b5583f9cadea1ec71", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tests/cli", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tests/cli/basic.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c4a2c376b9873e7288af220232d746696c00c0b306a04e35f3e6a564f2f33463", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tests/cli/auth.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6c6d7267368b97fd3d93042da03dc8c2fbe550981019283c7abc2f392bc4d001", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/defaults", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/defaults/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "126c357f960d8408c7d5e4c3bdc05e2e5e898330e173a4f56f72240f10aae4bb", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ddf85efe18296ec17d890e6539366e7ae535082e3ddb5e795f3bbb3de8e9625e", + "format": 1 + }, + { + "name": "tests/integration/targets/vyos_user/tasks/cli.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cbd846541920f944a49312dde34a352135711c806b04c10fca3e4ecac6470d10", + "format": 1 + }, + { + "name": "tox.ini", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c6e94fc72827b917d55ef15386cbe48fc9eca81755aed8f532d8da97a0be3483", + "format": 1 + }, + { + "name": "bindep.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "80645079eb025b3a905b4775ac545d080a3d7d35d537c31e04f7197c94315ab5", + "format": 1 + }, + { + "name": ".yamllint", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "827ef9e031ecdcaf137be239d33ef93fcbbc3611cbb6b30b0e507d0e03373d0e", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e336b4907ebd473182176142e30201b55ef2d37527556fc5198b03971ab545bb", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "13dd6e43c5cec36bba6486734a7b7bde8be5ff1a35eb347ce8750b92f4dde3d4", + "format": 1 + }, + { + "name": "requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "883b106f13b0c6536f55619685ddca25968b4167dedb12e08fa37c93f4c63b25", + "format": 1 + }, + { + "name": "docs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_firewall_global_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fa1073c7092d4e572d5da228bc21b8a918807a355e678951eb504531e7b5e074", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_user_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8c2f982d50efe75a3c0a66e91c9599526841866f90848d35075755178f5efe03", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_logging_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e6c124e24feaf77d95461c3ef3213a5797443b256878cb6dbdb4a543cc941e95", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_vlan_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c7c6635a9830db7282ac279a20abe57a66d26bcf2a67028a743faaa286d9f31a", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_lldp_interface_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c06c94d190fd22f7a4ba57ba05990bdc1a52fc64ec0b1e209a35d8b907ddb8b0", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_ospfv2_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1235f342f86a2fa615a483395b8fc5a7b032d5b845c71a6b8da9afbccd2511ae", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_lag_interfaces_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "831ef64d365d85fc05e63b7010533d92cef82630c2baad2c410c5a400ebb29e4", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_ospf_interfaces_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "528c522cf4aca40eb156bff678675dd142da7662c0ad7e157529945ff4ac8853", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_system_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f2d2fea8461859ea4de17c89ce72d820d55ee37bf3d5d990339fb37e6b3ae418", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_interfaces_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4a48735799a1b797caadfa327cc023ab28f2e2ee93a6893bb5be3ba47aec34eb", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_static_routes_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "98b83b0922096beb6dc4d7f4a14ca43e56b10fe34fe517d7d5f456e81d8f20ac", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_command_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ed3e60667fc989f020831dd36f5a5f89212c4ea642c0916ea0cc5d04137f6f9c", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_firewall_rules_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cfe426c4f2a17a8cb61e9c7213b25bb577c9a10d3b93fbf0999596da69527e42", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_lldp_global_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d18478c3ef85afdb55b10c615cf017681a10d3c8eb681830258527318f833de8", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_interface_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "50be9ffb107813f92ff264549ecbc4aba4a9720c48ff7409c8677febfff20603", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_config_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ad40efeae73c7ded5d8bda0d2a868ca7cb4ab9defc13d888178410d20a8b0530", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_ospfv3_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "df46e43aa57a49de1fb8f15b212cff06515284f82a7d79002fc4973f01f21f61", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_facts_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2919196bb8f751e6d5671bcfe87932ffd1fe8c234bde97796e55be1ba1d5ff08", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_cliconf.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5174575305c40c950273180f04fd1e62ff92f5aa794a0200422b444b6a724c3", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_l3_interface_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7f569f47c36fe52c6a0c1e514e3ece4dd243a1d2de837a6f1d7d20fd227fb78c", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_ping_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "46bf27281992e8de844619f4b82617112833292a5e67dc197c15c42cf66cd275", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_firewall_interfaces_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9cab7001740eb3b83b6fadd38e1d2f131b592826fce52cf67d82267b45174bd9", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_l3_interfaces_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "23e3a79b10fbbed478381e3bdcab8f7021b11e92d575bee8ef5462fc15de0ddd", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_static_route_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b2b6e9e0e129d22842f0ed4be9ec2710f2d6359c245447c7b50a857e00ffb4b8", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_lldp_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e2de1ea700350f22aae098d98c646eb5a9628983dc90b1ff260f22634c2b9c1", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_linkagg_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "47babe6df07402c91becb6e42e32952263606a4aa17b3a1556c7ccfc9afa5d2b", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_banner_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f762b2095921a2ee46db75d7645bc22ac75ee55af4fa3193579ebd4a8655cb6d", + "format": 1 + }, + { + "name": "docs/vyos.vyos.vyos_lldp_interfaces_module.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fb80d3f496215ef2ac4d3f94e61d965d526cf4852581f28722c7d4d1d6dea43b", + "format": 1 + } + ], + "format": 1 +}
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/LICENSE b/collections-debian-merged/ansible_collections/vyos/vyos/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>. diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/MANIFEST.json b/collections-debian-merged/ansible_collections/vyos/vyos/MANIFEST.json new file mode 100644 index 00000000..cba682ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/MANIFEST.json @@ -0,0 +1,33 @@ +{ + "collection_info": { + "namespace": "vyos", + "name": "vyos", + "version": "1.1.1", + "authors": [ + "Ansible Network Community (ansible-network)" + ], + "readme": "README.md", + "tags": [ + "vyos", + "networking" + ], + "description": "Ansible Network Collection for VYOS devices.", + "license": [], + "license_file": "LICENSE", + "dependencies": { + "ansible.netcommon": "*" + }, + "repository": "https://github.com/ansible-collections/vyos.vyos", + "documentation": null, + "homepage": null, + "issues": null + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bfa11557fbfc72866a49d77272333d305fa8c60879beb3e12756d41c6873ef94", + "format": 1 + }, + "format": 1 +}
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/README.md b/collections-debian-merged/ansible_collections/vyos/vyos/README.md new file mode 100644 index 00000000..d771dd70 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/README.md @@ -0,0 +1,173 @@ + + +# VyOS Collection +[![CI](https://zuul-ci.org/gated.svg)](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/vyos) <!--[![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/vyos)](https://codecov.io/gh/ansible-collections/vyos)--> + +The Ansible VyOS collection includes a variety of Ansible content to help automate the management of VyOS network appliances. + +This collection has been tested against VyOS 1.1.8 (helium). + +<!--start requires_ansible--> +## Ansible version compatibility + +This collection has been tested against following Ansible versions: **>=2.9.10,<2.11**. + +Plugins and modules within a collection may be tested with only specific Ansible versions. +A collection may contain metadata that identifies these versions. +PEP440 is the schema used to describe the versions of Ansible. +<!--end requires_ansible--> + + +### Supported connections +The VyOS collection supports ``network_cli`` connections. + +## Included content + +<!--start collection content--> +### Cliconf plugins +Name | Description +--- | --- +[vyos.vyos.vyos](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_cliconf.rst)|Use vyos cliconf to run command on VyOS platform + +### Filter plugins +Name | Description +--- | --- + +### Modules +Name | Description +--- | --- +[vyos.vyos.vyos_banner](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_banner_module.rst)|Manage multiline banners on VyOS devices +[vyos.vyos.vyos_command](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_command_module.rst)|Run one or more commands on VyOS devices +[vyos.vyos.vyos_config](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_config_module.rst)|Manage VyOS configuration on remote device +[vyos.vyos.vyos_facts](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_facts_module.rst)|Get facts about vyos devices. +[vyos.vyos.vyos_firewall_global](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_firewall_global_module.rst)|FIREWALL global resource module +[vyos.vyos.vyos_firewall_interfaces](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_firewall_interfaces_module.rst)|FIREWALL interfaces resource module +[vyos.vyos.vyos_firewall_rules](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_firewall_rules_module.rst)|FIREWALL rules resource module +[vyos.vyos.vyos_interface](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_interface_module.rst)|(deprecated, removed after 2022-06-01) Manage Interface on VyOS network devices +[vyos.vyos.vyos_interfaces](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_interfaces_module.rst)|Interfaces resource module +[vyos.vyos.vyos_l3_interface](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_l3_interface_module.rst)|(deprecated, removed after 2022-06-01) Manage L3 interfaces on VyOS network devices +[vyos.vyos.vyos_l3_interfaces](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_l3_interfaces_module.rst)|L3 interfaces resource module +[vyos.vyos.vyos_lag_interfaces](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_lag_interfaces_module.rst)|LAG interfaces resource module +[vyos.vyos.vyos_linkagg](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_linkagg_module.rst)|(deprecated, removed after 2022-06-01) Manage link aggregation groups on VyOS network devices +[vyos.vyos.vyos_lldp](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_lldp_module.rst)|(deprecated, removed after 2022-06-01) Manage LLDP configuration on VyOS network devices +[vyos.vyos.vyos_lldp_global](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_lldp_global_module.rst)|LLDP global resource module +[vyos.vyos.vyos_lldp_interface](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_lldp_interface_module.rst)|(deprecated, removed after 2022-06-01) Manage LLDP interfaces configuration on VyOS network devices +[vyos.vyos.vyos_lldp_interfaces](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_lldp_interfaces_module.rst)|LLDP interfaces resource module +[vyos.vyos.vyos_logging](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_logging_module.rst)|Manage logging on network devices +[vyos.vyos.vyos_ospf_interfaces](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_ospf_interfaces_module.rst)|OSPF Interfaces Resource Module. +[vyos.vyos.vyos_ospfv2](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_ospfv2_module.rst)|OSPFv2 resource module +[vyos.vyos.vyos_ospfv3](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_ospfv3_module.rst)|OSPFV3 resource module +[vyos.vyos.vyos_ping](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_ping_module.rst)|Tests reachability using ping from VyOS network devices +[vyos.vyos.vyos_static_route](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_static_route_module.rst)|(deprecated, removed after 2022-06-01) Manage static IP routes on Vyatta VyOS network devices +[vyos.vyos.vyos_static_routes](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_static_routes_module.rst)|Static routes resource module +[vyos.vyos.vyos_system](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_system_module.rst)|Run `set system` commands on VyOS devices +[vyos.vyos.vyos_user](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_user_module.rst)|Manage the collection of local users on VyOS device +[vyos.vyos.vyos_vlan](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_vlan_module.rst)|Manage VLANs on VyOS network devices + +### Inventory plugins +Name | Description +--- | --- + +<!--end collection content--> + +Click the ``Content`` button to see the list of content included in this collection. + +## Installing this collection + +You can install the VyOS collection with the Ansible Galaxy CLI: + + ansible-galaxy collection install vyos.vyos + +You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format: + +```yaml +--- +collections: + - name: vyos.vyos +``` +## Using this collection + + +This collection includes [network resource modules](https://docs.ansible.com/ansible/latest/network/user_guide/network_resource_modules.html). + +### Using modules from the VyOS collection in your playbooks + +You can call modules by their Fully Qualified Collection Namespace (FQCN), such as `vyos.vyos.vyos_static_routes`. +The following example task replaces configuration changes in the existing configuration on a VyOS network device, using the FQCN: + +```yaml +--- + - name: Replace device configurations of listed static routes with provided + configurations + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 192.0.2.7 + + - forward_router_address: 192.0.2.8 + + - forward_router_address: 192.0.2.9 + state: replaced +``` + +**NOTE**: For Ansible 2.9, you may not see deprecation warnings when you run your playbooks with this collection. Use this documentation to track when a module is deprecated. + + + +### See Also: + +* [VyOS Platform Options](https://docs.ansible.com/ansible/latest/network/user_guide/platform_vyos.html) +* [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details. + +## Contributing to this collection + +We welcome community contributions to this collection. If you find problems, please open an issue or create a PR against the [VyOS collection repository](https://github.com/ansible-collections/vyos). See [Contributing to Ansible-maintained collections](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html#contributing-maintained-collections) for complete details. + +You can also join us on: + +- Freenode IRC - ``#ansible-network`` Freenode channel +- Slack - https://ansiblenetwork.slack.com + +See the [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html) for details on contributing to Ansible. + +### Code of Conduct +This collection follows the Ansible project's +[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html). +Please read and familiarize yourself with this document. + + +## Changelogs +<!--Add a link to a changelog.md file or an external docsite to cover this information. --> + +## Release notes + +Release notes are available [here](https://github.com/ansible-collections/vyos.vyos/blob/main/changelogs/CHANGELOG.rst). + +## Roadmap + +<!-- Optional. Include the roadmap for this collection, and the proposed release/versioning strategy so users can anticipate the upgrade/update cycle. --> + +## More information + +- [Ansible network resources](https://docs.ansible.com/ansible/latest/network/getting_started/network_resources.html) +- [Ansible Collection overview](https://github.com/ansible-collections/overview) +- [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html) +- [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html) +- [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html) + +## Licensing + +GNU General Public License v3.0 or later. + +See [LICENSE](https://www.gnu.org/licenses/gpl-3.0.txt) to see the full text. diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/bindep.txt b/collections-debian-merged/ansible_collections/vyos/vyos/bindep.txt new file mode 100644 index 00000000..ba9c980f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/bindep.txt @@ -0,0 +1,6 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +gcc-c++ [doc test platform:rpm] +python3-devel [test platform:rpm] +python3 [test platform:rpm] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/CHANGELOG.rst b/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/CHANGELOG.rst new file mode 100644 index 00000000..f0ec9956 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/CHANGELOG.rst @@ -0,0 +1,122 @@ +============================= +Vyos Collection Release Notes +============================= + +.. contents:: Topics + + +v1.1.1 +====== + +Bugfixes +-------- + +- Add version key to galaxy.yaml to work around ansible-galaxy bug +- Enable configuring an interface which is not present in the running config. +- vyos_config - Only process src files as commands when they actually contain commands. This fixes an issue were the whitespace preceding a configuration key named 'set' was stripped, tripping up the parser. + +v1.1.0 +====== + +Minor Changes +------------- + +- Added ospf_interfaces resource module. + +New Modules +----------- + +- vyos_ospf_interfaces - OSPF Interfaces resource module + +v1.0.5 +====== + +Bugfixes +-------- + +- Added openvpn vtu interface support. +- Update network integration auth timeout for connection local. +- terminal plugin - Overhaul ansi_re to remove more escape sequences + +v1.0.4 +====== + +Minor Changes +------------- + +- Moved intent testcases from integration suite to unit tests. +- Reformatted files with latest version of Black (20.8b1). + +v1.0.3 +====== + +Release Summary +--------------- + +- Rereleasing 1.0.2 with updated changelog. + +v1.0.2 +====== + +Minor Changes +------------- + +- Fixed the typo in the modulename of ospfv2 and ospfv3 unit tests. +- Updated docs. +- terminal plugin - Added additional escape sequence to be removed from terminal output. + +Bugfixes +-------- + +- Added workaround to avoid set_fact dynamically assigning value. This behavior seems to have been broken after ansible2.9. +- Make `src`, `backup` and `backup_options` in vyos_config work when module alias is used (https://github.com/ansible-collections/vyos.vyos/pull/67). +- vyos_config - fixed issue where config could be saved while in check mode (https://github.com/ansible-collections/vyos.vyos/pull/53) + +v1.0.1 +====== + +Minor Changes +------------- + +- Add doc plugin fixes (https://github.com/ansible-collections/vyos.vyos/pull/51) + +v1.0.0 +====== + +New Plugins +----------- + +Cliconf +~~~~~~~ + +- vyos - Use vyos cliconf to run command on VyOS platform + +New Modules +----------- + +- vyos_banner - Manage multiline banners on VyOS devices +- vyos_command - Run one or more commands on VyOS devices +- vyos_config - Manage VyOS configuration on remote device +- vyos_facts - Get facts about vyos devices. +- vyos_firewall_global - FIREWALL global resource module +- vyos_firewall_interfaces - FIREWALL interfaces resource module +- vyos_firewall_rules - FIREWALL rules resource module +- vyos_interface - (deprecated, removed after 2022-06-01) Manage Interface on VyOS network devices +- vyos_interfaces - Interfaces resource module +- vyos_l3_interface - (deprecated, removed after 2022-06-01) Manage L3 interfaces on VyOS network devices +- vyos_l3_interfaces - L3 interfaces resource module +- vyos_lag_interfaces - LAG interfaces resource module +- vyos_linkagg - (deprecated, removed after 2022-06-01) Manage link aggregation groups on VyOS network devices +- vyos_lldp - (deprecated, removed after 2022-06-01) Manage LLDP configuration on VyOS network devices +- vyos_lldp_global - LLDP global resource module +- vyos_lldp_interface - (deprecated, removed after 2022-06-01) Manage LLDP interfaces configuration on VyOS network devices +- vyos_lldp_interfaces - LLDP interfaces resource module +- vyos_logging - Manage logging on network devices +- vyos_ospfv2 - OSPFv2 resource module +- vyos_ospfv3 - OSPFV3 resource module +- vyos_ping - Tests reachability using ping from VyOS network devices +- vyos_static_route - (deprecated, removed after 2022-06-01) Manage static IP routes on Vyatta VyOS network devices +- vyos_static_routes - Static routes resource module +- vyos_system - Run `set system` commands on VyOS devices +- vyos_user - Manage the collection of local users on VyOS device +- vyos_vlan - Manage VLANs on VyOS network devices diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/changelog.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/changelog.yaml new file mode 100644 index 00000000..e1b3bc64 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/changelog.yaml @@ -0,0 +1,174 @@ +ancestor: null +releases: + 1.0.0: + modules: + - description: Manage multiline banners on VyOS devices + name: vyos_banner + namespace: '' + - description: Run one or more commands on VyOS devices + name: vyos_command + namespace: '' + - description: Manage VyOS configuration on remote device + name: vyos_config + namespace: '' + - description: Get facts about vyos devices. + name: vyos_facts + namespace: '' + - description: FIREWALL global resource module + name: vyos_firewall_global + namespace: '' + - description: FIREWALL interfaces resource module + name: vyos_firewall_interfaces + namespace: '' + - description: FIREWALL rules resource module + name: vyos_firewall_rules + namespace: '' + - description: (deprecated, removed after 2022-06-01) Manage Interface on VyOS + network devices + name: vyos_interface + namespace: '' + - description: Interfaces resource module + name: vyos_interfaces + namespace: '' + - description: (deprecated, removed after 2022-06-01) Manage L3 interfaces on + VyOS network devices + name: vyos_l3_interface + namespace: '' + - description: L3 interfaces resource module + name: vyos_l3_interfaces + namespace: '' + - description: LAG interfaces resource module + name: vyos_lag_interfaces + namespace: '' + - description: (deprecated, removed after 2022-06-01) Manage link aggregation + groups on VyOS network devices + name: vyos_linkagg + namespace: '' + - description: (deprecated, removed after 2022-06-01) Manage LLDP configuration + on VyOS network devices + name: vyos_lldp + namespace: '' + - description: LLDP global resource module + name: vyos_lldp_global + namespace: '' + - description: (deprecated, removed after 2022-06-01) Manage LLDP interfaces configuration + on VyOS network devices + name: vyos_lldp_interface + namespace: '' + - description: LLDP interfaces resource module + name: vyos_lldp_interfaces + namespace: '' + - description: Manage logging on network devices + name: vyos_logging + namespace: '' + - description: OSPFv2 resource module + name: vyos_ospfv2 + namespace: '' + - description: OSPFV3 resource module + name: vyos_ospfv3 + namespace: '' + - description: Tests reachability using ping from VyOS network devices + name: vyos_ping + namespace: '' + - description: (deprecated, removed after 2022-06-01) Manage static IP routes + on Vyatta VyOS network devices + name: vyos_static_route + namespace: '' + - description: Static routes resource module + name: vyos_static_routes + namespace: '' + - description: Run `set system` commands on VyOS devices + name: vyos_system + namespace: '' + - description: Manage the collection of local users on VyOS device + name: vyos_user + namespace: '' + - description: Manage VLANs on VyOS network devices + name: vyos_vlan + namespace: '' + plugins: + cliconf: + - description: Use vyos cliconf to run command on VyOS platform + name: vyos + namespace: null + release_date: '2020-06-23' + 1.0.1: + changes: + minor_changes: + - Add doc plugin fixes (https://github.com/ansible-collections/vyos.vyos/pull/51) + fragments: + - 51-doc-plugin-fixes.yaml + release_date: '2020-06-23' + 1.0.2: + changes: + bugfixes: + - Added workaround to avoid set_fact dynamically assigning value. This behavior + seems to have been broken after ansible2.9. + - Make `src`, `backup` and `backup_options` in vyos_config work when module + alias is used (https://github.com/ansible-collections/vyos.vyos/pull/67). + - vyos_config - fixed issue where config could be saved while in check mode + (https://github.com/ansible-collections/vyos.vyos/pull/53) + minor_changes: + - Fixed the typo in the modulename of ospfv2 and ospfv3 unit tests. + - Updated docs. + - terminal plugin - Added additional escape sequence to be removed from terminal + output. + fragments: + - 65-remove-unwanted-terminal-chars.yaml + - 70-workaround-set_fact.yaml + - 72-modulename-typofix.yaml + - 73-update-docs.yaml + - fix_src_backup_with_module_alias.yaml + - prevent-vyos_config-saving-in-check-mode.yaml + release_date: '2020-07-31' + 1.0.3: + changes: + release_summary: + - Rereleasing 1.0.2 with updated changelog. + fragments: + - 1.0.3.yaml + release_date: '2020-08-06' + 1.0.4: + changes: + minor_changes: + - Moved intent testcases from integration suite to unit tests. + - Reformatted files with latest version of Black (20.8b1). + fragments: + - 71-refactor-interface-test.yaml + - 80-reformat-files.yaml + release_date: '2020-08-27' + 1.0.5: + changes: + bugfixes: + - Added openvpn vtu interface support. + - Update network integration auth timeout for connection local. + - terminal plugin - Overhaul ansi_re to remove more escape sequences + fragments: + - 86-openvpn_vtu_interface.yaml + - local_auth_timeout.yaml + - terminal-escape-codes.yaml + release_date: '2020-10-08' + 1.1.0: + changes: + minor_changes: + - Added ospf_interfaces resource module. + fragments: + - vyos_ospf_interfaces_rm.yaml + modules: + - description: OSPF Interfaces resource module + name: vyos_ospf_interfaces + namespace: '' + release_date: '2020-10-30' + 1.1.1: + changes: + bugfixes: + - Add version key to galaxy.yaml to work around ansible-galaxy bug + - Enable configuring an interface which is not present in the running config. + - vyos_config - Only process src files as commands when they actually contain + commands. This fixes an issue were the whitespace preceding a configuration + key named 'set' was stripped, tripping up the parser. + fragments: + - 91-new-interface.yaml + - config-processed-as-command.yaml + - galaxy-version.yaml + release_date: '2021-01-27' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/config.yaml new file mode 100644 index 00000000..1004e49c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/changelogs/config.yaml @@ -0,0 +1,30 @@ +changelog_filename_template: CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +keep_fragments: false +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +prelude_section_name: release_summary +prelude_section_title: Release Summary +flatmap: true +sections: +- - major_changes + - Major Changes +- - minor_changes + - Minor Changes +- - breaking_changes + - Breaking Changes / Porting Guide +- - deprecated_features + - Deprecated Features +- - removed_features + - Removed Features (previously deprecated) +- - security_fixes + - Security Fixes +- - bugfixes + - Bugfixes +- - known_issues + - Known Issues +title: Vyos Collection +trivial_section_name: trivial diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_banner_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_banner_module.rst new file mode 100644 index 00000000..8e14ce3c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_banner_module.rst @@ -0,0 +1,280 @@ +.. _vyos.vyos.vyos_banner_module: + + +********************* +vyos.vyos.vyos_banner +********************* + +**Manage multiline banners on VyOS devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This will configure both pre-login and post-login banners on remote devices running VyOS. It allows playbooks to add or remote banner text from the active running configuration. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>banner</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>pre-login</li> + <li>post-login</li> + </ul> + </td> + <td> + <div>Specifies which banner that should be configured on the remote device.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>Specifies whether or not the configuration is present in the current devices active running configuration.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>text</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The banner text that should be present in the remote device running configuration. This argument accepts a multiline string, with no empty lines. Requires <em>state=present</em>.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure the pre-login banner + vyos.vyos.vyos_banner: + banner: pre-login + text: | + this is my pre-login banner + that contains a multiline + string + state: present + - name: remove the post-login banner + vyos.vyos.vyos_banner: + banner: post-login + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['banner pre-login', 'this is my pre-login banner', 'that contains a multiline', 'string']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Trishna Guha (@trishnaguha) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_cliconf.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_cliconf.rst new file mode 100644 index 00000000..f4543224 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_cliconf.rst @@ -0,0 +1,43 @@ +.. _vyos.vyos.vyos_cliconf: + + +************** +vyos.vyos.vyos +************** + +**Use vyos cliconf to run command on VyOS platform** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This vyos plugin provides low level abstraction apis for sending and receiving CLI commands from VyOS network devices. + + + + + + + + + + + +Status +------ + + +Authors +~~~~~~~ + +- Ansible Networking Team + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_command_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_command_module.rst new file mode 100644 index 00000000..41041bc1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_command_module.rst @@ -0,0 +1,377 @@ +.. _vyos.vyos.vyos_command_module: + + +********************** +vyos.vyos.vyos_command +********************** + +**Run one or more commands on VyOS devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- The command module allows running one or more commands on remote devices running VyOS. This module can also be introspected to validate key parameters before returning successfully. If the conditional statements are not met in the wait period, the task fails. +- Certain ``show`` commands in VyOS produce many lines of output and use a custom pager that can cause this module to hang. If the value of the environment variable ``ANSIBLE_VYOS_TERMINAL_LENGTH`` is not set, the default number of 10000 is used. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=raw</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>The ordered set of commands to execute on the remote device running VyOS. The output from the command execution is returned to the playbook. If the <em>wait_for</em> argument is provided, the module is not returned until the condition is satisfied or the number of retries has been exceeded.</div> + <div>If a command sent to the device requires answering a prompt, it is possible to pass a dict containing command, answer and prompt. Common answers are 'y' or "\r" (carriage return, must be double quotes). Refer below examples.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">1</div> + </td> + <td> + <div>Configures the interval in seconds to wait between <em>retries</em> of the command. If the command does not pass the specified conditions, the interval indicates how long to wait before trying the command again.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>match</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>any</li> + <li><div style="color: blue"><b>all</b> ←</div></li> + </ul> + </td> + <td> + <div>The <em>match</em> argument is used in conjunction with the <em>wait_for</em> argument to specify the match policy. Valid values are <code>all</code> or <code>any</code>. If the value is set to <code>all</code> then all conditionals in the wait_for must be satisfied. If the value is set to <code>any</code> then only one of the values must be satisfied.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>retries</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">10</div> + </td> + <td> + <div>Specifies the number of retries a command should be tried before it is considered failed. The command is run on the target device every retry and evaluated against the <em>wait_for</em> conditionals.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>wait_for</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies what to evaluate from the output of the command and what conditionals to apply. This argument will cause the task to wait for a particular conditional to be true before moving forward. If the conditional is not true by the configured <em>retries</em>, the task fails. See examples.</div> + <div style="font-size: small; color: darkgreen"><br/>aliases: waitfor</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - Running ``show system boot-messages all`` will cause the module to hang since VyOS is using a custom pager setting to display the output of that command. + - If a command sent to the device requires answering a prompt, it is possible to pass a dict containing *command*, *answer* and *prompt*. See examples. + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: show configuration on ethernet devices eth0 and eth1 + vyos.vyos.vyos_command: + commands: + - show interfaces ethernet {{ item }} + with_items: + - eth0 + - eth1 + + - name: run multiple commands and check if version output contains specific version + string + vyos.vyos.vyos_command: + commands: + - show version + - show hardware cpu + wait_for: + - result[0] contains 'VyOS 1.1.7' + + - name: run command that requires answering a prompt + vyos.vyos.vyos_command: + commands: + - command: rollback 1 + prompt: Proceed with reboot? [confirm][y] + answer: y + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>failed_conditions</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>failed</td> + <td> + <div>The list of conditionals that have failed</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['...', '...']</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>stdout</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always apart from low level errors (such as action plugin)</td> + <td> + <div>The set of responses from the commands</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['...', '...']</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>stdout_lines</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The value of stdout split into a list</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[['...', '...'], ['...'], ['...']]</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>warnings</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of warnings (if any) generated by module based on arguments</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['...', '...']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nathaniel Case (@Qalthos) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_config_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_config_module.rst new file mode 100644 index 00000000..0914d8ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_config_module.rst @@ -0,0 +1,511 @@ +.. _vyos.vyos.vyos_config_module: + + +********************* +vyos.vyos.vyos_config +********************* + +**Manage VyOS configuration on remote device** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module provides configuration file management of VyOS devices. It provides arguments for managing both the configuration file and state of the active configuration. All configuration statements are based on `set` and `delete` commands in the device configuration. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>backup</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>no</b> ←</div></li> + <li>yes</li> + </ul> + </td> + <td> + <div>The <code>backup</code> argument will backup the current devices active configuration to the Ansible control host prior to making any changes. If the <code>backup_options</code> value is not given, the backup file will be located in the backup folder in the playbook root directory or role root directory, if playbook is part of an ansible role. If the directory does not exist, it is created.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>backup_options</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>This is a dict object containing configurable options related to backup file path. The value of this option is read only when <code>backup</code> is set to <em>yes</em>, if <code>backup</code> is set to <em>no</em> this option will be silently ignored.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dir_path</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>This option provides the path ending with directory name in which the backup configuration file will be stored. If the directory does not exist it will be first created and the filename is either the value of <code>filename</code> or default filename as described in <code>filename</code> options description. If the path value is not given in that case a <em>backup</em> directory will be created in the current working directory and backup configuration will be copied in <code>filename</code> within <em>backup</em> directory.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>filename</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The filename to be used to store the backup configuration. If the filename is not given it will be generated based on the hostname, current time and date in format defined by <hostname>_config.<current-date>@<current-time></div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>comment</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">"configured by vyos_config"</div> + </td> + <td> + <div>Allows a commit description to be specified to be included when the configuration is committed. If the configuration is not changed or committed, this argument is ignored.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The <code>config</code> argument specifies the base configuration to use to compare against the desired configuration. If this value is not specified, the module will automatically retrieve the current active configuration from the remote device.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>lines</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>The ordered set of configuration lines to be managed and compared with the existing configuration on the remote device.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>match</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>line</b> ←</div></li> + <li>none</li> + </ul> + </td> + <td> + <div>The <code>match</code> argument controls the method used to match against the current active configuration. By default, the desired config is matched against the active config and the deltas are loaded. If the <code>match</code> argument is set to <code>none</code> the active configuration is ignored and the configuration is always loaded.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>save</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>no</b> ←</div></li> + <li>yes</li> + </ul> + </td> + <td> + <div>The <code>save</code> argument controls whether or not changes made to the active configuration are saved to disk. This is independent of committing the config. When set to True, the active configuration is saved.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>src</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>The <code>src</code> argument specifies the path to the source config file to load. The source config file can either be in bracket format or set format. The source file can include Jinja2 template variables.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure the remote device + vyos.vyos.vyos_config: + lines: + - set system host-name {{ inventory_hostname }} + - set service lldp + - delete service dhcp-server + + - name: backup and load from file + vyos.vyos.vyos_config: + src: vyos.cfg + backup: yes + + - name: render a Jinja2 template onto the VyOS router + vyos.vyos.vyos_config: + src: vyos_template.j2 + + - name: for idempotency, use full-form commands + vyos.vyos.vyos_config: + lines: + # - set int eth eth2 description 'OUTSIDE' + - set interface ethernet eth2 description 'OUTSIDE' + + - name: configurable backup path + vyos.vyos.vyos_config: + backup: yes + backup_options: + filename: backup.cfg + dir_path: /home/user + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>backup_path</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>when backup is yes</td> + <td> + <div>The full path to the backup file</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">/playbooks/ansible/backup/vyos_config.2016-07-16@22:28:34</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration commands sent to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['...', '...']</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>date</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>when backup is yes</td> + <td> + <div>The date extracted from the backup file name</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">2016-07-16</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>filename</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>when backup is yes and filename is not specified in backup options</td> + <td> + <div>The name of the backup file</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">vyos_config.2016-07-16@22:28:34</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>filtered</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration commands removed to avoid a load failure</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['...', '...']</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>shortname</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>when backup is yes and filename is not specified in backup options</td> + <td> + <div>The full path to the backup file excluding the timestamp</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">/playbooks/ansible/backup/vyos_config</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>time</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>when backup is yes</td> + <td> + <div>The time extracted from the backup file name</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">22:28:34</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nathaniel Case (@Qalthos) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_facts_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_facts_module.rst new file mode 100644 index 00000000..d2858640 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_facts_module.rst @@ -0,0 +1,427 @@ +.. _vyos.vyos.vyos_facts_module: + + +******************** +vyos.vyos.vyos_facts +******************** + +**Get facts about vyos devices.** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Collects facts from network devices running the vyos operating system. This module places the facts gathered in the fact tree keyed by the respective resource name. The facts module will always collect a base set of facts from the device and can enable or disable collection of additional facts. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>gather_network_resources</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all and the resources like interfaces. Can specify a list of values to include a larger subset. Values can also be used with an initial <code><span class='module'>!</span></code> to specify that a specific subset should not be collected. Valid subsets are 'all', 'interfaces', 'l3_interfaces', 'lag_interfaces', 'lldp_global', 'lldp_interfaces', 'static_routes', 'firewall_rules', 'firewall_global', 'firewall_interfaces', 'ospfv3', 'ospfv2'.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>gather_subset</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">"!config"</div> + </td> + <td> + <div>When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all, default, config, and neighbors. Can specify a list of values to include a larger subset. Values can also be used with an initial <code><span class='module'>!</span></code> to specify that a specific subset should not be collected.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Gather all facts + - vyos.vyos.vyos_facts: + gather_subset: all + gather_network_resources: all + + # collect only the config and default facts + - vyos.vyos.vyos_facts: + gather_subset: config + + # collect everything exception the config + - vyos.vyos.vyos_facts: + gather_subset: '!config' + + # Collect only the interfaces facts + - vyos.vyos.vyos_facts: + gather_subset: + - '!all' + - '!min' + gather_network_resources: + - interfaces + + # Do not collect interfaces facts + - vyos.vyos.vyos_facts: + gather_network_resources: + - '!interfaces' + + # Collect interfaces and minimal default facts + - vyos.vyos.vyos_facts: + gather_subset: min + gather_network_resources: interfaces + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_api</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>The name of the transport</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_commits</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when present</td> + <td> + <div>The set of available configuration revisions</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_config</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>when config is configured</td> + <td> + <div>The running-config from the device</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_gather_network_resources</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of fact resource subsets collected from the device</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_gather_subset</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of subsets gathered by the module</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_hostname</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>The configured system hostname</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_model</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>The device model string</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_neighbors</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when interface is configured</td> + <td> + <div>The set of LLDP neighbors</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_python_version</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>The Python version Ansible controller is using</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_serialnum</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>The serial number of the device</div> + <br/> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>ansible_net_version</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>The version of the software running</div> + <br/> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nathaniel Case (@qalthos) +- Nilashish Chakraborty (@Nilashishc) +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_global_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_global_module.rst new file mode 100644 index 00000000..30f7ecf1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_global_module.rst @@ -0,0 +1,1749 @@ +.. _vyos.vyos.vyos_firewall_global_module: + + +****************************** +vyos.vyos.vyos_firewall_global +****************************** + +**FIREWALL global resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manage global policies or configurations for firewall on VyOS devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="5">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A dictionary of Firewall global configuration options.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config_trap</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>SNMP trap generation on firewall configuration changes.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Defines a group of objects for referencing in firewall rules.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Defines a group of IP addresses for referencing in firewall rules.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Allows you to specify a brief description for the address group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>members</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Address-group members.</div> + <div>IPv4 address to match.</div> + <div>IPv4 range to match.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IP address.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the firewall address group.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>network_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Defines a group of networks for referencing in firewall rules.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Allows you to specify a brief description for the network group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>members</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Adds an IPv4 network to the specified network group.</div> + <div>The format is ip-address/prefix.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IP address.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the firewall network group.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Defines a group of ports for referencing in firewall rules.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Allows you to specify a brief description for the port group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>members</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Port-group member.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Defines the number.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the firewall port group.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>log_martians</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Specifies whether or not to record packets with invalid addresses in the log.</div> + <div>(True) Logs packets with invalid addresses.</div> + <div>(False) Does not log packets with invalid addresses.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ping</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Policy for handling of all IPv4 ICMP echo requests.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>all</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enables or disables response to all IPv4 ICMP Echo Request (ping) messages.</div> + <div>The system responds to IPv4 ICMP Echo Request messages.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>broadcast</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enables or disables response to broadcast IPv4 ICMP Echo Request and Timestamp Request messages.</div> + <div>IPv4 ICMP Echo and Timestamp Request messages are not processed.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_redirects</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>-A dictionary of Firewall icmp redirect and source route global configuration options.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>afi</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>ipv4</li> + <li>ipv6</li> + </ul> + </td> + <td> + <div>Specifies IP address type</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>icmp_redirects</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies whether to allow sending/receiving of IPv4/v6 ICMP redirect messages.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>receive</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Permits or denies receiving packets ICMP redirect messages.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>send</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Permits or denies transmitting packets ICMP redirect messages.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ip_src_route</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Specifies whether or not to process source route IP options.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state_policy</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies global firewall state-policy.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>action</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>accept</li> + <li>drop</li> + <li>reject</li> + </ul> + </td> + <td> + <div>Action for packets part of an established connection.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>connection_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>established</li> + <li>invalid</li> + <li>related</li> + </ul> + </td> + <td> + <div>Specifies connection type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>log</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enable logging of packets part of an established connection.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>syn_cookies</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Specifies policy for using TCP SYN cookies with IPv4.</div> + <div>(True) Enables TCP SYN cookies with IPv4.</div> + <div>(False) Disables TCP SYN cookies with IPv4.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>twa_hazards_protection</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>RFC1337 TCP TIME-WAIT assasination hazards protection.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>validation</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>strict</li> + <li>loose</li> + <li>disable</li> + </ul> + </td> + <td> + <div>Specifies a policy for source validation by reversed path, as defined in RFC 3704.</div> + <div>(disable) No source validation is performed.</div> + <div>(loose) Enable Loose Reverse Path Forwarding as defined in RFC3704.</div> + <div>(strict) Enable Strict Reverse Path Forwarding as defined in RFC3704.</div> + </td> + </tr> + + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The module, by default, will connect to the remote device and retrieve the current running-config to use as a base for comparing against the contents of source. There are times when it is not desirable to have the task get the current running-config for every task in a playbook. The <em>running_config</em> argument allows the implementer to pass in the configuration to use as the base config for comparison. This value of this option should be the output received from device by executing command <code>show configuration commands | grep 'firewall'</code></div> + </td> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>deleted</li> + <li>gathered</li> + <li>rendered</li> + <li>parsed</li> + </ul> + </td> + <td> + <div>The state the configuration should be left in.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos# run show configuration commands | grep firewall + # + # + - name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": [] + # + # "commands": [ + # "set firewall group address-group MGMT-HOSTS address 192.0.1.1", + # "set firewall group address-group MGMT-HOSTS address 192.0.1.3", + # "set firewall group address-group MGMT-HOSTS address 192.0.1.5", + # "set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list'", + # "set firewall group address-group MGMT-HOSTS", + # "set firewall group network-group MGMT network 192.0.1.0/24", + # "set firewall group network-group MGMT description 'This group has the Management network addresses'", + # "set firewall group network-group MGMT", + # "set firewall ip-src-route 'enable'", + # "set firewall receive-redirects 'disable'", + # "set firewall send-redirects 'enable'", + # "set firewall config-trap 'enable'", + # "set firewall state-policy established action 'accept'", + # "set firewall state-policy established log 'enable'", + # "set firewall state-policy invalid action 'reject'", + # "set firewall broadcast-ping 'enable'", + # "set firewall all-ping 'enable'", + # "set firewall log-martians 'enable'", + # "set firewall twa-hazards-protection 'enable'", + # "set firewall syn-cookies 'enable'", + # "set firewall source-validation 'strict'" + # ] + # + # "after": { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "This group has the Management hosts address list", + # "members": [ + # { + # "address": "192.0.1.1" + # }, + # { + # "address": "192.0.1.3" + # }, + # { + # "address": "192.0.1.5" + # } + # ], + # "name": "MGMT-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep firewall + # set firewall all-ping 'enable' + # set firewall broadcast-ping 'enable' + # set firewall config-trap 'enable' + # set firewall group address-group MGMT-HOSTS address '192.0.1.1' + # set firewall group address-group MGMT-HOSTS address '192.0.1.3' + # set firewall group address-group MGMT-HOSTS address '192.0.1.5' + # set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' + # set firewall group network-group MGMT description 'This group has the Management network addresses' + # set firewall group network-group MGMT network '192.0.1.0/24' + # set firewall ip-src-route 'enable' + # set firewall log-martians 'enable' + # set firewall receive-redirects 'disable' + # set firewall send-redirects 'enable' + # set firewall source-validation 'strict' + # set firewall state-policy established action 'accept' + # set firewall state-policy established log 'enable' + # set firewall state-policy invalid action 'reject' + # set firewall syn-cookies 'enable' + # set firewall twa-hazards-protection 'enable' + # + # + # Using parsed + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_global: + running_config: + "set firewall all-ping 'enable' + set firewall broadcast-ping 'enable' + set firewall config-trap 'enable' + set firewall group address-group ENG-HOSTS address '192.0.3.1' + set firewall group address-group ENG-HOSTS address '192.0.3.2' + set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' + set firewall group address-group SALES-HOSTS address '192.0.2.1' + set firewall group address-group SALES-HOSTS address '192.0.2.2' + set firewall group address-group SALES-HOSTS address '192.0.2.3' + set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' + set firewall group network-group MGMT description 'This group has the Management network addresses' + set firewall group network-group MGMT network '192.0.1.0/24' + set firewall ip-src-route 'enable' + set firewall log-martians 'enable' + set firewall receive-redirects 'disable' + set firewall send-redirects 'enable' + set firewall source-validation 'strict' + set firewall state-policy established action 'accept' + set firewall state-policy established log 'enable' + set firewall state-policy invalid action 'reject' + set firewall syn-cookies 'enable' + set firewall twa-hazards-protection 'enable'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.3.1" + # }, + # { + # "address": "192.0.3.2" + # } + # ], + # "name": "ENG-HOSTS" + # }, + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.2.1" + # }, + # { + # "address": "192.0.2.2" + # }, + # { + # "address": "192.0.2.3" + # } + # ], + # "name": "SALES-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # } + # + # + # Using deleted + # + # Before state + # ------------- + # + # vyos@192# run show configuration commands | grep firewall + # set firewall all-ping 'enable' + # set firewall broadcast-ping 'enable' + # set firewall config-trap 'enable' + # set firewall group address-group MGMT-HOSTS address '192.0.1.1' + # set firewall group address-group MGMT-HOSTS address '192.0.1.3' + # set firewall group address-group MGMT-HOSTS address '192.0.1.5' + # set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' + # set firewall group network-group MGMT description 'This group has the Management network addresses' + # set firewall group network-group MGMT network '192.0.1.0/24' + # set firewall ip-src-route 'enable' + # set firewall log-martians 'enable' + # set firewall receive-redirects 'disable' + # set firewall send-redirects 'enable' + # set firewall source-validation 'strict' + # set firewall state-policy established action 'accept' + # set firewall state-policy established log 'enable' + # set firewall state-policy invalid action 'reject' + # set firewall syn-cookies 'enable' + # set firewall twa-hazards-protection 'enable' + - name: Delete attributes of firewall. + vyos.vyos.vyos_firewall_global: + config: + state_policy: + config_trap: + log_martians: + syn_cookies: + twa_hazards_protection: + route_redirects: + ping: + group: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "This group has the Management hosts address list", + # "members": [ + # { + # "address": "192.0.1.1" + # }, + # { + # "address": "192.0.1.3" + # }, + # { + # "address": "192.0.1.5" + # } + # ], + # "name": "MGMT-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # "commands": [ + # "delete firewall source-validation", + # "delete firewall group", + # "delete firewall log-martians", + # "delete firewall ip-src-route", + # "delete firewall receive-redirects", + # "delete firewall send-redirects", + # "delete firewall config-trap", + # "delete firewall state-policy", + # "delete firewall syn-cookies", + # "delete firewall broadcast-ping", + # "delete firewall all-ping", + # "delete firewall twa-hazards-protection" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@192# run show configuration commands | grep firewall + # set 'firewall' + # + # + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall all-ping 'enable' + # set firewall broadcast-ping 'enable' + # set firewall config-trap 'enable' + # set firewall group address-group MGMT-HOSTS address '192.0.1.1' + # set firewall group address-group MGMT-HOSTS address '192.0.1.3' + # set firewall group address-group MGMT-HOSTS address '192.0.1.5' + # set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' + # set firewall group network-group MGMT description 'This group has the Management network addresses' + # set firewall group network-group MGMT network '192.0.1.0/24' + # set firewall ip-src-route 'enable' + # set firewall log-martians 'enable' + # set firewall receive-redirects 'disable' + # set firewall send-redirects 'enable' + # set firewall source-validation 'strict' + # set firewall state-policy established action 'accept' + # set firewall state-policy established log 'enable' + # set firewall state-policy invalid action 'reject' + # set firewall syn-cookies 'enable' + # set firewall twa-hazards-protection 'enable' + # + - name: Replace firewall global attributes configuration. + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "This group has the Management hosts address list", + # "members": [ + # { + # "address": "192.0.1.1" + # }, + # { + # "address": "192.0.1.3" + # }, + # { + # "address": "192.0.1.5" + # } + # ], + # "name": "MGMT-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # + # "commands": [ + # "delete firewall group address-group MGMT-HOSTS", + # "set firewall group address-group SALES-HOSTS address 192.0.2.1", + # "set firewall group address-group SALES-HOSTS address 192.0.2.2", + # "set firewall group address-group SALES-HOSTS address 192.0.2.3", + # "set firewall group address-group SALES-HOSTS description 'Sales office hosts address list'", + # "set firewall group address-group SALES-HOSTS", + # "set firewall group address-group ENG-HOSTS address 192.0.3.1", + # "set firewall group address-group ENG-HOSTS address 192.0.3.2", + # "set firewall group address-group ENG-HOSTS description 'Sales office hosts address list'", + # "set firewall group address-group ENG-HOSTS" + # ] + # + # "after": { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.3.1" + # }, + # { + # "address": "192.0.3.2" + # } + # ], + # "name": "ENG-HOSTS" + # }, + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.2.1" + # }, + # { + # "address": "192.0.2.2" + # }, + # { + # "address": "192.0.2.3" + # } + # ], + # "name": "SALES-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep firewall + # set firewall all-ping 'enable' + # set firewall broadcast-ping 'enable' + # set firewall config-trap 'enable' + # set firewall group address-group ENG-HOSTS address '192.0.3.1' + # set firewall group address-group ENG-HOSTS address '192.0.3.2' + # set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' + # set firewall group address-group SALES-HOSTS address '192.0.2.1' + # set firewall group address-group SALES-HOSTS address '192.0.2.2' + # set firewall group address-group SALES-HOSTS address '192.0.2.3' + # set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' + # set firewall group network-group MGMT description 'This group has the Management network addresses' + # set firewall group network-group MGMT network '192.0.1.0/24' + # set firewall ip-src-route 'enable' + # set firewall log-martians 'enable' + # set firewall receive-redirects 'disable' + # set firewall send-redirects 'enable' + # set firewall source-validation 'strict' + # set firewall state-policy established action 'accept' + # set firewall state-policy established log 'enable' + # set firewall state-policy invalid action 'reject' + # set firewall syn-cookies 'enable' + # set firewall twa-hazards-protection 'enable' + # + # + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep firewall + # set firewall all-ping 'enable' + # set firewall broadcast-ping 'enable' + # set firewall config-trap 'enable' + # set firewall group address-group ENG-HOSTS address '192.0.3.1' + # set firewall group address-group ENG-HOSTS address '192.0.3.2' + # set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' + # set firewall group address-group SALES-HOSTS address '192.0.2.1' + # set firewall group address-group SALES-HOSTS address '192.0.2.2' + # set firewall group address-group SALES-HOSTS address '192.0.2.3' + # set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' + # set firewall group network-group MGMT description 'This group has the Management network addresses' + # set firewall group network-group MGMT network '192.0.1.0/24' + # set firewall ip-src-route 'enable' + # set firewall log-martians 'enable' + # set firewall receive-redirects 'disable' + # set firewall send-redirects 'enable' + # set firewall source-validation 'strict' + # set firewall state-policy established action 'accept' + # set firewall state-policy established log 'enable' + # set firewall state-policy invalid action 'reject' + # set firewall syn-cookies 'enable' + # set firewall twa-hazards-protection 'enable' + # + - name: Gather firewall global config with provided configurations + vyos.vyos.vyos_firewall_global: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.3.1" + # }, + # { + # "address": "192.0.3.2" + # } + # ], + # "name": "ENG-HOSTS" + # }, + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.2.1" + # }, + # { + # "address": "192.0.2.2" + # }, + # { + # "address": "192.0.2.3" + # } + # ], + # "name": "SALES-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep firewall + # set firewall all-ping 'enable' + # set firewall broadcast-ping 'enable' + # set firewall config-trap 'enable' + # set firewall group address-group ENG-HOSTS address '192.0.3.1' + # set firewall group address-group ENG-HOSTS address '192.0.3.2' + # set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' + # set firewall group address-group SALES-HOSTS address '192.0.2.1' + # set firewall group address-group SALES-HOSTS address '192.0.2.2' + # set firewall group address-group SALES-HOSTS address '192.0.2.3' + # set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' + # set firewall group network-group MGMT description 'This group has the Management network addresses' + # set firewall group network-group MGMT network '192.0.1.0/24' + # set firewall ip-src-route 'enable' + # set firewall log-martians 'enable' + # set firewall receive-redirects 'disable' + # set firewall send-redirects 'enable' + # set firewall source-validation 'strict' + # set firewall state-policy established action 'accept' + # set firewall state-policy established log 'enable' + # set firewall state-policy invalid action 'reject' + # set firewall syn-cookies 'enable' + # set firewall twa-hazards-protection 'enable' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set firewall group address-group SALES-HOSTS address 192.0.2.1", + # "set firewall group address-group SALES-HOSTS address 192.0.2.2", + # "set firewall group address-group SALES-HOSTS address 192.0.2.3", + # "set firewall group address-group SALES-HOSTS description 'Sales office hosts address list'", + # "set firewall group address-group SALES-HOSTS", + # "set firewall group address-group ENG-HOSTS address 192.0.3.1", + # "set firewall group address-group ENG-HOSTS address 192.0.3.2", + # "set firewall group address-group ENG-HOSTS description 'Sales office hosts address list'", + # "set firewall group address-group ENG-HOSTS", + # "set firewall group network-group MGMT network 192.0.1.0/24", + # "set firewall group network-group MGMT description 'This group has the Management network addresses'", + # "set firewall group network-group MGMT", + # "set firewall ip-src-route 'enable'", + # "set firewall receive-redirects 'disable'", + # "set firewall send-redirects 'enable'", + # "set firewall config-trap 'enable'", + # "set firewall state-policy established action 'accept'", + # "set firewall state-policy established log 'enable'", + # "set firewall state-policy invalid action 'reject'", + # "set firewall broadcast-ping 'enable'", + # "set firewall all-ping 'enable'", + # "set firewall log-martians 'enable'", + # "set firewall twa-hazards-protection 'enable'", + # "set firewall syn-cookies 'enable'", + # "set firewall source-validation 'strict'" + # ] + # + # + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The resulting configuration model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration prior to the model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set firewall group address-group ENG-HOSTS', 'set firewall group address-group ENG-HOSTS address 192.0.3.1']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_interfaces_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_interfaces_module.rst new file mode 100644 index 00000000..7c55b045 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_interfaces_module.rst @@ -0,0 +1,1413 @@ +.. _vyos.vyos.vyos_firewall_interfaces_module: + + +********************************** +vyos.vyos.vyos_firewall_interfaces +********************************** + +**FIREWALL interfaces resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Manage firewall rules of interfaces on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="4">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A list of firewall rules options for interfaces.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>access_rules</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies firewall rules attached to the interfaces.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>afi</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>ipv4</li> + <li>ipv6</li> + </ul> + </td> + <td> + <div>Specifies the AFI for the Firewall rules to be configured on this interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>rules</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the firewall rules for the provided AFI.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>direction</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>in</li> + <li>local</li> + <li>out</li> + </ul> + </td> + <td> + <div>Specifies the direction of packets that the firewall rule will be applied on.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the name of the IPv4/IPv6 Firewall rule for the interface.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name/Identifier for the interface.</div> + </td> + </tr> + + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The module, by default, will connect to the remote device and retrieve the current running-config to use as a base for comparing against the contents of source. There are times when it is not desirable to have the task get the current running-config for every task in a playbook. The <em>running_config</em> argument allows the implementer to pass in the configuration to use as the base config for comparison. This value of this option should be the output received from device by executing command C(show configuration commands | grep 'firewall'</div> + </td> + </tr> + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>parsed</li> + <li>rendered</li> + <li>gathered</li> + </ul> + </td> + <td> + <div>The state the configuration should be left in.</div> + </td> + </tr> + </table> + <br/> + + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # + - name: Merge the provided configuration with the existing running configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth3 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": [ + # { + # "name": "eth0" + # }, + # { + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ] + # + # "commands": [ + # "set interfaces ethernet eth1 firewall in name 'INBOUND'", + # "set interfaces ethernet eth1 firewall out name 'OUTBOUND'", + # "set interfaces ethernet eth1 firewall local name 'LOCAL'", + # "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'", + # "set interfaces ethernet eth3 firewall in name 'INBOUND'", + # "set interfaces ethernet eth3 firewall out name 'OUTBOUND'", + # "set interfaces ethernet eth3 firewall local name 'LOCAL'", + # "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'" + # ] + # + # "after": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'INBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'INBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + # + - name: Merge the provided configuration with the existing running configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: in + - name: INBOUND + direction: out + name: eth1 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # "commands": [ + # "set interfaces ethernet eth1 firewall in name 'OUTBOUND'", + # "set interfaces ethernet eth1 firewall out name 'INBOUND'" + # ] + # + # "after": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "OUTBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "INBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'OUTBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'INBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'INBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + # + - name: Replace device configurations of listed firewall interfaces with provided + configurations + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth1 + access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: out + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # "commands": [ + # "delete interfaces ethernet eth1 firewall in name", + # "delete interfaces ethernet eth1 firewall local name", + # "delete interfaces ethernet eth3 firewall local name", + # "delete interfaces ethernet eth3 firewall out name", + # "delete interfaces ethernet eth3 firewall local ipv6-name" + # ] + # + # "after": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall 'in' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall 'local' + # set interfaces ethernet eth3 firewall 'out' + + + # Using overridden + # + # Before state + # -------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall 'in' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall 'local' + # set interfaces ethernet eth3 firewall 'out' + # + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: out + state: overridden + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before":[ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # "commands": [ + # "delete interfaces ethernet eth1 firewall", + # "delete interfaces ethernet eth3 firewall in name", + # "set interfaces ethernet eth3 firewall out name 'INBOUND'" + # + # + # "after": [ + # { + # "name": "eth0" + # }, + # { + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "out", + # "name": "INBOUND" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # + # After state + # ------------ + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth3 firewall 'in' + # set interfaces ethernet eth3 firewall 'local' + # set interfaces ethernet eth3 firewall out name 'INBOUND' + + + # Using deleted per interface name + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'INBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + # + - name: Delete firewall interfaces based on interface name. + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth1 + - name: eth3 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # "commands": [ + # "delete interfaces ethernet eth1 firewall", + # "delete interfaces ethernet eth3 firewall" + # ] + # + # "after": [ + # { + # "name": "eth0" + # }, + # { + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ] + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + + + # Using deleted per afi + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'INBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + # + - name: Delete firewall interfaces config per afi. + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth1 + access_rules: + - afi: ipv4 + - afi: ipv6 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "commands": [ + # "delete interfaces ethernet eth1 firewall in name", + # "delete interfaces ethernet eth1 firewall out name", + # "delete interfaces ethernet eth1 firewall local name", + # "delete interfaces ethernet eth1 firewall local ipv6-name" + # ] + # + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + + + # Using deleted without config + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall in name 'INBOUND' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall local name 'LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth3 firewall local name 'LOCAL' + # set interfaces ethernet eth3 firewall out name 'OUTBOUND' + # + - name: Delete firewall interfaces config when empty config provided. + vyos.vyos.vyos_firewall_interfaces: + config: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "commands": [ + # "delete interfaces ethernet eth1 firewall", + # "delete interfaces ethernet eth1 firewall" + # ] + # + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + + + # Using parsed + # + # + - name: Parse the provided configuration + vyos.vyos.vyos_firewall_interfaces: + running_config: + "set interfaces ethernet eth1 firewall in name 'INBOUND' + set interfaces ethernet eth1 firewall out name 'OUTBOUND' + set interfaces ethernet eth1 firewall local name 'LOCAL' + set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + set interfaces ethernet eth2 firewall in name 'INBOUND' + set interfaces ethernet eth2 firewall out name 'OUTBOUND' + set interfaces ethernet eth2 firewall local name 'LOCAL' + set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # }, + # { + # "direction": "local", + # "name": "LOCAL" + # }, + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ] + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall 'in' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall 'local' + # set interfaces ethernet eth3 firewall 'out' + # + - name: Gather listed firewall interfaces. + vyos.vyos.vyos_firewall_interfaces: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "name": "eth0" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "out", + # "name": "OUTBOUND" + # } + # ] + # }, + # { + # "afi": "ipv6", + # "rules": [ + # { + # "direction": "local", + # "name": "V6-LOCAL" + # } + # ] + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "access_rules": [ + # { + # "afi": "ipv4", + # "rules": [ + # { + # "direction": "in", + # "name": "INBOUND" + # } + # ] + # } + # ], + # "name": "eth3" + # } + # ] + # + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name 'V6-LOCAL' + # set firewall name 'INBOUND' + # set firewall name 'LOCAL' + # set firewall name 'OUTBOUND' + # set interfaces ethernet eth1 firewall 'in' + # set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + # set interfaces ethernet eth1 firewall out name 'OUTBOUND' + # set interfaces ethernet eth3 firewall in name 'INBOUND' + # set interfaces ethernet eth3 firewall 'local' + # set interfaces ethernet eth3 firewall 'out' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INGRESS + - direction: out + name: OUTGRESS + - direction: local + name: DROP + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set interfaces ethernet eth2 firewall in name 'INGRESS'", + # "set interfaces ethernet eth2 firewall out name 'OUTGRESS'", + # "set interfaces ethernet eth2 firewall local name 'DROP'", + # "set interfaces ethernet eth2 firewall local ipv6-name 'LOCAL'" + # ] + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The resulting configuration model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration prior to the model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">["set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'", "set interfaces ethernet eth3 firewall in name 'INBOUND'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_rules_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_rules_module.rst new file mode 100644 index 00000000..15073b1e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_firewall_rules_module.rst @@ -0,0 +1,2440 @@ +.. _vyos.vyos.vyos_firewall_rules_module: + + +***************************** +vyos.vyos.vyos_firewall_rules +***************************** + +**FIREWALL rules resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages firewall rule-set attributes on VyOS devices + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="6">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="6"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A dictionary of Firewall rule-set options.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>afi</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>ipv4</li> + <li>ipv6</li> + </ul> + </td> + <td> + <div>Specifies the type of rule-set.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>rule_sets</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>The Firewall rule-set list.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>default_action</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>drop</li> + <li>reject</li> + <li>accept</li> + </ul> + </td> + <td> + <div>Default action for rule-set.</div> + <div>drop (Drop if no prior rules are hit (default))</div> + <div>reject (Drop and notify source if no prior rules are hit)</div> + <div>accept (Accept if no prior rules are hit)</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Rule set description.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enable_default_log</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Option to log packets hitting default-action.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Firewall rule set name.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>rules</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A ditionary that specifies the rule-set configurations.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>action</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>drop</li> + <li>reject</li> + <li>accept</li> + <li>inspect</li> + </ul> + </td> + <td> + <div>Specifying the action.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Description of this rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>destination</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifying the destination parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Destination ip address subnet or range.</div> + <div>IPv4/6 address, subnet or range to match.</div> + <div>Match everything except the specified address, subnet or range.</div> + <div>Destination ip address subnet or range.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Destination group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Group of addresses.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>network_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Group of networks.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Group of ports.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Multiple destination ports can be specified as a comma-separated list.</div> + <div>The whole list can also be "negated" using '!'.</div> + <div>For example:'!22,telnet,http,123,1001-1005'.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>disabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Option to disable firewall rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>fragment</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>match-frag</li> + <li>match-non-frag</li> + </ul> + </td> + <td> + <div>IP fragment match.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>icmp</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>ICMP type and code information.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>code</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>ICMP code.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>ICMP type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>type_name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>any</li> + <li>echo-reply</li> + <li>destination-unreachable</li> + <li>network-unreachable</li> + <li>host-unreachable</li> + <li>protocol-unreachable</li> + <li>port-unreachable</li> + <li>fragmentation-needed</li> + <li>source-route-failed</li> + <li>network-unknown</li> + <li>host-unknown</li> + <li>network-prohibited</li> + <li>host-prohibited</li> + <li>TOS-network-unreachable</li> + <li>TOS-host-unreachable</li> + <li>communication-prohibited</li> + <li>host-precedence-violation</li> + <li>precedence-cutoff</li> + <li>source-quench</li> + <li>redirect</li> + <li>network-redirect</li> + <li>host-redirect</li> + <li>TOS-network-redirect</li> + <li>TOS-host-redirect</li> + <li>echo-request</li> + <li>router-advertisement</li> + <li>router-solicitation</li> + <li>time-exceeded</li> + <li>ttl-zero-during-transit</li> + <li>ttl-zero-during-reassembly</li> + <li>parameter-problem</li> + <li>ip-header-bad</li> + <li>required-option-missing</li> + <li>timestamp-request</li> + <li>timestamp-reply</li> + <li>address-mask-request</li> + <li>address-mask-reply</li> + <li>ping</li> + <li>pong</li> + <li>ttl-exceeded</li> + </ul> + </td> + <td> + <div>ICMP type-name.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipsec</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>match-ipsec</li> + <li>match-none</li> + </ul> + </td> + <td> + <div>Inboud ip sec packets.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>limit</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Rate limit using a token bucket filter.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>burst</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Maximum number of packets to allow in excess of rate.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>rate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>format for rate (integer/time unit).</div> + <div>any one of second, minute, hour or day may be used to specify time unit.</div> + <div>eg. 1/second implies rule to be matched at an average of once per second.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>number</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>This is the integer value.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>unit</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This is the time unit.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>number</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Rule number.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>p2p</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>P2P application packets.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>application</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>all</li> + <li>applejuice</li> + <li>bittorrent</li> + <li>directconnect</li> + <li>edonkey</li> + <li>gnutella</li> + <li>kazaa</li> + </ul> + </td> + <td> + <div>Name of the application.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>protocol</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Protocol to match (protocol name in /etc/protocols or protocol number or all).</div> + <div><text> IP protocol name from /etc/protocols (e.g. "tcp" or "udp").</div> + <div><0-255> IP protocol number.</div> + <div>tcp_udp Both TCP and UDP.</div> + <div>all All IP protocols.</div> + <div>(!)All IP protocols except for the specified name or number.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>recent</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Parameters for matching recently seen sources.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>count</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Source addresses seen more than N times.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>time</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Source addresses seen in the last N seconds.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>source</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Source parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Source ip address subnet or range.</div> + <div>IPv4/6 address, subnet or range to match.</div> + <div>Match everything except the specified address, subnet or range.</div> + <div>Source ip address subnet or range.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Source group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Group of addresses.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>network_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Group of networks.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port_group</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Group of ports.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mac_address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div><MAC address> MAC address to match.</div> + <div><!MAC address> Match everything except the specified MAC address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Multiple source ports can be specified as a comma-separated list.</div> + <div>The whole list can also be "negated" using '!'.</div> + <div>For example:'!22,telnet,http,123,1001-1005'.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Session state.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>established</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Established state.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>invalid</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Invalid state.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>new</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>New state.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>related</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Related state.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>tcp</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>TCP flags to match.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>flags</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>TCP flags to be matched.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>time</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Time to match rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>monthdays</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Monthdays to match rule on.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>startdate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Date to start matching rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>starttime</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Time of day to start matching rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>stopdate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Date to stop matching rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>stoptime</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Time of day to stop matching rule.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>utc</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Interpret times for startdate, stopdate, starttime and stoptime to be UTC.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>weekdays</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Weekdays to match rule on.</div> + </td> + </tr> + + + + + <tr> + <td colspan="6"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep firewall</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="6"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>gathered</li> + <li>rendered</li> + <li>parsed</li> + </ul> + </td> + <td> + <div>The state the configuration should be left in</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using deleted to delete firewall rules based on rule-set name + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall name Downlink default-action 'accept' + # set firewall name Downlink description 'IPv4 INBOUND rule set' + # set firewall name Downlink rule 501 action 'accept' + # set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + # set firewall name Downlink rule 501 ipsec 'match-ipsec' + # set firewall name Downlink rule 502 action 'reject' + # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + # set firewall name Downlink rule 502 ipsec 'match-ipsec' + # + - name: Delete attributes of given firewall rules. + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv4 + rule_sets: + - name: Downlink + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "Downlink", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 501 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 501 + # }, + # { + # "action": "reject", + # "description": "Rule 502 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 502 + # } + # ] + # } + # ] + # } + # ] + # "commands": [ + # "delete firewall name Downlink" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep firewall + # set firewall group address-group 'inbound' + + + # Using deleted to delete firewall rules based on afi + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall ipv6-name UPLINK rule 1 action 'accept' + # set firewall ipv6-name UPLINK rule 1 + # set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + # set firewall ipv6-name UPLINK rule 2 action 'accept' + # set firewall ipv6-name UPLINK rule 2 + # set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + # set firewall group address-group 'inbound' + # set firewall name Downlink default-action 'accept' + # set firewall name Downlink description 'IPv4 INBOUND rule set' + # set firewall name Downlink rule 501 action 'accept' + # set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + # set firewall name Downlink rule 501 ipsec 'match-ipsec' + # set firewall name Downlink rule 502 action 'reject' + # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + # set firewall name Downlink rule 502 ipsec 'match-ipsec' + + # + - name: Delete attributes of given firewall rules. + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv4 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK", + # "rules": [ + # { + # "action": "accept", + # "description": "Fwipv6-Rule 1 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 1 + # }, + # { + # "action": "accept", + # "description": "Fwipv6-Rule 2 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 2 + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "Downlink", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 501 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 501 + # }, + # { + # "action": "reject", + # "description": "Rule 502 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 502 + # } + # ] + # } + # ] + # } + # ] + # "commands": [ + # "delete firewall name" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall ipv6-name UPLINK rule 1 action 'accept' + # set firewall ipv6-name UPLINK rule 1 + # set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + # set firewall ipv6-name UPLINK rule 2 action 'accept' + # set firewall ipv6-name UPLINK rule 2 + # set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + + + # Using deleted to delete all the the firewall rules when provided config is empty + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall name Downlink default-action 'accept' + # set firewall name Downlink description 'IPv4 INBOUND rule set' + # set firewall name Downlink rule 501 action 'accept' + # set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + # set firewall name Downlink rule 501 ipsec 'match-ipsec' + # set firewall name Downlink rule 502 action 'reject' + # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + # set firewall name Downlink rule 502 ipsec 'match-ipsec' + # + - name: Delete attributes of given firewall rules. + vyos.vyos.vyos_firewall_rules: + config: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "Downlink", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 501 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 501 + # }, + # { + # "action": "reject", + # "description": "Rule 502 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 502 + # } + # ] + # } + # ] + # } + # ] + # "commands": [ + # "delete firewall name" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep firewall + # set firewall group address-group 'inbound' + + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos# run show configuration commands | grep firewall + # set firewall group address-group 'inbound' + # + - name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": [] + # + # "commands": [ + # "set firewall ipv6-name UPLINK default-action 'accept'", + # "set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set'", + # "set firewall ipv6-name UPLINK rule 1 action 'accept'", + # "set firewall ipv6-name UPLINK rule 1", + # "set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible'", + # "set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec'", + # "set firewall ipv6-name UPLINK rule 2 action 'accept'", + # "set firewall ipv6-name UPLINK rule 2", + # "set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible'", + # "set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec'", + # "set firewall name INBOUND default-action 'accept'", + # "set firewall name INBOUND description 'IPv4 INBOUND rule set'", + # "set firewall name INBOUND rule 101 action 'accept'", + # "set firewall name INBOUND rule 101", + # "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", + # "set firewall name INBOUND rule 101 ipsec 'match-ipsec'", + # "set firewall name INBOUND rule 102 action 'reject'", + # "set firewall name INBOUND rule 102", + # "set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible'", + # "set firewall name INBOUND rule 102 ipsec 'match-ipsec'", + # "set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible'", + # "set firewall name INBOUND rule 103 destination group address-group inbound", + # "set firewall name INBOUND rule 103", + # "set firewall name INBOUND rule 103 source address 192.0.2.0", + # "set firewall name INBOUND rule 103 state established enable", + # "set firewall name INBOUND rule 103 state related enable", + # "set firewall name INBOUND rule 103 state invalid disable", + # "set firewall name INBOUND rule 103 state new disable", + # "set firewall name INBOUND rule 103 action 'accept'" + # ] + # + # "after": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK", + # "rules": [ + # { + # "action": "accept", + # "description": "Fwipv6-Rule 1 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 1 + # }, + # { + # "action": "accept", + # "description": "Fwipv6-Rule 2 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 2 + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "INBOUND", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 101 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 101 + # }, + # { + # "action": "reject", + # "description": "Rule 102 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 102 + # }, + # { + # "action": "accept", + # "description": "Rule 103 is configured by Ansible", + # "destination": { + # "group": { + # "address_group": "inbound" + # } + # }, + # "number": 103, + # "source": { + # "address": "192.0.2.0" + # }, + # "state": { + # "established": true, + # "invalid": false, + # "new": false, + # "related": true + # } + # } + # ] + # } + # ] + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall ipv6-name UPLINK rule 1 action 'accept' + # set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + # set firewall ipv6-name UPLINK rule 2 action 'accept' + # set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + # set firewall name INBOUND default-action 'accept' + # set firewall name INBOUND description 'IPv4 INBOUND rule set' + # set firewall name INBOUND rule 101 action 'accept' + # set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + # set firewall name INBOUND rule 101 ipsec 'match-ipsec' + # set firewall name INBOUND rule 102 action 'reject' + # set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + # set firewall name INBOUND rule 102 ipsec 'match-ipsec' + # set firewall name INBOUND rule 103 action 'accept' + # set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + # set firewall name INBOUND rule 103 destination group address-group 'inbound' + # set firewall name INBOUND rule 103 source address '192.0.2.0' + # set firewall name INBOUND rule 103 state established 'enable' + # set firewall name INBOUND rule 103 state invalid 'disable' + # set firewall name INBOUND rule 103 state new 'disable' + # set firewall name INBOUND rule 103 state related 'enable' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall ipv6-name UPLINK rule 1 action 'accept' + # set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + # set firewall ipv6-name UPLINK rule 2 action 'accept' + # set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + # set firewall name INBOUND default-action 'accept' + # set firewall name INBOUND description 'IPv4 INBOUND rule set' + # set firewall name INBOUND rule 101 action 'accept' + # set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + # set firewall name INBOUND rule 101 ipsec 'match-ipsec' + # set firewall name INBOUND rule 102 action 'reject' + # set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + # set firewall name INBOUND rule 102 ipsec 'match-ipsec' + # set firewall name INBOUND rule 103 action 'accept' + # set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + # set firewall name INBOUND rule 103 destination group address-group 'inbound' + # set firewall name INBOUND rule 103 source address '192.0.2.0' + # set firewall name INBOUND rule 103 state established 'enable' + # set firewall name INBOUND rule 103 state invalid 'disable' + # set firewall name INBOUND rule 103 state new 'disable' + # set firewall name INBOUND rule 103 state related 'enable' + # + - name: Replace device configurations of listed firewall rules with provided configurations + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK", + # "rules": [ + # { + # "action": "accept", + # "description": "Fwipv6-Rule 1 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 1 + # }, + # { + # "action": "accept", + # "description": "Fwipv6-Rule 2 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 2 + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "INBOUND", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 101 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 101 + # }, + # { + # "action": "reject", + # "description": "Rule 102 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 102 + # }, + # { + # "action": "accept", + # "description": "Rule 103 is configured by Ansible", + # "destination": { + # "group": { + # "address_group": "inbound" + # } + # }, + # "number": 103, + # "source": { + # "address": "192.0.2.0" + # }, + # "state": { + # "established": true, + # "invalid": false, + # "new": false, + # "related": true + # } + # } + # ] + # } + # ] + # } + # ] + # + # "commands": [ + # "delete firewall ipv6-name UPLINK rule 1", + # "delete firewall ipv6-name UPLINK rule 2", + # "delete firewall name INBOUND rule 102", + # "delete firewall name INBOUND rule 103", + # "set firewall name INBOUND rule 104 action 'reject'", + # "set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible'", + # "set firewall name INBOUND rule 104", + # "set firewall name INBOUND rule 104 ipsec 'match-none'" + # ] + # + # "after": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK" + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "INBOUND", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 101 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 101 + # }, + # { + # "action": "reject", + # "description": "Rule 104 is configured by Ansible", + # "ipsec": "match-none", + # "number": 104 + # } + # ] + # } + # ] + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall name INBOUND default-action 'accept' + # set firewall name INBOUND description 'IPv4 INBOUND rule set' + # set firewall name INBOUND rule 101 action 'accept' + # set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + # set firewall name INBOUND rule 101 ipsec 'match-ipsec' + # set firewall name INBOUND rule 104 action 'reject' + # set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible' + # set firewall name INBOUND rule 104 ipsec 'match-none' + + + # Using overridden + # + # Before state + # -------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall name INBOUND default-action 'accept' + # set firewall name INBOUND description 'IPv4 INBOUND rule set' + # set firewall name INBOUND rule 101 action 'accept' + # set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + # set firewall name INBOUND rule 101 ipsec 'match-ipsec' + # set firewall name INBOUND rule 104 action 'reject' + # set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible' + # set firewall name INBOUND rule 104 ipsec 'match-none' + # + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv4 + rule_sets: + - name: Downlink + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 501 + action: accept + description: Rule 501 is configured by Ansible + ipsec: match-ipsec + - number: 502 + action: reject + description: Rule 502 is configured by Ansible + ipsec: match-ipsec + state: overridden + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK" + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "INBOUND", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 101 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 101 + # }, + # { + # "action": "reject", + # "description": "Rule 104 is configured by Ansible", + # "ipsec": "match-none", + # "number": 104 + # } + # ] + # } + # ] + # } + # ] + # + # "commands": [ + # "delete firewall ipv6-name UPLINK", + # "delete firewall name INBOUND", + # "set firewall name Downlink default-action 'accept'", + # "set firewall name Downlink description 'IPv4 INBOUND rule set'", + # "set firewall name Downlink rule 501 action 'accept'", + # "set firewall name Downlink rule 501", + # "set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible'", + # "set firewall name Downlink rule 501 ipsec 'match-ipsec'", + # "set firewall name Downlink rule 502 action 'reject'", + # "set firewall name Downlink rule 502", + # "set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'", + # "set firewall name Downlink rule 502 ipsec 'match-ipsec'" + # + # + # "after": [ + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "Downlink", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 501 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 501 + # }, + # { + # "action": "reject", + # "description": "Rule 502 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 502 + # } + # ] + # } + # ] + # } + # ] + # + # + # After state + # ------------ + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall name Downlink default-action 'accept' + # set firewall name Downlink description 'IPv4 INBOUND rule set' + # set firewall name Downlink rule 501 action 'accept' + # set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + # set firewall name Downlink rule 501 ipsec 'match-ipsec' + # set firewall name Downlink rule 502 action 'reject' + # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + # set firewall name Downlink rule 502 ipsec 'match-ipsec' + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall ipv6-name UPLINK rule 1 action 'accept' + # set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + # set firewall ipv6-name UPLINK rule 2 action 'accept' + # set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + # set firewall name INBOUND default-action 'accept' + # set firewall name INBOUND description 'IPv4 INBOUND rule set' + # set firewall name INBOUND rule 101 action 'accept' + # set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + # set firewall name INBOUND rule 101 ipsec 'match-ipsec' + # set firewall name INBOUND rule 102 action 'reject' + # set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + # set firewall name INBOUND rule 102 ipsec 'match-ipsec' + # set firewall name INBOUND rule 103 action 'accept' + # set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + # set firewall name INBOUND rule 103 destination group address-group 'inbound' + # set firewall name INBOUND rule 103 source address '192.0.2.0' + # set firewall name INBOUND rule 103 state established 'enable' + # set firewall name INBOUND rule 103 state invalid 'disable' + # set firewall name INBOUND rule 103 state new 'disable' + # set firewall name INBOUND rule 103 state related 'enable' + # + - name: Gather listed firewall rules with provided configurations + vyos.vyos.vyos_firewall_rules: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK", + # "rules": [ + # { + # "action": "accept", + # "description": "Fwipv6-Rule 1 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 1 + # }, + # { + # "action": "accept", + # "description": "Fwipv6-Rule 2 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 2 + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "INBOUND", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 101 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 101 + # }, + # { + # "action": "reject", + # "description": "Rule 102 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 102 + # }, + # { + # "action": "accept", + # "description": "Rule 103 is configured by Ansible", + # "destination": { + # "group": { + # "address_group": "inbound" + # } + # }, + # "number": 103, + # "source": { + # "address": "192.0.2.0" + # }, + # "state": { + # "established": true, + # "invalid": false, + # "new": false, + # "related": true + # } + # } + # ] + # } + # ] + # } + # ] + # + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep firewall + # set firewall group address-group 'inbound' + # set firewall ipv6-name UPLINK default-action 'accept' + # set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + # set firewall ipv6-name UPLINK rule 1 action 'accept' + # set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + # set firewall ipv6-name UPLINK rule 2 action 'accept' + # set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + # set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + # set firewall name INBOUND default-action 'accept' + # set firewall name INBOUND description 'IPv4 INBOUND rule set' + # set firewall name INBOUND rule 101 action 'accept' + # set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + # set firewall name INBOUND rule 101 ipsec 'match-ipsec' + # set firewall name INBOUND rule 102 action 'reject' + # set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + # set firewall name INBOUND rule 102 ipsec 'match-ipsec' + # set firewall name INBOUND rule 103 action 'accept' + # set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + # set firewall name INBOUND rule 103 destination group address-group 'inbound' + # set firewall name INBOUND rule 103 source address '192.0.2.0' + # set firewall name INBOUND rule 103 state established 'enable' + # set firewall name INBOUND rule 103 state invalid 'disable' + # set firewall name INBOUND rule 103 state new 'disable' + # set firewall name INBOUND rule 103 state related 'enable' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set firewall ipv6-name UPLINK default-action 'accept'", + # "set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set'", + # "set firewall name INBOUND default-action 'accept'", + # "set firewall name INBOUND description 'IPv4 INBOUND rule set'", + # "set firewall name INBOUND rule 101 action 'accept'", + # "set firewall name INBOUND rule 101", + # "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", + # "set firewall name INBOUND rule 101 ipsec 'match-ipsec'", + # "set firewall name INBOUND rule 102 action 'reject'", + # "set firewall name INBOUND rule 102", + # "set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible'", + # "set firewall name INBOUND rule 102 ipsec 'match-ipsec'", + # "set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible'", + # "set firewall name INBOUND rule 103 destination group address-group inbound", + # "set firewall name INBOUND rule 103", + # "set firewall name INBOUND rule 103 source address 192.0.2.0", + # "set firewall name INBOUND rule 103 state established enable", + # "set firewall name INBOUND rule 103 state related enable", + # "set firewall name INBOUND rule 103 state invalid disable", + # "set firewall name INBOUND rule 103 state new disable", + # "set firewall name INBOUND rule 103 action 'accept'" + # ] + + + # Using parsed + # + # + - name: Parsed the provided input commands. + vyos.vyos.vyos_firewall_rules: + running_config: + "set firewall group address-group 'inbound' + set firewall name Downlink default-action 'accept' + set firewall name Downlink description 'IPv4 INBOUND rule set' + set firewall name Downlink rule 501 action 'accept' + set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + set firewall name Downlink rule 501 ipsec 'match-ipsec' + set firewall name Downlink rule 502 action 'reject' + set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + set firewall name Downlink rule 502 ipsec 'match-ipsec'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "Downlink", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 501 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 501 + # }, + # { + # "action": "reject", + # "description": "Rule 502 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 502 + # } + # ] + # } + # ] + # } + # ] + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The resulting configuration model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration prior to the model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">["set firewall name Downlink default-action 'accept'", "set firewall name Downlink description 'IPv4 INBOUND rule set'", "set firewall name Downlink rule 501 action 'accept'", "set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'", "set firewall name Downlink rule 502 ipsec 'match-ipsec'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_interface_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_interface_module.rst new file mode 100644 index 00000000..111ff311 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_interface_module.rst @@ -0,0 +1,684 @@ +.. _vyos.vyos.vyos_interface_module: + + +************************ +vyos.vyos.vyos_interface +************************ + +**(deprecated, removed after 2022-06-01) Manage Interface on VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + +DEPRECATED +---------- +:Removed in collection release after 2022-06-01 +:Why: Updated modules released with more functionality. +:Alternative: vyos_interfaces + + + +Synopsis +-------- +- This module provides declarative management of Interfaces on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="3">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of Interfaces definitions.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state argument which are <em>state</em> with values <code>up</code>/<code>down</code> and <em>neighbors</em>.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Description of Interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>duplex</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>full</li> + <li>half</li> + <li>auto</li> + </ul> + </td> + <td> + <div>Interface link status.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Interface link status.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mtu</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Maximum size of transmit packet.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the Interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>neighbors</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Check the operational state of given interface <code>name</code> for LLDP neighbor.</div> + <div>The following suboptions are available.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP neighbor host for given interface <code>name</code>.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP neighbor port to which given interface <code>name</code> is connected.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>speed</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Interface link speed.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + <li>up</li> + <li>down</li> + </ul> + </td> + <td> + <div>State of the Interface configuration, <code>up</code> means present and operationally up and <code>down</code> means present and operationally <code>down</code></div> + </td> + </tr> + + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">10</div> + </td> + <td> + <div>Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state argument which are <em>state</em> with values <code>up</code>/<code>down</code> and <em>neighbors</em>.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Description of Interface.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>duplex</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>full</li> + <li>half</li> + <li>auto</li> + </ul> + </td> + <td> + <div>Interface link status.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li><div style="color: blue"><b>yes</b> ←</div></li> + </ul> + </td> + <td> + <div>Interface link status.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mtu</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Maximum size of transmit packet.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the Interface.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>neighbors</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Check the operational state of given interface <code>name</code> for LLDP neighbor.</div> + <div>The following suboptions are available.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP neighbor host for given interface <code>name</code>.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP neighbor port to which given interface <code>name</code> is connected.</div> + </td> + </tr> + + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>speed</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Interface link speed.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + <li>up</li> + <li>down</li> + </ul> + </td> + <td> + <div>State of the Interface configuration, <code>up</code> means present and operationally up and <code>down</code> means present and operationally <code>down</code></div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VYOS 1.1.7 + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure interface + vyos.vyos.vyos_interface: + name: eth0 + description: test-interface + + - name: remove interface + vyos.vyos.vyos_interface: + name: eth0 + state: absent + + - name: make interface down + vyos.vyos.vyos_interface: + name: eth0 + enabled: false + + - name: make interface up + vyos.vyos.vyos_interface: + name: eth0 + enabled: true + + - name: Configure interface speed, mtu, duplex + vyos.vyos.vyos_interface: + name: eth5 + state: present + speed: 100 + mtu: 256 + duplex: full + + - name: Set interface using aggregate + vyos.vyos.vyos_interface: + aggregate: + - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512} + - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256} + + - name: Disable interface on aggregate + net_interface: + aggregate: + - name: eth1 + - name: eth2 + enabled: false + + - name: Delete interface using aggregate + net_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + + - name: Check lldp neighbors intent arguments + vyos.vyos.vyos_interface: + name: eth0 + neighbors: + - port: eth0 + host: netdev + + - name: Config + intent + vyos.vyos.vyos_interface: + name: eth1 + enabled: false + state: down + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always, except for the platforms that use Netconf transport to manage the device.</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set interfaces ethernet eth0 description "test-interface"', 'set interfaces ethernet eth0 speed 100', 'set interfaces ethernet eth0 mtu 256', 'set interfaces ethernet eth0 duplex full']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +- This module will be removed in version . *[deprecated]* +- For more information see `DEPRECATED`_. + + +Authors +~~~~~~~ + +- Ganesh Nalawade (@ganeshrn) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_interfaces_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_interfaces_module.rst new file mode 100644 index 00000000..5bf5d231 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_interfaces_module.rst @@ -0,0 +1,1328 @@ +.. _vyos.vyos.vyos_interfaces_module: + + +************************* +vyos.vyos.vyos_interfaces +************************* + +**Interfaces resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages the interface attributes on VyOS network devices. +- This module supports managing base attributes of Ethernet, Bonding, VXLAN, Loopback and Virtual Tunnel Interfaces. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="3">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>The provided interfaces configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Interface description.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>duplex</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>full</li> + <li>half</li> + <li>auto</li> + </ul> + </td> + <td> + <div>Interface duplex mode.</div> + <div>Applicable for Ethernet interfaces only.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li><div style="color: blue"><b>yes</b> ←</div></li> + </ul> + </td> + <td> + <div>Administrative state of the interface.</div> + <div>Set the value to <code>true</code> to administratively enable the interface or <code>false</code> to disable it.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mtu</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>MTU for a specific interface. Refer to vendor documentation for valid values.</div> + <div>Applicable for Ethernet, Bonding, VXLAN and Virtual Tunnel interfaces.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Full name of the interface, e.g. eth0, eth1, bond0, vti1, vxlan2.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>speed</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>auto</li> + <li>10</li> + <li>100</li> + <li>1000</li> + <li>2500</li> + <li>10000</li> + </ul> + </td> + <td> + <div>Interface link speed.</div> + <div>Applicable for Ethernet interfaces only.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>vifs</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Virtual sub-interfaces related configuration.</div> + <div>802.1Q VLAN interfaces are represented as virtual sub-interfaces in VyOS.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>description</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Virtual sub-interface description.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li><div style="color: blue"><b>yes</b> ←</div></li> + </ul> + </td> + <td> + <div>Administrative state of the virtual sub-interface.</div> + <div>Set the value to <code>true</code> to administratively enable the interface or <code>false</code> to disable it.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mtu</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>MTU for the virtual sub-interface.</div> + <div>Refer to vendor documentation for valid values.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>vlan_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Identifier for the virtual sub-interface.</div> + </td> + </tr> + + + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep interfaces</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>rendered</li> + <li>gathered</li> + <li>parsed</li> + </ul> + </td> + <td> + <div>The state of the configuration after module completion.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # ------------- + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces loopback lo + + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_interfaces: + config: + - name: eth2 + description: Configured by Ansible + enabled: true + vifs: + - vlan_id: 200 + description: VIF 200 - ETH2 + + - name: eth3 + description: Configured by Ansible + mtu: 1500 + + - name: bond1 + description: Bond - 1 + mtu: 1200 + + - name: vti2 + description: VTI - 2 + enabled: false + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "enabled": true, + # "name": "eth3" + # }, + # { + # "enabled": true, + # "name": "eth2" + # }, + # { + # "enabled": true, + # "name": "eth1" + # }, + # { + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # "commands": [ + # "set interfaces ethernet eth2 description 'Configured by Ansible'", + # "set interfaces ethernet eth2 vif 200", + # "set interfaces ethernet eth2 vif 200 description 'VIF 200 - ETH2'", + # "set interfaces ethernet eth3 description 'Configured by Ansible'", + # "set interfaces ethernet eth3 mtu '1500'", + # "set interfaces bonding bond1", + # "set interfaces bonding bond1 description 'Bond - 1'", + # "set interfaces bonding bond1 mtu '1200'", + # "set interfaces vti vti2", + # "set interfaces vti vti2 description 'VTI - 2'", + # "set interfaces vti vti2 disable" + # ] + # + # "after": [ + # { + # "description": "Bond - 1", + # "enabled": true, + # "mtu": 1200, + # "name": "bond1" + # }, + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "description": "VTI - 2", + # "enabled": false, + # "name": "vti2" + # }, + # { + # "description": "Configured by Ansible", + # "enabled": true, + # "mtu": 1500, + # "name": "eth3" + # }, + # { + # "description": "Configured by Ansible", + # "enabled": true, + # "name": "eth2", + # "vifs": [ + # { + # "description": "VIF 200 - ETH2", + # "enabled": true, + # "vlan_id": "200" + # } + # ] + # }, + # { + # "enabled": true, + # "name": "eth1" + # }, + # { + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # + # ------------- + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces bonding bond1 description 'Bond - 1' + # set interfaces bonding bond1 mtu '1200' + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth2 description 'Configured by Ansible' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth2 vif 200 description 'VIF 200 - ETH2' + # set interfaces ethernet eth3 description 'Configured by Ansible' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 mtu '1500' + # set interfaces loopback lo + # set interfaces vti vti2 description 'VTI - 2' + # set interfaces vti vti2 disable + # + + + # Using replaced + # + # ------------- + # Before state: + # ------------- + # + # vyos:~$ show configuration commands | grep eth + # set interfaces bonding bond1 description 'Bond - 1' + # set interfaces bonding bond1 mtu '1400' + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 description 'Management Interface for the Appliance' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:f3:6c:b5' + # set interfaces ethernet eth0 smp_affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 description 'Configured by Ansible Eng Team' + # set interfaces ethernet eth1 duplex 'full' + # set interfaces ethernet eth1 hw-id '08:00:27:ad:ef:65' + # set interfaces ethernet eth1 smp_affinity 'auto' + # set interfaces ethernet eth1 speed '100' + # set interfaces ethernet eth2 description 'Configured by Ansible' + # set interfaces ethernet eth2 duplex 'full' + # set interfaces ethernet eth2 hw-id '08:00:27:ab:4e:79' + # set interfaces ethernet eth2 mtu '500' + # set interfaces ethernet eth2 smp_affinity 'auto' + # set interfaces ethernet eth2 speed '100' + # set interfaces ethernet eth2 vif 200 description 'Configured by Ansible' + # set interfaces ethernet eth3 description 'Configured by Ansible' + # set interfaces ethernet eth3 duplex 'full' + # set interfaces ethernet eth3 hw-id '08:00:27:17:3c:85' + # set interfaces ethernet eth3 mtu '1500' + # set interfaces ethernet eth3 smp_affinity 'auto' + # set interfaces ethernet eth3 speed '100' + # set interfaces loopback lo + # + # + - name: Replace device configurations of listed interfaces with provided configurations + vyos.vyos.vyos_interfaces: + config: + - name: eth2 + description: Replaced by Ansible + + - name: eth3 + description: Replaced by Ansible + + - name: eth1 + description: Replaced by Ansible + state: replaced + # + # + # ----------------------- + # Module Execution Result + # ----------------------- + # + # "before": [ + # { + # "description": "Bond - 1", + # "enabled": true, + # "mtu": 1400, + # "name": "bond1" + # }, + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "description": "Configured by Ansible", + # "duplex": "full", + # "enabled": true, + # "mtu": 1500, + # "name": "eth3", + # "speed": "100" + # }, + # { + # "description": "Configured by Ansible", + # "duplex": "full", + # "enabled": true, + # "mtu": 500, + # "name": "eth2", + # "speed": "100", + # "vifs": [ + # { + # "description": "VIF 200 - ETH2", + # "enabled": true, + # "vlan_id": "200" + # } + # ] + # }, + # { + # "description": "Configured by Ansible Eng Team", + # "duplex": "full", + # "enabled": true, + # "name": "eth1", + # "speed": "100" + # }, + # { + # "description": "Management Interface for the Appliance", + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # "commands": [ + # "delete interfaces ethernet eth2 speed", + # "delete interfaces ethernet eth2 duplex", + # "delete interfaces ethernet eth2 mtu", + # "delete interfaces ethernet eth2 vif 200 description", + # "set interfaces ethernet eth2 description 'Replaced by Ansible'", + # "delete interfaces ethernet eth3 speed", + # "delete interfaces ethernet eth3 duplex", + # "delete interfaces ethernet eth3 mtu", + # "set interfaces ethernet eth3 description 'Replaced by Ansible'", + # "delete interfaces ethernet eth1 speed", + # "delete interfaces ethernet eth1 duplex", + # "set interfaces ethernet eth1 description 'Replaced by Ansible'" + # ] + # + # "after": [ + # { + # "description": "Bond - 1", + # "enabled": true, + # "mtu": 1400, + # "name": "bond1" + # }, + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "description": "Replaced by Ansible", + # "enabled": true, + # "name": "eth3" + # }, + # { + # "description": "Replaced by Ansible", + # "enabled": true, + # "name": "eth2", + # "vifs": [ + # { + # "enabled": true, + # "vlan_id": "200" + # } + # ] + # }, + # { + # "description": "Replaced by Ansible", + # "enabled": true, + # "name": "eth1" + # }, + # { + # "description": "Management Interface for the Appliance", + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # + # ------------- + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces bonding bond1 description 'Bond - 1' + # set interfaces bonding bond1 mtu '1400' + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 description 'Management Interface for the Appliance' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 description 'Replaced by Ansible' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth2 description 'Replaced by Ansible' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth2 vif 200 + # set interfaces ethernet eth3 description 'Replaced by Ansible' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces loopback lo + # + # + # Using overridden + # + # + # -------------- + # Before state + # -------------- + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 description 'Ethernet Interface - 0' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 mtu '1200' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 description 'Configured by Ansible Eng Team' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 mtu '100' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth1 vif 100 description 'VIF 100 - ETH1' + # set interfaces ethernet eth1 vif 100 disable + # set interfaces ethernet eth2 description 'Configured by Ansible Team (Admin Down)' + # set interfaces ethernet eth2 disable + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 mtu '600' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth3 description 'Configured by Ansible Network' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces loopback lo + # set interfaces vti vti1 description 'Virtual Tunnel Interface - 1' + # set interfaces vti vti1 mtu '68' + # + # + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_interfaces: + config: + - name: eth0 + description: Outbound Interface For The Appliance + speed: auto + duplex: auto + + - name: eth2 + speed: auto + duplex: auto + + - name: eth3 + mtu: 1200 + state: overridden + # + # + # ------------------------ + # Module Execution Result + # ------------------------ + # + # "before": [ + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "description": "Virtual Tunnel Interface - 1", + # "enabled": true, + # "mtu": 68, + # "name": "vti1" + # }, + # { + # "description": "Configured by Ansible Network", + # "enabled": true, + # "name": "eth3" + # }, + # { + # "description": "Configured by Ansible Team (Admin Down)", + # "enabled": false, + # "mtu": 600, + # "name": "eth2" + # }, + # { + # "description": "Configured by Ansible Eng Team", + # "enabled": true, + # "mtu": 100, + # "name": "eth1", + # "vifs": [ + # { + # "description": "VIF 100 - ETH1", + # "enabled": false, + # "vlan_id": "100" + # } + # ] + # }, + # { + # "description": "Ethernet Interface - 0", + # "duplex": "auto", + # "enabled": true, + # "mtu": 1200, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # "commands": [ + # "delete interfaces vti vti1 description", + # "delete interfaces vti vti1 mtu", + # "delete interfaces ethernet eth1 description", + # "delete interfaces ethernet eth1 mtu", + # "delete interfaces ethernet eth1 vif 100 description", + # "delete interfaces ethernet eth1 vif 100 disable", + # "delete interfaces ethernet eth0 mtu", + # "set interfaces ethernet eth0 description 'Outbound Interface For The Appliance'", + # "delete interfaces ethernet eth2 description", + # "delete interfaces ethernet eth2 mtu", + # "set interfaces ethernet eth2 duplex 'auto'", + # "delete interfaces ethernet eth2 disable", + # "set interfaces ethernet eth2 speed 'auto'", + # "delete interfaces ethernet eth3 description", + # "set interfaces ethernet eth3 mtu '1200'" + # ], + # + # "after": [ + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "enabled": true, + # "name": "vti1" + # }, + # { + # "enabled": true, + # "mtu": 1200, + # "name": "eth3" + # }, + # { + # "duplex": "auto", + # "enabled": true, + # "name": "eth2", + # "speed": "auto" + # }, + # { + # "enabled": true, + # "name": "eth1", + # "vifs": [ + # { + # "enabled": true, + # "vlan_id": "100" + # } + # ] + # }, + # { + # "description": "Outbound Interface For The Appliance", + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # + # ------------ + # After state + # ------------ + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 description 'Outbound Interface For The Appliance' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth1 vif 100 + # set interfaces ethernet eth2 duplex 'auto' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth2 speed 'auto' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 mtu '1200' + # set interfaces loopback lo + # set interfaces vti vti1 + # + # + # Using deleted + # + # + # ------------- + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces bonding bond0 mtu '1300' + # set interfaces bonding bond1 description 'LAG - 1' + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 description 'Outbound Interface for this appliance' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 description 'Configured by Ansible Network' + # set interfaces ethernet eth1 duplex 'full' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth1 speed '100' + # set interfaces ethernet eth2 description 'Configured by Ansible' + # set interfaces ethernet eth2 disable + # set interfaces ethernet eth2 duplex 'full' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 mtu '600' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth2 speed '100' + # set interfaces ethernet eth3 description 'Configured by Ansible Network' + # set interfaces ethernet eth3 duplex 'full' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 speed '100' + # set interfaces loopback lo + # + # + - name: Delete attributes of given interfaces (Note - This won't delete the interfaces + themselves) + vyos.vyos.vyos_interfaces: + config: + - name: bond1 + + - name: eth1 + + - name: eth2 + + - name: eth3 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "enabled": true, + # "mtu": 1300, + # "name": "bond0" + # }, + # { + # "description": "LAG - 1", + # "enabled": true, + # "name": "bond1" + # }, + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "description": "Configured by Ansible Network", + # "duplex": "full", + # "enabled": true, + # "name": "eth3", + # "speed": "100" + # }, + # { + # "description": "Configured by Ansible", + # "duplex": "full", + # "enabled": false, + # "mtu": 600, + # "name": "eth2", + # "speed": "100" + # }, + # { + # "description": "Configured by Ansible Network", + # "duplex": "full", + # "enabled": true, + # "name": "eth1", + # "speed": "100" + # }, + # { + # "description": "Outbound Interface for this appliance", + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # "commands": [ + # "delete interfaces bonding bond1 description", + # "delete interfaces ethernet eth1 speed", + # "delete interfaces ethernet eth1 duplex", + # "delete interfaces ethernet eth1 description", + # "delete interfaces ethernet eth2 speed", + # "delete interfaces ethernet eth2 disable", + # "delete interfaces ethernet eth2 duplex", + # "delete interfaces ethernet eth2 disable", + # "delete interfaces ethernet eth2 description", + # "delete interfaces ethernet eth2 disable", + # "delete interfaces ethernet eth2 mtu", + # "delete interfaces ethernet eth2 disable", + # "delete interfaces ethernet eth3 speed", + # "delete interfaces ethernet eth3 duplex", + # "delete interfaces ethernet eth3 description" + # ] + # + # "after": [ + # { + # "enabled": true, + # "mtu": 1300, + # "name": "bond0" + # }, + # { + # "enabled": true, + # "name": "bond1" + # }, + # { + # "enabled": true, + # "name": "lo" + # }, + # { + # "enabled": true, + # "name": "eth3" + # }, + # { + # "enabled": true, + # "name": "eth2" + # }, + # { + # "enabled": true, + # "name": "eth1" + # }, + # { + # "description": "Outbound Interface for this appliance", + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # + # ------------ + # After state + # ------------ + # + # vyos@vyos:~$ show configuration commands | grep interfaces + # set interfaces bonding bond0 mtu '1300' + # set interfaces bonding bond1 + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 description 'Outbound Interface for this appliance' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' + # set interfaces ethernet eth1 smp-affinity 'auto' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth2 smp-affinity 'auto' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces loopback lo + # + # + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep interfaces + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' + # set interfaces ethernet eth0 smp_affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 description 'Configured by Ansible' + # set interfaces ethernet eth1 duplex 'auto' + # set interfaces ethernet eth1 mtu '1500' + # set interfaces ethernet eth1 speed 'auto' + # set interfaces ethernet eth1 vif 200 description 'VIF - 200' + # set interfaces ethernet eth2 description 'Configured by Ansible' + # set interfaces ethernet eth2 duplex 'auto' + # set interfaces ethernet eth2 mtu '1500' + # set interfaces ethernet eth2 speed 'auto' + # set interfaces ethernet eth2 vif 200 description 'VIF - 200' + # + - name: Gather listed interfaces with provided configurations + vyos.vyos.vyos_interfaces: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "description": "Configured by Ansible", + # "duplex": "auto", + # "enabled": true, + # "mtu": 1500, + # "name": "eth2", + # "speed": "auto", + # "vifs": [ + # { + # "description": "VIF - 200", + # "enabled": true, + # "vlan_id": 200 + # } + # ] + # }, + # { + # "description": "Configured by Ansible", + # "duplex": "auto", + # "enabled": true, + # "mtu": 1500, + # "name": "eth1", + # "speed": "auto", + # "vifs": [ + # { + # "description": "VIF - 200", + # "enabled": true, + # "vlan_id": 200 + # } + # ] + # }, + # { + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + # + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep interfaces + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' + # set interfaces ethernet eth0 smp_affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 description 'Configured by Ansible' + # set interfaces ethernet eth1 duplex 'auto' + # set interfaces ethernet eth1 mtu '1500' + # set interfaces ethernet eth1 speed 'auto' + # set interfaces ethernet eth1 vif 200 description 'VIF - 200' + # set interfaces ethernet eth2 description 'Configured by Ansible' + # set interfaces ethernet eth2 duplex 'auto' + # set interfaces ethernet eth2 mtu '1500' + # set interfaces ethernet eth2 speed 'auto' + # set interfaces ethernet eth2 vif 200 description 'VIF - 200' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_interfaces: + config: + - name: eth0 + enabled: true + duplex: auto + speed: auto + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + enabled: true + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 + enabled: true + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set interfaces ethernet eth0 duplex 'auto'", + # "set interfaces ethernet eth0 speed 'auto'", + # "delete interfaces ethernet eth0 disable", + # "set interfaces ethernet eth1 duplex 'auto'", + # "delete interfaces ethernet eth1 disable", + # "set interfaces ethernet eth1 speed 'auto'", + # "set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'", + # "set interfaces ethernet eth1 mtu '1500'", + # "set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'", + # "set interfaces ethernet eth1 vif 100 mtu '400'", + # "set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'", + # "set interfaces ethernet eth2 disable", + # "set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'", + # "set interfaces ethernet eth2 mtu '600'" + # ] + + + # Using parsed + # + # + - name: Parse the configuration. + vyos.vyos.vyos_interfaces: + running_config: + "set interfaces ethernet eth0 address 'dhcp' + set interfaces ethernet eth0 duplex 'auto' + set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' + set interfaces ethernet eth0 smp_affinity 'auto' + set interfaces ethernet eth0 speed 'auto' + set interfaces ethernet eth1 description 'Configured by Ansible' + set interfaces ethernet eth1 duplex 'auto' + set interfaces ethernet eth1 mtu '1500' + set interfaces ethernet eth1 speed 'auto' + set interfaces ethernet eth1 vif 200 description 'VIF - 200' + set interfaces ethernet eth2 description 'Configured by Ansible' + set interfaces ethernet eth2 duplex 'auto' + set interfaces ethernet eth2 mtu '1500' + set interfaces ethernet eth2 speed 'auto' + set interfaces ethernet eth2 vif 200 description 'VIF - 200'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "description": "Configured by Ansible", + # "duplex": "auto", + # "enabled": true, + # "mtu": 1500, + # "name": "eth2", + # "speed": "auto", + # "vifs": [ + # { + # "description": "VIF - 200", + # "enabled": true, + # "vlan_id": 200 + # } + # ] + # }, + # { + # "description": "Configured by Ansible", + # "duplex": "auto", + # "enabled": true, + # "mtu": 1500, + # "name": "eth1", + # "speed": "auto", + # "vifs": [ + # { + # "description": "VIF - 200", + # "enabled": true, + # "vlan_id": 200 + # } + # ] + # }, + # { + # "duplex": "auto", + # "enabled": true, + # "name": "eth0", + # "speed": "auto" + # } + # ] + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The configuration as structured data after module completion.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration as structured data prior to module invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set interfaces ethernet eth1 mtu 1200', 'set interfaces ethernet eth2 vif 100 description VIF 100']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nilashish Chakraborty (@nilashishc) +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_l3_interface_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_l3_interface_module.rst new file mode 100644 index 00000000..a8fe6040 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_l3_interface_module.rst @@ -0,0 +1,396 @@ +.. _vyos.vyos.vyos_l3_interface_module: + + +*************************** +vyos.vyos.vyos_l3_interface +*************************** + +**(deprecated, removed after 2022-06-01) Manage L3 interfaces on VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + +DEPRECATED +---------- +:Removed in collection release after 2022-06-01 +:Why: Updated modules released with more functionality. +:Alternative: vyos_l3_interfaces + + + +Synopsis +-------- +- This module provides declarative management of L3 interfaces on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of L3 interfaces definitions</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv4</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv4 of the L3 interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv6</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv6 of the L3 interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the L3 interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the L3 interface configuration.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv4</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv4 of the L3 interface.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv6</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv6 of the L3 interface.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the L3 interface.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the L3 interface configuration.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VYOS 1.1.7 + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Set eth0 IPv4 address + vyos.vyos.vyos_l3_interface: + name: eth0 + ipv4: 192.168.0.1/24 + + - name: Remove eth0 IPv4 address + vyos.vyos.vyos_l3_interface: + name: eth0 + state: absent + + - name: Set IP addresses on aggregate + vyos.vyos.vyos_l3_interface: + aggregate: + - {name: eth1, ipv4: 192.168.2.10/24} + - {name: eth2, ipv4: 192.168.3.10/24, ipv6: fd5d:12c9:2201:1::1/64} + + - name: Remove IP addresses on aggregate + vyos.vyos.vyos_l3_interface: + aggregate: + - {name: eth1, ipv4: 192.168.2.10/24} + - {name: eth2, ipv4: 192.168.3.10/24, ipv6: fd5d:12c9:2201:1::1/64} + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always, except for the platforms that use Netconf transport to manage the device.</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">["set interfaces ethernet eth0 address '192.168.0.1/24'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +- This module will be removed in version . *[deprecated]* +- For more information see `DEPRECATED`_. + + +Authors +~~~~~~~ + +- Ricardo Carrillo Cruz (@rcarrillocruz) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_l3_interfaces_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_l3_interfaces_module.rst new file mode 100644 index 00000000..38dd3e91 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_l3_interfaces_module.rst @@ -0,0 +1,771 @@ +.. _vyos.vyos.vyos_l3_interfaces_module: + + +**************************** +vyos.vyos.vyos_l3_interfaces +**************************** + +**L3 interfaces resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages the L3 interface attributes on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="4">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>The provided L3 interfaces configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv4</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of IPv4 addresses of the interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv4 address of the interface.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv6</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of IPv6 addresses of the interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv6 address of the interface.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Full name of the interface, e.g. eth0, eth1.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>vifs</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Virtual sub-interfaces L3 configurations.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv4</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of IPv4 addresses of the virtual interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv4 address of the virtual interface.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ipv6</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of IPv6 addresses of the virtual interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>IPv6 address of the virtual interface.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>vlan_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Identifier for the virtual sub-interface.</div> + </td> + </tr> + + + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep -e eth[2,3]</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>parsed</li> + <li>gathered</li> + <li>rendered</li> + </ul> + </td> + <td> + <div>The state of the configuration after module completion.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos:~$ show configuration commands | grep -e eth[2,3] + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 vif 101 + # set interfaces ethernet eth3 vif 102 + + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth2 + ipv4: + - address: 192.0.2.10/28 + - address: 198.51.100.40/27 + ipv6: + - address: 2001:db8:100::2/32 + - address: 2001:db8:400::10/32 + + - name: eth3 + ipv4: + - address: 203.0.113.65/26 + vifs: + - vlan_id: 101 + ipv4: + - address: 192.0.2.71/28 + - address: 198.51.100.131/25 + - vlan_id: 102 + ipv6: + - address: 2001:db8:1000::5/38 + - address: 2001:db8:1400::3/38 + state: merged + + # After state: + # ------------- + # + # vyos:~$ show configuration commands | grep -e eth[2,3] + # set interfaces ethernet eth2 address '192.0.2.10/28' + # set interfaces ethernet eth2 address '198.51.100.40/27' + # set interfaces ethernet eth2 address '2001:db8:100::2/32' + # set interfaces ethernet eth2 address '2001:db8:400::10/32' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 address '203.0.113.65/26' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 vif 101 address '192.0.2.71/28' + # set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' + # set interfaces ethernet eth3 vif 102 address '2001:db8:1000::5/38' + # set interfaces ethernet eth3 vif 102 address '2001:db8:1400::3/38' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos:~$ show configuration commands | grep eth + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' + # set interfaces ethernet eth1 address '192.0.2.14/24' + # set interfaces ethernet eth2 address '192.0.2.10/24' + # set interfaces ethernet eth2 address '192.0.2.11/24' + # set interfaces ethernet eth2 address '2001:db8::10/32' + # set interfaces ethernet eth2 address '2001:db8::11/32' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 address '198.51.100.10/24' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 vif 101 address '198.51.100.130/25' + # set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::3/34' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + # + - name: Replace device configurations of listed interfaces with provided configurations + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + + - name: eth3 + ipv6: + - address: 2001:db8::11/32 + state: replaced + + # After state: + # ------------- + # + # vyos:~$ show configuration commands | grep eth + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' + # set interfaces ethernet eth1 address '192.0.2.14/24' + # set interfaces ethernet eth2 address '192.0.2.10/24' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 address '2001:db8::11/32' + # set interfaces ethernet eth3 vif 101 + # set interfaces ethernet eth3 vif 102 + + + # Using overridden + # + # Before state + # -------------- + # + # vyos@vyos-appliance:~$ show configuration commands | grep eth + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' + # set interfaces ethernet eth1 address '192.0.2.14/24' + # set interfaces ethernet eth2 address '192.0.2.10/24' + # set interfaces ethernet eth2 address '192.0.2.11/24' + # set interfaces ethernet eth2 address '2001:db8::10/32' + # set interfaces ethernet eth2 address '2001:db8::11/32' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 address '198.51.100.10/24' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 vif 101 address '198.51.100.130/25' + # set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::3/34' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth0 + ipv4: + - address: dhcp + ipv6: + - address: dhcpv6 + state: overridden + + # After state + # ------------ + # + # vyos@vyos-appliance:~$ show configuration commands | grep eth + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 address 'dhcpv6' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 vif 101 + # set interfaces ethernet eth3 vif 102 + + + # Using deleted + # + # Before state + # ------------- + # vyos@vyos-appliance:~$ show configuration commands | grep eth + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' + # set interfaces ethernet eth0 smp-affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' + # set interfaces ethernet eth1 address '192.0.2.14/24' + # set interfaces ethernet eth2 address '192.0.2.10/24' + # set interfaces ethernet eth2 address '192.0.2.11/24' + # set interfaces ethernet eth2 address '2001:db8::10/32' + # set interfaces ethernet eth2 address '2001:db8::11/32' + # set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' + # set interfaces ethernet eth3 address '198.51.100.10/24' + # set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' + # set interfaces ethernet eth3 vif 101 address '198.51.100.130/25' + # set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::3/34' + # set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + + - name: Delete L3 attributes of given interfaces (Note - This won't delete the interface + itself) + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth1 + - name: eth2 + - name: eth3 + state: deleted + + # After state + # ------------ + # vyos@vyos-appliance:~$ show configuration commands | grep eth + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:f3:6c:b5' + # set interfaces ethernet eth0 smp_affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 hw-id '08:00:27:ad:ef:65' + # set interfaces ethernet eth1 smp_affinity 'auto' + # set interfaces ethernet eth2 hw-id '08:00:27:ab:4e:79' + # set interfaces ethernet eth2 smp_affinity 'auto' + # set interfaces ethernet eth3 hw-id '08:00:27:17:3c:85' + # set interfaces ethernet eth3 smp_affinity 'auto' + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos:~$ show configuration commands | grep -e eth[2,3,0] + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' + # set interfaces ethernet eth0 smp_affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 address '192.0.2.14/24' + # set interfaces ethernet eth2 address '192.0.2.11/24' + # set interfaces ethernet eth2 address '192.0.2.10/24' + # set interfaces ethernet eth2 address '2001:db8::10/32' + # set interfaces ethernet eth2 address '2001:db8::12/32' + # + - name: Gather listed l3 interfaces with provided configurations + vyos.vyos.vyos_l3_interfaces: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "ipv4": [ + # { + # "address": "192.0.2.11/24" + # }, + # { + # "address": "192.0.2.10/24" + # } + # ], + # "ipv6": [ + # { + # "address": "2001:db8::10/32" + # }, + # { + # "address": "2001:db8::12/32" + # } + # ], + # "name": "eth2" + # }, + # { + # "ipv4": [ + # { + # "address": "192.0.2.14/24" + # } + # ], + # "name": "eth1" + # }, + # { + # "ipv4": [ + # { + # "address": "dhcp" + # } + # ], + # "name": "eth0" + # } + # ] + # + # + # After state: + # ------------- + # + # vyos:~$ show configuration commands | grep -e eth[2,3] + # set interfaces ethernet eth0 address 'dhcp' + # set interfaces ethernet eth0 duplex 'auto' + # set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' + # set interfaces ethernet eth0 smp_affinity 'auto' + # set interfaces ethernet eth0 speed 'auto' + # set interfaces ethernet eth1 address '192.0.2.14/24' + # set interfaces ethernet eth2 address '192.0.2.11/24' + # set interfaces ethernet eth2 address '192.0.2.10/24' + # set interfaces ethernet eth2 address '2001:db8::10/32' + # set interfaces ethernet eth2 address '2001:db8::12/32' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: 2001:db8::10/32 + - address: 2001:db8::12/32 + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set interfaces ethernet eth1 address '192.0.2.14/24'", + # "set interfaces ethernet eth2 address '192.0.2.11/24'", + # "set interfaces ethernet eth2 address '192.0.2.10/24'", + # "set interfaces ethernet eth2 address '2001:db8::10/32'", + # "set interfaces ethernet eth2 address '2001:db8::12/32'" + # ] + + + # Using parsed + # + # + - name: parse the provided running configuration + vyos.vyos.vyos_l3_interfaces: + running_config: + "set interfaces ethernet eth0 address 'dhcp' + set interfaces ethernet eth1 address '192.0.2.14/24' + set interfaces ethernet eth2 address '192.0.2.10/24' + set interfaces ethernet eth2 address '192.0.2.11/24' + set interfaces ethernet eth2 address '2001:db8::10/32' + set interfaces ethernet eth2 address '2001:db8::12/32'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "ipv4": [ + # { + # "address": "192.0.2.10/24" + # }, + # { + # "address": "192.0.2.11/24" + # } + # ], + # "ipv6": [ + # { + # "address": "2001:db8::10/32" + # }, + # { + # "address": "2001:db8::12/32" + # } + # ], + # "name": "eth2" + # }, + # { + # "ipv4": [ + # { + # "address": "192.0.2.14/24" + # } + # ], + # "name": "eth1" + # }, + # { + # "ipv4": [ + # { + # "address": "dhcp" + # } + # ], + # "name": "eth0" + # } + # ] + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The configuration as structured data after module completion.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration as structured data prior to module invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set interfaces ethernet eth1 192.0.2.14/2', 'set interfaces ethernet eth3 vif 101 address 198.51.100.130/25']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nilashish Chakraborty (@NilashishC) +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lag_interfaces_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lag_interfaces_module.rst new file mode 100644 index 00000000..153e20e2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lag_interfaces_module.rst @@ -0,0 +1,947 @@ +.. _vyos.vyos.vyos_lag_interfaces_module: + + +***************************** +vyos.vyos.vyos_lag_interfaces +***************************** + +**LAG interfaces resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages attributes of link aggregation groups on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="3">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A list of link aggregation group configurations.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>arp_monitor</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>ARP Link monitoring parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>ARP link monitoring frequency in milliseconds.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>target</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>IP address to use for ARP monitoring.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>hash_policy</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>layer2</li> + <li>layer2+3</li> + <li>layer3+4</li> + </ul> + </td> + <td> + <div>LAG or bonding transmit hash policy.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>members</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of member interfaces for the LAG (bond).</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>member</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the member interface.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mode</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>802.3ad</li> + <li>active-backup</li> + <li>broadcast</li> + <li>round-robin</li> + <li>transmit-load-balance</li> + <li>adaptive-load-balance</li> + <li>xor-hash</li> + </ul> + </td> + <td> + <div>LAG or bond mode.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the link aggregation group (LAG) or bond.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>primary</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Primary device interfaces for the LAG (bond).</div> + </td> + </tr> + + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep bond</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>parsed</li> + <li>gathered</li> + <li>rendered</li> + </ul> + </td> + <td> + <div>The state of the configuration after module completion.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 + # set interfaces bonding bond3 + # + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond2 + mode: active-backup + members: + - member: eth2 + - member: eth1 + hash_policy: layer2 + primary: eth2 + + - name: bond3 + mode: active-backup + hash_policy: layer2+3 + members: + - member: eth3 + primary: eth3 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "name": "bond2" + # }, + # { + # "name": "bond3" + # } + # ], + # + # "commands": [ + # "set interfaces bonding bond2 hash-policy 'layer2'", + # "set interfaces bonding bond2 mode 'active-backup'", + # "set interfaces ethernet eth2 bond-group bond2", + # "set interfaces ethernet eth1 bond-group bond2", + # "set interfaces bonding bond2 primary 'eth2'", + # "set interfaces bonding bond3 hash-policy 'layer2+3'", + # "set interfaces bonding bond3 mode 'active-backup'", + # "set interfaces ethernet eth3 bond-group bond3", + # "set interfaces bonding bond3 primary 'eth3'" + # ] + # + # "after": [ + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # }, + # { + # "member": "eth2" + # } + # ], + # "mode": "active-backup", + # "name": "bond2", + # "primary": "eth2" + # }, + # { + # "hash_policy": "layer2+3", + # "members": [ + # { + # "member": "eth3" + # } + # ], + # "mode": "active-backup", + # "name": "bond3", + # "primary": "eth3" + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 hash-policy 'layer2' + # set interfaces bonding bond2 mode 'active-backup' + # set interfaces bonding bond2 primary 'eth2' + # set interfaces bonding bond3 hash-policy 'layer2+3' + # set interfaces bonding bond3 mode 'active-backup' + # set interfaces bonding bond3 primary 'eth3' + # set interfaces ethernet eth1 bond-group 'bond2' + # set interfaces ethernet eth2 bond-group 'bond2' + # set interfaces ethernet eth3 bond-group 'bond3' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 hash-policy 'layer2' + # set interfaces bonding bond2 mode 'active-backup' + # set interfaces bonding bond2 primary 'eth2' + # set interfaces bonding bond3 hash-policy 'layer2+3' + # set interfaces bonding bond3 mode 'active-backup' + # set interfaces bonding bond3 primary 'eth3' + # set interfaces ethernet eth1 bond-group 'bond2' + # set interfaces ethernet eth2 bond-group 'bond2' + # set interfaces ethernet eth3 bond-group 'bond3' + # + - name: Replace device configurations of listed LAGs with provided configurations + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond3 + mode: 802.3ad + hash_policy: layer2 + members: + - member: eth3 + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # }, + # { + # "member": "eth2" + # } + # ], + # "mode": "active-backup", + # "name": "bond2", + # "primary": "eth2" + # }, + # { + # "hash_policy": "layer2+3", + # "members": [ + # { + # "member": "eth3" + # } + # ], + # "mode": "active-backup", + # "name": "bond3", + # "primary": "eth3" + # } + # ], + # + # "commands": [ + # "delete interfaces bonding bond3 primary", + # "set interfaces bonding bond3 hash-policy 'layer2'", + # "set interfaces bonding bond3 mode '802.3ad'" + # ], + # + # "after": [ + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # }, + # { + # "member": "eth2" + # } + # ], + # "mode": "active-backup", + # "name": "bond2", + # "primary": "eth2" + # }, + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth3" + # } + # ], + # "mode": "802.3ad", + # "name": "bond3" + # } + # ], + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 hash-policy 'layer2' + # set interfaces bonding bond2 mode 'active-backup' + # set interfaces bonding bond2 primary 'eth2' + # set interfaces bonding bond3 hash-policy 'layer2' + # set interfaces bonding bond3 mode '802.3ad' + # set interfaces ethernet eth1 bond-group 'bond2' + # set interfaces ethernet eth2 bond-group 'bond2' + # set interfaces ethernet eth3 bond-group 'bond3' + + + # Using overridden + # + # Before state + # -------------- + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 hash-policy 'layer2' + # set interfaces bonding bond2 mode 'active-backup' + # set interfaces bonding bond2 primary 'eth2' + # set interfaces bonding bond3 hash-policy 'layer2' + # set interfaces bonding bond3 mode '802.3ad' + # set interfaces ethernet eth1 bond-group 'bond2' + # set interfaces ethernet eth2 bond-group 'bond2' + # set interfaces ethernet eth3 bond-group 'bond3' + # + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond3 + mode: active-backup + members: + - member: eth1 + - member: eth2 + - member: eth3 + primary: eth3 + hash_policy: layer2 + state: overridden + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # }, + # { + # "member": "eth2" + # } + # ], + # "mode": "active-backup", + # "name": "bond2", + # "primary": "eth2" + # }, + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth3" + # } + # ], + # "mode": "802.3ad", + # "name": "bond3" + # } + # ], + # + # "commands": [ + # "delete interfaces bonding bond2 hash-policy", + # "delete interfaces ethernet eth1 bond-group bond2", + # "delete interfaces ethernet eth2 bond-group bond2", + # "delete interfaces bonding bond2 mode", + # "delete interfaces bonding bond2 primary", + # "set interfaces bonding bond3 mode 'active-backup'", + # "set interfaces ethernet eth1 bond-group bond3", + # "set interfaces ethernet eth2 bond-group bond3", + # "set interfaces bonding bond3 primary 'eth3'" + # ], + # + # "after": [ + # { + # "name": "bond2" + # }, + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # }, + # { + # "member": "eth2" + # }, + # { + # "member": "eth3" + # } + # ], + # "mode": "active-backup", + # "name": "bond3", + # "primary": "eth3" + # } + # ], + # + # + # After state + # ------------ + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 + # set interfaces bonding bond3 hash-policy 'layer2' + # set interfaces bonding bond3 mode 'active-backup' + # set interfaces bonding bond3 primary 'eth3' + # set interfaces ethernet eth1 bond-group 'bond3' + # set interfaces ethernet eth2 bond-group 'bond3' + # set interfaces ethernet eth3 bond-group 'bond3' + + + # Using deleted + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 hash-policy 'layer2' + # set interfaces bonding bond2 mode 'active-backup' + # set interfaces bonding bond2 primary 'eth2' + # set interfaces bonding bond3 hash-policy 'layer2+3' + # set interfaces bonding bond3 mode 'active-backup' + # set interfaces bonding bond3 primary 'eth3' + # set interfaces ethernet eth1 bond-group 'bond2' + # set interfaces ethernet eth2 bond-group 'bond2' + # set interfaces ethernet eth3 bond-group 'bond3' + # + - name: Delete LAG attributes of given interfaces (Note This won't delete the interface + itself) + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond2 + - name: bond3 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # }, + # { + # "member": "eth2" + # } + # ], + # "mode": "active-backup", + # "name": "bond2", + # "primary": "eth2" + # }, + # { + # "hash_policy": "layer2+3", + # "members": [ + # { + # "member": "eth3" + # } + # ], + # "mode": "active-backup", + # "name": "bond3", + # "primary": "eth3" + # } + # ], + # "commands": [ + # "delete interfaces bonding bond2 hash-policy", + # "delete interfaces ethernet eth1 bond-group bond2", + # "delete interfaces ethernet eth2 bond-group bond2", + # "delete interfaces bonding bond2 mode", + # "delete interfaces bonding bond2 primary", + # "delete interfaces bonding bond3 hash-policy", + # "delete interfaces ethernet eth3 bond-group bond3", + # "delete interfaces bonding bond3 mode", + # "delete interfaces bonding bond3 primary" + # ], + # + # "after": [ + # { + # "name": "bond2" + # }, + # { + # "name": "bond3" + # } + # ], + # + # After state + # ------------ + # vyos@vyos:~$ show configuration commands | grep bond + # set interfaces bonding bond2 + # set interfaces bonding bond3 + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep bond + # set interfaces bonding bond0 hash-policy 'layer2' + # set interfaces bonding bond0 mode 'active-backup' + # set interfaces bonding bond0 primary 'eth1' + # set interfaces bonding bond1 hash-policy 'layer2+3' + # set interfaces bonding bond1 mode 'active-backup' + # set interfaces bonding bond1 primary 'eth2' + # set interfaces ethernet eth1 bond-group 'bond0' + # set interfaces ethernet eth2 bond-group 'bond1' + # + - name: Gather listed lag interfaces with provided configurations + vyos.vyos.vyos_lag_interfaces: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "afi": "ipv6", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "This is ipv6 specific rule-set", + # "name": "UPLINK", + # "rules": [ + # { + # "action": "accept", + # "description": "Fwipv6-Rule 1 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 1 + # }, + # { + # "action": "accept", + # "description": "Fwipv6-Rule 2 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 2 + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv4", + # "rule_sets": [ + # { + # "default_action": "accept", + # "description": "IPv4 INBOUND rule set", + # "name": "INBOUND", + # "rules": [ + # { + # "action": "accept", + # "description": "Rule 101 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 101 + # }, + # { + # "action": "reject", + # "description": "Rule 102 is configured by Ansible", + # "ipsec": "match-ipsec", + # "number": 102 + # }, + # { + # "action": "accept", + # "description": "Rule 103 is configured by Ansible", + # "destination": { + # "group": { + # "address_group": "inbound" + # } + # }, + # "number": 103, + # "source": { + # "address": "192.0.2.0" + # }, + # "state": { + # "established": true, + # "invalid": false, + # "new": false, + # "related": true + # } + # } + # ] + # } + # ] + # } + # ] + # + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep bond + # set interfaces bonding bond0 hash-policy 'layer2' + # set interfaces bonding bond0 mode 'active-backup' + # set interfaces bonding bond0 primary 'eth1' + # set interfaces bonding bond1 hash-policy 'layer2+3' + # set interfaces bonding bond1 mode 'active-backup' + # set interfaces bonding bond1 primary 'eth2' + # set interfaces ethernet eth1 bond-group 'bond0' + # set interfaces ethernet eth2 bond-group 'bond1' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set interfaces bonding bond0 hash-policy 'layer2'", + # "set interfaces ethernet eth1 bond-group 'bond0'", + # "set interfaces bonding bond0 mode 'active-backup'", + # "set interfaces bonding bond0 primary 'eth1'", + # "set interfaces bonding bond1 hash-policy 'layer2+3'", + # "set interfaces ethernet eth2 bond-group 'bond1'", + # "set interfaces bonding bond1 mode 'active-backup'", + # "set interfaces bonding bond1 primary 'eth2'" + # ] + + + # Using parsed + # + # + - name: Parsed the commands for provided configuration + vyos.vyos.vyos_l3_interfaces: + running_config: + "set interfaces bonding bond0 hash-policy 'layer2' + set interfaces bonding bond0 mode 'active-backup' + set interfaces bonding bond0 primary 'eth1' + set interfaces bonding bond1 hash-policy 'layer2+3' + set interfaces bonding bond1 mode 'active-backup' + set interfaces bonding bond1 primary 'eth2' + set interfaces ethernet eth1 bond-group 'bond0' + set interfaces ethernet eth2 bond-group 'bond1'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "hash_policy": "layer2", + # "members": [ + # { + # "member": "eth1" + # } + # ], + # "mode": "active-backup", + # "name": "bond0", + # "primary": "eth1" + # }, + # { + # "hash_policy": "layer2+3", + # "members": [ + # { + # "member": "eth2" + # } + # ], + # "mode": "active-backup", + # "name": "bond1", + # "primary": "eth2" + # } + # ] + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The configuration as structured data after module completion.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration as structured data prior to module invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set interfaces bonding bond2', 'set interfaces bonding bond2 hash-policy layer2']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_linkagg_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_linkagg_module.rst new file mode 100644 index 00000000..ae7eea7b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_linkagg_module.rst @@ -0,0 +1,424 @@ +.. _vyos.vyos.vyos_linkagg_module: + + +********************** +vyos.vyos.vyos_linkagg +********************** + +**(deprecated, removed after 2022-06-01) Manage link aggregation groups on VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + +DEPRECATED +---------- +:Removed in collection release after 2022-06-01 +:Why: Updated modules released with more functionality. +:Alternative: vyos_lag_interfaces + + + +Synopsis +-------- +- This module provides declarative management of link aggregation groups on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of link aggregation definitions.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>members</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>List of members of the link aggregation group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mode</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>802.3ad</li> + <li>active-backup</li> + <li>broadcast</li> + <li>round-robin</li> + <li>transmit-load-balance</li> + <li>adaptive-load-balance</li> + <li>xor-hash</li> + <li>on</li> + </ul> + </td> + <td> + <div>Mode of the link aggregation group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the link aggregation group.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + <li>up</li> + <li>down</li> + </ul> + </td> + <td> + <div>State of the link aggregation group.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>members</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>List of members of the link aggregation group.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mode</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>802.3ad</b> ←</div></li> + <li>active-backup</li> + <li>broadcast</li> + <li>round-robin</li> + <li>transmit-load-balance</li> + <li>adaptive-load-balance</li> + <li>xor-hash</li> + <li>on</li> + </ul> + </td> + <td> + <div>Mode of the link aggregation group.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the link aggregation group.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + <li>up</li> + <li>down</li> + </ul> + </td> + <td> + <div>State of the link aggregation group.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VYOS 1.1.7 + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure link aggregation group + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth0 + - eth1 + + - name: remove configuration + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + + - name: Create aggregate of linkagg definitions + vyos.vyos.vyos_linkagg: + aggregate: + - {name: bond0, members: [eth1]} + - {name: bond1, members: [eth2]} + + - name: Remove aggregate of linkagg definitions + vyos.vyos.vyos_linkagg: + aggregate: + - name: bond0 + - name: bond1 + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always, except for the platforms that use Netconf transport to manage the device.</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set interfaces bonding bond0', "set interfaces ethernet eth0 bond-group 'bond0'", "set interfaces ethernet eth1 bond-group 'bond0'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +- This module will be removed in version . *[deprecated]* +- For more information see `DEPRECATED`_. + + +Authors +~~~~~~~ + +- Ricardo Carrillo Cruz (@rcarrillocruz) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_global_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_global_module.rst new file mode 100644 index 00000000..92244211 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_global_module.rst @@ -0,0 +1,609 @@ +.. _vyos.vyos.vyos_lldp_global_module: + + +************************** +vyos.vyos.vyos_lldp_global +************************** + +**LLDP global resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages link layer discovery protocol (LLDP) attributes on VyOS devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>The provided link layer discovery protocol (LLDP) configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This argument defines management-address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enable</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>This argument is a boolean value to enable or disable LLDP.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>legacy_protocols</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>cdp</li> + <li>edp</li> + <li>fdp</li> + <li>sonmp</li> + </ul> + </td> + <td> + <div>List of the supported legacy protocols.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>snmp</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This argument enable the SNMP queries to LLDP database.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep lldp</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>deleted</li> + <li>gathered</li> + <li>rendered</li> + <li>parsed</li> + </ul> + </td> + <td> + <div>The state of the configuration after module completion.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands|grep lldp + # + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_lldp_global: + config: + legacy_protocols: + - fdp + - cdp + snmp: enable + address: 192.0.2.11 + state: merged + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [] + # + # "commands": [ + # "set service lldp legacy-protocols fdp", + # "set service lldp legacy-protocols cdp", + # "set service lldp snmp enable", + # "set service lldp management-address '192.0.2.11'" + # ] + # + # "after": [ + # { + # "snmp": "enable" + # }, + # { + # "address": "192.0.2.11" + # }, + # { + # "legacy_protocols": [ + # "cdp", + # "fdp" + # ] + # } + # { + # "enable": true + # } + # ] + # + # After state: + # ------------- + # + # set service lldp legacy-protocols cdp + # set service lldp legacy-protocols fdp + # set service lldp management-address '192.0.2.11' + # set service lldp snmp enable + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep lldp + # set service lldp legacy-protocols cdp + # set service lldp legacy-protocols fdp + # set service lldp management-address '192.0.2.11' + # set service lldp snmp enable + # + - name: Replace device configurations with provided configurations + vyos.vyos.vyos_lldp_global: + config: + legacy_protocols: + - edp + - sonmp + - cdp + address: 192.0.2.14 + state: replaced + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # + # "before": [ + # { + # "snmp": "enable" + # }, + # { + # "address": "192.0.2.11" + # }, + # { + # "legacy_protocols": [ + # "cdp", + # "fdp" + # ] + # } + # { + # "enable": true + # } + # ] + # "commands": [ + # "delete service lldp snmp", + # "delete service lldp legacy-protocols fdp", + # "set service lldp management-address '192.0.2.14'", + # "set service lldp legacy-protocols edp", + # "set service lldp legacy-protocols sonmp" + # ] + # + # "after": [ + # { + # "address": "192.0.2.14" + # }, + # { + # "legacy_protocols": [ + # "cdp", + # "edp", + # "sonmp" + # ] + # } + # { + # "enable": true + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands|grep lldp + # set service lldp legacy-protocols cdp + # set service lldp legacy-protocols edp + # set service lldp legacy-protocols sonmp + # set service lldp management-address '192.0.2.14' + + + # Using deleted + # + # Before state + # ------------- + # vyos@vyos:~$ show configuration commands|grep lldp + # set service lldp legacy-protocols cdp + # set service lldp legacy-protocols edp + # set service lldp legacy-protocols sonmp + # set service lldp management-address '192.0.2.14' + # + - name: Delete attributes of given lldp service (This won't delete the LLDP service + itself) + vyos.vyos.vyos_lldp_global: + config: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "address": "192.0.2.14" + # }, + # { + # "legacy_protocols": [ + # "cdp", + # "edp", + # "sonmp" + # ] + # } + # { + # "enable": true + # } + # ] + # + # "commands": [ + # "delete service lldp management-address", + # "delete service lldp legacy-protocols" + # ] + # + # "after": [ + # { + # "enable": true + # } + # ] + # + # After state + # ------------ + # vyos@vyos:~$ show configuration commands | grep lldp + # set service lldp + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep lldp + # set service lldp legacy-protocols 'cdp' + # set service lldp management-address '192.0.2.17' + # + - name: Gather lldp global config with provided configurations + vyos.vyos.vyos_lldp_global: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "config_trap": true, + # "group": { + # "address_group": [ + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.3.1" + # }, + # { + # "address": "192.0.3.2" + # } + # ], + # "name": "ENG-HOSTS" + # }, + # { + # "description": "Sales office hosts address list", + # "members": [ + # { + # "address": "192.0.2.1" + # }, + # { + # "address": "192.0.2.2" + # }, + # { + # "address": "192.0.2.3" + # } + # ], + # "name": "SALES-HOSTS" + # } + # ], + # "network_group": [ + # { + # "description": "This group has the Management network addresses", + # "members": [ + # { + # "address": "192.0.1.0/24" + # } + # ], + # "name": "MGMT" + # } + # ] + # }, + # "log_martians": true, + # "ping": { + # "all": true, + # "broadcast": true + # }, + # "route_redirects": [ + # { + # "afi": "ipv4", + # "icmp_redirects": { + # "receive": false, + # "send": true + # }, + # "ip_src_route": true + # } + # ], + # "state_policy": [ + # { + # "action": "accept", + # "connection_type": "established", + # "log": true + # }, + # { + # "action": "reject", + # "connection_type": "invalid" + # } + # ], + # "syn_cookies": true, + # "twa_hazards_protection": true, + # "validation": "strict" + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep lldp + # set service lldp legacy-protocols 'cdp' + # set service lldp management-address '192.0.2.17' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_lldp_global: + config: + address: 192.0.2.17 + enable: true + legacy_protocols: + - cdp + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set service lldp legacy-protocols 'cdp'", + # "set service lldp", + # "set service lldp management-address '192.0.2.17'" + # ] + # + + + # Using parsed + # + # + - name: Parse the provided commands to provide structured configuration + vyos.vyos.vyos_lldp_global: + running_config: + "set service lldp legacy-protocols 'cdp' + set service lldp legacy-protocols 'fdp' + set service lldp management-address '192.0.2.11'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": { + # "address": "192.0.2.11", + # "enable": true, + # "legacy_protocols": [ + # "cdp", + # "fdp" + # ] + # } + # + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The configuration as structured data after module completion.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration as structured data prior to module invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set service lldp legacy-protocols sonmp', "set service lldp management-address '192.0.2.14'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_interface_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_interface_module.rst new file mode 100644 index 00000000..1c860e7d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_interface_module.rst @@ -0,0 +1,344 @@ +.. _vyos.vyos.vyos_lldp_interface_module: + + +***************************** +vyos.vyos.vyos_lldp_interface +***************************** + +**(deprecated, removed after 2022-06-01) Manage LLDP interfaces configuration on VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + +DEPRECATED +---------- +:Removed in collection release after 2022-06-01 +:Why: Updated modules released with more functionality. +:Alternative: vyos_lldp_interfaces + + + +Synopsis +-------- +- This module provides declarative management of LLDP interfaces configuration on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of interfaces LLDP should be configured on.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the interface LLDP should be configured on.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + <li>enabled</li> + <li>disabled</li> + </ul> + </td> + <td> + <div>State of the LLDP configuration.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the interface LLDP should be configured on.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + <li>enabled</li> + <li>disabled</li> + </ul> + </td> + <td> + <div>State of the LLDP configuration.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VYOS 1.1.7 + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Enable LLDP on eth1 + net_lldp_interface: + state: present + + - name: Enable LLDP on specific interfaces + net_lldp_interface: + interfaces: + - eth1 + - eth2 + state: present + + - name: Disable LLDP globally + net_lldp_interface: + state: disabled + + - name: Create aggregate of LLDP interface configurations + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: present + + - name: Delete aggregate of LLDP interface configurations + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always, except for the platforms that use Netconf transport to manage the device.</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set service lldp eth1', 'set service lldp eth2 disable']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +- This module will be removed in version . *[deprecated]* +- For more information see `DEPRECATED`_. + + +Authors +~~~~~~~ + +- Ricardo Carrillo Cruz (@rcarrillocruz) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_interfaces_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_interfaces_module.rst new file mode 100644 index 00000000..c5ea47bc --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_interfaces_module.rst @@ -0,0 +1,928 @@ +.. _vyos.vyos.vyos_lldp_interfaces_module: + + +****************************** +vyos.vyos.vyos_lldp_interfaces +****************************** + +**LLDP interfaces resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages attributes of lldp interfaces on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="5">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A list of lldp interfaces configurations.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enable</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li><div style="color: blue"><b>yes</b> ←</div></li> + </ul> + </td> + <td> + <div>to disable lldp on the interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>location</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP-MED location data.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>civic_based</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Civic-based location data.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ca_info</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP-MED address info</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ca_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP-MED Civic Address type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ca_value</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>LLDP-MED Civic Address value.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>country_code</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Country Code</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>coordinate_based</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Coordinate-based location.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>altitude</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Altitude in meters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>datum</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>WGS84</li> + <li>NAD83</li> + <li>MLLW</li> + </ul> + </td> + <td> + <div>Coordinate datum type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>latitude</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Latitude.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>longitude</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Longitude.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>elin</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Emergency Call Service ELIN number (between 10-25 numbers).</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the lldp interface.</div> + </td> + </tr> + + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep lldp</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>rendered</li> + <li>parsed</li> + <li>gathered</li> + </ul> + </td> + <td> + <div>The state of the configuration after module completion.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep lldp + # + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": [] + # + # "commands": [ + # "set service lldp interface eth1 location civic-based country-code 'US'", + # "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'", + # "set service lldp interface eth1", + # "set service lldp interface eth2 location coordinate-based latitude '33.524449N'", + # "set service lldp interface eth2 location coordinate-based altitude '2200'", + # "set service lldp interface eth2 location coordinate-based datum 'WGS84'", + # "set service lldp interface eth2 location coordinate-based longitude '222.267255W'", + # "set service lldp interface eth2 location coordinate-based latitude '33.524449N'", + # "set service lldp interface eth2 location coordinate-based altitude '2200'", + # "set service lldp interface eth2 location coordinate-based datum 'WGS84'", + # "set service lldp interface eth2 location coordinate-based longitude '222.267255W'", + # "set service lldp interface eth2" + # + # "after": [ + # { + # "location": { + # "coordinate_based": { + # "altitude": 2200, + # "datum": "WGS84", + # "latitude": "33.524449N", + # "longitude": "222.267255W" + # } + # }, + # "name": "eth2" + # }, + # { + # "location": { + # "civic_based": { + # "ca_info": [ + # { + # "ca_type": 0, + # "ca_value": "ENGLISH" + # } + # ], + # "country_code": "US" + # } + # }, + # "name": "eth1" + # } + # ], + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep lldp + # set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + # set service lldp interface eth1 location civic-based country-code 'US' + # set service lldp interface eth2 location coordinate-based altitude '2200' + # set service lldp interface eth2 location coordinate-based datum 'WGS84' + # set service lldp interface eth2 location coordinate-based latitude '33.524449N' + # set service lldp interface eth2 location coordinate-based longitude '222.267255W' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep lldp + # set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + # set service lldp interface eth1 location civic-based country-code 'US' + # set service lldp interface eth2 location coordinate-based altitude '2200' + # set service lldp interface eth2 location coordinate-based datum 'WGS84' + # set service lldp interface eth2 location coordinate-based latitude '33.524449N' + # set service lldp interface eth2 location coordinate-based longitude '222.267255W' + # + - name: Replace device configurations of listed LLDP interfaces with provided configurations + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth2 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + + - name: eth1 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "location": { + # "coordinate_based": { + # "altitude": 2200, + # "datum": "WGS84", + # "latitude": "33.524449N", + # "longitude": "222.267255W" + # } + # }, + # "name": "eth2" + # }, + # { + # "location": { + # "civic_based": { + # "ca_info": [ + # { + # "ca_type": 0, + # "ca_value": "ENGLISH" + # } + # ], + # "country_code": "US" + # } + # }, + # "name": "eth1" + # } + # ] + # + # "commands": [ + # "delete service lldp interface eth2 location", + # "set service lldp interface eth2 'disable'", + # "set service lldp interface eth2 location civic-based country-code 'US'", + # "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'", + # "delete service lldp interface eth1 location", + # "set service lldp interface eth1 'disable'", + # "set service lldp interface eth1 location coordinate-based latitude '33.524449N'", + # "set service lldp interface eth1 location coordinate-based altitude '2200'", + # "set service lldp interface eth1 location coordinate-based datum 'WGS84'", + # "set service lldp interface eth1 location coordinate-based longitude '222.267255W'" + # ] + # + # "after": [ + # { + # "location": { + # "civic_based": { + # "ca_info": [ + # { + # "ca_type": 0, + # "ca_value": "ENGLISH" + # } + # ], + # "country_code": "US" + # } + # }, + # "name": "eth2" + # }, + # { + # "location": { + # "coordinate_based": { + # "altitude": 2200, + # "datum": "WGS84", + # "latitude": "33.524449N", + # "longitude": "222.267255W" + # } + # }, + # "name": "eth1" + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep lldp + # set service lldp interface eth1 'disable' + # set service lldp interface eth1 location coordinate-based altitude '2200' + # set service lldp interface eth1 location coordinate-based datum 'WGS84' + # set service lldp interface eth1 location coordinate-based latitude '33.524449N' + # set service lldp interface eth1 location coordinate-based longitude '222.267255W' + # set service lldp interface eth2 'disable' + # set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH' + # set service lldp interface eth2 location civic-based country-code 'US' + + + # Using overridden + # + # Before state + # -------------- + # + # vyos@vyos:~$ show configuration commands | grep lldp + # set service lldp interface eth1 'disable' + # set service lldp interface eth1 location coordinate-based altitude '2200' + # set service lldp interface eth1 location coordinate-based datum 'WGS84' + # set service lldp interface eth1 location coordinate-based latitude '33.524449N' + # set service lldp interface eth1 location coordinate-based longitude '222.267255W' + # set service lldp interface eth2 'disable' + # set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH' + # set service lldp interface eth2 location civic-based country-code 'US' + # + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth2 + location: + elin: 0000000911 + + state: overridden + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "enable": false, + # "location": { + # "civic_based": { + # "ca_info": [ + # { + # "ca_type": 0, + # "ca_value": "ENGLISH" + # } + # ], + # "country_code": "US" + # } + # }, + # "name": "eth2" + # }, + # { + # "enable": false, + # "location": { + # "coordinate_based": { + # "altitude": 2200, + # "datum": "WGS84", + # "latitude": "33.524449N", + # "longitude": "222.267255W" + # } + # }, + # "name": "eth1" + # } + # ] + # + # "commands": [ + # "delete service lldp interface eth2 location", + # "delete service lldp interface eth2 disable", + # "set service lldp interface eth2 location elin 0000000911" + # + # + # "after": [ + # { + # "location": { + # "elin": 0000000911 + # }, + # "name": "eth2" + # } + # ] + # + # + # After state + # ------------ + # + # vyos@vyos# run show configuration commands | grep lldp + # set service lldp interface eth2 location elin '0000000911' + + + # Using deleted + # + # Before state + # ------------- + # + # vyos@vyos# run show configuration commands | grep lldp + # set service lldp interface eth2 location elin '0000000911' + # + - name: Delete lldp interface attributes of given interfaces. + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth2 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + before: [{location: {elin: 0000000911}, name: eth2}] + # "commands": [ + # "commands": [ + # "delete service lldp interface eth2" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep lldp + # set service 'lldp' + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep lldp + # set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + # set service lldp interface eth1 location civic-based country-code 'US' + # set service lldp interface eth2 location coordinate-based altitude '2200' + # set service lldp interface eth2 location coordinate-based datum 'WGS84' + # set service lldp interface eth2 location coordinate-based latitude '33.524449N' + # set service lldp interface eth2 location coordinate-based longitude '222.267255W' + # + - name: Gather listed lldp interfaces from running configuration + vyos.vyos.vyos_lldp_interfaces: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "location": { + # "coordinate_based": { + # "altitude": 2200, + # "datum": "WGS84", + # "latitude": "33.524449N", + # "longitude": "222.267255W" + # } + # }, + # "name": "eth2" + # }, + # { + # "location": { + # "civic_based": { + # "ca_info": [ + # { + # "ca_type": 0, + # "ca_value": "ENGLISH" + # } + # ], + # "country_code": "US" + # } + # }, + # "name": "eth1" + # } + # ] + # + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep lldp + # set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + # set service lldp interface eth1 location civic-based country-code 'US' + # set service lldp interface eth2 location coordinate-based altitude '2200' + # set service lldp interface eth2 location coordinate-based datum 'WGS84' + # set service lldp interface eth2 location coordinate-based latitude '33.524449N' + # set service lldp interface eth2 location coordinate-based longitude '222.267255W' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set service lldp interface eth1 location civic-based country-code 'US'", + # "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'", + # "set service lldp interface eth1", + # "set service lldp interface eth2 location coordinate-based latitude '33.524449N'", + # "set service lldp interface eth2 location coordinate-based altitude '2200'", + # "set service lldp interface eth2 location coordinate-based datum 'WGS84'", + # "set service lldp interface eth2 location coordinate-based longitude '222.267255W'", + # "set service lldp interface eth2" + # ] + + + # Using parsed + # + # + - name: Parsed the commands to provide structured configuration. + vyos.vyos.vyos_lldp_interfaces: + running_config: + "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + set service lldp interface eth1 location civic-based country-code 'US' + set service lldp interface eth2 location coordinate-based altitude '2200' + set service lldp interface eth2 location coordinate-based datum 'WGS84' + set service lldp interface eth2 location coordinate-based latitude '33.524449N' + set service lldp interface eth2 location coordinate-based longitude '222.267255W'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "location": { + # "coordinate_based": { + # "altitude": 2200, + # "datum": "WGS84", + # "latitude": "33.524449N", + # "longitude": "222.267255W" + # } + # }, + # "name": "eth2" + # }, + # { + # "location": { + # "civic_based": { + # "ca_info": [ + # { + # "ca_type": 0, + # "ca_value": "ENGLISH" + # } + # ], + # "country_code": "US" + # } + # }, + # "name": "eth1" + # } + # ] + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The configuration as structured data after module completion.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration as structured data prior to module invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">["set service lldp interface eth2 'disable'", 'delete service lldp interface eth1 location']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_module.rst new file mode 100644 index 00000000..92aa732e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_lldp_module.rst @@ -0,0 +1,268 @@ +.. _vyos.vyos.vyos_lldp_module: + + +******************* +vyos.vyos.vyos_lldp +******************* + +**(deprecated, removed after 2022-06-01) Manage LLDP configuration on VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + +DEPRECATED +---------- +:Removed in collection release after 2022-06-01 +:Why: Updated modules released with more functionality. +:Alternative: vyos_lldp_global + + + +Synopsis +-------- +- This module provides declarative management of LLDP service on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interfaces</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the interfaces.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + <li>enabled</li> + <li>disabled</li> + </ul> + </td> + <td> + <div>State of the link aggregation group.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VYOS 1.1.7 + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Enable LLDP service + vyos.vyos.vyos_lldp: + state: present + + - name: Disable LLDP service + vyos.vyos.vyos_lldp: + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always, except for the platforms that use Netconf transport to manage the device.</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set service lldp']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +- This module will be removed in version . *[deprecated]* +- For more information see `DEPRECATED`_. + + +Authors +~~~~~~~ + +- Ricardo Carrillo Cruz (@rcarrillocruz) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_logging_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_logging_module.rst new file mode 100644 index 00000000..f651b7a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_logging_module.rst @@ -0,0 +1,440 @@ +.. _vyos.vyos.vyos_logging_module: + + +********************** +vyos.vyos.vyos_logging +********************** + +**Manage logging on network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module provides declarative management of logging on Vyatta Vyos devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of logging definitions.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dest</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>console</li> + <li>file</li> + <li>global</li> + <li>host</li> + <li>user</li> + </ul> + </td> + <td> + <div>Destination of the logs.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>facility</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Set logging facility.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>level</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Set logging severity levels.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>If value of <code>dest</code> is <em>file</em> it indicates file-name, for <em>user</em> it indicates username and for <em>host</em> indicates the host name to be notified.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the logging configuration.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dest</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>console</li> + <li>file</li> + <li>global</li> + <li>host</li> + <li>user</li> + </ul> + </td> + <td> + <div>Destination of the logs.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>facility</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Set logging facility.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>level</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Set logging severity levels.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>If value of <code>dest</code> is <em>file</em> it indicates file-name, for <em>user</em> it indicates username and for <em>host</em> indicates the host name to be notified.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the logging configuration.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure console logging + vyos.vyos.vyos_logging: + dest: console + facility: all + level: crit + + - name: remove console logging configuration + vyos.vyos.vyos_logging: + dest: console + state: absent + + - name: configure file logging + vyos.vyos.vyos_logging: + dest: file + name: test + facility: local3 + level: err + + - name: Add logging aggregate + vyos.vyos.vyos_logging: + aggregate: + - {dest: file, name: test1, facility: all, level: info} + - {dest: file, name: test2, facility: news, level: debug} + state: present + + - name: Remove logging aggregate + vyos.vyos.vyos_logging: + aggregate: + - {dest: console, facility: all, level: info} + - {dest: console, facility: daemon, level: warning} + - {dest: file, name: test2, facility: news, level: debug} + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set system syslog global facility all level notice']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Trishna Guha (@trishnaguha) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospf_interfaces_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospf_interfaces_module.rst new file mode 100644 index 00000000..141c0cf3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospf_interfaces_module.rst @@ -0,0 +1,1204 @@ +.. _vyos.vyos.vyos_ospf_interfaces_module: + + +****************************** +vyos.vyos.vyos_ospf_interfaces +****************************** + +**OSPF Interfaces Resource Module.** + + +Version added: 1.2.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages OSPF configuration of interfaces on devices running VYOS. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="5">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A list of OSPF configuration for interfaces.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address_family</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPF settings on the interfaces in address-family context.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>afi</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>ipv4</li> + <li>ipv6</li> + </ul> + </td> + <td> + <div>Address Family Identifier (AFI) for OSPF settings on the interfaces.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>authentication</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Authentication settings on the interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>md5_key</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>md5 parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>key</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>md5 key.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>key_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>key id.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>plaintext_password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Plain Text password.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>bandwidth</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Bandwidth of interface (kilobits/sec)</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>cost</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>metric associated with interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dead_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Time interval to detect a dead router.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>hello_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Timer interval between transmission of hello packets.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ifmtu</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>interface MTU.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>instance</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Instance ID.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mtu_ignore</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>if True, Disable MTU check for Database Description packets.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>network</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Interface type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>passive</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>If True, disables forming adjacency.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>priority</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Interface priority.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>retransmit_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>LSA retransmission interval.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>transmit_delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>LSA transmission delay.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name/Identifier of the interface.</div> + </td> + </tr> + + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the IOS device by executing the command <b>sh running-config | section ^interface</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>gathered</li> + <li>parsed</li> + <li>rendered</li> + </ul> + </td> + <td> + <div>The state the configuration should be left in.</div> + </td> + </tr> + </table> + <br/> + + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + + # @vyos:~$ show configuration commands | match "ospf" + + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: True + state: merged + + # After State: + # -------------- + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + + # "after": [ + # " + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "before": [ + # { + # "name": "eth0" + # }, + # { + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "changed": true, + # "commands": [ + # "set interfaces ethernet eth1 ip ospf transmit-delay 50", + # "set interfaces ethernet eth1 ip ospf priority 26", + # "set interfaces ethernet eth1 ip ospf network point-to-point", + # "set interfaces ethernet eth1 ipv6 ospfv3 dead-interval 39", + # "set interfaces bonding bond2 ip ospf transmit-delay 45", + # "set interfaces bonding bond2 ip ospf bandwidth 70", + # "set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345", + # "set interfaces bonding bond2 ipv6 ospfv3 passive" + # ], + + + + + # Using replaced: + + # Before State: + # ------------ + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + + - name: Replace provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: True + state: replaced + + # After State: + # ----------- + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf cost '100' + # set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' + # vyos@vyos:~$ + + # Module Execution + # ---------------- + # "after": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "cost": 100 + # }, + # { + # "afi": "ipv6", + # "ifmtu": 33 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "before": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "changed": true, + # "commands": [ + # "set interfaces ethernet eth1 ip ospf cost 100", + # "set interfaces ethernet eth1 ipv6 ospfv3 ifmtu 33", + # "delete interfaces ethernet eth1 ip ospf network point-to-point", + # "delete interfaces ethernet eth1 ip ospf priority 26", + # "delete interfaces ethernet eth1 ip ospf transmit-delay 50", + # "delete interfaces ethernet eth1 ipv6 ospfv3 dead-interval 39", + # "delete interfaces bonding bond2 ip ospf authentication", + # "delete interfaces bonding bond2 ip ospf bandwidth 70" + # ], + # + + # Using Overridden: + # ----------------- + + # Before State: + # ------------ + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf cost '100' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + # set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' + # vyos@vyos:~$ + + - name: Override device configuration with provided configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + passive: True + state: overridden + # After State: + # ----------- + + # 200~vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces ethernet eth0 ip ospf cost '100' + # set interfaces ethernet eth0 ipv6 ospfv3 ifmtu '33' + # set interfaces ethernet eth0 ipv6 ospfv3 'passive' + # vyos@vyos:~$ + # + # + # "after": [ + # { + # "name": "bond2" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "cost": 100 + # }, + # { + # "afi": "ipv6", + # "ifmtu": 33, + # "passive": true + # } + # ], + # "name": "eth0" + # }, + # { + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "before": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "cost": 100, + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39, + # "ifmtu": 33 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "changed": true, + # "commands": [ + # "delete interfaces bonding bond2 ip ospf", + # "delete interfaces bonding bond2 ipv6 ospfv3", + # "delete interfaces ethernet eth1 ip ospf", + # "delete interfaces ethernet eth1 ipv6 ospfv3", + # "set interfaces ethernet eth0 ip ospf cost 100", + # "set interfaces ethernet eth0 ipv6 ospfv3 ifmtu 33", + # "set interfaces ethernet eth0 ipv6 ospfv3 passive" + # ], + # + + # Using deleted: + # ------------- + + # before state: + # ------------- + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth0 ip ospf cost '100' + # set interfaces ethernet eth0 ipv6 ospfv3 ifmtu '33' + # set interfaces ethernet eth0 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + # vyos@vyos:~$ + + - name: Delete device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + state: deleted + + # After State: + # ----------- + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + # vyos@vyos:~$ + # + # + # "after": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "before": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "cost": 100 + # }, + # { + # "afi": "ipv6", + # "ifmtu": 33, + # "passive": true + # } + # ], + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + # "changed": true, + # "commands": [ + # "delete interfaces ethernet eth0 ip ospf", + # "delete interfaces ethernet eth0 ipv6 ospfv3" + # ], + # + # Using parsed: + # parsed.cfg: + + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth0 ip ospf cost '50' + # set interfaces ethernet eth0 ip ospf priority '26' + # set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33' + # set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + # + + - name: parse configs + vyos.vyos.vyos_ospf_interfaces: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed + + # Module Execution: + # ---------------- + + # "parsed": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "cost": 50, + # "priority": 26 + # }, + # { + # "afi": "ipv6", + # "instance": "33", + # "mtu_ignore": true + # } + # ], + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39 + # } + # ], + # "name": "eth1" + # } + # ] + + # Using rendered: + # -------------- + + - name: Render + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: True + state: rendered + + # Module Execution: + # ---------------- + + # "rendered": [ + # "set interfaces ethernet eth1 ip ospf transmit-delay 50", + # "set interfaces ethernet eth1 ip ospf priority 26", + # "set interfaces ethernet eth1 ip ospf network point-to-point", + # "set interfaces ethernet eth1 ipv6 ospfv3 dead-interval 39", + # "set interfaces bonding bond2 ip ospf transmit-delay 45", + # "set interfaces bonding bond2 ip ospf bandwidth 70", + # "set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345", + # "set interfaces bonding bond2 ipv6 ospfv3 passive" + # ] + # + + # Using Gathered: + # -------------- + + # Native Config: + + # vyos@vyos:~$ show configuration commands | match "ospf" + # set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' + # set interfaces bonding bond2 ip ospf bandwidth '70' + # set interfaces bonding bond2 ip ospf transmit-delay '45' + # set interfaces bonding bond2 ipv6 ospfv3 'passive' + # set interfaces ethernet eth1 ip ospf network 'point-to-point' + # set interfaces ethernet eth1 ip ospf priority '26' + # set interfaces ethernet eth1 ip ospf transmit-delay '50' + # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + # vyos@vyos:~$ + + - name: gather configs + vyos.vyos.vyos_ospf_interfaces: + state: gathered + + # Module Execution: + # ----------------- + + # "gathered": [ + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "authentication": { + # "md5_key": { + # "key": "1111111111232345", + # "key_id": 10 + # } + # }, + # "bandwidth": 70, + # "transmit_delay": 45 + # }, + # { + # "afi": "ipv6", + # "passive": true + # } + # ], + # "name": "bond2" + # }, + # { + # "name": "eth0" + # }, + # { + # "address_family": [ + # { + # "afi": "ipv4", + # "network": "point-to-point", + # "priority": 26, + # "transmit_delay": 50 + # }, + # { + # "afi": "ipv6", + # "dead_interval": 39 + # } + # ], + # "name": "eth1" + # }, + # { + # "name": "eth2" + # }, + # { + # "name": "eth3" + # } + # ], + + + + +Status +------ + + +Authors +~~~~~~~ + +- Gomathi Selvi Srinivasan (@GomathiselviS) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospfv2_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospfv2_module.rst new file mode 100644 index 00000000..50ed5d34 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospfv2_module.rst @@ -0,0 +1,3127 @@ +.. _vyos.vyos.vyos_ospfv2_module: + + +********************* +vyos.vyos.vyos_ospfv2 +********************* + +**OSPFv2 resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This resource module configures and manages attributes of OSPFv2 routes on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="6">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="6"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A provided OSPFv2 route configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>areas</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>area_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 area identity.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>area_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Area type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>normal</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Normal OSPFv2 area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>nssa</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>NSSA OSPFv2 area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>default_cost</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Summary-default cost of NSSA area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>no_summary</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Do not inject inter-area routes into stub.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>set</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enabling NSSA.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>translate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>always</li> + <li>candidate</li> + <li>never</li> + </ul> + </td> + <td> + <div>NSSA-ABR.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>stub</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Stub OSPFv2 area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>default_cost</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Summary-default cost of stub area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>no_summary</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Do not inject inter-area routes into stub.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>set</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enabling stub.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>authentication</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>plaintext-password</li> + <li>md5</li> + </ul> + </td> + <td> + <div>OSPFv2 area authentication type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>network</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 network.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 IPv4 network address.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>range</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Summarize routes matching prefix (border routers only).</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>border router IPv4 address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>cost</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Metric for this range.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>not_advertise</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Don't advertise this range.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>substitute</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Announce area range (IPv4 address) as another prefix.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>shortcut</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>default</li> + <li>disable</li> + <li>enable</li> + </ul> + </td> + <td> + <div>Area's shortcut mode.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>virtual_link</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Virtual link address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>virtual link address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>authentication</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 area authentication type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>md5</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>MD5 key id based authentication.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>key_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>MD5 key id.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>md5_key</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>MD5 key.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>plaintext_password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Plain text password.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dead_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Interval after which a neighbor is declared dead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>hello_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Interval between hello packets.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>retransmit_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Interval between retransmitting lost link state advertisements.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>transmit_delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Link state transmit delay.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>auto_cost</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Calculate OSPFv2 interface cost according to bandwidth.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>reference_bandwidth</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Reference bandwidth cost in Mbits/sec.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>default_information</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Control distribution of default information.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>originate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Distribute a default route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>always</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Always advertise default route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>metric</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 default metric.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>metric_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 Metric types for default routes.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_map</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Route map references.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>default_metric</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Metric of redistributed routes</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>distance</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Administrative distance.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>global</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Global OSPFv2 administrative distance.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ospf</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 administrative distance.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>external</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Distance for external routes.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>inter_area</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Distance for inter-area routes.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>intra_area</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Distance for intra-area routes.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>log_adjacency_changes</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>detail</li> + </ul> + </td> + <td> + <div>Log changes in adjacency state.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>max_metric</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 maximum/infinite-distance metric.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>router_lsa</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Advertise own Router-LSA with infinite distance (stub router).</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>administrative</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Administratively apply, for an indefinite period.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>on_shutdown</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Time to advertise self as stub-router.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>on_startup</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Time to advertise self as stub-router</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mpls_te</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>MultiProtocol Label Switching-Traffic Engineering (MPLS-TE) parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enable MPLS-TE functionality.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>router_address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Stable IP address of the advertising router.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>neighbor</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Neighbor IP address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>neighbor_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Identity (number/IP address) of neighbor.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>poll_interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Seconds between dead neighbor polling interval.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>priority</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Neighbor priority.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>parameters</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 specific parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>abr_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>cisco</li> + <li>ibm</li> + <li>shortcut</li> + <li>standard</li> + </ul> + </td> + <td> + <div>OSPFv2 ABR Type.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>opaque_lsa</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enable the Opaque-LSA capability (rfc2370).</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>rfc1583_compatibility</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Enable rfc1583 criteria for handling AS external routes.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>router_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Override the default router identifier.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>passive_interface</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>Suppress routing updates on an interface.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>passive_interface_exclude</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>Interface to exclude when using passive-interface default.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>redistribute</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Redistribute information from another routing protocol.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>metric</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Metric for redistribution routes.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>metric_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 Metric types.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_map</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Route map references.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>bgp</li> + <li>connected</li> + <li>kernel</li> + <li>rip</li> + <li>static</li> + </ul> + </td> + <td> + <div>Route type to redistribute.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_map</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>Filter routes installed in local route map.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timers</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Adjust routing timers.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>refresh</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Adjust refresh parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timers</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>refresh timer.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>throttle</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Throttling adaptive timers.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>spf</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv2 SPF timers.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Delay (msec) from first change received till SPF calculation.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>initial_holdtime</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Initial hold time(msec) between consecutive SPF calculations.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>max_holdtime</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>maximum hold time (sec).</div> + </td> + </tr> + + + + + <tr> + <td colspan="6"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep ospf</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="6"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>deleted</li> + <li>parsed</li> + <li>gathered</li> + <li>rendered</li> + </ul> + </td> + <td> + <div>The state the configuration should be left in.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos# run show configuration commands | grep ospf + # + # + - name: Merge the provided configuration with the existing running configuration + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: detail + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: ingress + mpls_te: + enabled: true + router_address: 192.0.11.11 + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 + redistribute: + - route_type: bgp + metric: 10 + metric_type: 2 + passive_interface: + - eth1 + - eth2 + parameters: + router_id: 192.0.1.1 + opaque_lsa: true + rfc1583_compatibility: true + abr_type: cisco + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": {} + # + # "commands": [ + # "set protocols ospf mpls-te enable", + # "set protocols ospf mpls-te router-address '192.0.11.11'", + # "set protocols ospf redistribute bgp", + # "set protocols ospf redistribute bgp metric-type 2", + # "set protocols ospf redistribute bgp metric 10", + # "set protocols ospf default-information originate metric-type 2", + # "set protocols ospf default-information originate always", + # "set protocols ospf default-information originate metric 10", + # "set protocols ospf default-information originate route-map ingress", + # "set protocols ospf auto-cost reference-bandwidth '2'", + # "set protocols ospf parameters router-id '192.0.1.1'", + # "set protocols ospf parameters opaque-lsa", + # "set protocols ospf parameters abr-type 'cisco'", + # "set protocols ospf parameters rfc1583-compatibility", + # "set protocols ospf passive-interface eth1", + # "set protocols ospf passive-interface eth2", + # "set protocols ospf max-metric router-lsa on-shutdown 10", + # "set protocols ospf max-metric router-lsa administrative", + # "set protocols ospf max-metric router-lsa on-startup 10", + # "set protocols ospf log-adjacency-changes 'detail'", + # "set protocols ospf neighbor 192.0.11.12 priority 2", + # "set protocols ospf neighbor 192.0.11.12 poll-interval 10", + # "set protocols ospf neighbor 192.0.11.12", + # "set protocols ospf area '2'", + # "set protocols ospf area 2 authentication plaintext-password", + # "set protocols ospf area 2 shortcut enable", + # "set protocols ospf area 2 area-type normal", + # "set protocols ospf area '3'", + # "set protocols ospf area 3 area-type nssa", + # "set protocols ospf area 4 range 192.0.3.0/24 cost 10", + # "set protocols ospf area 4 range 192.0.3.0/24", + # "set protocols ospf area 4 range 192.0.4.0/24 cost 12", + # "set protocols ospf area 4 range 192.0.4.0/24", + # "set protocols ospf area 4 area-type stub default-cost 20", + # "set protocols ospf area '4'", + # "set protocols ospf area 4 network 192.0.2.0/24" + # ] + # + # "after": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 3 area-type 'nssa' + # set protocols ospf area 4 area-type stub default-cost '20' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 range 192.0.3.0/24 cost '10' + # set protocols ospf area 4 range 192.0.4.0/24 cost '12' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.11.11' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf passive-interface 'eth2' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos# run show configuration commands | grep ospf + # + # + - name: Merge the provided configuration to update existing running configuration + vyos.vyos.vyos_ospfv2: + config: + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: false + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # + # "commands": [ + # "delete protocols ospf area 4 area-type stub", + # "set protocols ospf area 4 network 192.0.22.0/24" + # "set protocols ospf area 4 network 192.0.32.0/24" + # ] + # + # "after": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # }, + # { + # "address": "192.0.22.0/24" + # }, + # { + # "address": "192.0.32.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 3 area-type 'nssa' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 network '192.0.22.0/24' + # set protocols ospf area 4 network '192.0.32.0/24' + # set protocols ospf area 4 range 192.0.3.0/24 cost '10' + # set protocols ospf area 4 range 192.0.4.0/24 cost '12' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.11.11' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf passive-interface 'eth2' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 3 area-type 'nssa' + # set protocols ospf area 4 area-type stub default-cost '20' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 range 192.0.3.0/24 cost '10' + # set protocols ospf area 4 range 192.0.4.0/24 cost '12' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.11.11' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf passive-interface 'eth2' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + # + - name: Replace ospfv2 routes attributes configuration. + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: detail + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: ingress + mpls_te: + enabled: true + router_address: 192.0.22.22 + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 + redistribute: + - route_type: bgp + metric: 10 + metric_type: 2 + passive_interface: + - eth1 + parameters: + router_id: 192.0.1.1 + opaque_lsa: true + rfc1583_compatibility: true + abr_type: cisco + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.12.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 + range: + - address: 192.0.42.0/24 + cost: 10 + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # + # "commands": [ + # "delete protocols ospf passive-interface eth2", + # "delete protocols ospf area 3", + # "delete protocols ospf area 4 range 192.0.3.0/24 cost", + # "delete protocols ospf area 4 range 192.0.3.0/24", + # "delete protocols ospf area 4 range 192.0.4.0/24 cost", + # "delete protocols ospf area 4 range 192.0.4.0/24", + # "set protocols ospf mpls-te router-address '192.0.22.22'", + # "set protocols ospf area 4 range 192.0.42.0/24 cost 10", + # "set protocols ospf area 4 range 192.0.42.0/24", + # "set protocols ospf area 4 network 192.0.12.0/24", + # "set protocols ospf area 4 network 192.0.22.0/24", + # "set protocols ospf area 4 network 192.0.32.0/24" + # ] + # + # "after": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.12.0/24" + # }, + # { + # "address": "192.0.2.0/24" + # }, + # { + # "address": "192.0.22.0/24" + # }, + # { + # "address": "192.0.32.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.42.0/24", + # "cost": 10 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.22.22" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 4 area-type stub default-cost '20' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 network '192.0.12.0/24' + # set protocols ospf area 4 network '192.0.22.0/24' + # set protocols ospf area 4 network '192.0.32.0/24' + # set protocols ospf area 4 range 192.0.42.0/24 cost '10' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.22.22' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: detail + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: ingress + mpls_te: + enabled: true + router_address: 192.0.11.11 + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 + redistribute: + - route_type: bgp + metric: 10 + metric_type: 2 + passive_interface: + - eth1 + - eth2 + parameters: + router_id: 192.0.1.1 + opaque_lsa: true + rfc1583_compatibility: true + abr_type: cisco + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # [ + # "set protocols ospf mpls-te enable", + # "set protocols ospf mpls-te router-address '192.0.11.11'", + # "set protocols ospf redistribute bgp", + # "set protocols ospf redistribute bgp metric-type 2", + # "set protocols ospf redistribute bgp metric 10", + # "set protocols ospf default-information originate metric-type 2", + # "set protocols ospf default-information originate always", + # "set protocols ospf default-information originate metric 10", + # "set protocols ospf default-information originate route-map ingress", + # "set protocols ospf auto-cost reference-bandwidth '2'", + # "set protocols ospf parameters router-id '192.0.1.1'", + # "set protocols ospf parameters opaque-lsa", + # "set protocols ospf parameters abr-type 'cisco'", + # "set protocols ospf parameters rfc1583-compatibility", + # "set protocols ospf passive-interface eth1", + # "set protocols ospf passive-interface eth2", + # "set protocols ospf max-metric router-lsa on-shutdown 10", + # "set protocols ospf max-metric router-lsa administrative", + # "set protocols ospf max-metric router-lsa on-startup 10", + # "set protocols ospf log-adjacency-changes 'detail'", + # "set protocols ospf neighbor 192.0.11.12 priority 2", + # "set protocols ospf neighbor 192.0.11.12 poll-interval 10", + # "set protocols ospf neighbor 192.0.11.12", + # "set protocols ospf area '2'", + # "set protocols ospf area 2 authentication plaintext-password", + # "set protocols ospf area 2 shortcut enable", + # "set protocols ospf area 2 area-type normal", + # "set protocols ospf area '3'", + # "set protocols ospf area 3 area-type nssa", + # "set protocols ospf area 4 range 192.0.3.0/24 cost 10", + # "set protocols ospf area 4 range 192.0.3.0/24", + # "set protocols ospf area 4 range 192.0.4.0/24 cost 12", + # "set protocols ospf area 4 range 192.0.4.0/24", + # "set protocols ospf area 4 area-type stub default-cost 20", + # "set protocols ospf area '4'", + # "set protocols ospf area 4 network 192.0.2.0/24" + # ] + + + # Using parsed + # + # + - name: Parse the commands for provided structured configuration + vyos.vyos.vyos_ospfv2: + running_config: + "set protocols ospf area 2 area-type 'normal' + set protocols ospf area 2 authentication 'plaintext-password' + set protocols ospf area 2 shortcut 'enable' + set protocols ospf area 3 area-type 'nssa' + set protocols ospf area 4 area-type stub default-cost '20' + set protocols ospf area 4 network '192.0.2.0/24' + set protocols ospf area 4 range 192.0.3.0/24 cost '10' + set protocols ospf area 4 range 192.0.4.0/24 cost '12' + set protocols ospf auto-cost reference-bandwidth '2' + set protocols ospf default-information originate 'always' + set protocols ospf default-information originate metric '10' + set protocols ospf default-information originate metric-type '2' + set protocols ospf default-information originate route-map 'ingress' + set protocols ospf log-adjacency-changes 'detail' + set protocols ospf max-metric router-lsa 'administrative' + set protocols ospf max-metric router-lsa on-shutdown '10' + set protocols ospf max-metric router-lsa on-startup '10' + set protocols ospf mpls-te 'enable' + set protocols ospf mpls-te router-address '192.0.11.11' + set protocols ospf neighbor 192.0.11.12 poll-interval '10' + set protocols ospf neighbor 192.0.11.12 priority '2' + set protocols ospf parameters abr-type 'cisco' + set protocols ospf parameters 'opaque-lsa' + set protocols ospf parameters 'rfc1583-compatibility' + set protocols ospf parameters router-id '192.0.1.1' + set protocols ospf passive-interface 'eth1' + set protocols ospf passive-interface 'eth2' + set protocols ospf redistribute bgp metric '10' + set protocols ospf redistribute bgp metric-type '2'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # } + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 3 area-type 'nssa' + # set protocols ospf area 4 area-type stub default-cost '20' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 range 192.0.3.0/24 cost '10' + # set protocols ospf area 4 range 192.0.4.0/24 cost '12' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.11.11' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf passive-interface 'eth2' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + # + - name: Gather ospfv2 routes config with provided configurations + vyos.vyos.vyos_ospfv2: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 3 area-type 'nssa' + # set protocols ospf area 4 area-type stub default-cost '20' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 range 192.0.3.0/24 cost '10' + # set protocols ospf area 4 range 192.0.4.0/24 cost '12' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.11.11' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf passive-interface 'eth2' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + + + # Using deleted + # + # Before state + # ------------- + # + # vyos@192# run show configuration commands | grep ospf + # set protocols ospf area 2 area-type 'normal' + # set protocols ospf area 2 authentication 'plaintext-password' + # set protocols ospf area 2 shortcut 'enable' + # set protocols ospf area 3 area-type 'nssa' + # set protocols ospf area 4 area-type stub default-cost '20' + # set protocols ospf area 4 network '192.0.2.0/24' + # set protocols ospf area 4 range 192.0.3.0/24 cost '10' + # set protocols ospf area 4 range 192.0.4.0/24 cost '12' + # set protocols ospf auto-cost reference-bandwidth '2' + # set protocols ospf default-information originate 'always' + # set protocols ospf default-information originate metric '10' + # set protocols ospf default-information originate metric-type '2' + # set protocols ospf default-information originate route-map 'ingress' + # set protocols ospf log-adjacency-changes 'detail' + # set protocols ospf max-metric router-lsa 'administrative' + # set protocols ospf max-metric router-lsa on-shutdown '10' + # set protocols ospf max-metric router-lsa on-startup '10' + # set protocols ospf mpls-te 'enable' + # set protocols ospf mpls-te router-address '192.0.11.11' + # set protocols ospf neighbor 192.0.11.12 poll-interval '10' + # set protocols ospf neighbor 192.0.11.12 priority '2' + # set protocols ospf parameters abr-type 'cisco' + # set protocols ospf parameters 'opaque-lsa' + # set protocols ospf parameters 'rfc1583-compatibility' + # set protocols ospf parameters router-id '192.0.1.1' + # set protocols ospf passive-interface 'eth1' + # set protocols ospf passive-interface 'eth2' + # set protocols ospf redistribute bgp metric '10' + # set protocols ospf redistribute bgp metric-type '2' + # + - name: Delete attributes of ospfv2 routes. + vyos.vyos.vyos_ospfv2: + config: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": { + # "areas": [ + # { + # "area_id": "2", + # "area_type": { + # "normal": true + # }, + # "authentication": "plaintext-password", + # "shortcut": "enable" + # }, + # { + # "area_id": "3", + # "area_type": { + # "nssa": { + # "set": true + # } + # } + # }, + # { + # "area_id": "4", + # "area_type": { + # "stub": { + # "default_cost": 20, + # "set": true + # } + # }, + # "network": [ + # { + # "address": "192.0.2.0/24" + # } + # ], + # "range": [ + # { + # "address": "192.0.3.0/24", + # "cost": 10 + # }, + # { + # "address": "192.0.4.0/24", + # "cost": 12 + # } + # ] + # } + # ], + # "auto_cost": { + # "reference_bandwidth": 2 + # }, + # "default_information": { + # "originate": { + # "always": true, + # "metric": 10, + # "metric_type": 2, + # "route_map": "ingress" + # } + # }, + # "log_adjacency_changes": "detail", + # "max_metric": { + # "router_lsa": { + # "administrative": true, + # "on_shutdown": 10, + # "on_startup": 10 + # } + # }, + # "mpls_te": { + # "enabled": true, + # "router_address": "192.0.11.11" + # }, + # "neighbor": [ + # { + # "neighbor_id": "192.0.11.12", + # "poll_interval": 10, + # "priority": 2 + # } + # ], + # "parameters": { + # "abr_type": "cisco", + # "opaque_lsa": true, + # "rfc1583_compatibility": true, + # "router_id": "192.0.1.1" + # }, + # "passive_interface": [ + # "eth2", + # "eth1" + # ], + # "redistribute": [ + # { + # "metric": 10, + # "metric_type": 2, + # "route_type": "bgp" + # } + # ] + # } + # "commands": [ + # "delete protocols ospf" + # ] + # + # "after": {} + # After state + # ------------ + # vyos@192# run show configuration commands | grep ospf + # + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The resulting configuration model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration prior to the model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set protocols ospf parameters router-id 192.0.1.1', "set protocols ospf passive-interface 'eth1'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospfv3_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospfv3_module.rst new file mode 100644 index 00000000..d1ee1b18 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ospfv3_module.rst @@ -0,0 +1,916 @@ +.. _vyos.vyos.vyos_ospfv3_module: + + +********************* +vyos.vyos.vyos_ospfv3 +********************* + +**OSPFV3 resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This resource module configures and manages attributes of OSPFv3 routes on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="4">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A provided OSPFv3 route configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>areas</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv3 area.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>area_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv3 Area name/identity.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>export_list</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of export-list.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>import_list</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of import-list.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>range</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Summarize routes matching prefix (border routers only).</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>border router IPv4 address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>advertise</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Advertise this range.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>not_advertise</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Don't advertise this range.</div> + </td> + </tr> + + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>parameters</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>OSPFv3 specific parameters.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>router_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Override the default router identifier.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>redistribute</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Redistribute information from another routing protocol.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_map</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Route map references.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>route_type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>bgp</li> + <li>connected</li> + <li>kernel</li> + <li>ripng</li> + <li>static</li> + </ul> + </td> + <td> + <div>Route type to redistribute.</div> + </td> + </tr> + + + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep ospfv3</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>deleted</li> + <li>parsed</li> + <li>gathered</li> + <li>rendered</li> + </ul> + </td> + <td> + <div>The state the configuration should be left in.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos# run show configuration commands | grep ospfv3 + # + # + - name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: bgp + parameters: + router_id: 192.0.2.10 + areas: + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 + - area_id: '3' + range: + - address: 2001:db40::/32 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": {} + # + # "commands": [ + # "set protocols ospfv3 redistribute bgp", + # "set protocols ospfv3 parameters router-id '192.0.2.10'", + # "set protocols ospfv3 area 2 range 2001:db10::/32", + # "set protocols ospfv3 area 2 range 2001:db20::/32", + # "set protocols ospfv3 area 2 range 2001:db30::/32", + # "set protocols ospfv3 area '2'", + # "set protocols ospfv3 area 2 export-list export1", + # "set protocols ospfv3 area 2 import-list import1", + # "set protocols ospfv3 area '3'", + # "set protocols ospfv3 area 3 range 2001:db40::/32" + # ] + # + # "after": { + # "areas": [ + # { + # "area_id": "2", + # "export_list": "export1", + # "import_list": "import1", + # "range": [ + # { + # "address": "2001:db10::/32" + # }, + # { + # "address": "2001:db20::/32" + # }, + # { + # "address": "2001:db30::/32" + # } + # ] + # }, + # { + # "area_id": "3", + # "range": [ + # { + # "address": "2001:db40::/32" + # } + # ] + # } + # ], + # "parameters": { + # "router_id": "192.0.2.10" + # }, + # "redistribute": [ + # { + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospfv3 + # set protocols ospfv3 area 2 export-list 'export1' + # set protocols ospfv3 area 2 import-list 'import1' + # set protocols ospfv3 area 2 range '2001:db10::/32' + # set protocols ospfv3 area 2 range '2001:db20::/32' + # set protocols ospfv3 area 2 range '2001:db30::/32' + # set protocols ospfv3 area 3 range '2001:db40::/32' + # set protocols ospfv3 parameters router-id '192.0.2.10' + # set protocols ospfv3 redistribute 'bgp' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospfv3 + # set protocols ospfv3 area 2 export-list 'export1' + # set protocols ospfv3 area 2 import-list 'import1' + # set protocols ospfv3 area 2 range '2001:db10::/32' + # set protocols ospfv3 area 2 range '2001:db20::/32' + # set protocols ospfv3 area 2 range '2001:db30::/32' + # set protocols ospfv3 area 3 range '2001:db40::/32' + # set protocols ospfv3 parameters router-id '192.0.2.10' + # set protocols ospfv3 redistribute 'bgp' + # + - name: Replace ospfv3 routes attributes configuration. + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: bgp + parameters: + router_id: 192.0.2.10 + areas: + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: 2001:db10::/32 + - address: 2001:db30::/32 + - address: 2001:db50::/32 + - area_id: '4' + range: + - address: 2001:db60::/32 + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": { + # "areas": [ + # { + # "area_id": "2", + # "export_list": "export1", + # "import_list": "import1", + # "range": [ + # { + # "address": "2001:db10::/32" + # }, + # { + # "address": "2001:db20::/32" + # }, + # { + # "address": "2001:db30::/32" + # } + # ] + # }, + # { + # "area_id": "3", + # "range": [ + # { + # "address": "2001:db40::/32" + # } + # ] + # } + # ], + # "parameters": { + # "router_id": "192.0.2.10" + # }, + # "redistribute": [ + # { + # "route_type": "bgp" + # } + # ] + # } + # + # "commands": [ + # "delete protocols ospfv3 area 2 range 2001:db20::/32", + # "delete protocols ospfv3 area 3", + # "set protocols ospfv3 area 2 range 2001:db50::/32", + # "set protocols ospfv3 area '4'", + # "set protocols ospfv3 area 4 range 2001:db60::/32" + # ] + # + # "after": { + # "areas": [ + # { + # "area_id": "2", + # "export_list": "export1", + # "import_list": "import1", + # "range": [ + # { + # "address": "2001:db10::/32" + # }, + # { + # "address": "2001:db30::/32" + # }, + # { + # "address": "2001:db50::/32" + # } + # ] + # }, + # { + # "area_id": "4", + # "range": [ + # { + # "address": "2001:db60::/32" + # } + # ] + # } + # ], + # "parameters": { + # "router_id": "192.0.2.10" + # }, + # "redistribute": [ + # { + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospfv3 + # set protocols ospfv3 area 2 export-list 'export1' + # set protocols ospfv3 area 2 import-list 'import1' + # set protocols ospfv3 area 2 range '2001:db10::/32' + # set protocols ospfv3 area 2 range '2001:db30::/32' + # set protocols ospfv3 area 2 range '2001:db50::/32' + # set protocols ospfv3 area 4 range '2001:db60::/32' + # set protocols ospfv3 parameters router-id '192.0.2.10' + # set protocols ospfv3 redistribute 'bgp' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: bgp + parameters: + router_id: 192.0.2.10 + areas: + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 + - area_id: '3' + range: + - address: 2001:db40::/32 + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # [ + # "set protocols ospfv3 redistribute bgp", + # "set protocols ospfv3 parameters router-id '192.0.2.10'", + # "set protocols ospfv3 area 2 range 2001:db10::/32", + # "set protocols ospfv3 area 2 range 2001:db20::/32", + # "set protocols ospfv3 area 2 range 2001:db30::/32", + # "set protocols ospfv3 area '2'", + # "set protocols ospfv3 area 2 export-list export1", + # "set protocols ospfv3 area 2 import-list import1", + # "set protocols ospfv3 area '3'", + # "set protocols ospfv3 area 3 range 2001:db40::/32" + # ] + + + # Using parsed + # + # + - name: Parse the commands to provide structured configuration. + vyos.vyos.vyos_ospfv3: + running_config: + "set protocols ospfv3 area 2 export-list 'export1' + set protocols ospfv3 area 2 import-list 'import1' + set protocols ospfv3 area 2 range '2001:db10::/32' + set protocols ospfv3 area 2 range '2001:db20::/32' + set protocols ospfv3 area 2 range '2001:db30::/32' + set protocols ospfv3 area 3 range '2001:db40::/32' + set protocols ospfv3 parameters router-id '192.0.2.10' + set protocols ospfv3 redistribute 'bgp'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": { + # "areas": [ + # { + # "area_id": "2", + # "export_list": "export1", + # "import_list": "import1", + # "range": [ + # { + # "address": "2001:db10::/32" + # }, + # { + # "address": "2001:db20::/32" + # }, + # { + # "address": "2001:db30::/32" + # } + # ] + # }, + # { + # "area_id": "3", + # "range": [ + # { + # "address": "2001:db40::/32" + # } + # ] + # } + # ], + # "parameters": { + # "router_id": "192.0.2.10" + # }, + # "redistribute": [ + # { + # "route_type": "bgp" + # } + # ] + # } + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospfv3 + # set protocols ospfv3 area 2 export-list 'export1' + # set protocols ospfv3 area 2 import-list 'import1' + # set protocols ospfv3 area 2 range '2001:db10::/32' + # set protocols ospfv3 area 2 range '2001:db20::/32' + # set protocols ospfv3 area 2 range '2001:db30::/32' + # set protocols ospfv3 area 3 range '2001:db40::/32' + # set protocols ospfv3 parameters router-id '192.0.2.10' + # set protocols ospfv3 redistribute 'bgp' + # + - name: Gather ospfv3 routes config with provided configurations + vyos.vyos.vyos_ospfv3: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": { + # "areas": [ + # { + # "area_id": "2", + # "export_list": "export1", + # "import_list": "import1", + # "range": [ + # { + # "address": "2001:db10::/32" + # }, + # { + # "address": "2001:db20::/32" + # }, + # { + # "address": "2001:db30::/32" + # } + # ] + # }, + # { + # "area_id": "3", + # "range": [ + # { + # "address": "2001:db40::/32" + # } + # ] + # } + # ], + # "parameters": { + # "router_id": "192.0.2.10" + # }, + # "redistribute": [ + # { + # "route_type": "bgp" + # } + # ] + # } + # + # After state: + # ------------- + # + # vyos@192# run show configuration commands | grep ospfv3 + # set protocols ospfv3 area 2 export-list 'export1' + # set protocols ospfv3 area 2 import-list 'import1' + # set protocols ospfv3 area 2 range '2001:db10::/32' + # set protocols ospfv3 area 2 range '2001:db20::/32' + # set protocols ospfv3 area 2 range '2001:db30::/32' + # set protocols ospfv3 area 3 range '2001:db40::/32' + # set protocols ospfv3 parameters router-id '192.0.2.10' + # set protocols ospfv3 redistribute 'bgp' + + + # Using deleted + # + # Before state + # ------------- + # + # vyos@192# run show configuration commands | grep ospfv3 + # set protocols ospfv3 area 2 export-list 'export1' + # set protocols ospfv3 area 2 import-list 'import1' + # set protocols ospfv3 area 2 range '2001:db10::/32' + # set protocols ospfv3 area 2 range '2001:db20::/32' + # set protocols ospfv3 area 2 range '2001:db30::/32' + # set protocols ospfv3 area 3 range '2001:db40::/32' + # set protocols ospfv3 parameters router-id '192.0.2.10' + # set protocols ospfv3 redistribute 'bgp' + # + - name: Delete attributes of ospfv3 routes. + vyos.vyos.vyos_ospfv3: + config: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": { + # "areas": [ + # { + # "area_id": "2", + # "export_list": "export1", + # "import_list": "import1", + # "range": [ + # { + # "address": "2001:db10::/32" + # }, + # { + # "address": "2001:db20::/32" + # }, + # { + # "address": "2001:db30::/32" + # } + # ] + # }, + # { + # "area_id": "3", + # "range": [ + # { + # "address": "2001:db40::/32" + # } + # ] + # } + # ], + # "parameters": { + # "router_id": "192.0.2.10" + # }, + # "redistribute": [ + # { + # "route_type": "bgp" + # } + # ] + # } + # "commands": [ + # "delete protocols ospfv3" + # ] + # + # "after": {} + # After state + # ------------ + # vyos@192# run show configuration commands | grep ospfv3 + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The resulting configuration model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration prior to the model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set protocols ospf parameters router-id 192.0.1.1', "set protocols ospfv3 area 2 range '2001:db10::/32'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ping_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ping_module.rst new file mode 100644 index 00000000..e3377fc5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_ping_module.rst @@ -0,0 +1,422 @@ +.. _vyos.vyos.vyos_ping_module: + + +******************* +vyos.vyos.vyos_ping +******************* + +**Tests reachability using ping from VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Tests reachability using ping from a VyOS device to a remote destination. +- Tested against VyOS 1.1.8 (helium) +- For a general purpose network module, see the :ref:`net_ping <net_ping_module>` module. +- For Windows targets, use the :ref:`win_ping <win_ping_module>` module instead. +- For targets running Python, use the :ref:`ping <ping_module>` module instead. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>count</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">5</div> + </td> + <td> + <div>Number of packets to send to check reachability.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dest</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>The IP Address or hostname (resolvable by the device) of the remote node.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interval</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Determines the interval (in seconds) between consecutive pings.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>size</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Determines the size (in bytes) of the ping packet(s).</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>source</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The source interface or IP Address to use while sending the ping packet(s).</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>absent</li> + <li><div style="color: blue"><b>present</b> ←</div></li> + </ul> + </td> + <td> + <div>Determines if the expected result is success or fail.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ttl</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>The time-to-live value for the ICMP packet(s).</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - For a general purpose network module, see the :ref:`net_ping <net_ping_module>` module. + - For Windows targets, use the :ref:`win_ping <win_ping_module>` module instead. + - For targets running Python, use the :ref:`ping <ping_module>` module instead. + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Test reachability to 10.10.10.10 + vyos.vyos.vyos_ping: + dest: 10.10.10.10 + + - name: Test reachability to 10.20.20.20 using source and ttl set + vyos.vyos.vyos_ping: + dest: 10.20.20.20 + source: eth0 + ttl: 128 + + - name: Test unreachability to 10.30.30.30 using interval + vyos.vyos.vyos_ping: + dest: 10.30.30.30 + interval: 3 + state: absent + + - name: Test reachability to 10.40.40.40 setting count and source + vyos.vyos.vyos_ping: + dest: 10.40.40.40 + source: eth1 + count: 20 + size: 512 + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>List of commands sent.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['ping 10.8.38.44 count 10 interface eth0 ttl 128']</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>packet_loss</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td>always</td> + <td> + <div>Percentage of packets lost.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">0%</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>packets_rx</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td>always</td> + <td> + <div>Packets successfully received.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">20</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>packets_tx</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td>always</td> + <td> + <div>Packets successfully transmitted.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">20</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>rtt</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td>when ping succeeds</td> + <td> + <div>The round trip time (RTT) stats.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">AnsibleMapping([('avg', 2), ('max', 8), ('min', 1), ('mdev', 24)])</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nilashish Chakraborty (@NilashishC) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_static_route_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_static_route_module.rst new file mode 100644 index 00000000..74f296d4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_static_route_module.rst @@ -0,0 +1,437 @@ +.. _vyos.vyos.vyos_static_route_module: + + +*************************** +vyos.vyos.vyos_static_route +*************************** + +**(deprecated, removed after 2022-06-01) Manage static IP routes on Vyatta VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + +DEPRECATED +---------- +:Removed in collection release after 2022-06-01 +:Why: Updated modules released with more functionality. +:Alternative: vyos_static_routes + + + +Synopsis +-------- +- This module provides declarative management of static IP routes on Vyatta VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>admin_distance</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Admin distance of the static route.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of static route definitions</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>admin_distance</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Admin distance of the static route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mask</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Network prefix mask of the static route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>next_hop</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Next hop IP of the static route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>prefix</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>Network prefix of the static route. <code>mask</code> param should be ignored if <code>prefix</code> is provided with <code>mask</code> value <code>prefix/mask</code>.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the static route configuration.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>mask</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Network prefix mask of the static route.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>next_hop</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Next hop IP of the static route.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>prefix</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Network prefix of the static route. <code>mask</code> param should be ignored if <code>prefix</code> is provided with <code>mask</code> value <code>prefix/mask</code>.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the static route configuration.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure static route + vyos.vyos.vyos_static_route: + prefix: 192.168.2.0 + mask: 24 + next_hop: 10.0.0.1 + + - name: configure static route prefix/mask + vyos.vyos.vyos_static_route: + prefix: 192.168.2.0/16 + next_hop: 10.0.0.1 + + - name: remove configuration + vyos.vyos.vyos_static_route: + prefix: 192.168.2.0 + mask: 16 + next_hop: 10.0.0.1 + state: absent + + - name: configure aggregates of static routes + vyos.vyos.vyos_static_route: + aggregate: + - {prefix: 192.168.2.0, mask: 24, next_hop: 10.0.0.1} + - {prefix: 192.168.3.0, mask: 16, next_hop: 10.0.2.1} + - {prefix: 192.168.3.0/16, next_hop: 10.0.2.1} + + - name: Remove static route collections + vyos.vyos.vyos_static_route: + aggregate: + - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64} + - {prefix: 172.24.3.0/24, next_hop: 192.168.42.64} + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set protocols static route 192.168.2.0/16 next-hop 10.0.0.1']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +- This module will be removed in version . *[deprecated]* +- For more information see `DEPRECATED`_. + + +Authors +~~~~~~~ + +- Trishna Guha (@trishnaguha) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_static_routes_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_static_routes_module.rst new file mode 100644 index 00000000..53942a5c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_static_routes_module.rst @@ -0,0 +1,1165 @@ +.. _vyos.vyos.vyos_static_routes_module: + + +**************************** +vyos.vyos.vyos_static_routes +**************************** + +**Static routes resource module** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages attributes of static routes on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="5">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A provided static route configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="4"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address_families</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A dictionary specifying the address family to which the static route(s) belong.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>afi</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>ipv4</li> + <li>ipv6</li> + </ul> + </td> + <td> + <div>Specifies the type of route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="3"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>routes</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>A ditionary that specify the static route configurations.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>blackhole_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Configured to silently discard packets.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>distance</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Distance for the route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>type</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This is to configure only blackhole.</div> + </td> + </tr> + + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>dest</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>An IPv4/v6 address in CIDR notation that specifies the destination network for the static route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>next_hops</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>Next hops to the specified destination.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>admin_distance</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Distance value for the route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>enabled</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>no</li> + <li>yes</li> + </ul> + </td> + <td> + <div>Disable IPv4/v6 next-hop static route.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>forward_router_address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>The IP address of the next hop that can be used to reach the destination network.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interface</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the outgoing interface.</div> + </td> + </tr> + + + + + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>running_config</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>This option is used only with state <em>parsed</em>.</div> + <div>The value of this option should be the output received from the VyOS device by executing the command <b>show configuration commands | grep static route</b>.</div> + <div>The state <em>parsed</em> reads the configuration from <code>running_config</code> option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the <em>parsed</em> key within the result.</div> + </td> + </tr> + <tr> + <td colspan="5"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>merged</b> ←</div></li> + <li>replaced</li> + <li>overridden</li> + <li>deleted</li> + <li>gathered</li> + <li>rendered</li> + <li>parsed</li> + </ul> + </td> + <td> + <div>The state of the configuration after module completion.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # Using merged + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands | grep static + # + - name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 + state: merged + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # before": [] + # + # "commands": [ + # "set protocols static route 192.0.2.32/28", + # "set protocols static route 192.0.2.32/28 blackhole", + # "set protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", + # "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", + # "set protocols static route6 2001:db8:1000::/36", + # "set protocols static route6 2001:db8:1000::/36 blackhole distance '2'", + # "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'", + # "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" + # ] + # + # "after": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.6" + # }, + # { + # "forward_router_address": "192.0.2.7" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 'blackhole' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + + + # Using replaced + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 'blackhole' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + # set protocols static route 192.0.2.33/28 'blackhole' + # set protocols static route 192.0.2.33/28 next-hop '192.0.2.3' + # set protocols static route 192.0.2.33/28 next-hop '192.0.2.4' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + # + - name: Replace device configurations of listed static routes with provided configurations + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 192.0.2.7 + enabled: false + - forward_router_address: 192.0.2.9 + state: replaced + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.6" + # }, + # { + # "forward_router_address": "192.0.2.7" + # } + # ] + # }, + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.33/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.3" + # }, + # { + # "forward_router_address": "192.0.2.4" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # + # "commands": [ + # "delete protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", + # "delete protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", + # "set protocols static route 192.0.2.32/28 next-hop 192.0.2.7 'disable'", + # "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", + # "set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'", + # "set protocols static route 192.0.2.32/28 blackhole distance '2'" + # ] + # + # "after": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "enabled": false, + # "forward_router_address": "192.0.2.7" + # }, + # { + # "forward_router_address": "192.0.2.9" + # } + # ] + # }, + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.33/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.3" + # }, + # { + # "forward_router_address": "192.0.2.4" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 blackhole distance '2' + # set protocols static route 192.0.2.32/28 next-hop 192.0.2.7 'disable' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' + # set protocols static route 192.0.2.33/28 'blackhole' + # set protocols static route 192.0.2.33/28 next-hop '192.0.2.3' + # set protocols static route 192.0.2.33/28 next-hop '192.0.2.4' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + + + # Using overridden + # + # Before state + # -------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 blackhole distance '2' + # set protocols static route 192.0.2.32/28 next-hop 192.0.2.7 'disable' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + # + - name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 198.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.18 + state: overridden + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "before": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "enabled": false, + # "forward_router_address": "192.0.2.7" + # }, + # { + # "forward_router_address": "192.0.2.9" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # + # "commands": [ + # "delete protocols static route 192.0.2.32/28", + # "delete protocols static route6 2001:db8:1000::/36", + # "set protocols static route 198.0.2.48/28", + # "set protocols static route 198.0.2.48/28 next-hop '192.0.2.18'" + # + # + # "after": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "dest": "198.0.2.48/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.18" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # + # + # After state + # ------------ + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 198.0.2.48/28 next-hop '192.0.2.18' + + + # Using deleted to delete static route based on afi + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 'blackhole' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + # + - name: Delete static route based on afi. + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + - afi: ipv6 + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.6" + # }, + # { + # "forward_router_address": "192.0.2.7" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # "commands": [ + # "delete protocols static route", + # "delete protocols static route6" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep static + # set protocols 'static' + + + # Using deleted to delete all the static routes when passes config is empty + # + # Before state + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 'blackhole' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + # + - name: Delete all the static routes. + vyos.vyos.vyos_static_routes: + config: + state: deleted + # + # + # ------------------------ + # Module Execution Results + # ------------------------ + # + # "before": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.6" + # }, + # { + # "forward_router_address": "192.0.2.7" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # "commands": [ + # "delete protocols static route", + # "delete protocols static route6" + # ] + # + # "after": [] + # After state + # ------------ + # vyos@vyos# run show configuration commands | grep static + # set protocols 'static' + + + # Using rendered + # + # + - name: Render the commands for provided configuration + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 + state: rendered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "rendered": [ + # "set protocols static route 192.0.2.32/28", + # "set protocols static route 192.0.2.32/28 blackhole", + # "set protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", + # "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", + # "set protocols static route6 2001:db8:1000::/36", + # "set protocols static route6 2001:db8:1000::/36 blackhole distance '2'", + # "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'", + # "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" + # ] + + + # Using parsed + # + # + - name: Parse the provided running configuration + vyos.vyos.vyos_static_routes: + running_config: + "set protocols static route 192.0.2.32/28 'blackhole' + set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" + state: parsed + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # + # "parsed": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + + + # Using gathered + # + # Before state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 'blackhole' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + # + - name: Gather listed static routes with provided configurations + vyos.vyos.vyos_static_routes: + config: + state: gathered + # + # + # ------------------------- + # Module Execution Result + # ------------------------- + # + # "gathered": [ + # { + # "address_families": [ + # { + # "afi": "ipv4", + # "routes": [ + # { + # "blackhole_config": { + # "type": "blackhole" + # }, + # "dest": "192.0.2.32/28", + # "next_hops": [ + # { + # "forward_router_address": "192.0.2.6" + # }, + # { + # "forward_router_address": "192.0.2.7" + # } + # ] + # } + # ] + # }, + # { + # "afi": "ipv6", + # "routes": [ + # { + # "blackhole_config": { + # "distance": 2 + # }, + # "dest": "2001:db8:1000::/36", + # "next_hops": [ + # { + # "forward_router_address": "2001:db8:2000:2::1" + # }, + # { + # "forward_router_address": "2001:db8:2000:2::2" + # } + # ] + # } + # ] + # } + # ] + # } + # ] + # + # + # After state: + # ------------- + # + # vyos@vyos:~$ show configuration commands| grep static + # set protocols static route 192.0.2.32/28 'blackhole' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + # set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>after</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>when changed</td> + <td> + <div>The resulting configuration model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>before</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The configuration prior to the model invocation.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">The configuration returned will always be in the same format + of the parameters above.</div> + </td> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The set of commands pushed to the remote device.</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">["set protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", "set protocols static route 192.0.2.32/28 'blackhole'"]</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Rohit Thakur (@rohitthakur2590) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_system_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_system_module.rst new file mode 100644 index 00000000..a71303c4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_system_module.rst @@ -0,0 +1,312 @@ +.. _vyos.vyos.vyos_system_module: + + +********************* +vyos.vyos.vyos_system +********************* + +**Run `set system` commands on VyOS devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Runs one or more commands on remote devices running VyOS. This module can also be introspected to validate key parameters before returning successfully. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>domain_name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The new domain name to apply to the device.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>domain_search</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>A list of domain names to search. Mutually exclusive with <em>name_server</em></div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host_name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configure the device hostname parameter. This option takes an ASCII string value.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name_server</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>A list of name servers to use with the device. Mutually exclusive with <em>domain_search</em></div> + <div style="font-size: small; color: darkgreen"><br/>aliases: name_servers</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>Whether to apply (<code>present</code>) or remove (<code>absent</code>) the settings.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: configure hostname and domain-name + vyos.vyos.vyos_system: + host_name: vyos01 + domain_name: test.example.com + + - name: remove all configuration + vyos.vyos.vyos_system: + state: absent + + - name: configure name servers + vyos.vyos.vyos_system: name_servers - 8.8.8.8 - 8.8.4.4 + - name: configure domain search suffixes + vyos.vyos.vyos_system: + domain_search: + - sub1.example.com + - sub2.example.com + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set system hostname vyos01', 'set system domain-name foo.example.com']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Nathaniel Case (@Qalthos) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_user_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_user_module.rst new file mode 100644 index 00000000..04a7a6e2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_user_module.rst @@ -0,0 +1,477 @@ +.. _vyos.vyos.vyos_user_module: + + +******************* +vyos.vyos.vyos_user +******************* + +**Manage the collection of local users on VyOS device** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module provides declarative management of the local usernames configured on network devices. It allows playbooks to manage either individual usernames or the collection of usernames in the current running config. It also supports purging usernames from the configuration that are not explicitly defined. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>The set of username objects to be configured on the remote VyOS device. The list entries can either be the username or a hash of username and properties. This argument is mutually exclusive with the <code>name</code> argument.</div> + <div style="font-size: small; color: darkgreen"><br/>aliases: users, collection</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>configured_password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The password to be configured on the VyOS device. The password needs to be provided in clear and it will be encrypted on the device. Please note that this option is not same as <code>provider password</code>.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>full_name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The <code>full_name</code> argument provides the full name of the user account to be created on the remote device. This argument accepts any text string value.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>level</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The <code>level</code> argument configures the level of the user when logged into the system. This argument accepts string values admin or operator.</div> + <div style="font-size: small; color: darkgreen"><br/>aliases: role</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>The username to be configured on the VyOS device. This argument accepts a string value and is mutually exclusive with the <code>aggregate</code> argument. Please note that this option is not same as <code>provider username</code>.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + </ul> + </td> + <td> + <div>Configures the state of the username definition as it relates to the device operational configuration. When set to <em>present</em>, the username(s) should be configured in the device active configuration and when set to <em>absent</em> the username(s) should not be in the device active configuration</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>update_password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>on_create</li> + <li>always</li> + </ul> + </td> + <td> + <div>Since passwords are encrypted in the device running config, this argument will instruct the module when to change the password. When set to <code>always</code>, the password will always be updated in the device and when set to <code>on_create</code> the password will be updated only if the username is created.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>configured_password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The password to be configured on the VyOS device. The password needs to be provided in clear and it will be encrypted on the device. Please note that this option is not same as <code>provider password</code>.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>full_name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The <code>full_name</code> argument provides the full name of the user account to be created on the remote device. This argument accepts any text string value.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>level</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The <code>level</code> argument configures the level of the user when logged into the system. This argument accepts string values admin or operator.</div> + <div style="font-size: small; color: darkgreen"><br/>aliases: role</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>The username to be configured on the VyOS device. This argument accepts a string value and is mutually exclusive with the <code>aggregate</code> argument. Please note that this option is not same as <code>provider username</code>.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>purge</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>no</b> ←</div></li> + <li>yes</li> + </ul> + </td> + <td> + <div>Instructs the module to consider the resource definition absolute. It will remove any previously configured usernames on the device with the exception of the `admin` user (the current defined set of users).</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>Configures the state of the username definition as it relates to the device operational configuration. When set to <em>present</em>, the username(s) should be configured in the device active configuration and when set to <em>absent</em> the username(s) should not be in the device active configuration</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>update_password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>on_create</li> + <li><div style="color: blue"><b>always</b> ←</div></li> + </ul> + </td> + <td> + <div>Since passwords are encrypted in the device running config, this argument will instruct the module when to change the password. When set to <code>always</code>, the password will always be updated in the device and when set to <code>on_create</code> the password will be updated only if the username is created.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: create a new user + vyos.vyos.vyos_user: + name: ansible + configured_password: password + state: present + - name: remove all users except admin + vyos.vyos.vyos_user: + purge: yes + - name: set multiple users to level operator + vyos.vyos.vyos_user: + aggregate: + - name: netop + - name: netend + level: operator + state: present + - name: Change Password for User netop + vyos.vyos.vyos_user: + name: netop + configured_password: '{{ new_password }}' + update_password: always + state: present + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set system login user test level operator', 'set system login user authentication plaintext-password password']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Trishna Guha (@trishnaguha) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_vlan_module.rst b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_vlan_module.rst new file mode 100644 index 00000000..d00260ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/docs/vyos.vyos.vyos_vlan_module.rst @@ -0,0 +1,521 @@ +.. _vyos.vyos.vyos_vlan_module: + + +******************* +vyos.vyos.vyos_vlan +******************* + +**Manage VLANs on VyOS network devices** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module provides declarative management of VLANs on VyOS network devices. + + + + +Parameters +---------- + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="2">Parameter</th> + <th>Choices/<font color="blue">Defaults</font></th> + <th width="100%">Comments</th> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configure Virtual interface address.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>aggregate</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div>List of VLANs definitions.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>address</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configure Virtual interface address.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>associated_interfaces</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>This is a intent option and checks the operational state of the for given vlan <code>name</code> for associated interfaces. If the value in the <code>associated_interfaces</code> does not match with the operational state of vlan on device it will result in failure.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Delay the play should wait to check for declarative intent params values.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interfaces</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>List of interfaces that should be associated to the VLAN.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the VLAN.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li>present</li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the VLAN configuration.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>vlan_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + / <span style="color: red">required</span> + </div> + </td> + <td> + </td> + <td> + <div>ID of the VLAN. Range 0-4094.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>associated_interfaces</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>This is a intent option and checks the operational state of the for given vlan <code>name</code> for associated interfaces. If the value in the <code>associated_interfaces</code> does not match with the operational state of vlan on device it will result in failure.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>delay</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + <b>Default:</b><br/><div style="color: blue">10</div> + </td> + <td> + <div>Delay the play should wait to check for declarative intent params values.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>interfaces</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + / <span style="color: purple">elements=string</span> + </div> + </td> + <td> + </td> + <td> + <div>List of interfaces that should be associated to the VLAN.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>name</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Name of the VLAN.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>provider</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">dictionary</span> + </div> + </td> + <td> + </td> + <td> + <div><b>Deprecated</b></div> + <div>Starting with Ansible 2.5 we recommend using <code>connection: network_cli</code>.</div> + <div>For more information please see the <a href='../network/getting_started/network_differences.html#multiple-communication-protocols'>Network Guide</a>.</div> + <div><hr/></div> + <div>A dict object containing connection details.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>host</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>password</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_PASSWORD</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>port</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the port to use when building the connection to the remote device.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>ssh_keyfile</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">path</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_SSH_KEYFILE</code> will be used instead.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>timeout</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.</div> + </td> + </tr> + <tr> + <td class="elbow-placeholder"></td> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>username</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + </td> + <td> + <div>Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable <code>ANSIBLE_NET_USERNAME</code> will be used instead.</div> + </td> + </tr> + + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>purge</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">boolean</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>no</b> ←</div></li> + <li>yes</li> + </ul> + </td> + <td> + <div>Purge VLANs not defined in the <em>aggregate</em> parameter.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>state</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">string</span> + </div> + </td> + <td> + <ul style="margin: 0; padding: 0"><b>Choices:</b> + <li><div style="color: blue"><b>present</b> ←</div></li> + <li>absent</li> + </ul> + </td> + <td> + <div>State of the VLAN configuration.</div> + </td> + </tr> + <tr> + <td colspan="2"> + <div class="ansibleOptionAnchor" id="parameter-"></div> + <b>vlan_id</b> + <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> + <div style="font-size: small"> + <span style="color: purple">integer</span> + </div> + </td> + <td> + </td> + <td> + <div>ID of the VLAN. Range 0-4094.</div> + </td> + </tr> + </table> + <br/> + + +Notes +----- + +.. note:: + - Tested against VyOS 1.1.8 (helium). + - This module works with connection ``network_cli``. See `the VyOS OS Platform Options <../network/user_guide/platform_vyos.html>`_. + - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>` + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Create vlan + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + state: present + + - name: Add interfaces to VLAN + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: + - eth1 + - eth2 + + - name: Configure virtual interface address + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth1 + address: 172.26.100.37/24 + + - name: vlan interface config + intent + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth0 + associated_interfaces: + - eth0 + + - name: vlan intent check + vyos.vyos.vyos_vlan: + vlan_id: 100 + associated_interfaces: + - eth3 + - eth4 + + - name: Delete vlan + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth1 + state: absent + + + +Return Values +------------- +Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module: + +.. raw:: html + + <table border=0 cellpadding=0 class="documentation-table"> + <tr> + <th colspan="1">Key</th> + <th>Returned</th> + <th width="100%">Description</th> + </tr> + <tr> + <td colspan="1"> + <div class="ansibleOptionAnchor" id="return-"></div> + <b>commands</b> + <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> + <div style="font-size: small"> + <span style="color: purple">list</span> + </div> + </td> + <td>always</td> + <td> + <div>The list of configuration mode commands to send to the device</div> + <br/> + <div style="font-size: smaller"><b>Sample:</b></div> + <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">['set interfaces ethernet eth1 vif 100 description VLAN 100', 'set interfaces ethernet eth1 vif 100 address 172.26.100.37/24', 'delete interfaces ethernet eth1 vif 100']</div> + </td> + </tr> + </table> + <br/><br/> + + +Status +------ + + +Authors +~~~~~~~ + +- Trishna Guha (@trishnaguha) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/meta/runtime.yml b/collections-debian-merged/ansible_collections/vyos/vyos/meta/runtime.yml new file mode 100644 index 00000000..00bbaca7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/meta/runtime.yml @@ -0,0 +1,209 @@ +--- +requires_ansible: '>=2.9.10,<2.11' +plugin_routing: + action: + vyos_banner: + redirect: vyos.vyos.vyos + banner: + redirect: vyos.vyos.vyos + vyos_command: + redirect: vyos.vyos.vyos + command: + redirect: vyos.vyos.vyos + vyos_config: + redirect: vyos.vyos.vyos + config: + redirect: vyos.vyos.vyos + vyos_facts: + redirect: vyos.vyos.vyos + facts: + redirect: vyos.vyos.vyos + vyos_firewall_global: + redirect: vyos.vyos.vyos + firewall_global: + redirect: vyos.vyos.vyos + vyos_firewall_interfaces: + redirect: vyos.vyos.vyos + firewall_interfaces: + redirect: vyos.vyos.vyos + vyos_firewall_rules: + redirect: vyos.vyos.vyos + firewall_rules: + redirect: vyos.vyos.vyos + vyos_interface: + redirect: vyos.vyos.vyos + interface: + redirect: vyos.vyos.vyos + vyos_interfaces: + redirect: vyos.vyos.vyos + interfaces: + redirect: vyos.vyos.vyos + vyos_l3_interface: + redirect: vyos.vyos.vyos + l3_interface: + redirect: vyos.vyos.vyos + vyos_l3_interfaces: + redirect: vyos.vyos.vyos + l3_interfaces: + redirect: vyos.vyos.vyos + vyos_lag_interfaces: + redirect: vyos.vyos.vyos + lag_interfaces: + redirect: vyos.vyos.vyos + vyos_linkagg: + redirect: vyos.vyos.vyos + linkagg: + redirect: vyos.vyos.vyos + vyos_lldp: + redirect: vyos.vyos.vyos + lldp: + redirect: vyos.vyos.vyos + vyos_lldp_global: + redirect: vyos.vyos.vyos + lldp_global: + redirect: vyos.vyos.vyos + vyos_lldp_interface: + redirect: vyos.vyos.vyos + lldp_interface: + redirect: vyos.vyos.vyos + vyos_lldp_interfaces: + redirect: vyos.vyos.vyos + lldp_interfaces: + redirect: vyos.vyos.vyos + vyos_logging: + redirect: vyos.vyos.vyos + logging: + redirect: vyos.vyos.vyos + vyos_ospfv2: + redirect: vyos.vyos.vyos + ospfv2: + redirect: vyos.vyos.vyos + vyos_ospfv3: + redirect: vyos.vyos.vyos + ospfv3: + redirect: vyos.vyos.vyos + vyos_ospf_interfaces: + redirect: vyos.vyos.vyos + ospf_interfaces: + redirect: vyos.vyos.vyos + vyos_ping: + redirect: vyos.vyos.vyos + ping: + redirect: vyos.vyos.vyos + vyos_static_route: + redirect: vyos.vyos.vyos + static_route: + redirect: vyos.vyos.vyos + vyos_static_routes: + redirect: vyos.vyos.vyos + static_routes: + redirect: vyos.vyos.vyos + vyos_system: + redirect: vyos.vyos.vyos + system: + redirect: vyos.vyos.vyos + vyos_user: + redirect: vyos.vyos.vyos + user: + redirect: vyos.vyos.vyos + vyos_vlan: + redirect: vyos.vyos.vyos + vlan: + redirect: vyos.vyos.vyos + modules: + banner: + redirect: vyos.vyos.vyos_banner + command: + redirect: vyos.vyos.vyos_command + config: + redirect: vyos.vyos.vyos_config + facts: + redirect: vyos.vyos.vyos_facts + firewall_global: + redirect: vyos.vyos.vyos_firewall_global + firewall_interfaces: + redirect: vyos.vyos.vyos_firewall_interfaces + firewall_rules: + redirect: vyos.vyos.vyos_firewall_rules + interface: + redirect: vyos.vyos.vyos_interface + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + vyos_interface: + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + interfaces: + redirect: vyos.vyos.vyos_interfaces + l3_interface: + redirect: vyos.vyos.vyos_l3_interface + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + vyos_l3_interface: + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + l3_interfaces: + redirect: vyos.vyos.vyos_l3_interfaces + lag_interfaces: + redirect: vyos.vyos.vyos_lag_interfaces + linkagg: + redirect: vyos.vyos.vyos_linkagg + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + vyos_linkagg: + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + lldp: + redirect: vyos.vyos.vyos_lldp + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + vyos_lldp: + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + lldp_global: + redirect: vyos.vyos.vyos_lldp_global + lldp_interface: + redirect: vyos.vyos.vyos_lldp_interface + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + vyos_lldp_interface: + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + lldp_interfaces: + redirect: vyos.vyos.vyos_lldp_interfaces + logging: + redirect: vyos.vyos.vyos_logging + ospfv2: + redirect: vyos.vyos.vyos_ospfv2 + ospfv3: + redirect: vyos.vyos.vyos_ospfv3 + ospf_interfaces: + redirect: vyos.vyos.vyos_ospf_interfaces + ping: + redirect: vyos.vyos.vyos_ping + static_route: + redirect: vyos.vyos.vyos_static_route + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + vyos_static_route: + deprecation: + removal_date: '2022-06-01' + warning_text: See the plugin documentation for more details + static_routes: + redirect: vyos.vyos.vyos_static_routes + system: + redirect: vyos.vyos.vyos_system + user: + redirect: vyos.vyos.vyos_user + vlan: + redirect: vyos.vyos.vyos_vlan diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/action/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/action/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/action/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/action/vyos.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/action/vyos.py new file mode 100644 index 00000000..61f377b2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/action/vyos.py @@ -0,0 +1,132 @@ +# +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import sys +import copy + +from ansible_collections.ansible.netcommon.plugins.action.network import ( + ActionModule as ActionNetworkModule, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + load_provider, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_provider_spec, +) +from ansible.utils.display import Display + +display = Display() + + +class ActionModule(ActionNetworkModule): + def run(self, tmp=None, task_vars=None): + del tmp # tmp no longer has any effect + + module_name = self._task.action.split(".")[-1] + self._config_module = ( + True if module_name in ["vyos_config", "config"] else False + ) + persistent_connection = self._play_context.connection.split(".")[-1] + warnings = [] + + if persistent_connection == "network_cli": + provider = self._task.args.get("provider", {}) + if any(provider.values()): + display.warning( + "provider is unnecessary when using network_cli and will be ignored" + ) + del self._task.args["provider"] + elif self._play_context.connection == "local": + provider = load_provider(vyos_provider_spec, self._task.args) + pc = copy.deepcopy(self._play_context) + pc.connection = "ansible.netcommon.network_cli" + pc.network_os = "vyos.vyos.vyos" + pc.remote_addr = provider["host"] or self._play_context.remote_addr + pc.port = int(provider["port"] or self._play_context.port or 22) + pc.remote_user = ( + provider["username"] or self._play_context.connection_user + ) + pc.password = provider["password"] or self._play_context.password + pc.private_key_file = ( + provider["ssh_keyfile"] or self._play_context.private_key_file + ) + + connection = self._shared_loader_obj.connection_loader.get( + "ansible.netcommon.persistent", + pc, + sys.stdin, + task_uuid=self._task._uuid, + ) + + # TODO: Remove below code after ansible minimal is cut out + if connection is None: + pc.connection = "network_cli" + pc.network_os = "vyos" + connection = self._shared_loader_obj.connection_loader.get( + "persistent", pc, sys.stdin, task_uuid=self._task._uuid + ) + + display.vvv( + "using connection plugin %s (was local)" % pc.connection, + pc.remote_addr, + ) + + command_timeout = ( + int(provider["timeout"]) + if provider["timeout"] + else connection.get_option("persistent_command_timeout") + ) + connection.set_options( + direct={"persistent_command_timeout": command_timeout} + ) + + pc.timeout = command_timeout + socket_path = connection.run() + display.vvvv("socket_path: %s" % socket_path, pc.remote_addr) + if not socket_path: + return { + "failed": True, + "msg": "unable to open shell. Please see: " + + "https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell", + } + + task_vars["ansible_socket"] = socket_path + warnings.append( + [ + "connection local support for this module is deprecated and will be removed in version 2.14, use connection %s" + % pc.connection + ] + ) + else: + return { + "failed": True, + "msg": "Connection type %s is not valid for this module" + % self._play_context.connection, + } + + result = super(ActionModule, self).run(task_vars=task_vars) + if warnings: + if "warnings" in result: + result["warnings"].extend(warnings) + else: + result["warnings"] = warnings + return result diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/cliconf/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/cliconf/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/cliconf/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py new file mode 100644 index 00000000..de9e93d6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py @@ -0,0 +1,341 @@ +# +# (c) 2017 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +author: Ansible Networking Team +cliconf: vyos +short_description: Use vyos cliconf to run command on VyOS platform +description: +- This vyos plugin provides low level abstraction apis for sending and receiving CLI + commands from VyOS network devices. +version_added: 1.0.0 +""" + +import re +import json + +from ansible.errors import AnsibleConnectionFailure +from ansible.module_utils._text import to_text +from ansible.module_utils.common._collections_compat import Mapping +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( + NetworkConfig, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, +) +from ansible.plugins.cliconf import CliconfBase + + +class Cliconf(CliconfBase): + def get_device_info(self): + device_info = {} + + device_info["network_os"] = "vyos" + reply = self.get("show version") + data = to_text(reply, errors="surrogate_or_strict").strip() + + match = re.search(r"Version:\s*(.*)", data) + if match: + device_info["network_os_version"] = match.group(1) + + match = re.search(r"HW model:\s*(\S+)", data) + if match: + device_info["network_os_model"] = match.group(1) + + reply = self.get("show host name") + device_info["network_os_hostname"] = to_text( + reply, errors="surrogate_or_strict" + ).strip() + + return device_info + + def get_config(self, flags=None, format=None): + if format: + option_values = self.get_option_values() + if format not in option_values["format"]: + raise ValueError( + "'format' value %s is invalid. Valid values of format are %s" + % (format, ", ".join(option_values["format"])) + ) + + if not flags: + flags = [] + + if format == "text": + command = "show configuration" + else: + command = "show configuration commands" + + command += " ".join(to_list(flags)) + command = command.strip() + + out = self.send_command(command) + return out + + def edit_config( + self, candidate=None, commit=True, replace=None, comment=None + ): + resp = {} + operations = self.get_device_operations() + self.check_edit_config_capability( + operations, candidate, commit, replace, comment + ) + + results = [] + requests = [] + self.send_command("configure") + for cmd in to_list(candidate): + if not isinstance(cmd, Mapping): + cmd = {"command": cmd} + + results.append(self.send_command(**cmd)) + requests.append(cmd["command"]) + out = self.get("compare") + out = to_text(out, errors="surrogate_or_strict") + diff_config = out if not out.startswith("No changes") else None + + if diff_config: + if commit: + try: + self.commit(comment) + except AnsibleConnectionFailure as e: + msg = "commit failed: %s" % e.message + self.discard_changes() + raise AnsibleConnectionFailure(msg) + else: + self.send_command("exit") + else: + self.discard_changes() + else: + self.send_command("exit") + if ( + to_text( + self._connection.get_prompt(), errors="surrogate_or_strict" + ) + .strip() + .endswith("#") + ): + self.discard_changes() + + if diff_config: + resp["diff"] = diff_config + resp["response"] = results + resp["request"] = requests + return resp + + def get( + self, + command=None, + prompt=None, + answer=None, + sendonly=False, + output=None, + newline=True, + check_all=False, + ): + if not command: + raise ValueError("must provide value of command to execute") + if output: + raise ValueError( + "'output' value %s is not supported for get" % output + ) + + return self.send_command( + command=command, + prompt=prompt, + answer=answer, + sendonly=sendonly, + newline=newline, + check_all=check_all, + ) + + def commit(self, comment=None): + if comment: + command = 'commit comment "{0}"'.format(comment) + else: + command = "commit" + self.send_command(command) + + def discard_changes(self): + self.send_command("exit discard") + + def get_diff( + self, + candidate=None, + running=None, + diff_match="line", + diff_ignore_lines=None, + path=None, + diff_replace=None, + ): + diff = {} + device_operations = self.get_device_operations() + option_values = self.get_option_values() + + if candidate is None and device_operations["supports_generate_diff"]: + raise ValueError( + "candidate configuration is required to generate diff" + ) + + if diff_match not in option_values["diff_match"]: + raise ValueError( + "'match' value %s in invalid, valid values are %s" + % (diff_match, ", ".join(option_values["diff_match"])) + ) + + if diff_replace: + raise ValueError("'replace' in diff is not supported") + + if diff_ignore_lines: + raise ValueError("'diff_ignore_lines' in diff is not supported") + + if path: + raise ValueError("'path' in diff is not supported") + + set_format = candidate.startswith("set") or candidate.startswith( + "delete" + ) + candidate_obj = NetworkConfig(indent=4, contents=candidate) + if not set_format: + config = [c.line for c in candidate_obj.items] + commands = list() + # this filters out less specific lines + for item in config: + for index, entry in enumerate(commands): + if item.startswith(entry): + del commands[index] + break + commands.append(item) + + candidate_commands = [ + "set %s" % cmd.replace(" {", "") for cmd in commands + ] + + else: + candidate_commands = str(candidate).strip().split("\n") + + if diff_match == "none": + diff["config_diff"] = list(candidate_commands) + return diff + + running_commands = [ + str(c).replace("'", "") for c in running.splitlines() + ] + + updates = list() + visited = set() + + for line in candidate_commands: + item = str(line).replace("'", "") + + if not item.startswith("set") and not item.startswith("delete"): + raise ValueError( + "line must start with either `set` or `delete`" + ) + + elif item.startswith("set") and item not in running_commands: + updates.append(line) + + elif item.startswith("delete"): + if not running_commands: + updates.append(line) + else: + item = re.sub(r"delete", "set", item) + for entry in running_commands: + if entry.startswith(item) and line not in visited: + updates.append(line) + visited.add(line) + + diff["config_diff"] = list(updates) + return diff + + def run_commands(self, commands=None, check_rc=True): + if commands is None: + raise ValueError("'commands' value is required") + + responses = list() + for cmd in to_list(commands): + if not isinstance(cmd, Mapping): + cmd = {"command": cmd} + + output = cmd.pop("output", None) + if output: + raise ValueError( + "'output' value %s is not supported for run_commands" + % output + ) + + try: + out = self.send_command(**cmd) + except AnsibleConnectionFailure as e: + if check_rc: + raise + out = getattr(e, "err", e) + + responses.append(out) + + return responses + + def get_device_operations(self): + return { + "supports_diff_replace": False, + "supports_commit": True, + "supports_rollback": False, + "supports_defaults": False, + "supports_onbox_diff": True, + "supports_commit_comment": True, + "supports_multiline_delimiter": False, + "supports_diff_match": True, + "supports_diff_ignore_lines": False, + "supports_generate_diff": False, + "supports_replace": False, + } + + def get_option_values(self): + return { + "format": ["text", "set"], + "diff_match": ["line", "none"], + "diff_replace": [], + "output": [], + } + + def get_capabilities(self): + result = super(Cliconf, self).get_capabilities() + result["rpc"] += [ + "commit", + "discard_changes", + "get_diff", + "run_commands", + ] + result["device_operations"] = self.get_device_operations() + result.update(self.get_option_values()) + return json.dumps(result) + + def set_cli_prompt_context(self): + """ + Make sure we are in the operational cli mode + :return: None + """ + if self._connection.connected: + self._update_cli_prompt_context( + config_context="#", exit_command="exit discard" + ) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/doc_fragments/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/doc_fragments/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/doc_fragments/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py new file mode 100644 index 00000000..ca406737 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# Copyright: (c) 2015, Peter Sprygada <psprygada@ansible.com> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + + +class ModuleDocFragment(object): + + # Standard files documentation fragment + DOCUMENTATION = r"""options: + provider: + description: + - B(Deprecated) + - 'Starting with Ansible 2.5 we recommend using C(connection: network_cli).' + - For more information please see the L(Network Guide, ../network/getting_started/network_differences.html#multiple-communication-protocols). + - HORIZONTALLINE + - A dict object containing connection details. + type: dict + suboptions: + host: + description: + - Specifies the DNS host name or address for connecting to the remote device + over the specified transport. The value of host is used as the destination + address for the transport. + type: str + port: + description: + - Specifies the port to use when building the connection to the remote device. + type: int + username: + description: + - Configures the username to use to authenticate the connection to the remote + device. This value is used to authenticate the SSH session. If the value + is not specified in the task, the value of environment variable C(ANSIBLE_NET_USERNAME) + will be used instead. + type: str + password: + description: + - Specifies the password to use to authenticate the connection to the remote + device. This value is used to authenticate the SSH session. If the value + is not specified in the task, the value of environment variable C(ANSIBLE_NET_PASSWORD) + will be used instead. + type: str + timeout: + description: + - Specifies the timeout in seconds for communicating with the network device + for either connecting or sending commands. If the timeout is exceeded before + the operation is completed, the module will error. + type: int + ssh_keyfile: + description: + - Specifies the SSH key to use to authenticate the connection to the remote + device. This value is the path to the key used to authenticate the SSH + session. If the value is not specified in the task, the value of environment + variable C(ANSIBLE_NET_SSH_KEYFILE) will be used instead. + type: path +notes: +- For more information on using Ansible to manage network devices see the :ref:`Ansible + Network Guide <network_guide>` +""" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/filter/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/filter/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/filter/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/inventory/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/inventory/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/inventory/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py new file mode 100644 index 00000000..d78dd3ab --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py @@ -0,0 +1,23 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The arg spec for the vyos facts module. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class FactsArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos facts module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "gather_subset": dict( + default=["!config"], type="list", elements="str" + ), + "gather_network_resources": dict(type="list", elements="str"), + } diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_global/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_global/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_global/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py new file mode 100644 index 00000000..92a02559 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py @@ -0,0 +1,151 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_firewall_global module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Firewall_globalArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_firewall_global module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "options": { + "config_trap": {"type": "bool"}, + "group": { + "options": { + "address_group": { + "elements": "dict", + "options": { + "description": {"type": "str"}, + "members": { + "elements": "dict", + "options": {"address": {"type": "str"}}, + "type": "list", + }, + "name": {"required": True, "type": "str"}, + }, + "type": "list", + }, + "network_group": { + "elements": "dict", + "options": { + "description": {"type": "str"}, + "members": { + "elements": "dict", + "options": {"address": {"type": "str"}}, + "type": "list", + }, + "name": {"required": True, "type": "str"}, + }, + "type": "list", + }, + "port_group": { + "elements": "dict", + "options": { + "description": {"type": "str"}, + "members": { + "elements": "dict", + "options": {"port": {"type": "str"}}, + "type": "list", + }, + "name": {"required": True, "type": "str"}, + }, + "type": "list", + }, + }, + "type": "dict", + }, + "log_martians": {"type": "bool"}, + "ping": { + "options": { + "all": {"type": "bool"}, + "broadcast": {"type": "bool"}, + }, + "type": "dict", + }, + "route_redirects": { + "elements": "dict", + "options": { + "afi": { + "choices": ["ipv4", "ipv6"], + "required": True, + "type": "str", + }, + "icmp_redirects": { + "options": { + "receive": {"type": "bool"}, + "send": {"type": "bool"}, + }, + "type": "dict", + }, + "ip_src_route": {"type": "bool"}, + }, + "type": "list", + }, + "state_policy": { + "elements": "dict", + "options": { + "action": { + "choices": ["accept", "drop", "reject"], + "type": "str", + }, + "connection_type": { + "choices": ["established", "invalid", "related"], + "type": "str", + }, + "log": {"type": "bool"}, + }, + "type": "list", + }, + "syn_cookies": {"type": "bool"}, + "twa_hazards_protection": {"type": "bool"}, + "validation": { + "choices": ["strict", "loose", "disable"], + "type": "str", + }, + }, + "type": "dict", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "deleted", + "gathered", + "rendered", + "parsed", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py new file mode 100644 index 00000000..16e66155 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py @@ -0,0 +1,84 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_firewall_interfaces module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Firewall_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_firewall_interfaces module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "access_rules": { + "elements": "dict", + "options": { + "afi": { + "choices": ["ipv4", "ipv6"], + "required": True, + "type": "str", + }, + "rules": { + "elements": "dict", + "options": { + "direction": { + "choices": ["in", "local", "out"], + "required": True, + "type": "str", + }, + "name": {"type": "str"}, + }, + "type": "list", + }, + }, + "type": "list", + }, + "name": {"required": True, "type": "str"}, + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "parsed", + "rendered", + "gathered", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py new file mode 100644 index 00000000..2df77589 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py @@ -0,0 +1,262 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_firewall_rules module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Firewall_rulesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_firewall_rules module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "afi": { + "choices": ["ipv4", "ipv6"], + "required": True, + "type": "str", + }, + "rule_sets": { + "elements": "dict", + "options": { + "default_action": { + "choices": ["drop", "reject", "accept"], + "type": "str", + }, + "description": {"type": "str"}, + "enable_default_log": {"type": "bool"}, + "name": {"type": "str"}, + "rules": { + "elements": "dict", + "options": { + "action": { + "choices": [ + "drop", + "reject", + "accept", + "inspect", + ], + "type": "str", + }, + "description": {"type": "str"}, + "destination": { + "options": { + "address": {"type": "str"}, + "group": { + "options": { + "address_group": { + "type": "str" + }, + "network_group": { + "type": "str" + }, + "port_group": {"type": "str"}, + }, + "type": "dict", + }, + "port": {"type": "str"}, + }, + "type": "dict", + }, + "disabled": {"type": "bool"}, + "fragment": { + "choices": [ + "match-frag", + "match-non-frag", + ], + "type": "str", + }, + "icmp": { + "options": { + "code": {"type": "int"}, + "type": {"type": "int"}, + "type_name": { + "choices": [ + "any", + "echo-reply", + "destination-unreachable", + "network-unreachable", + "host-unreachable", + "protocol-unreachable", + "port-unreachable", + "fragmentation-needed", + "source-route-failed", + "network-unknown", + "host-unknown", + "network-prohibited", + "host-prohibited", + "TOS-network-unreachable", + "TOS-host-unreachable", + "communication-prohibited", + "host-precedence-violation", + "precedence-cutoff", + "source-quench", + "redirect", + "network-redirect", + "host-redirect", + "TOS-network-redirect", + "TOS-host-redirect", + "echo-request", + "router-advertisement", + "router-solicitation", + "time-exceeded", + "ttl-zero-during-transit", + "ttl-zero-during-reassembly", + "parameter-problem", + "ip-header-bad", + "required-option-missing", + "timestamp-request", + "timestamp-reply", + "address-mask-request", + "address-mask-reply", + "ping", + "pong", + "ttl-exceeded", + ], + "type": "str", + }, + }, + "type": "dict", + }, + "ipsec": { + "choices": ["match-ipsec", "match-none"], + "type": "str", + }, + "limit": { + "options": { + "burst": {"type": "int"}, + "rate": { + "options": { + "number": {"type": "int"}, + "unit": {"type": "str"}, + }, + "type": "dict", + }, + }, + "type": "dict", + }, + "number": {"required": True, "type": "int"}, + "p2p": { + "elements": "dict", + "options": { + "application": { + "choices": [ + "all", + "applejuice", + "bittorrent", + "directconnect", + "edonkey", + "gnutella", + "kazaa", + ], + "type": "str", + } + }, + "type": "list", + }, + "protocol": {"type": "str"}, + "recent": { + "options": { + "count": {"type": "int"}, + "time": {"type": "int"}, + }, + "type": "dict", + }, + "source": { + "options": { + "address": {"type": "str"}, + "group": { + "options": { + "address_group": { + "type": "str" + }, + "network_group": { + "type": "str" + }, + "port_group": {"type": "str"}, + }, + "type": "dict", + }, + "mac_address": {"type": "str"}, + "port": {"type": "str"}, + }, + "type": "dict", + }, + "state": { + "options": { + "established": {"type": "bool"}, + "invalid": {"type": "bool"}, + "new": {"type": "bool"}, + "related": {"type": "bool"}, + }, + "type": "dict", + }, + "tcp": { + "options": {"flags": {"type": "str"}}, + "type": "dict", + }, + "time": { + "options": { + "monthdays": {"type": "str"}, + "startdate": {"type": "str"}, + "starttime": {"type": "str"}, + "stopdate": {"type": "str"}, + "stoptime": {"type": "str"}, + "utc": {"type": "bool"}, + "weekdays": {"type": "str"}, + }, + "type": "dict", + }, + }, + "type": "list", + }, + }, + "type": "list", + }, + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "gathered", + "rendered", + "parsed", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py new file mode 100644 index 00000000..9ae4c65f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py @@ -0,0 +1,77 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_interfaces module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class InterfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_interfaces module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "description": {"type": "str"}, + "duplex": {"choices": ["full", "half", "auto"]}, + "enabled": {"default": True, "type": "bool"}, + "mtu": {"type": "int"}, + "name": {"required": True, "type": "str"}, + "speed": { + "choices": ["auto", "10", "100", "1000", "2500", "10000"], + "type": "str", + }, + "vifs": { + "elements": "dict", + "options": { + "vlan_id": {"type": "int"}, + "description": {"type": "str"}, + "enabled": {"default": True, "type": "bool"}, + "mtu": {"type": "int"}, + }, + "type": "list", + }, + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "rendered", + "parsed", + "gathered", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py new file mode 100644 index 00000000..d6d9e298 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py @@ -0,0 +1,88 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_l3_interfaces module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class L3_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_l3_interfaces module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "ipv4": { + "elements": "dict", + "options": {"address": {"type": "str"}}, + "type": "list", + }, + "ipv6": { + "elements": "dict", + "options": {"address": {"type": "str"}}, + "type": "list", + }, + "name": {"required": True, "type": "str"}, + "vifs": { + "elements": "dict", + "options": { + "ipv4": { + "elements": "dict", + "options": {"address": {"type": "str"}}, + "type": "list", + }, + "ipv6": { + "elements": "dict", + "options": {"address": {"type": "str"}}, + "type": "list", + }, + "vlan_id": {"type": "int"}, + }, + "type": "list", + }, + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "rendered", + "gathered", + "parsed", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py new file mode 100644 index 00000000..14ac7957 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py @@ -0,0 +1,87 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_lag_interfaces module +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Lag_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_lag_interfaces module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "arp_monitor": { + "options": { + "interval": {"type": "int"}, + "target": {"type": "list", "elements": "str"}, + }, + "type": "dict", + }, + "hash_policy": { + "choices": ["layer2", "layer2+3", "layer3+4"], + "type": "str", + }, + "members": { + "elements": "dict", + "options": {"member": {"type": "str"}}, + "type": "list", + }, + "mode": { + "choices": [ + "802.3ad", + "active-backup", + "broadcast", + "round-robin", + "transmit-load-balance", + "adaptive-load-balance", + "xor-hash", + ], + "type": "str", + }, + "name": {"required": True, "type": "str"}, + "primary": {"type": "str"}, + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "rendered", + "gathered", + "parsed", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py new file mode 100644 index 00000000..635322b9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py @@ -0,0 +1,63 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_lldp_global module +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Lldp_globalArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_lldp_global module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "options": { + "address": {"type": "str"}, + "enable": {"type": "bool"}, + "legacy_protocols": { + "choices": ["cdp", "edp", "fdp", "sonmp"], + "type": "list", + "elements": "str", + }, + "snmp": {"type": "str"}, + }, + "type": "dict", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "deleted", + "rendered", + "parsed", + "gathered", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py new file mode 100644 index 00000000..b641aebc --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py @@ -0,0 +1,97 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_lldp_interfaces module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Lldp_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_lldp_interfaces module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "enable": {"default": True, "type": "bool"}, + "location": { + "options": { + "civic_based": { + "options": { + "ca_info": { + "elements": "dict", + "options": { + "ca_type": {"type": "int"}, + "ca_value": {"type": "str"}, + }, + "type": "list", + }, + "country_code": { + "required": True, + "type": "str", + }, + }, + "type": "dict", + }, + "coordinate_based": { + "options": { + "altitude": {"type": "int"}, + "datum": { + "choices": ["WGS84", "NAD83", "MLLW"], + "type": "str", + }, + "latitude": {"required": True, "type": "str"}, + "longitude": {"required": True, "type": "str"}, + }, + "type": "dict", + }, + "elin": {"type": "str"}, + }, + "type": "dict", + }, + "name": {"required": True, "type": "str"}, + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "rendered", + "gathered", + "parsed", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospf_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospf_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospf_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py new file mode 100644 index 00000000..e7dd10c7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The arg spec for the vyos_ospf_interfaces module +""" + + +class Ospf_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_ospf_interfaces module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "running_config": {}, + "state": { + "default": "merged", + "type": "str", + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "gathered", + "parsed", + "rendered", + ], + }, + "config": { + "elements": "dict", + "type": "list", + "options": { + "name": {"type": "str"}, + "address_family": { + "elements": "dict", + "type": "list", + "options": { + "passive": {"type": "bool"}, + "retransmit_interval": {"type": "int"}, + "cost": {"type": "int"}, + "afi": { + "required": True, + "type": "str", + "choices": ["ipv4", "ipv6"], + }, + "authentication": { + "type": "dict", + "options": { + "plaintext_password": {"type": "str"}, + "md5_key": { + "type": "dict", + "options": { + "key_id": {"type": "int"}, + "key": {"type": "str"}, + }, + }, + }, + }, + "mtu_ignore": {"type": "bool"}, + "priority": {"type": "int"}, + "instance": {"type": "str"}, + "bandwidth": {"type": "int"}, + "dead_interval": {"type": "int"}, + "ifmtu": {"type": "int"}, + "hello_interval": {"type": "int"}, + "transmit_delay": {"type": "int"}, + "network": {"type": "str"}, + }, + }, + }, + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv2/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv2/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv2/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py new file mode 100644 index 00000000..b8e915c7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py @@ -0,0 +1,275 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_ospfv2 module +""" + + +class Ospfv2Args(object): # pylint: disable=R0903 + """The arg spec for the vyos_ospfv2 module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "options": { + "auto_cost": { + "options": {"reference_bandwidth": {"type": "int"}}, + "type": "dict", + }, + "default_information": { + "options": { + "originate": { + "options": { + "always": {"type": "bool"}, + "metric": {"type": "int"}, + "metric_type": {"type": "int"}, + "route_map": {"type": "str"}, + }, + "type": "dict", + } + }, + "type": "dict", + }, + "default_metric": {"type": "int"}, + "distance": { + "options": { + "global": {"type": "int"}, + "ospf": { + "options": { + "external": {"type": "int"}, + "inter_area": {"type": "int"}, + "intra_area": {"type": "int"}, + }, + "type": "dict", + }, + }, + "type": "dict", + }, + "log_adjacency_changes": { + "choices": ["detail"], + "type": "str", + }, + "max_metric": { + "options": { + "router_lsa": { + "options": { + "administrative": {"type": "bool"}, + "on_shutdown": {"type": "int"}, + "on_startup": {"type": "int"}, + }, + "type": "dict", + } + }, + "type": "dict", + }, + "mpls_te": { + "options": { + "enabled": {"type": "bool"}, + "router_address": {"type": "str"}, + }, + "type": "dict", + }, + "neighbor": { + "elements": "dict", + "options": { + "neighbor_id": {"type": "str"}, + "poll_interval": {"type": "int"}, + "priority": {"type": "int"}, + }, + "type": "list", + }, + "areas": { + "elements": "dict", + "options": { + "area_id": {"type": "str"}, + "area_type": { + "options": { + "normal": {"type": "bool"}, + "nssa": { + "options": { + "default_cost": {"type": "int"}, + "no_summary": {"type": "bool"}, + "set": {"type": "bool"}, + "translate": { + "choices": [ + "always", + "candidate", + "never", + ], + "type": "str", + }, + }, + "type": "dict", + }, + "stub": { + "options": { + "default_cost": {"type": "int"}, + "no_summary": {"type": "bool"}, + "set": {"type": "bool"}, + }, + "type": "dict", + }, + }, + "type": "dict", + }, + "authentication": { + "choices": ["plaintext-password", "md5"], + "type": "str", + }, + "network": { + "elements": "dict", + "options": { + "address": {"required": True, "type": "str"} + }, + "type": "list", + }, + "range": { + "elements": "dict", + "options": { + "address": {"type": "str"}, + "cost": {"type": "int"}, + "not_advertise": {"type": "bool"}, + "substitute": {"type": "str"}, + }, + "type": "list", + }, + "shortcut": { + "choices": ["default", "disable", "enable"], + "type": "str", + }, + "virtual_link": { + "elements": "dict", + "options": { + "address": {"type": "str"}, + "authentication": { + "options": { + "md5": { + "elements": "dict", + "options": { + "key_id": {"type": "int"}, + "md5_key": {"type": "str"}, + }, + "type": "list", + }, + "plaintext_password": {"type": "str"}, + }, + "type": "dict", + }, + "dead_interval": {"type": "int"}, + "hello_interval": {"type": "int"}, + "retransmit_interval": {"type": "int"}, + "transmit_delay": {"type": "int"}, + }, + "type": "list", + }, + }, + "type": "list", + }, + "parameters": { + "options": { + "abr_type": { + "choices": [ + "cisco", + "ibm", + "shortcut", + "standard", + ], + "type": "str", + }, + "opaque_lsa": {"type": "bool"}, + "rfc1583_compatibility": {"type": "bool"}, + "router_id": {"type": "str"}, + }, + "type": "dict", + }, + "passive_interface": {"type": "list", "elements": "str"}, + "passive_interface_exclude": { + "type": "list", + "elements": "str", + }, + "redistribute": { + "elements": "dict", + "options": { + "metric": {"type": "int"}, + "metric_type": {"type": "int"}, + "route_map": {"type": "str"}, + "route_type": { + "choices": [ + "bgp", + "connected", + "kernel", + "rip", + "static", + ], + "type": "str", + }, + }, + "type": "list", + }, + "route_map": {"type": "list", "elements": "str"}, + "timers": { + "options": { + "refresh": { + "options": {"timers": {"type": "int"}}, + "type": "dict", + }, + "throttle": { + "options": { + "spf": { + "options": { + "delay": {"type": "int"}, + "initial_holdtime": {"type": "int"}, + "max_holdtime": {"type": "int"}, + }, + "type": "dict", + } + }, + "type": "dict", + }, + }, + "type": "dict", + }, + }, + "type": "dict", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "deleted", + "parsed", + "gathered", + "rendered", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv3/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv3/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv3/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py new file mode 100644 index 00000000..7fac36c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py @@ -0,0 +1,97 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_ospfv3 module +""" + + +class Ospfv3Args(object): # pylint: disable=R0903 + """The arg spec for the vyos_ospfv3 module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "options": { + "areas": { + "elements": "dict", + "options": { + "area_id": {"type": "str"}, + "export_list": {"type": "str"}, + "import_list": {"type": "str"}, + "range": { + "elements": "dict", + "options": { + "address": {"type": "str"}, + "advertise": {"type": "bool"}, + "not_advertise": {"type": "bool"}, + }, + "type": "list", + }, + }, + "type": "list", + }, + "parameters": { + "options": {"router_id": {"type": "str"}}, + "type": "dict", + }, + "redistribute": { + "elements": "dict", + "options": { + "route_map": {"type": "str"}, + "route_type": { + "choices": [ + "bgp", + "connected", + "kernel", + "ripng", + "static", + ], + "type": "str", + }, + }, + "type": "list", + }, + }, + "type": "dict", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "deleted", + "parsed", + "gathered", + "rendered", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py new file mode 100644 index 00000000..f8602e33 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py @@ -0,0 +1,98 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# +""" +The arg spec for the vyos_static_routes module +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Static_routesArgs(object): # pylint: disable=R0903 + """The arg spec for the vyos_static_routes module""" + + def __init__(self, **kwargs): + pass + + argument_spec = { + "config": { + "elements": "dict", + "options": { + "address_families": { + "elements": "dict", + "options": { + "afi": { + "choices": ["ipv4", "ipv6"], + "required": True, + "type": "str", + }, + "routes": { + "elements": "dict", + "options": { + "blackhole_config": { + "options": { + "distance": {"type": "int"}, + "type": {"type": "str"}, + }, + "type": "dict", + }, + "dest": {"required": True, "type": "str"}, + "next_hops": { + "elements": "dict", + "options": { + "admin_distance": {"type": "int"}, + "enabled": {"type": "bool"}, + "forward_router_address": { + "required": True, + "type": "str", + }, + "interface": {"type": "str"}, + }, + "type": "list", + }, + }, + "type": "list", + }, + }, + "type": "list", + } + }, + "type": "list", + }, + "running_config": {"type": "str"}, + "state": { + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "gathered", + "rendered", + "parsed", + ], + "default": "merged", + "type": "str", + }, + } # pylint: disable=C0301 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_global/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_global/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_global/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py new file mode 100644 index 00000000..08b724ab --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py @@ -0,0 +1,810 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_firewall_global class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + remove_empties, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + list_diff_want_only, +) + + +class Firewall_global(ConfigBase): + """ + The vyos_firewall_global class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "firewall_global", + ] + + def __init__(self, module): + super(Firewall_global, self).__init__(module) + + def get_firewall_global_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + firewall_global_facts = facts["ansible_network_resources"].get( + "firewall_global" + ) + if not firewall_global_facts: + return [] + return firewall_global_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_firewall_global_facts = self.get_firewall_global_facts() + else: + existing_firewall_global_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_firewall_global_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_firewall_global_facts = self.get_firewall_global_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_firewall_global_facts( + data=running_config + ) + else: + changed_firewall_global_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_firewall_global_facts + if result["changed"]: + result["after"] = changed_firewall_global_facts + elif self.state == "gathered": + result["gathered"] = changed_firewall_global_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_firewall_global_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_firewall_global_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, w, h): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if self.state in ("merged", "replaced", "rendered") and not w: + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "deleted": + commands.extend(self._state_deleted(want=None, have=h)) + elif w: + if self.state == "merged" or self.state == "rendered": + commands.extend(self._state_merged(w, h)) + elif self.state == "replaced": + commands.extend(self._state_replaced(w, h)) + return commands + + def _state_replaced(self, w, h): + """The command generator when state is replaced + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if h: + commands.extend(self._state_deleted(h, w)) + commands.extend(self._state_merged(w, h)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + commands.extend(self._add_global_attr(want, have)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + b_set = ( + "config_trap", + "validation", + "log_martians", + "syn_cookies", + "twa_hazards_protection", + ) + if want: + for key, val in iteritems(want): + if val and key in b_set and not have: + commands.append(self._form_attr_cmd(attr=key, opr=False)) + elif ( + val + and key in b_set + and have + and key in have + and have[key] != val + ): + commands.append(self._form_attr_cmd(attr=key, opr=False)) + else: + commands.extend(self._render_attr_config(want, have, key)) + elif not want and have: + commands.append(self._compute_command(opr=False)) + elif have: + for key, val in iteritems(have): + if val and key in b_set: + commands.append(self._form_attr_cmd(attr=key, opr=False)) + else: + commands.extend(self._render_attr_config(want, have, key)) + return commands + + def _render_attr_config(self, w, h, key, opr=False): + """ + This function invoke the function to extend commands + based on the key. + :param w: the desired configuration. + :param h: the current configuration. + :param key: attribute name + :param opr: operation + :return: list of commands + """ + commands = [] + if key == "ping": + commands.extend(self._render_ping(key, w, h, opr=opr)) + elif key == "group": + commands.extend(self._render_group(key, w, h, opr=opr)) + elif key == "state_policy": + commands.extend(self._render_state_policy(key, w, h, opr=opr)) + elif key == "route_redirects": + commands.extend(self._render_route_redirects(key, w, h, opr=opr)) + return commands + + def _add_global_attr(self, w, h, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for firewall_global attributes. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + w_fg = deepcopy(remove_empties(w)) + l_set = ( + "config_trap", + "validation", + "log_martians", + "syn_cookies", + "twa_hazards_protection", + ) + if w_fg: + for key, val in iteritems(w_fg): + if ( + opr + and key in l_set + and not (h and self._is_w_same(w_fg, h, key)) + ): + commands.append( + self._form_attr_cmd( + attr=key, val=self._bool_to_str(val), opr=opr + ) + ) + elif not opr: + if key and self._is_del(l_set, h): + commands.append( + self._form_attr_cmd( + attr=key, key=self._bool_to_str(val), opr=opr + ) + ) + continue + if ( + key in l_set + and not (h and self._in_target(h, key)) + and not self._is_del(l_set, h) + ): + commands.append( + self._form_attr_cmd( + attr=key, val=self._bool_to_str(val), opr=opr + ) + ) + else: + commands.extend( + self._render_attr_config(w_fg, h, key, opr) + ) + return commands + + def _render_ping(self, attr, w, h, opr): + """ + This function forms the commands for 'ping' attributes based on the 'opr'. + :param attr: attribute name. + :param w: the desired configuration. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + h_ping = {} + l_set = ("all", "broadcast") + if h: + h_ping = h.get(attr) or {} + if self._is_root_del(w[attr], h_ping, attr): + for item, value in iteritems(h[attr]): + if not opr and item in l_set: + commands.append(self._form_attr_cmd(attr=item, opr=opr)) + elif w[attr]: + if h and attr in h.keys(): + h_ping = h.get(attr) or {} + for item, value in iteritems(w[attr]): + if ( + opr + and item in l_set + and not (h_ping and self._is_w_same(w[attr], h_ping, item)) + ): + commands.append( + self._form_attr_cmd( + attr=item, val=self._bool_to_str(value), opr=opr + ) + ) + elif ( + not opr + and item in l_set + and not (h_ping and self._is_w_same(w[attr], h_ping, item)) + ): + commands.append(self._form_attr_cmd(attr=item, opr=opr)) + return commands + + def _render_group(self, attr, w, h, opr): + """ + This function forms the commands for 'group' attribute based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + h_grp = {} + if not opr and self._is_root_del(h, w, attr): + commands.append(self._form_attr_cmd(attr=attr, opr=opr)) + else: + if h: + h_grp = h.get("group") or {} + if w: + commands.extend( + self._render_grp_mem("port-group", w["group"], h_grp, opr) + ) + commands.extend( + self._render_grp_mem( + "address_group", w["group"], h_grp, opr + ) + ) + commands.extend( + self._render_grp_mem( + "network_group", w["group"], h_grp, opr + ) + ) + return commands + + def _render_grp_mem(self, attr, w, h, opr): + """ + This function forms the commands for group list/members attributes based on the 'opr'. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + h_grp = [] + w_grp = [] + l_set = ("name", "description") + if w: + w_grp = w.get(attr) or [] + if h: + h_grp = h.get(attr) or [] + + if w_grp: + for want in w_grp: + cmd = self._compute_command(key="group", attr=attr, opr=opr) + h = self.search_attrib_in_have(h_grp, want, "name") + for key, val in iteritems(want): + if val: + if ( + opr + and key in l_set + and not (h and self._is_w_same(want, h, key)) + ): + if key == "name": + commands.append(cmd + " " + str(val)) + else: + commands.append( + cmd + + " " + + want["name"] + + " " + + key + + " '" + + str(want[key]) + + "'" + ) + elif not opr and key in l_set: + if key == "name" and self._is_grp_del( + h, want, key + ): + commands.append(cmd + " " + want["name"]) + continue + if not ( + h and self._in_target(h, key) + ) and not self._is_grp_del(h, want, key): + commands.append( + cmd + " " + want["name"] + " " + key + ) + elif key == "members": + commands.extend( + self._render_ports_addrs( + key, want, h, opr, cmd, want["name"], attr + ) + ) + return commands + + def _render_ports_addrs(self, attr, w, h, opr, cmd, name, type): + """ + This function forms the commands for port/address/network group members + based on the 'opr'. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param name: name of group. + :param type: group type. + :return: generated list of commands. + """ + commands = [] + have = [] + if w: + want = w.get(attr) or [] + if h: + have = h.get(attr) or [] + + if want: + if opr: + members = list_diff_want_only(want, have) + for member in members: + commands.append( + cmd + + " " + + name + + " " + + self._grp_type(type) + + " " + + member[self._get_mem_type(type)] + ) + elif not opr and have: + members = list_diff_want_only(want, have) + for member in members: + commands.append( + cmd + + " " + + name + + " " + + self._grp_type(type) + + " " + + member[self._get_mem_type(type)] + ) + return commands + + def _get_mem_type(self, group): + """ + This function returns the member type + based on the type of group. + """ + return "port" if group == "port_group" else "address" + + def _render_state_policy(self, attr, w, h, opr): + """ + This function forms the commands for 'state-policy' attributes + based on the 'opr'. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + have = [] + l_set = ("log", "action", "connection_type") + if not opr and self._is_root_del(h, w, attr): + commands.append(self._form_attr_cmd(attr=attr, opr=opr)) + else: + w_sp = deepcopy(remove_empties(w)) + want = w_sp.get(attr) or [] + if h: + have = h.get(attr) or [] + if want: + for w in want: + h = self.search_attrib_in_have(have, w, "connection_type") + for key, val in iteritems(w): + if val and key != "connection_type": + if ( + opr + and key in l_set + and not (h and self._is_w_same(w, h, key)) + ): + commands.append( + self._form_attr_cmd( + key=attr + " " + w["connection_type"], + attr=key, + val=self._bool_to_str(val), + opr=opr, + ) + ) + elif not opr and key in l_set: + if not ( + h and self._in_target(h, key) + ) and not self._is_del(l_set, h): + if key == "action": + commands.append( + self._form_attr_cmd( + attr=attr + + " " + + w["connection_type"], + opr=opr, + ) + ) + else: + commands.append( + self._form_attr_cmd( + attr=attr + + " " + + w["connection_type"], + val=self._bool_to_str(val), + opr=opr, + ) + ) + return commands + + def _render_route_redirects(self, attr, w, h, opr): + """ + This function forms the commands for 'route_redirects' attributes based on the 'opr'. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + have = [] + l_set = ("afi", "ip_src_route") + + if w: + want = w.get(attr) or [] + if h: + have = h.get(attr) or [] + + if want: + for w in want: + h = self.search_attrib_in_have(have, w, "afi") + for key, val in iteritems(w): + if val and key != "afi": + if ( + opr + and key in l_set + and not (h and self._is_w_same(w, h, key)) + ): + commands.append( + self._form_attr_cmd( + attr=key, + val=self._bool_to_str(val), + opr=opr, + ) + ) + elif not opr and key in l_set: + if self._is_del(l_set, h): + commands.append( + self._form_attr_cmd( + attr=key, + val=self._bool_to_str(val), + opr=opr, + ) + ) + continue + if not ( + h and self._in_target(h, key) + ) and not self._is_del(l_set, h): + commands.append( + self._form_attr_cmd( + attr=key, + val=self._bool_to_str(val), + opr=opr, + ) + ) + elif key == "icmp_redirects": + commands.extend( + self._render_icmp_redirects(key, w, h, opr) + ) + return commands + + def _render_icmp_redirects(self, attr, w, h, opr): + """ + This function forms the commands for 'icmp_redirects' attributes + based on the 'opr'. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + h_red = {} + l_set = ("send", "receive") + if w[attr]: + if h and attr in h.keys(): + h_red = h.get(attr) or {} + for item, value in iteritems(w[attr]): + if ( + opr + and item in l_set + and not (h_red and self._is_w_same(w[attr], h_red, item)) + ): + commands.append( + self._form_attr_cmd( + attr=item, val=self._bool_to_str(value), opr=opr + ) + ) + elif ( + not opr + and item in l_set + and not (h_red and self._is_w_same(w[attr], h_red, item)) + ): + commands.append(self._form_attr_cmd(attr=item, opr=opr)) + return commands + + def search_attrib_in_have(self, have, want, attr): + """ + This function returns the attribute if it is present in target config. + :param have: the target config. + :param want: the desired config. + :param attr: attribute name . + :return: attribute/None + """ + if have: + for h in have: + if h[attr] == want[attr]: + return h + return None + + def _form_attr_cmd(self, key=None, attr=None, val=None, opr=True): + """ + This function forms the command for leaf attribute. + :param key: parent key. + :param attr: attribute name + :param value: value + :param opr: True/False. + :return: generated command. + """ + command = self._compute_command( + key=key, attr=self._map_attrib(attr), val=val, opr=opr + ) + return command + + def _compute_command( + self, key=None, attr=None, val=None, remove=False, opr=True + ): + """ + This function construct the add/delete command based on passed attributes. + :param key: parent key. + :param attr: attribute name + :param value: value + :param remove: True/False. + :param opr: True/False. + :return: generated command. + """ + if remove or not opr: + cmd = "delete firewall " + else: + cmd = "set firewall " + if key: + cmd += key.replace("_", "-") + " " + if attr: + cmd += attr.replace("_", "-") + if val and opr: + cmd += " '" + str(val) + "'" + return cmd + + def _bool_to_str(self, val): + """ + This function converts the bool value into string. + :param val: bool value. + :return: enable/disable. + """ + return ( + "enable" + if str(val) == "True" + else "disable" + if str(val) == "False" + else val + ) + + def _grp_type(self, val): + """ + This function returns the group member type based on value argument. + :param val: value. + :return: member type. + """ + return ( + "address" + if val == "address_group" + else "network" + if val == "network_group" + else "port" + ) + + def _is_w_same(self, w, h, key): + """ + This function checks whether the key value is same in desired and + target config dictionary. + :param w: base config. + :param h: target config. + :param key:attribute name. + :return: True/False. + """ + return True if h and key in h and h[key] == w[key] else False + + def _in_target(self, h, key): + """ + This function checks whether the target exist and key present in target config. + :param h: target config. + :param key: attribute name. + :return: True/False. + """ + return True if h and key in h else False + + def _is_grp_del(self, w, h, key): + """ + This function checks whether group needed to be deleted based on + desired and target configs. + :param w: the desired config. + :param h: the target config. + :param key: group name. + :return: True/False. + """ + return ( + True + if h and key in h and (not w or key not in w or not w[key]) + else False + ) + + def _is_root_del(self, w, h, key): + """ + This function checks whether a root attribute which can have + further child attributes needed to be deleted. + :param w: the desired config. + :param h: the target config. + :param key: attribute name. + :return: True/False. + """ + return ( + True + if h and key in h and (not w or key not in w or not w[key]) + else False + ) + + def _is_del(self, b_set, h, key="number"): + """ + This function checks whether attribute needs to be deleted + when operation is false and attribute present in present target config. + :param b_set: attribute set. + :param h: target config. + :param key: number. + :return: True/False. + """ + return key in b_set and not (h and self._in_target(h, key)) + + def _map_attrib(self, attrib, type=None): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + regex = attrib.replace("_", "-") + if attrib == "send": + if type == "ipv6": + regex = "ipv6-send-redirects" + else: + regex = "send-redirects" + elif attrib == "ip_src_route": + if type == "ipv6": + regex = "ipv6-src-route" + elif attrib == "receive": + if type == "ipv6": + regex = "ipv6-receive-redirects" + else: + regex = "receive-redirects" + elif attrib == "disabled": + regex = "disable" + elif attrib == "all": + regex = "all-ping" + elif attrib == "broadcast": + regex = "broadcast-ping" + elif attrib == "validation": + regex = "source-validation" + return regex diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py new file mode 100644 index 00000000..45842f1c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py @@ -0,0 +1,454 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_firewall_interfaces class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + remove_empties, + search_obj_in_list, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) + + +class Firewall_interfaces(ConfigBase): + """ + The vyos_firewall_interfaces class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "firewall_interfaces", + ] + + def __init__(self, module): + super(Firewall_interfaces, self).__init__(module) + + def get_firewall_interfaces_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + firewall_interfaces_facts = facts["ansible_network_resources"].get( + "firewall_interfaces" + ) + if not firewall_interfaces_facts: + return [] + return firewall_interfaces_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_firewall_interfaces_facts = ( + self.get_firewall_interfaces_facts() + ) + else: + existing_firewall_interfaces_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend( + self.set_config(existing_firewall_interfaces_facts) + ) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_firewall_interfaces_facts = ( + self.get_firewall_interfaces_facts() + ) + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_firewall_interfaces_facts( + data=running_config + ) + else: + changed_firewall_interfaces_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_firewall_interfaces_facts + if result["changed"]: + result["after"] = changed_firewall_interfaces_facts + elif self.state == "gathered": + result["gathered"] = changed_firewall_interfaces_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_firewall_interfaces_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_firewall_interfaces_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, w, h): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not w + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "overridden": + commands.extend(self._state_overridden(w, h)) + elif self.state == "deleted": + commands.extend(self._state_deleted(w, h)) + elif w: + if self.state == "merged" or self.state == "rendered": + commands.extend(self._state_merged(w, h)) + elif self.state == "replaced": + commands.extend(self._state_replaced(w, h)) + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + for h in have: + w = search_obj_in_list(h["name"], want) + commands.extend(self._render_access_rules(h, w, opr=False)) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + for h_ar in have: + w_ar = search_obj_in_list(h_ar["name"], want) + if not w_ar and "access_rules" in h_ar: + commands.append( + self._compute_command(name=h_ar["name"], opr=False) + ) + else: + h_rules = h_ar.get("access_rules") or [] + key = "direction" + if w_ar: + w_rules = w_ar.get("access_rules") or [] + if not w_rules and h_rules: + commands.append( + self._compute_command( + name=h_ar["name"], opr=False + ) + ) + if h_rules: + for h_rule in h_rules: + w_rule = search_obj_in_list( + h_rule["afi"], w_rules, key="afi" + ) + have_rules = h_rule.get("rules") or [] + if w_rule: + want_rules = w_rule.get("rules") or [] + for h in have_rules: + if key in h: + w = search_obj_in_list( + h[key], want_rules, key=key + ) + if ( + not w + or key not in w + or ( + "name" in h + and w + and "name" not in w + ) + ): + commands.append( + self._compute_command( + afi=h_rule["afi"], + name=h_ar["name"], + attrib=h[key], + opr=False, + ) + ) + + commands.extend(self._state_merged(want, have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + for w in want: + h = search_obj_in_list(w["name"], have) + commands.extend(self._render_access_rules(w, h)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + + if want: + for w in want: + h = search_obj_in_list(w["name"], have) + if h and "access_rules" in h: + commands.extend(self._delete_access_rules(w, h, opr=False)) + elif have: + for h in have: + if "access_rules" in h: + commands.append( + self._compute_command(name=h["name"], opr=False) + ) + return commands + + def _delete_access_rules(self, want, have, opr=False): + """ + This function forms the delete commands based on the 'opr' type + for 'access_rules' attributes. + :param want: desired config. + :param have: target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + h_rules = {} + w_rs = deepcopy(remove_empties(want)) + w_rules = w_rs.get("access_rules") or [] + if have: + h_rs = deepcopy(remove_empties(have)) + h_rules = h_rs.get("access_rules") or [] + + # if all firewall config needed to be deleted for specific interface + # when operation is delete. + if not w_rules and h_rules: + commands.append(self._compute_command(name=want["name"], opr=opr)) + if w_rules: + for w in w_rules: + h = search_obj_in_list(w["afi"], h_rules, key="afi") + commands.extend(self._delete_rules(want["name"], w, h)) + return commands + + def _delete_rules(self, name, want, have, opr=False): + """ + This function forms the delete commands based on the 'opr' type + for rules attributes. + :param name: interface id/name. + :param want: desired config. + :param have: target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + h_rules = [] + key = "direction" + w_rules = want.get("rules") or [] + if have: + h_rules = have.get("rules") or [] + # when rule set needed to be removed on + # (inbound|outbound|local interface) + if h_rules and not w_rules: + for h in h_rules: + if key in h: + commands.append( + self._compute_command( + afi=want["afi"], name=name, attrib=h[key], opr=opr + ) + ) + for w in w_rules: + h = search_obj_in_list(w[key], h_rules, key=key) + if ( + key in w + and h + and key in h + and "name" in w + and "name" in h + and w["name"] == h["name"] + ): + commands.append( + self._compute_command( + afi=want["afi"], + name=name, + attrib=w[key], + value=w["name"], + opr=opr, + ) + ) + return commands + + def _render_access_rules(self, want, have, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for 'access_rules' attributes. + :param want: desired config. + :param have: target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + h_rules = {} + w_rs = deepcopy(remove_empties(want)) + w_rules = w_rs.get("access_rules") or [] + if have: + h_rs = deepcopy(remove_empties(have)) + h_rules = h_rs.get("access_rules") or [] + if w_rules: + for w in w_rules: + h = search_obj_in_list(w["afi"], h_rules, key="afi") + commands.extend(self._render_rules(want["name"], w, h, opr)) + return commands + + def _render_rules(self, name, want, have, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for rules attributes. + :param name: interface id/name. + :param want: desired config. + :param have: target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + h_rules = [] + key = "direction" + w_rules = want.get("rules") or [] + if have: + h_rules = have.get("rules") or [] + for w in w_rules: + h = search_obj_in_list(w[key], h_rules, key=key) + if key in w: + if opr: + if "name" in w and not ( + h and h[key] == w[key] and h["name"] == w["name"] + ): + commands.append( + self._compute_command( + afi=want["afi"], + name=name, + attrib=w[key], + value=w["name"], + ) + ) + elif not (h and key in h): + commands.append( + self._compute_command( + afi=want["afi"], name=name, attrib=w[key] + ) + ) + elif not opr: + if ( + not h + or key not in h + or ("name" in w and h and "name" not in h) + ): + commands.append( + self._compute_command( + afi=want["afi"], + name=name, + attrib=w[key], + opr=opr, + ) + ) + return commands + + def _compute_command( + self, afi=None, name=None, attrib=None, value=None, opr=True + ): + """ + This function construct the add/delete command based on passed attributes. + :param afi: address type. + :param name: interface name. + :param attrib: attribute name. + :param value: attribute value. + :param opr: operation flag. + :return: generated command. + """ + if not opr: + cmd = "delete interfaces ethernet" + " " + name + " firewall" + else: + cmd = "set interfaces ethernet" + " " + name + " firewall" + if attrib: + cmd += " " + attrib + if afi: + cmd += " " + self._get_fw_type(afi) + if value: + cmd += " '" + str(value) + "'" + return cmd + + def _get_fw_type(self, afi): + """ + This function returns the firewall rule-set type based on IP address. + :param afi: address type + :return: rule-set type. + """ + return "ipv6-name" if afi == "ipv6" else "name" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_rules/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_rules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_rules/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py new file mode 100644 index 00000000..ffc642f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py @@ -0,0 +1,1017 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_firewall_rules class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + remove_empties, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + list_diff_want_only, +) + + +class Firewall_rules(ConfigBase): + """ + The vyos_firewall_rules class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "firewall_rules", + ] + + def __init__(self, module): + super(Firewall_rules, self).__init__(module) + + def get_firewall_rules_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + firewall_rules_facts = facts["ansible_network_resources"].get( + "firewall_rules" + ) + if not firewall_rules_facts: + return [] + return firewall_rules_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_firewall_rules_facts = self.get_firewall_rules_facts() + else: + existing_firewall_rules_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_firewall_rules_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_firewall_rules_facts = self.get_firewall_rules_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_firewall_rules_facts( + data=running_config + ) + else: + changed_firewall_rules_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_firewall_rules_facts + if result["changed"]: + result["after"] = changed_firewall_rules_facts + elif self.state == "gathered": + result["gathered"] = changed_firewall_rules_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_firewall_rules_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_firewall_rules_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, w, h): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not w + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "overridden": + commands.extend(self._state_overridden(w, h)) + elif self.state == "deleted": + commands.extend(self._state_deleted(w, h)) + elif w: + if self.state == "merged" or self.state == "rendered": + commands.extend(self._state_merged(w, h)) + elif self.state == "replaced": + commands.extend(self._state_replaced(w, h)) + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + for h in have: + r_sets = self._get_r_sets(h) + for rs in r_sets: + w = self.search_r_sets_in_have(want, rs["name"], "r_list") + commands.extend( + self._add_r_sets(h["afi"], rs, w, opr=False) + ) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + for h in have: + r_sets = self._get_r_sets(h) + for rs in r_sets: + w = self.search_r_sets_in_have(want, rs["name"], "r_list") + if not w: + commands.append( + self._compute_command( + h["afi"], rs["name"], remove=True + ) + ) + else: + commands.extend( + self._add_r_sets(h["afi"], rs, w, opr=False) + ) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + for w in want: + r_sets = self._get_r_sets(w) + for rs in r_sets: + h = self.search_r_sets_in_have(have, rs["name"], "r_list") + commands.extend(self._add_r_sets(w["afi"], rs, h)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + if want: + for w in want: + r_sets = self._get_r_sets(w) + if r_sets: + for rs in r_sets: + h = self.search_r_sets_in_have( + have, rs["name"], "r_list" + ) + if h: + commands.append( + self._compute_command( + w["afi"], h["name"], remove=True + ) + ) + elif have: + for h in have: + if h["afi"] == w["afi"]: + commands.append( + self._compute_command(w["afi"], remove=True) + ) + elif have: + for h in have: + r_sets = self._get_r_sets(h) + if r_sets: + commands.append( + self._compute_command(afi=h["afi"], remove=True) + ) + return commands + + def _add_r_sets(self, afi, want, have, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for rule-sets attributes. + :param afi: address type. + :param want: desired config. + :param have: target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + l_set = ("description", "default_action", "enable_default_log") + h_rs = {} + h_rules = {} + w_rs = deepcopy(remove_empties(want)) + w_rules = w_rs.pop("rules", None) + if have: + h_rs = deepcopy(remove_empties(have)) + h_rules = h_rs.pop("rules", None) + if w_rs: + for key, val in iteritems(w_rs): + if ( + opr + and key in l_set + and not (h_rs and self._is_w_same(w_rs, h_rs, key)) + ): + if key == "enable_default_log": + if val and ( + not h_rs or key not in h_rs or not h_rs[key] + ): + commands.append( + self._add_rs_base_attrib( + afi, want["name"], key, w_rs + ) + ) + else: + commands.append( + self._add_rs_base_attrib( + afi, want["name"], key, w_rs + ) + ) + elif not opr and key in l_set: + if ( + key == "enable_default_log" + and val + and h_rs + and (key not in h_rs or not h_rs[key]) + ): + commands.append( + self._add_rs_base_attrib( + afi, want["name"], key, w_rs, opr + ) + ) + elif not (h_rs and self._in_target(h_rs, key)): + commands.append( + self._add_rs_base_attrib( + afi, want["name"], key, w_rs, opr + ) + ) + commands.extend( + self._add_rules(afi, want["name"], w_rules, h_rules, opr) + ) + if h_rules: + have["rules"] = h_rules + if w_rules: + want["rules"] = w_rules + return commands + + def _add_rules(self, afi, name, w_rules, h_rules, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for rules attributes. + :param want: desired config. + :param have: target config. + :return: generated commands list. + """ + commands = [] + l_set = ( + "ipsec", + "action", + "number", + "protocol", + "fragment", + "disabled", + "description", + ) + if w_rules: + for w in w_rules: + cmd = self._compute_command(afi, name, w["number"], opr=opr) + h = self.search_r_sets_in_have( + h_rules, w["number"], type="rules" + ) + for key, val in iteritems(w): + if val: + if ( + opr + and key in l_set + and not (h and self._is_w_same(w, h, key)) + ): + if key == "disabled": + if not ( + not val + and (not h or key not in h or not h[key]) + ): + commands.append( + self._add_r_base_attrib( + afi, name, key, w + ) + ) + else: + commands.append( + self._add_r_base_attrib(afi, name, key, w) + ) + elif not opr: + if key == "number" and self._is_del(l_set, h): + commands.append( + self._add_r_base_attrib( + afi, name, key, w, opr=opr + ) + ) + continue + if ( + key == "disabled" + and val + and h + and (key not in h or not h[key]) + ): + commands.append( + self._add_r_base_attrib( + afi, name, key, w, opr=opr + ) + ) + elif ( + key in l_set + and not (h and self._in_target(h, key)) + and not self._is_del(l_set, h) + ): + commands.append( + self._add_r_base_attrib( + afi, name, key, w, opr=opr + ) + ) + elif key == "p2p": + commands.extend(self._add_p2p(key, w, h, cmd, opr)) + elif key == "tcp": + commands.extend(self._add_tcp(key, w, h, cmd, opr)) + elif key == "time": + commands.extend( + self._add_time(key, w, h, cmd, opr) + ) + elif key == "icmp": + commands.extend( + self._add_icmp(key, w, h, cmd, opr) + ) + elif key == "state": + commands.extend( + self._add_state(key, w, h, cmd, opr) + ) + elif key == "limit": + commands.extend( + self._add_limit(key, w, h, cmd, opr) + ) + elif key == "recent": + commands.extend( + self._add_recent(key, w, h, cmd, opr) + ) + elif key == "destination" or key == "source": + commands.extend( + self._add_src_or_dest(key, w, h, cmd, opr) + ) + return commands + + def _add_p2p(self, attr, w, h, cmd, opr): + """ + This function forms the set/delete commands based on the 'opr' type + for p2p applications attributes. + :param want: desired config. + :param have: target config. + :return: generated commands list. + """ + commands = [] + have = [] + if w: + want = w.get(attr) or [] + if h: + have = h.get(attr) or [] + if want: + if opr: + applications = list_diff_want_only(want, have) + for app in applications: + commands.append( + cmd + (" " + attr + " " + app["application"]) + ) + elif not opr and have: + applications = list_diff_want_only(want, have) + for app in applications: + commands.append( + cmd + (" " + attr + " " + app["application"]) + ) + return commands + + def _add_state(self, attr, w, h, cmd, opr): + """ + This function forms the command for 'state' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + h_state = {} + commands = [] + l_set = ("new", "invalid", "related", "established") + if w[attr]: + if h and attr in h.keys(): + h_state = h.get(attr) or {} + for item, val in iteritems(w[attr]): + if ( + opr + and item in l_set + and not ( + h_state and self._is_w_same(w[attr], h_state, item) + ) + ): + commands.append( + cmd + + ( + " " + + attr + + " " + + item + + " " + + self._bool_to_str(val) + ) + ) + elif ( + not opr + and item in l_set + and not (h_state and self._in_target(h_state, item)) + ): + commands.append(cmd + (" " + attr + " " + item)) + return commands + + def _add_recent(self, attr, w, h, cmd, opr): + """ + This function forms the command for 'recent' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + commands = [] + h_recent = {} + l_set = ("count", "time") + if w[attr]: + if h and attr in h.keys(): + h_recent = h.get(attr) or {} + for item, val in iteritems(w[attr]): + if ( + opr + and item in l_set + and not ( + h_recent and self._is_w_same(w[attr], h_recent, item) + ) + ): + commands.append( + cmd + (" " + attr + " " + item + " " + str(val)) + ) + elif ( + not opr + and item in l_set + and not (h_recent and self._in_target(h_recent, item)) + ): + commands.append(cmd + (" " + attr + " " + item)) + return commands + + def _add_icmp(self, attr, w, h, cmd, opr): + """ + This function forms the commands for 'icmp' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + commands = [] + h_icmp = {} + l_set = ("code", "type", "type_name") + if w[attr]: + if h and attr in h.keys(): + h_icmp = h.get(attr) or {} + for item, val in iteritems(w[attr]): + if ( + opr + and item in l_set + and not (h_icmp and self._is_w_same(w[attr], h_icmp, item)) + ): + if item == "type_name": + if "ipv6-name" in cmd: + commands.append( + cmd + + (" " + "icmpv6" + " " + "type" + " " + val) + ) + else: + commands.append( + cmd + + ( + " " + + attr + + " " + + item.replace("_", "-") + + " " + + val + ) + ) + else: + commands.append( + cmd + (" " + attr + " " + item + " " + str(val)) + ) + elif ( + not opr + and item in l_set + and not (h_icmp and self._in_target(h_icmp, item)) + ): + commands.append(cmd + (" " + attr + " " + item)) + return commands + + def _add_time(self, attr, w, h, cmd, opr): + """ + This function forms the commands for 'time' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + commands = [] + h_time = {} + l_set = ( + "utc", + "stopdate", + "stoptime", + "weekdays", + "monthdays", + "startdate", + "starttime", + ) + if w[attr]: + if h and attr in h.keys(): + h_time = h.get(attr) or {} + for item, val in iteritems(w[attr]): + if ( + opr + and item in l_set + and not (h_time and self._is_w_same(w[attr], h_time, item)) + ): + if item == "utc": + if not ( + not val and (not h_time or item not in h_time) + ): + commands.append(cmd + (" " + attr + " " + item)) + else: + commands.append( + cmd + (" " + attr + " " + item + " " + val) + ) + elif ( + not opr + and item in l_set + and not (h_time and self._is_w_same(w[attr], h_time, item)) + ): + commands.append(cmd + (" " + attr + " " + item)) + return commands + + def _add_tcp(self, attr, w, h, cmd, opr): + """ + This function forms the commands for 'tcp' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + h_tcp = {} + commands = [] + if w[attr]: + key = "flags" + flags = w[attr].get(key) or {} + if flags: + if h and key in h[attr].keys(): + h_tcp = h[attr].get(key) or {} + if flags: + if opr and not ( + h_tcp and self._is_w_same(w[attr], h[attr], key) + ): + commands.append( + cmd + (" " + attr + " " + key + " " + flags) + ) + if not opr and not ( + h_tcp and self._is_w_same(w[attr], h[attr], key) + ): + commands.append( + cmd + (" " + attr + " " + key + " " + flags) + ) + return commands + + def _add_limit(self, attr, w, h, cmd, opr): + """ + This function forms the commands for 'limit' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + h_limit = {} + commands = [] + if w[attr]: + key = "burst" + if ( + opr + and key in w[attr].keys() + and not ( + h + and attr in h.keys() + and self._is_w_same(w[attr], h[attr], key) + ) + ): + commands.append( + cmd + + (" " + attr + " " + key + " " + str(w[attr].get(key))) + ) + elif ( + not opr + and key in w[attr].keys() + and not ( + h and attr in h.keys() and self._in_target(h[attr], key) + ) + ): + commands.append( + cmd + + (" " + attr + " " + key + " " + str(w[attr].get(key))) + ) + key = "rate" + rate = w[attr].get(key) or {} + if rate: + if h and key in h[attr].keys(): + h_limit = h[attr].get(key) or {} + if "unit" in rate and "number" in rate: + if opr and not ( + h_limit + and self._is_w_same(rate, h_limit, "unit") + and self.is_w_same(rate, h_limit, "number") + ): + commands.append( + cmd + + ( + " " + + attr + + " " + + key + + " " + + str(rate["number"]) + + "/" + + rate["unit"] + ) + ) + if not opr and not ( + h_limit + and self._is_w_same(rate, h_limit, "unit") + and self._is_w_same(rate, h_limit, "number") + ): + commands.append(cmd + (" " + attr + " " + key)) + return commands + + def _add_src_or_dest(self, attr, w, h, cmd, opr=True): + """ + This function forms the commands for 'src/dest' attributes based on the 'opr'. + :param attr: attribute name. + :param w: base config. + :param h: target config. + :param cmd: commands to be prepend. + :return: generated list of commands. + """ + commands = [] + h_group = {} + g_set = ("port_group", "address_group", "network_group") + if w[attr]: + keys = ("address", "mac_address", "port") + for key in keys: + if ( + opr + and key in w[attr].keys() + and not ( + h + and attr in h.keys() + and self._is_w_same(w[attr], h[attr], key) + ) + ): + commands.append( + cmd + + ( + " " + + attr + + " " + + key.replace("_", "-") + + " " + + w[attr].get(key) + ) + ) + elif ( + not opr + and key in w[attr].keys() + and not ( + h + and attr in h.keys() + and self._in_target(h[attr], key) + ) + ): + commands.append(cmd + (" " + attr + " " + key)) + + key = "group" + group = w[attr].get(key) or {} + if group: + if h and key in h[attr].keys(): + h_group = h[attr].get(key) or {} + for item, val in iteritems(group): + if val: + if ( + opr + and item in g_set + and not ( + h_group + and self._is_w_same(group, h_group, item) + ) + ): + commands.append( + cmd + + ( + " " + + attr + + " " + + key + + " " + + item.replace("_", "-") + + " " + + val + ) + ) + elif ( + not opr + and item in g_set + and not ( + h_group and self._in_target(h_group, item) + ) + ): + commands.append( + cmd + + ( + " " + + attr + + " " + + key + + " " + + item.replace("_", "-") + ) + ) + return commands + + def search_r_sets_in_have(self, have, w_name, type="rule_sets"): + """ + This function returns the rule-set/rule if it is present in target config. + :param have: target config. + :param w_name: rule-set name. + :param type: rule_sets/rule/r_list. + :return: rule-set/rule. + """ + if have: + key = "name" + if type == "rules": + key = "number" + for r in have: + if r[key] == w_name: + return r + elif type == "r_list": + for h in have: + r_sets = self._get_r_sets(h) + for rs in r_sets: + if rs[key] == w_name: + return rs + else: + for rs in have: + if rs[key] == w_name: + return rs + return None + + def _get_r_sets(self, item, type="rule_sets"): + """ + This function returns the list of rule-sets/rules. + :param item: config dictionary. + :param type: rule_sets/rule/r_list. + :return: list of rule-sets/rules. + """ + rs_list = [] + r_sets = item[type] + if r_sets: + for rs in r_sets: + rs_list.append(rs) + return rs_list + + def _compute_command( + self, + afi, + name=None, + number=None, + attrib=None, + value=None, + remove=False, + opr=True, + ): + """ + This function construct the add/delete command based on passed attributes. + :param afi: address type. + :param name: rule-set name. + :param number: rule-number. + :param attrib: attribute name. + :param value: value. + :param remove: True if delete command needed to be construct. + :param opr: opeeration flag. + :return: generated command. + """ + if remove or not opr: + cmd = "delete firewall " + self._get_fw_type(afi) + else: + cmd = "set firewall " + self._get_fw_type(afi) + if name: + cmd += " " + name + if number: + cmd += " rule " + str(number) + if attrib: + cmd += " " + attrib.replace("_", "-") + if ( + value + and opr + and attrib != "enable_default_log" + and attrib != "disabled" + ): + cmd += " '" + str(value) + "'" + return cmd + + def _add_r_base_attrib(self, afi, name, attr, rule, opr=True): + """ + This function forms the command for 'rules' attributes which doesn't + have further sub attributes. + :param afi: address type. + :param name: rule-set name + :param attrib: attribute name + :param rule: rule config dictionary. + :param opr: True/False. + :return: generated command. + """ + if attr == "number": + command = self._compute_command( + afi=afi, name=name, number=rule["number"], opr=opr + ) + else: + command = self._compute_command( + afi=afi, + name=name, + number=rule["number"], + attrib=attr, + value=rule[attr], + opr=opr, + ) + return command + + def _add_rs_base_attrib(self, afi, name, attrib, rule, opr=True): + """ + + This function forms the command for 'rule-sets' attributes which doesn't + have further sub attributes. + :param afi: address type. + :param name: rule-set name + :param attrib: attribute name + :param rule: rule config dictionary. + :param opr: True/False. + :return: generated command. + """ + command = self._compute_command( + afi=afi, name=name, attrib=attrib, value=rule[attrib], opr=opr + ) + return command + + def _bool_to_str(self, val): + """ + This function converts the bool value into string. + :param val: bool value. + :return: enable/disable. + """ + return "enable" if val else "disable" + + def _get_fw_type(self, afi): + """ + This function returns the firewall rule-set type based on IP address. + :param afi: address type + :return: rule-set type. + """ + return "ipv6-name" if afi == "ipv6" else "name" + + def _is_del(self, l_set, h, key="number"): + """ + This function checks whether rule needs to be deleted based on + the rule number. + :param l_set: attribute set. + :param h: target config. + :param key: number. + :return: True/False. + """ + return key in l_set and not (h and self._in_target(h, key)) + + def _is_w_same(self, w, h, key): + """ + This function checks whether the key value is same in base and + target config dictionary. + :param w: base config. + :param h: target config. + :param key:attribute name. + :return: True/False. + """ + return True if h and key in h and h[key] == w[key] else False + + def _in_target(self, h, key): + """ + This function checks whether the target nexist and key present in target config. + :param h: target config. + :param key: attribute name. + :return: True/False. + """ + return True if h and key in h else False + + def _is_base_attrib(self, key): + """ + This function checks whether key is present in predefined + based attribute set. + :param key: + :return: True/False. + """ + r_set = ( + "p2p", + "ipsec", + "action", + "fragment", + "protocol", + "disabled", + "description", + "mac_address", + "default_action", + "enable_default_log", + ) + return True if key in r_set else False diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/interfaces/interfaces.py new file mode 100644 index 00000000..484e6000 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/interfaces/interfaces.py @@ -0,0 +1,354 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_interfaces class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + dict_diff, + remove_empties, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + search_obj_in_list, + get_interface_type, + dict_delete, +) + + +class Interfaces(ConfigBase): + """ + The vyos_interfaces class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = ["interfaces"] + + def __init__(self, module): + super(Interfaces, self).__init__(module) + + def get_interfaces_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + interfaces_facts = facts["ansible_network_resources"].get("interfaces") + if not interfaces_facts: + return [] + return interfaces_facts + + def execute_module(self): + """Execute the module + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + commands = list() + warnings = list() + + if self.state in self.ACTION_STATES: + existing_interfaces_facts = self.get_interfaces_facts() + else: + existing_interfaces_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_interfaces_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_interfaces_facts = self.get_interfaces_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_interfaces_facts(data=running_config) + else: + changed_interfaces_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_interfaces_facts + if result["changed"]: + result["after"] = changed_interfaces_facts + elif self.state == "gathered": + result["gathered"] = changed_interfaces_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_interfaces_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_interfaces_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, want, have): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not want + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + + if self.state == "overridden": + commands.extend(self._state_overridden(want=want, have=have)) + + elif self.state == "deleted": + if not want: + for intf in have: + commands.extend( + self._state_deleted({"name": intf["name"]}, intf) + ) + else: + for item in want: + obj_in_have = search_obj_in_list(item["name"], have) + commands.extend(self._state_deleted(item, obj_in_have)) + else: + for item in want: + name = item["name"] + enable_state = item["enabled"] + obj_in_have = search_obj_in_list(name, have) + if not obj_in_have: + obj_in_have = {"name": name, "enabled": enable_state} + + if self.state in ("merged", "rendered"): + commands.extend(self._state_merged(item, obj_in_have)) + + elif self.state == "replaced": + commands.extend(self._state_replaced(item, obj_in_have)) + + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + commands.extend(self._state_deleted(want, have)) + + commands.extend(self._state_merged(want, have)) + + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + + for intf in have: + intf_in_want = search_obj_in_list(intf["name"], want) + if not intf_in_want: + commands.extend( + self._state_deleted({"name": intf["name"]}, intf) + ) + + for intf in want: + intf_in_have = search_obj_in_list(intf["name"], have) + if not intf_in_have: + intf_in_have = { + "name": intf["name"], + "enabled": intf["enabled"], + } + commands.extend(self._state_replaced(intf, intf_in_have)) + + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(have) + + want_vifs = want_copy.pop("vifs", []) + have_vifs = have_copy.pop("vifs", []) + + updates = dict_diff(have_copy, want_copy) + + if updates: + for key, value in iteritems(updates): + commands.append( + self._compute_commands( + key=key, value=value, interface=want_copy["name"] + ) + ) + + if want_vifs: + for want_vif in want_vifs: + have_vif = search_obj_in_list( + want_vif["vlan_id"], have_vifs, key="vlan_id" + ) + if not have_vif: + have_vif = { + "vlan_id": want_vif["vlan_id"], + "enabled": True, + } + + vif_updates = dict_diff(have_vif, want_vif) + if vif_updates: + for key, value in iteritems(vif_updates): + commands.append( + self._compute_commands( + key=key, + value=value, + interface=want_copy["name"], + vif=want_vif["vlan_id"], + ) + ) + + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(have) + want_vifs = want_copy.pop("vifs", []) + have_vifs = have_copy.pop("vifs", []) + + for key in dict_delete(have_copy, want_copy).keys(): + if key == "enabled": + continue + commands.append( + self._compute_commands( + key=key, interface=want_copy["name"], remove=True + ) + ) + if have_copy["enabled"] is False: + commands.append( + self._compute_commands( + key="enabled", value=True, interface=want_copy["name"] + ) + ) + + if have_vifs: + for have_vif in have_vifs: + want_vif = search_obj_in_list( + have_vif["vlan_id"], want_vifs, key="vlan_id" + ) + if not want_vif: + want_vif = { + "vlan_id": have_vif["vlan_id"], + "enabled": True, + } + + for key in dict_delete(have_vif, want_vif).keys(): + if key == "enabled": + continue + commands.append( + self._compute_commands( + key=key, + interface=want_copy["name"], + vif=want_vif["vlan_id"], + remove=True, + ) + ) + if have_vif["enabled"] is False: + commands.append( + self._compute_commands( + key="enabled", + value=True, + interface=want_copy["name"], + vif=want_vif["vlan_id"], + ) + ) + return commands + + def _compute_commands( + self, interface, key, vif=None, value=None, remove=False + ): + intf_context = "interfaces {0} {1}".format( + get_interface_type(interface), interface + ) + set_cmd = "set {0}".format(intf_context) + del_cmd = "delete {0}".format(intf_context) + + if vif: + set_cmd = set_cmd + (" vif {0}".format(vif)) + del_cmd = del_cmd + (" vif {0}".format(vif)) + + if key == "enabled": + if not value: + command = "{0} disable".format(set_cmd) + else: + command = "{0} disable".format(del_cmd) + else: + if not remove: + command = "{0} {1} '{2}'".format(set_cmd, key, value) + else: + command = "{0} {1}".format(del_cmd, key) + + return command diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/l3_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/l3_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/l3_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py new file mode 100644 index 00000000..6f143be7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py @@ -0,0 +1,344 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_l3_interfaces class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + remove_empties, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + search_obj_in_list, + get_interface_type, + diff_list_of_dicts, +) + + +class L3_interfaces(ConfigBase): + """ + The vyos_l3_interfaces class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "l3_interfaces", + ] + + def __init__(self, module): + super(L3_interfaces, self).__init__(module) + + def get_l3_interfaces_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + l3_interfaces_facts = facts["ansible_network_resources"].get( + "l3_interfaces" + ) + if not l3_interfaces_facts: + return [] + return l3_interfaces_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_l3_interfaces_facts = self.get_l3_interfaces_facts() + else: + existing_l3_interfaces_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_l3_interfaces_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_l3_interfaces_facts = self.get_l3_interfaces_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_l3_interfaces_facts( + data=running_config + ) + else: + changed_l3_interfaces_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_l3_interfaces_facts + if result["changed"]: + result["after"] = changed_l3_interfaces_facts + elif self.state == "gathered": + result["gathered"] = changed_l3_interfaces_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_l3_interfaces_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_l3_interfaces_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, want, have): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + state = self._module.params["state"] + + if ( + state in ("merged", "replaced", "overridden", "rendered") + and not want + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + state + ) + ) + + if state == "overridden": + commands.extend(self._state_overridden(want=want, have=have)) + + elif state == "deleted": + if not want: + for intf in have: + commands.extend( + self._state_deleted({"name": intf["name"]}, intf) + ) + else: + for item in want: + obj_in_have = search_obj_in_list(item["name"], have) + commands.extend(self._state_deleted(item, obj_in_have)) + else: + for item in want: + name = item["name"] + obj_in_have = search_obj_in_list(name, have) + + if not obj_in_have: + obj_in_have = {"name": item["name"]} + + if state in ("merged", "rendered"): + commands.extend(self._state_merged(item, obj_in_have)) + + elif state == "replaced": + commands.extend(self._state_replaced(item, obj_in_have)) + + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + commands.extend(self._state_deleted(want, have)) + + commands.extend(self._state_merged(want, have)) + + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + + for intf in have: + intf_in_want = search_obj_in_list(intf["name"], want) + if not intf_in_want: + commands.extend( + self._state_deleted({"name": intf["name"]}, intf) + ) + + for intf in want: + intf_in_have = search_obj_in_list(intf["name"], have) + commands.extend(self._state_replaced(intf, intf_in_have)) + + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(remove_empties(have)) + + want_vifs = want_copy.pop("vifs", []) + have_vifs = have_copy.pop("vifs", []) + + for update in self._get_updates(want_copy, have_copy): + for key, value in iteritems(update): + commands.append( + self._compute_commands( + key=key, value=value, interface=want_copy["name"] + ) + ) + + if want_vifs: + for want_vif in want_vifs: + have_vif = search_obj_in_list( + want_vif["vlan_id"], have_vifs, key="vlan_id" + ) + if not have_vif: + have_vif = {} + + for update in self._get_updates(want_vif, have_vif): + for key, value in iteritems(update): + commands.append( + self._compute_commands( + key=key, + value=value, + interface=want_copy["name"], + vif=want_vif["vlan_id"], + ) + ) + + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(have) + + want_vifs = want_copy.pop("vifs", []) + have_vifs = have_copy.pop("vifs", []) + + for update in self._get_updates(have_copy, want_copy): + for key, value in iteritems(update): + commands.append( + self._compute_commands( + key=key, + value=value, + interface=want_copy["name"], + remove=True, + ) + ) + + if have_vifs: + for have_vif in have_vifs: + want_vif = search_obj_in_list( + have_vif["vlan_id"], want_vifs, key="vlan_id" + ) + if not want_vif: + want_vif = {"vlan_id": have_vif["vlan_id"]} + + for update in self._get_updates(have_vif, want_vif): + for key, value in iteritems(update): + commands.append( + self._compute_commands( + key=key, + interface=want_copy["name"], + value=value, + vif=want_vif["vlan_id"], + remove=True, + ) + ) + + return commands + + def _compute_commands( + self, interface, key, vif=None, value=None, remove=False + ): + intf_context = "interfaces {0} {1}".format( + get_interface_type(interface), interface + ) + set_cmd = "set {0}".format(intf_context) + del_cmd = "delete {0}".format(intf_context) + + if vif: + set_cmd = set_cmd + (" vif {0}".format(vif)) + del_cmd = del_cmd + (" vif {0}".format(vif)) + + if remove: + command = "{0} {1} '{2}'".format(del_cmd, key, value) + else: + command = "{0} {1} '{2}'".format(set_cmd, key, value) + + return command + + def _get_updates(self, want, have): + updates = [] + + updates = diff_list_of_dicts( + want.get("ipv4", []), have.get("ipv4", []) + ) + updates.extend( + diff_list_of_dicts(want.get("ipv6", []), have.get("ipv6", [])) + ) + + return updates diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lag_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lag_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lag_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py new file mode 100644 index 00000000..7e7b39a6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py @@ -0,0 +1,468 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_lag_interfaces class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + dict_diff, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + search_obj_in_list, + get_lst_diff_for_dicts, + list_diff_want_only, + list_diff_have_only, +) + + +class Lag_interfaces(ConfigBase): + """ + The vyos_lag_interfaces class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "lag_interfaces", + ] + + params = [ + "arp_monitor", + "hash_policy", + "members", + "mode", + "name", + "primary", + ] + + def __init__(self, module): + super(Lag_interfaces, self).__init__(module) + + def get_lag_interfaces_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + lag_interfaces_facts = facts["ansible_network_resources"].get( + "lag_interfaces" + ) + if not lag_interfaces_facts: + return [] + return lag_interfaces_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_lag_interfaces_facts = self.get_lag_interfaces_facts() + else: + existing_lag_interfaces_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_lag_interfaces_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_lag_interfaces_facts = self.get_lag_interfaces_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_lag_interfaces_facts( + data=running_config + ) + else: + changed_lag_interfaces_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_lag_interfaces_facts + if result["changed"]: + result["after"] = changed_lag_interfaces_facts + elif self.state == "gathered": + result["gathered"] = changed_lag_interfaces_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_lag_interfaces_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_lag_interfaces_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, want, have): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not want + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "overridden": + commands.extend(self._state_overridden(want, have)) + elif self.state == "deleted": + if want: + for want_item in want: + name = want_item["name"] + obj_in_have = search_obj_in_list(name, have) + commands.extend(self._state_deleted(obj_in_have)) + else: + for have_item in have: + commands.extend(self._state_deleted(have_item)) + else: + for want_item in want: + name = want_item["name"] + obj_in_have = search_obj_in_list(name, have) + if self.state in ("merged", "rendered"): + commands.extend(self._state_merged(want_item, obj_in_have)) + elif self.state == "replaced": + commands.extend( + self._state_replaced(want_item, obj_in_have) + ) + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + commands.extend(self._render_del_commands(want, have)) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + for have_item in have: + lag_name = have_item["name"] + obj_in_want = search_obj_in_list(lag_name, want) + if not obj_in_want: + commands.extend(self._purge_attribs(have_item)) + + for want_item in want: + name = want_item["name"] + obj_in_have = search_obj_in_list(name, have) + commands.extend(self._state_replaced(want_item, obj_in_have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + if have: + commands.extend(self._render_updates(want, have)) + else: + commands.extend(self._render_set_commands(want)) + return commands + + def _state_deleted(self, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + if have: + commands.extend(self._purge_attribs(have)) + return commands + + def _render_updates(self, want, have): + commands = [] + + temp_have_members = have.pop("members", None) + temp_want_members = want.pop("members", None) + + updates = dict_diff(have, want) + + if temp_have_members: + have["members"] = temp_have_members + if temp_want_members: + want["members"] = temp_want_members + + commands.extend(self._add_bond_members(want, have)) + + if updates: + for key, value in iteritems(updates): + if value: + if key == "arp_monitor": + commands.extend( + self._add_arp_monitor(updates, key, want, have) + ) + else: + commands.append( + self._compute_command( + have["name"], key, str(value) + ) + ) + return commands + + def _render_set_commands(self, want): + commands = [] + have = [] + + params = Lag_interfaces.params + + for attrib in params: + value = want[attrib] + if value: + if attrib == "arp_monitor": + commands.extend( + self._add_arp_monitor(want, attrib, want, have) + ) + elif attrib == "members": + commands.extend(self._add_bond_members(want, have)) + elif attrib != "name": + commands.append( + self._compute_command( + want["name"], attrib, value=str(value) + ) + ) + return commands + + def _purge_attribs(self, have): + commands = [] + for item in Lag_interfaces.params: + if have.get(item): + if item == "members": + commands.extend(self._delete_bond_members(have)) + elif item != "name": + commands.append( + self._compute_command( + have["name"], attrib=item, remove=True + ) + ) + return commands + + def _render_del_commands(self, want, have): + commands = [] + + params = Lag_interfaces.params + for attrib in params: + if attrib == "members": + commands.extend(self._update_bond_members(attrib, want, have)) + elif attrib == "arp_monitor": + commands.extend(self._update_arp_monitor(attrib, want, have)) + elif have.get(attrib) and not want.get(attrib): + commands.append( + self._compute_command(have["name"], attrib, remove=True) + ) + return commands + + def _add_bond_members(self, want, have): + commands = [] + diff_members = get_lst_diff_for_dicts(want, have, "members") + if diff_members: + for key in diff_members: + commands.append( + self._compute_command( + key["member"], + "bond-group", + want["name"], + type="ethernet", + ) + ) + return commands + + def _add_arp_monitor(self, updates, key, want, have): + commands = [] + arp_monitor = updates.get(key) or {} + diff_targets = self._get_arp_monitor_target_diff( + want, have, key, "target" + ) + + if "interval" in arp_monitor: + commands.append( + self._compute_command( + key=want["name"] + " arp-monitor", + attrib="interval", + value=str(arp_monitor["interval"]), + ) + ) + if diff_targets: + for target in diff_targets: + commands.append( + self._compute_command( + key=want["name"] + " arp-monitor", + attrib="target", + value=target, + ) + ) + return commands + + def _delete_bond_members(self, have): + commands = [] + for member in have["members"]: + commands.append( + self._compute_command( + member["member"], + "bond-group", + have["name"], + remove=True, + type="ethernet", + ) + ) + return commands + + def _update_arp_monitor(self, key, want, have): + commands = [] + want_arp_target = [] + have_arp_target = [] + want_arp_monitor = want.get(key) or {} + have_arp_monitor = have.get(key) or {} + + if want_arp_monitor and "target" in want_arp_monitor: + want_arp_target = want_arp_monitor["target"] + + if have_arp_monitor and "target" in have_arp_monitor: + have_arp_target = have_arp_monitor["target"] + + if "interval" in have_arp_monitor and not want_arp_monitor: + commands.append( + self._compute_command( + key=have["name"] + " arp-monitor", + attrib="interval", + remove=True, + ) + ) + if "target" in have_arp_monitor: + target_diff = list_diff_have_only(want_arp_target, have_arp_target) + if target_diff: + for target in target_diff: + commands.append( + self._compute_command( + key=have["name"] + " arp-monitor", + attrib="target", + value=target, + remove=True, + ) + ) + + return commands + + def _update_bond_members(self, key, want, have): + commands = [] + want_members = want.get(key) or [] + have_members = have.get(key) or [] + + members_diff = list_diff_have_only(want_members, have_members) + if members_diff: + for member in members_diff: + commands.append( + self._compute_command( + member["member"], + "bond-group", + have["name"], + True, + "ethernet", + ) + ) + return commands + + def _get_arp_monitor_target_diff( + self, want_list, have_list, dict_name, lst + ): + want_arp_target = [] + have_arp_target = [] + + want_arp_monitor = want_list.get(dict_name) or {} + if want_arp_monitor and lst in want_arp_monitor: + want_arp_target = want_arp_monitor[lst] + + if not have_list: + diff = want_arp_target + else: + have_arp_monitor = have_list.get(dict_name) or {} + if have_arp_monitor and lst in have_arp_monitor: + have_arp_target = have_arp_monitor[lst] + + diff = list_diff_want_only(want_arp_target, have_arp_target) + return diff + + def _compute_command( + self, key, attrib, value=None, remove=False, type="bonding" + ): + if remove: + cmd = "delete interfaces " + type + else: + cmd = "set interfaces " + type + cmd += " " + key + if attrib == "arp_monitor": + attrib = "arp-monitor" + elif attrib == "hash_policy": + attrib = "hash-policy" + cmd += " " + attrib + if value: + cmd += " '" + value + "'" + return cmd diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_global/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_global/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_global/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py new file mode 100644 index 00000000..d66e9c64 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py @@ -0,0 +1,286 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_lldp_global class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + dict_diff, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + get_lst_diff_for_dicts, + list_diff_have_only, +) + + +class Lldp_global(ConfigBase): + """ + The vyos_lldp_global class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "lldp_global", + ] + + params = ["enable", "address", "snmp", "legacy_protocols"] + + def __init__(self, module): + super(Lldp_global, self).__init__(module) + + def get_lldp_global_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + lldp_global_facts = facts["ansible_network_resources"].get( + "lldp_global" + ) + if not lldp_global_facts: + return [] + return lldp_global_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_lldp_global_facts = self.get_lldp_global_facts() + else: + existing_lldp_global_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_lldp_global_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_lldp_global_facts = self.get_lldp_global_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_lldp_global_facts(data=running_config) + else: + changed_lldp_global_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_lldp_global_facts + if result["changed"]: + result["after"] = changed_lldp_global_facts + elif self.state == "gathered": + result["gathered"] = changed_lldp_global_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_lldp_global_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_lldp_global_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, want, have): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if self.state in ("merged", "replaced", "rendered") and not want: + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "deleted": + commands.extend(self._state_deleted(want=None, have=have)) + elif self.state in ("merged", "rendered"): + commands.extend(self._state_merged(want=want, have=have)) + elif self.state == "replaced": + commands.extend(self._state_replaced(want=want, have=have)) + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + commands.extend(self._state_deleted(want, have)) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + commands.extend(self._render_updates(want, have)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + if want: + for item in Lldp_global.params: + if item == "legacy_protocols": + commands.extend(self._update_lldp_protocols(want, have)) + elif ( + have.get(item) and not want.get(item) and item != "enable" + ): + commands.append(Lldp_global.del_cmd + item) + elif have: + for item in Lldp_global.params: + if have.get(item): + if item == "legacy_protocols": + commands.append( + self._compute_command( + "legacy-protocols", remove=True + ) + ) + elif item == "address": + commands.append( + self._compute_command( + "management-address", remove=True + ) + ) + elif item == "snmp": + commands.append( + self._compute_command(item, remove=True) + ) + + return commands + + def _render_updates(self, want, have): + commands = [] + if have: + temp_have_legacy_protos = have.pop("legacy_protocols", None) + else: + have = {} + temp_want_legacy_protos = want.pop("legacy_protocols", None) + + updates = dict_diff(have, want) + + if have and temp_have_legacy_protos: + have["legacy_protocols"] = temp_have_legacy_protos + if not have and temp_want_legacy_protos: + want["legacy_protocols"] = temp_want_legacy_protos + + commands.extend(self._add_lldp_protocols(want, have)) + + if updates: + for key, value in iteritems(updates): + if value: + if key == "enable": + commands.append(self._compute_command()) + elif key == "address": + commands.append( + self._compute_command( + "management-address", str(value) + ) + ) + elif key == "snmp": + if value == "disable": + commands.append( + self._compute_command(key, remove=True) + ) + else: + commands.append( + self._compute_command(key, str(value)) + ) + return commands + + def _add_lldp_protocols(self, want, have): + commands = [] + diff_members = get_lst_diff_for_dicts(want, have, "legacy_protocols") + for key in diff_members: + commands.append(self._compute_command("legacy-protocols", key)) + return commands + + def _update_lldp_protocols(self, want_item, have_item): + commands = [] + want_protocols = want_item.get("legacy_protocols") or [] + have_protocols = have_item.get("legacy_protocols") or [] + + members_diff = list_diff_have_only(want_protocols, have_protocols) + if members_diff: + for member in members_diff: + commands.append( + self._compute_command( + "legacy-protocols", member, remove=True + ) + ) + return commands + + def _compute_command(self, key=None, value=None, remove=False): + if remove: + cmd = "delete service lldp" + else: + cmd = "set service lldp" + if key: + cmd += " " + key + + if value: + cmd += " '" + value + "'" + return cmd diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py new file mode 100644 index 00000000..f1f299fb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py @@ -0,0 +1,459 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_lldp_interfaces class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + dict_diff, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + search_obj_in_list, + search_dict_tv_in_list, + key_value_in_dict, + is_dict_element_present, +) + + +class Lldp_interfaces(ConfigBase): + """ + The vyos_lldp_interfaces class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "lldp_interfaces", + ] + + params = ["enable", "location", "name"] + + def __init__(self, module): + super(Lldp_interfaces, self).__init__(module) + + def get_lldp_interfaces_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + lldp_interfaces_facts = facts["ansible_network_resources"].get( + "lldp_interfaces" + ) + if not lldp_interfaces_facts: + return [] + return lldp_interfaces_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_lldp_interfaces_facts = self.get_lldp_interfaces_facts() + else: + existing_lldp_interfaces_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_lldp_interfaces_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_lldp_interfaces_facts = self.get_lldp_interfaces_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_lldp_interfaces_facts( + data=running_config + ) + else: + changed_lldp_interfaces_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_lldp_interfaces_facts + if result["changed"]: + result["after"] = changed_lldp_interfaces_facts + elif self.state == "gathered": + result["gathered"] = changed_lldp_interfaces_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_lldp_interfaces_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_lldp_interfaces_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, want, have): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not want + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "overridden": + commands.extend(self._state_overridden(want=want, have=have)) + elif self.state == "deleted": + if want: + for item in want: + name = item["name"] + have_item = search_obj_in_list(name, have) + commands.extend( + self._state_deleted(want=None, have=have_item) + ) + else: + for have_item in have: + commands.extend( + self._state_deleted(want=None, have=have_item) + ) + else: + for want_item in want: + name = want_item["name"] + have_item = search_obj_in_list(name, have) + if self.state in ("merged", "rendered"): + commands.extend( + self._state_merged(want=want_item, have=have_item) + ) + if self.state == "replaced": + commands.extend( + self._state_replaced(want=want_item, have=have_item) + ) + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + commands.extend(self._state_deleted(want, have)) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + for have_item in have: + lldp_name = have_item["name"] + lldp_in_want = search_obj_in_list(lldp_name, want) + if not lldp_in_want: + commands.append( + self._compute_command(have_item["name"], remove=True) + ) + + for want_item in want: + name = want_item["name"] + lldp_in_have = search_obj_in_list(name, have) + commands.extend(self._state_replaced(want_item, lldp_in_have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + if have: + commands.extend(self._render_updates(want, have)) + else: + commands.extend(self._render_set_commands(want)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + if want: + params = Lldp_interfaces.params + for attrib in params: + if attrib == "location": + commands.extend( + self._update_location(have["name"], want, have) + ) + + elif have: + commands.append(self._compute_command(have["name"], remove=True)) + return commands + + def _render_updates(self, want, have): + commands = [] + lldp_name = have["name"] + commands.extend(self._configure_status(lldp_name, want, have)) + commands.extend(self._add_location(lldp_name, want, have)) + + return commands + + def _render_set_commands(self, want): + commands = [] + have = {} + lldp_name = want["name"] + params = Lldp_interfaces.params + + for attrib in params: + value = want[attrib] + if value: + if attrib == "location": + commands.extend(self._add_location(lldp_name, want, have)) + elif attrib == "enable": + if not value: + commands.append( + self._compute_command(lldp_name, value="disable") + ) + else: + commands.append(self._compute_command(lldp_name)) + + return commands + + def _configure_status(self, name, want_item, have_item): + commands = [] + if is_dict_element_present(have_item, "enable"): + temp_have_item = False + else: + temp_have_item = True + if want_item["enable"] != temp_have_item: + if want_item["enable"]: + commands.append( + self._compute_command(name, value="disable", remove=True) + ) + else: + commands.append(self._compute_command(name, value="disable")) + return commands + + def _add_location(self, name, want_item, have_item): + commands = [] + have_dict = {} + have_ca = {} + set_cmd = name + " location " + want_location_type = want_item.get("location") or {} + have_location_type = have_item.get("location") or {} + + if want_location_type["coordinate_based"]: + want_dict = want_location_type.get("coordinate_based") or {} + if is_dict_element_present(have_location_type, "coordinate_based"): + have_dict = have_location_type.get("coordinate_based") or {} + location_type = "coordinate-based" + updates = dict_diff(have_dict, want_dict) + for key, value in iteritems(updates): + if value: + commands.append( + self._compute_command( + set_cmd + location_type, key, str(value) + ) + ) + + elif want_location_type["civic_based"]: + location_type = "civic-based" + want_dict = want_location_type.get("civic_based") or {} + want_ca = want_dict.get("ca_info") or [] + if is_dict_element_present(have_location_type, "civic_based"): + have_dict = have_location_type.get("civic_based") or {} + have_ca = have_dict.get("ca_info") or [] + if want_dict["country_code"] != have_dict["country_code"]: + commands.append( + self._compute_command( + set_cmd + location_type, + "country-code", + str(want_dict["country_code"]), + ) + ) + else: + commands.append( + self._compute_command( + set_cmd + location_type, + "country-code", + str(want_dict["country_code"]), + ) + ) + commands.extend(self._add_civic_address(name, want_ca, have_ca)) + + elif want_location_type["elin"]: + location_type = "elin" + if is_dict_element_present(have_location_type, "elin"): + if want_location_type.get("elin") != have_location_type.get( + "elin" + ): + commands.append( + self._compute_command( + set_cmd + location_type, + value=str(want_location_type["elin"]), + ) + ) + else: + commands.append( + self._compute_command( + set_cmd + location_type, + value=str(want_location_type["elin"]), + ) + ) + return commands + + def _update_location(self, name, want_item, have_item): + commands = [] + del_cmd = name + " location" + want_location_type = want_item.get("location") or {} + have_location_type = have_item.get("location") or {} + + if want_location_type["coordinate_based"]: + want_dict = want_location_type.get("coordinate_based") or {} + if is_dict_element_present(have_location_type, "coordinate_based"): + have_dict = have_location_type.get("coordinate_based") or {} + location_type = "coordinate-based" + for key, value in iteritems(have_dict): + only_in_have = key_value_in_dict(key, value, want_dict) + if not only_in_have: + commands.append( + self._compute_command( + del_cmd + location_type, key, str(value), True + ) + ) + else: + commands.append(self._compute_command(del_cmd, remove=True)) + + elif want_location_type["civic_based"]: + want_dict = want_location_type.get("civic_based") or {} + want_ca = want_dict.get("ca_info") or [] + if is_dict_element_present(have_location_type, "civic_based"): + have_dict = have_location_type.get("civic_based") or {} + have_ca = have_dict.get("ca_info") + commands.extend( + self._update_civic_address(name, want_ca, have_ca) + ) + else: + commands.append(self._compute_command(del_cmd, remove=True)) + + else: + if is_dict_element_present(have_location_type, "elin"): + if want_location_type.get("elin") != have_location_type.get( + "elin" + ): + commands.append( + self._compute_command(del_cmd, remove=True) + ) + else: + commands.append(self._compute_command(del_cmd, remove=True)) + return commands + + def _add_civic_address(self, name, want, have): + commands = [] + for item in want: + ca_type = item["ca_type"] + ca_value = item["ca_value"] + obj_in_have = search_dict_tv_in_list( + ca_type, ca_value, have, "ca_type", "ca_value" + ) + if not obj_in_have: + commands.append( + self._compute_command( + key=name + " location civic-based ca-type", + attrib=str(ca_type) + " ca-value", + value=ca_value, + ) + ) + return commands + + def _update_civic_address(self, name, want, have): + commands = [] + for item in have: + ca_type = item["ca_type"] + ca_value = item["ca_value"] + in_want = search_dict_tv_in_list( + ca_type, ca_value, want, "ca_type", "ca_value" + ) + if not in_want: + commands.append( + self._compute_command( + name, + "location civic-based ca-type", + str(ca_type), + remove=True, + ) + ) + return commands + + def _compute_command(self, key, attrib=None, value=None, remove=False): + if remove: + cmd = "delete service lldp interface " + else: + cmd = "set service lldp interface " + cmd += key + if attrib: + cmd += " " + attrib + if value: + cmd += " '" + value + "'" + return cmd diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospf_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospf_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospf_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py new file mode 100644 index 00000000..d01b1e02 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py @@ -0,0 +1,164 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2020 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +""" +The vyos_ospf_interfaces config file. +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to its desired end-state is +created. +""" + +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module import ( + ResourceModule, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.rm_templates.ospf_interfaces import ( + Ospf_interfacesTemplate, +) + + +class Ospf_interfaces(ResourceModule): + """ + The vyos_ospf_interfaces config class + """ + + def __init__(self, module): + super(Ospf_interfaces, self).__init__( + empty_fact_val={}, + facts_module=Facts(module), + module=module, + resource="ospf_interfaces", + tmplt=Ospf_interfacesTemplate(), + ) + self.parsers = [ + "authentication_password", + "authentication_md5", + "bandwidth", + "cost", + "hello_interval", + "dead_interval", + "mtu_ignore", + "network", + "priority", + "retransmit_interval", + "transmit_delay", + "ifmtu", + "instance", + "passive", + ] + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + if self.state not in ["parsed", "gathered"]: + self.generate_commands() + self.run_commands() + return self.result + + def generate_commands(self): + """Generate configuration commands to send based on + want, have and desired state. + """ + wantd = {entry["name"]: entry for entry in self.want} + haved = {entry["name"]: entry for entry in self.have} + + # turn all lists of dicts into dicts prior to merge + for entry in wantd, haved: + self._ospf_int_list_to_dict(entry) + # if state is merged, merge want onto have and then compare + if self.state == "merged": + wantd = dict_merge(haved, wantd) + + # if state is deleted, empty out wantd and set haved to wantd + if self.state == "deleted": + haved = { + k: v for k, v in iteritems(haved) if k in wantd or not wantd + } + have_int = [] + for k, have in iteritems(haved): + if k in wantd: + have_int.append(k) + self._remove_ospf_int(have) + wantd = {} + + if self.state == "overridden": + have_int = [] + for k, have in iteritems(haved): + if k not in wantd: + have_int.append(k) + self._remove_ospf_int(have) + + # remove superfluous config for overridden and deleted + if self.state in ["overridden", "deleted"]: + # removing the interfaces from haved that are already negated + for interface in have_int: + haved.pop(interface) + for k, have in iteritems(haved): + if k not in wantd: + self._compare(want={}, have=have) + + for k, want in iteritems(wantd): + self._compare(want=want, have=haved.pop(k, {})) + + def _remove_ospf_int(self, entry): + int_name = entry.get("name", {}) + int_addr = entry.get("address_family", {}) + for k, addr in iteritems(int_addr): + rem_entry = {"name": int_name, "address_family": {"afi": k}} + self.addcmd(rem_entry, "ip_ospf", True) + + def _compare(self, want, have): + """Leverages the base class `compare()` method and + populates the list of commands to be run by comparing + the `want` and `have` data with the `parsers` defined + for the Ospf_interfaces network resource. + """ + self._compare_addr_family(want=want, have=have) + + def _compare_addr_family(self, want, have): + wdict = want.get("address_family", {}) + hdict = have.get("address_family", {}) + wname = want.get("name") + hname = have.get("name") + for name, entry in iteritems(wdict): + for key, param in iteritems(entry): + w_addr = {"afi": name, key: param} + h_addr = {} + if hdict.get(name): + h_addr = {"afi": name, key: hdict[name].pop(key, {})} + w = {"name": wname, "address_family": w_addr} + h = {"name": hname, "address_family": h_addr} + self.compare(parsers=self.parsers, want=w, have=h) + for name, entry in iteritems(hdict): + for key, param in iteritems(entry): + h_addr = {"afi": name, key: param} + w_addr = {} + w = {"name": wname, "address_family": w_addr} + h = {"name": hname, "address_family": h_addr} + self.compare(parsers=self.parsers, want=w, have=h) + + def _ospf_int_list_to_dict(self, entry): + for name, family in iteritems(entry): + if "address_family" in family: + family["address_family"] = { + entry["afi"]: entry + for entry in family.get("address_family", []) + } + self._ospf_int_list_to_dict(family["address_family"]) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv2/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv2/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv2/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py new file mode 100644 index 00000000..059b92d8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py @@ -0,0 +1,949 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_ospfv2 class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + remove_empties, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible.module_utils.six import iteritems + +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + list_diff_want_only, + _in_target, + _is_w_same, + _bool_to_str, +) + + +class Ospfv2(ConfigBase): + + """ + The vyos_ospfv2 class + """ + + gather_subset = ["!all", "!min"] + + gather_network_resources = ["ospfv2"] + + def __init__(self, module): + super(Ospfv2, self).__init__(module) + + def get_ospfv2_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + + (facts, _warnings) = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + ospfv2_facts = facts["ansible_network_resources"].get("ospfv2", {}) + return ospfv2_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_ospfv2_facts = self.get_ospfv2_facts() + else: + existing_ospfv2_facts = {} + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_ospfv2_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_ospfv2_facts = self.get_ospfv2_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_ospfv2_facts(data=running_config) + else: + changed_ospfv2_facts = {} + + if self.state in self.ACTION_STATES: + result["before"] = existing_ospfv2_facts + if result["changed"]: + result["after"] = changed_ospfv2_facts + elif self.state == "gathered": + result["gathered"] = changed_ospfv2_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_ospfv2_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + + want = self._module.params["config"] + have = existing_ospfv2_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, w, h): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not w + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + + if self.state == "deleted": + commands.extend(self._state_deleted(h)) + elif self.state in ("merged", "rendered"): + commands.extend(self._state_merged(w, h)) + elif self.state == "replaced": + commands.extend(self._state_replaced(w, h)) + return commands + + def search_obj_in_have(self, have, w_name, key): + """ + This function returns the rule-set/rule if it is present in target config. + :param have: target config. + :param w_name: rule-set name. + :param type: rule_sets/rule/r_list. + :return: rule-set/rule. + """ + + if have: + for item in have: + if item[key] == w_name[key]: + return item + return None + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + + commands = [] + if have: + commands.extend(self._render_ospf_param(have, want, opr=False)) + commands.extend(self._render_ospf_param(want, have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + + commands = [] + commands.extend(self._render_ospf_param(want, have)) + return commands + + def _state_deleted(self, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + + commands = [] + if have: + commands.append("delete protocols ospf") + return commands + + def _render_ospf_param(self, want, have, opr=True): + """ + This function forms the set/delete commands for ospf leaf attributes + and triggers the process for other child attributes. + for firewall_global attributes. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + w = deepcopy(remove_empties(want)) + leaf = ("default_metric", "log_adjacency_changes") + if w: + for (key, val) in iteritems(w): + if opr and key in leaf and not _is_w_same(w, have, key): + commands.append( + self._form_attr_cmd( + attr=key, val=_bool_to_str(val), opr=opr + ) + ) + elif not opr and key in leaf and not _in_target(have, key): + commands.append( + self._form_attr_cmd( + attr=key, val=_bool_to_str(val), opr=opr + ) + ) + else: + commands.extend( + self._render_child_param(w, have, key, opr) + ) + return commands + + def _render_child_param(self, w, h, key, opr=True): + """ + This function invoke the function to extend commands + based on the key. + :param w: the desired configuration. + :param h: the current configuration. + :param key: attribute name. + :param opr: operation. + :return: list of commands. + """ + + commands = [] + if key in ("neighbor", "redistribute"): + commands.extend(self._render_list_dict_param(key, w, h, opr=opr)) + elif key in ("default_information", "max_metric"): + commands.extend(self._render_nested_dict_param(key, w, h, opr=opr)) + elif key in ("mpls_te", "auto_cost", "parameters", "auto_cost"): + commands.extend(self._render_dict_param(key, w, h, opr=opr)) + elif key in ( + "route_map", + "passive_interface", + "passive_interface_exclude", + ): + commands.extend(self._render_list_param(key, w, h, opr=opr)) + elif key == "areas": + commands.extend(self._render_areas(key, w, h, opr=opr)) + elif key == "timers": + commands.extend(self._render_timers(key, w, h, opr=opr)) + elif key == "distance": + commands.extend(self._render_distance(key, w, h, opr=opr)) + return commands + + def _render_dict_param(self, attr, want, have, opr=True): + """ + This function generate the commands for dictionary elements. + :param attr: attribute name. + :param w: the desired configuration. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + + commands = [] + h = {} + if have: + h = have.get(attr) or {} + if not opr and not h: + commands.append(self._form_attr_cmd(attr=attr, opr=opr)) + elif want[attr]: + leaf_dict = { + "auto_cost": "reference_bandwidth", + "mpls_te": ("enabled", "router_address"), + "parameters": ( + "router_id", + "abr_type", + "opaque_lsa", + "rfc1583_compatibility", + ), + } + leaf = leaf_dict[attr] + for (item, value) in iteritems(want[attr]): + if ( + opr + and item in leaf + and not _is_w_same(want[attr], h, item) + ): + if item == "enabled": + item = "enable" + if item in ( + "opaque_lsa", + "enable", + "rfc1583_compatibility", + ): + commands.append( + self._form_attr_cmd(key=attr, attr=item, opr=opr) + ) + else: + commands.append( + self._form_attr_cmd( + key=attr, attr=item, val=value, opr=opr + ) + ) + elif not opr and item in leaf and not _in_target(h, item): + if item == "enabled": + commands.append( + self._form_attr_cmd( + key=attr, attr="enable", opr=opr + ) + ) + else: + commands.append( + self._form_attr_cmd(key=attr, attr=item, opr=opr) + ) + return commands + + def _render_list_param(self, attr, want, have, cmd=None, opr=True): + """ + This function forms the commands for passed target list attributes'. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param opr: True/False. + :return: generated list of commands. + """ + + commands = [] + h = [] + if want: + w = want.get(attr) or [] + if have: + h = have.get(attr) or [] + if not cmd: + cmd = self._compute_command(opr=opr) + if w: + if opr: + members = list_diff_want_only(w, h) + for member in members: + command = cmd + attr.replace("_", "-") + " " + if attr == "network": + command += member["address"] + else: + command += member + commands.append(command) + elif not opr: + if h: + for member in w: + if attr == "network": + if not self.search_obj_in_have( + h, member, "address" + ): + commands.append( + cmd + + attr.replace("_", "-") + + " " + + member["address"] + ) + elif member not in h: + commands.append( + cmd + attr.replace("_", "-") + " " + member + ) + else: + commands.append(cmd + " " + attr.replace("_", "-")) + return commands + + def _render_vlink(self, attr, want, have, cmd=None, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for attributes with in desired list of dictionary. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + h = [] + name = {"virtual_link": "address"} + leaf_dict = { + "virtual_link": ( + "address", + "dead_interval", + "transmit_delay", + "hello_interval", + "retransmit_interval", + ) + } + leaf = leaf_dict[attr] + w = want.get(attr) or [] + if have: + h = have.get(attr) or [] + if not opr and not h: + commands.append(cmd + attr.replace("_", "-")) + elif w: + for w_item in w: + for (key, val) in iteritems(w_item): + if not cmd: + cmd = self._compute_command(opr=opr) + h_item = self.search_obj_in_have(h, w_item, name[attr]) + if ( + opr + and key in leaf + and not _is_w_same(w_item, h_item, key) + ): + if key in "address": + commands.append( + cmd + attr.replace("_", "-") + " " + str(val) + ) + else: + commands.append( + cmd + + attr.replace("_", "-") + + " " + + w_item[name[attr]] + + " " + + key.replace("_", "-") + + " " + + str(val) + ) + elif ( + not opr and key in leaf and not _in_target(h_item, key) + ): + if key in "address": + commands.append( + cmd + attr.replace("_", "-") + " " + str(val) + ) + else: + commands.append( + cmd + + attr.replace("_", "-") + + " " + + w_item[name[attr]] + + " " + + key + ) + elif key == "authentication": + commands.extend( + self._render_vlink_auth( + attr, + key, + w_item, + h_item, + w_item["address"], + cmd, + opr, + ) + ) + return commands + + def _render_vlink_auth( + self, attr, key, want, have, address, cmd=None, opr=True + ): + """ + This function forms the set/delete commands based on the 'opr' type + for attributes with in desired list of dictionary. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + h = [] + + w = want.get(key) or {} + if have: + h = have.get(key) or {} + cmd += attr.replace("_", "-") + " " + address + " " + key + " " + commands.extend(self._render_list_dict_param("md5", w, h, cmd, opr)) + return commands + + def _render_list_dict_param(self, attr, want, have, cmd=None, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for attributes with in desired list of dictionary. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + h = [] + name = { + "redistribute": "route_type", + "neighbor": "neighbor_id", + "range": "address", + "md5": "key_id", + "vlink": "address", + } + leaf_dict = { + "md5": "md5_key", + "redistribute": ( + "metric", + "route_map", + "route_type", + "metric_type", + ), + "neighbor": ("priority", "poll_interval", "neighbor_id"), + "range": ("cost", "address", "substitute", "not_advertise"), + "vlink": ( + "address", + "dead_interval", + "transmit_delay", + "hello_interval", + "retransmit_interval", + ), + } + leaf = leaf_dict[attr] + w = want.get(attr) or [] + if have: + h = have.get(attr) or [] + if not opr and not h: + commands.append(self._compute_command(attr=attr, opr=opr)) + elif w: + for w_item in w: + for (key, val) in iteritems(w_item): + if not cmd: + cmd = self._compute_command(opr=opr) + h_item = self.search_obj_in_have(h, w_item, name[attr]) + if ( + opr + and key in leaf + and not _is_w_same(w_item, h_item, key) + ): + if key in ( + "route_type", + "neighbor_id", + "address", + "key_id", + ): + commands.append(cmd + attr + " " + str(val)) + elif key == "cost": + commands.append( + cmd + + attr + + " " + + w_item[name[attr]] + + " " + + key + + " " + + str(val) + ) + elif key == "not_advertise": + commands.append( + cmd + + attr + + " " + + w_item[name[attr]] + + " " + + key.replace("_", "-") + ) + elif key == "md5_key": + commands.append( + cmd + + attr + + " " + + "key-id" + + " " + + str(w_item[name[attr]]) + + " " + + key.replace("_", "-") + + " " + + w_item[key] + ) + else: + commands.append( + cmd + + attr + + " " + + w_item[name[attr]] + + " " + + key.replace("_", "-") + + " " + + str(val) + ) + elif ( + not opr and key in leaf and not _in_target(h_item, key) + ): + if key in ( + "route_type", + "neighbor_id", + "address", + "key_id", + ): + commands.append(cmd + attr + " " + str(val)) + else: + commands.append( + cmd + + attr + + " " + + w_item[name[attr]] + + " " + + key + ) + return commands + + def _render_nested_dict_param(self, attr, want, have, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for attributes with in desired nested dicts. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + attr_dict = { + "default_information": "originate", + "max_metric": "router_lsa", + } + leaf_dict = { + "default_information": ( + "always", + "metric", + "metric_type", + "route_map", + ), + "max_metric": ("administrative", "on_startup", "on_shutdown"), + } + h = {} + w = want.get(attr) or {} + if have: + h = have.get(attr) or {} + if not opr and not h: + commands.append(self._form_attr_cmd(attr=attr, opr=opr)) + elif w: + key = attr_dict[attr] + w_attrib = want[attr].get(key) or {} + cmd = self._compute_command(opr=opr) + h_attrib = {} + if w_attrib: + leaf = leaf_dict[attr] + if h and key in h.keys(): + h_attrib = h.get(key) or {} + for (item, val) in iteritems(w[key]): + if ( + opr + and item in leaf + and not _is_w_same(w[key], h_attrib, item) + ): + if item in ("administrative", "always") and val: + commands.append( + cmd + + attr.replace("_", "-") + + " " + + key.replace("_", "-") + + " " + + item.replace("_", "-") + ) + elif item not in ("administrative", "always"): + commands.append( + cmd + + attr.replace("_", "-") + + " " + + key.replace("_", "-") + + " " + + item.replace("_", "-") + + " " + + str(val) + ) + elif ( + not opr + and item in leaf + and not _in_target(h_attrib, item) + ): + + commands.append(cmd + attr + " " + item) + return commands + + def _render_areas(self, attr, want, have, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for ospf area attributes. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + h_lst = {} + w_lst = want.get(attr) or [] + l_set = ("area_id", "shortcut", "authentication") + if have: + h_lst = have.get(attr) or [] + if not opr and not h_lst: + commands.append(self._form_attr_cmd(attr="area", opr=opr)) + elif w_lst: + for w_area in w_lst: + cmd = ( + self._compute_command( + key="area", + attr=_bool_to_str(w_area["area_id"]), + opr=opr, + ) + + " " + ) + h_area = self.search_obj_in_have(h_lst, w_area, "area_id") + if not opr and not h_area: + commands.append( + self._form_attr_cmd( + key="area", attr=w_area["area_id"], opr=opr + ) + ) + else: + for (key, val) in iteritems(w_area): + if ( + opr + and key in l_set + and not _is_w_same(w_area, h_area, key) + ): + if key == "area_id": + commands.append( + self._form_attr_cmd( + attr="area", + val=_bool_to_str(val), + opr=opr, + ) + ) + else: + commands.append( + cmd + + key + + " " + + _bool_to_str(val).replace("_", "-") + ) + elif not opr and key in l_set: + if key == "area_id" and not _in_target( + h_area, key + ): + commands.append(cmd) + continue + if key != "area_id" and not _in_target( + h_area, key + ): + commands.append(cmd + val + " " + key) + elif key == "area_type": + commands.extend( + self._render_area_type( + w_area, h_area, key, cmd, opr + ) + ) + elif key == "network": + commands.extend( + self._render_list_param( + key, w_area, h_area, cmd, opr + ) + ) + elif key == "range": + commands.extend( + self._render_list_dict_param( + key, w_area, h_area, cmd, opr + ) + ) + elif key == "virtual_link": + commands.extend( + self._render_vlink( + key, w_area, h_area, cmd, opr + ) + ) + return commands + + def _render_area_type(self, want, have, attr, cmd, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for area_types attributes. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: command to prepend. + :param opr: True/False. + :return: generated commands list. + """ + + commands = [] + h_type = {} + w_type = want.get(attr) or [] + if have: + h_type = have.get(attr) or {} + if not opr and not h_type: + commands.append(cmd + attr.replace("_", "-")) + elif w_type: + key = "normal" + if ( + opr + and key in w_type.keys() + and not _is_w_same(w_type, h_type, key) + ): + if not w_type[key] and h_type and h_type[key]: + commands.append( + cmd.replace("set", "delete") + + attr.replace("_", "-") + + " " + + key + ) + elif w_type[key]: + commands.append(cmd + attr.replace("_", "-") + " " + key) + elif ( + not opr + and key in w_type.keys() + and not (h_type and key in h_type.keys()) + ): + commands.append( + cmd + want["area"] + " " + attr.replace("_", "-") + ) + + a_type = { + "nssa": ("set", "default_cost", "no_summary", "translate"), + "stub": ("set", "default_cost", "no_summary"), + } + for key in a_type: + w_area = want[attr].get(key) or {} + h_area = {} + if w_area: + if h_type and key in h_type.keys(): + h_area = h_type.get(key) or {} + for (item, val) in iteritems(w_type[key]): + if ( + opr + and item in a_type[key] + and not _is_w_same(w_type[key], h_area, item) + ): + if item == "set" and val: + commands.append( + cmd + attr.replace("_", "-") + " " + key + ) + elif not val and h_area and h_area[item]: + commands.append( + cmd.replace("set", "delete") + + attr.replace("_", "-") + + " " + + key + ) + elif item != "set": + commands.append( + cmd + + attr.replace("_", "-") + + " " + + key + + " " + + item.replace("_", "-") + + " " + + str(val) + ) + elif ( + not opr + and item in a_type[key] + and not (h_type and key in h_type) + ): + if item == "set": + commands.append( + cmd + attr.replace("_", "-") + " " + key + ) + else: + commands.append( + cmd + + want["area"] + + " " + + attr.replace("_", "-") + + " " + + key + + " " + + item.replace("_", "-") + ) + return commands + + def _form_attr_cmd(self, key=None, attr=None, val=None, opr=True): + """ + This function forms the command for leaf attribute. + :param key: parent key. + :param attr: attribute name + :param value: value + :param opr: True/False. + :return: generated command. + """ + + return self._compute_command( + key, attr=self._map_attrib(attr), val=val, opr=opr + ) + + def _compute_command( + self, key=None, attr=None, val=None, remove=False, opr=True + ): + """ + This function construct the add/delete command based on passed attributes. + :param key: parent key. + :param attr: attribute name + :param value: value + :param opr: True/False. + :return: generated command. + """ + + if remove or not opr: + cmd = "delete protocols ospf " + else: + cmd = "set protocols ospf " + if key: + cmd += key.replace("_", "-") + " " + if attr: + cmd += attr.replace("_", "-") + if val: + cmd += " '" + str(val) + "'" + return cmd + + def _map_attrib(self, attrib): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + + return "disable" if attrib == "disabled" else attrib.replace("_", "-") diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv3/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv3/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv3/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py new file mode 100644 index 00000000..c43dfe7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py @@ -0,0 +1,464 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_ospfv3 class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + remove_empties, + search_obj_in_list, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible.module_utils.six import iteritems + +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + _in_target, + _is_w_same, + _bool_to_str, +) + + +class Ospfv3(ConfigBase): + """ + The vyos_ospfv3 class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "ospfv3", + ] + + def __init__(self, module): + super(Ospfv3, self).__init__(module) + + def get_ospfv3_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + ospfv3_facts = facts["ansible_network_resources"].get("ospfv3", {}) + return ospfv3_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_ospfv3_facts = self.get_ospfv3_facts() + else: + existing_ospfv3_facts = {} + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_ospfv3_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_ospfv3_facts = self.get_ospfv3_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_ospfv3_facts(data=running_config) + else: + changed_ospfv3_facts = {} + + if self.state in self.ACTION_STATES: + result["before"] = existing_ospfv3_facts + if result["changed"]: + result["after"] = changed_ospfv3_facts + elif self.state == "gathered": + result["gathered"] = changed_ospfv3_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_ospfv3_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_ospfv3_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, w, h): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not w + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "deleted": + commands.extend(self._state_deleted(w, h)) + elif self.state in ("merged", "rendered"): + commands.extend(self._state_merged(w, h)) + elif self.state == "replaced": + commands.extend(self._state_replaced(w, h)) + return commands + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + commands.extend(self._render_ospf_param(have, want, opr=False)) + commands.extend(self._render_ospf_param(want, have)) + return commands + + def _state_merged(self, want, have): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + commands.extend(self._render_ospf_param(want, have)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + if have: + commands.append("delete protocols ospfv3") + return commands + + def _render_ospf_param(self, want, have, opr=True): + """ + This function forms the set/delete commands for ospf leaf attributes + and triggers the process for other child attributes. + for firewall_global attributes. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + w = deepcopy(remove_empties(want)) + if w: + for key, val in iteritems(w): + commands.extend(self._render_child_param(w, have, key, opr)) + return commands + + def _render_child_param(self, w, h, key, opr=True): + """ + This function invoke the function to extend commands + based on the key. + :param w: the desired configuration. + :param h: the current configuration. + :param key: attribute name. + :param opr: operation. + :return: list of commands. + """ + commands = [] + if key == "areas": + commands.extend(self._render_areas(key, w, h, opr=opr)) + elif key == "parameters": + commands.extend(self._render_dict_param(key, w, h, opr=opr)) + elif key == "redistribute": + commands.extend(self._render_list_dict_param(key, w, h, opr=opr)) + return commands + + def _render_dict_param(self, attr, want, have, opr=True): + """ + This function generate the commands for dictionary elements. + :param attr: attribute name. + :param w: the desired configuration. + :param h: the target config. + :param opr: True/False. + :return: generated list of commands. + """ + commands = [] + h = {} + if have: + h = have.get(attr) or {} + if not opr and not h: + commands.append(self._form_attr_cmd(attr=attr, opr=opr)) + elif want[attr]: + leaf_dict = {"parameters": "router_id"} + leaf = leaf_dict[attr] + for item, value in iteritems(want[attr]): + if ( + opr + and item in leaf + and not _is_w_same(want[attr], h, item) + ): + commands.append( + self._form_attr_cmd( + key=attr, attr=item, val=value, opr=opr + ) + ) + elif not opr and item in leaf and not _in_target(h, item): + commands.append( + self._form_attr_cmd(key=attr, attr=item, opr=opr) + ) + return commands + + def _render_list_dict_param(self, attr, want, have, cmd=None, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for attributes with in desired list of dictionary. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param cmd: commands to be prepend. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + h = [] + name = { + "redistribute": "route_type", + "range": "address", + } + leaf_dict = { + "redistribute": ("route_map", "route_type"), + "range": ("address", "advertise", "not_advertise"), + } + leaf = leaf_dict[attr] + w = want.get(attr) or [] + if have: + h = have.get(attr) or [] + if not opr and not h: + commands.append(self._compute_command(attr=attr, opr=opr)) + elif w: + for w_item in w: + for key, val in iteritems(w_item): + if not cmd: + cmd = self._compute_command(opr=opr) + h_item = search_obj_in_list( + w_item[name[attr]], h, name[attr] + ) + if ( + opr + and key in leaf + and not _is_w_same(w_item, h_item, key) + ): + if key == "route_type" or ( + key == "address" + and "advertise" not in w_item + and "not-advertise" not in w_item + ): + if not val: + cmd = cmd.replace("set", "delete") + commands.append(cmd + attr + " " + str(val)) + elif key in leaf_dict["range"] and key != "address": + commands.append( + cmd + + attr + + " " + + w_item[name[attr]] + + " " + + key.replace("_", "-") + ) + elif key == "route_map": + commands.append( + cmd + + attr + + " " + + w_item[name[attr]] + + " " + + key.replace("_", "-") + + " " + + str(val) + ) + elif ( + not opr and key in leaf and not _in_target(h_item, key) + ): + if key in ("route_type", "address"): + commands.append(cmd + attr + " " + str(val)) + else: + commands.append( + cmd + + (attr + " " + w_item[name[attr]] + " " + key) + ) + return commands + + def _render_areas(self, attr, want, have, opr=True): + """ + This function forms the set/delete commands based on the 'opr' type + for ospf area attributes. + :param attr: attribute name. + :param w: the desired config. + :param h: the target config. + :param opr: True/False. + :return: generated commands list. + """ + commands = [] + h_lst = {} + w_lst = want.get(attr) or [] + l_set = ("area_id", "export_list", "import_list") + if have: + h_lst = have.get(attr) or [] + if not opr and not h_lst: + commands.append(self._form_attr_cmd(attr="area", opr=opr)) + elif w_lst: + for w_area in w_lst: + cmd = ( + self._compute_command( + key="area", + attr=_bool_to_str(w_area["area_id"]), + opr=opr, + ) + + " " + ) + h_area = search_obj_in_list( + w_area["area_id"], h_lst, "area_id" + ) + if not opr and not h_area: + commands.append( + self._form_attr_cmd( + key="area", attr=w_area["area_id"], opr=opr + ) + ) + else: + for key, val in iteritems(w_area): + if ( + opr + and key in l_set + and not _is_w_same(w_area, h_area, key) + ): + if key == "area_id": + commands.append( + self._form_attr_cmd( + attr="area", + val=_bool_to_str(val), + opr=opr, + ) + ) + else: + commands.append( + cmd + + key.replace("_", "-") + + " " + + _bool_to_str(val).replace("_", "-") + ) + elif not opr and key in l_set: + if key == "area_id" and not _in_target( + h_area, key + ): + commands.append(cmd) + continue + if key != "area_id" and not _in_target( + h_area, key + ): + commands.append(cmd + val + " " + key) + elif key == "range": + commands.extend( + self._render_list_dict_param( + key, w_area, h_area, cmd, opr + ) + ) + return commands + + def _form_attr_cmd(self, key=None, attr=None, val=None, opr=True): + """ + This function forms the command for leaf attribute. + :param key: parent key. + :param attr: attribute name + :param value: value + :param opr: True/False. + :return: generated command. + """ + return self._compute_command( + key, attr=self._map_attrib(attr), val=val, opr=opr + ) + + def _compute_command( + self, key=None, attr=None, val=None, remove=False, opr=True + ): + """ + This function construct the add/delete command based on passed attributes. + :param key: parent key. + :param attr: attribute name + :param value: value + :param opr: True/False. + :return: generated command. + """ + if remove or not opr: + cmd = "delete protocols ospfv3 " + else: + cmd = "set protocols ospfv3 " + if key: + cmd += key.replace("_", "-") + " " + if attr: + cmd += attr.replace("_", "-") + if val and opr: + cmd += " '" + str(val) + "'" + return cmd + + def _map_attrib(self, attrib): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + return "disable" if attrib == "disabled" else attrib.replace("_", "-") diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/static_routes/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/static_routes/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/static_routes/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/static_routes/static_routes.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/static_routes/static_routes.py new file mode 100644 index 00000000..f1d4f38d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/static_routes/static_routes.py @@ -0,0 +1,621 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos_static_routes class +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to it's desired end-state is +created +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( + ConfigBase, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + to_list, + dict_diff, + remove_empties, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + get_route_type, + get_lst_diff_for_dicts, + get_lst_same_for_dicts, + dict_delete, +) + + +class Static_routes(ConfigBase): + """ + The vyos_static_routes class + """ + + gather_subset = [ + "!all", + "!min", + ] + + gather_network_resources = [ + "static_routes", + ] + + def __init__(self, module): + super(Static_routes, self).__init__(module) + + def get_static_routes_facts(self, data=None): + """Get the 'facts' (the current configuration) + + :rtype: A dictionary + :returns: The current configuration as a dictionary + """ + facts, _warnings = Facts(self._module).get_facts( + self.gather_subset, self.gather_network_resources, data=data + ) + static_routes_facts = facts["ansible_network_resources"].get( + "static_routes" + ) + if not static_routes_facts: + return [] + return static_routes_facts + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + result = {"changed": False} + warnings = list() + commands = list() + + if self.state in self.ACTION_STATES: + existing_static_routes_facts = self.get_static_routes_facts() + else: + existing_static_routes_facts = [] + + if self.state in self.ACTION_STATES or self.state == "rendered": + commands.extend(self.set_config(existing_static_routes_facts)) + + if commands and self.state in self.ACTION_STATES: + if not self._module.check_mode: + self._connection.edit_config(commands) + result["changed"] = True + + if self.state in self.ACTION_STATES: + result["commands"] = commands + + if self.state in self.ACTION_STATES or self.state == "gathered": + changed_static_routes_facts = self.get_static_routes_facts() + elif self.state == "rendered": + result["rendered"] = commands + elif self.state == "parsed": + running_config = self._module.params["running_config"] + if not running_config: + self._module.fail_json( + msg="value of running_config parameter must not be empty for state parsed" + ) + result["parsed"] = self.get_static_routes_facts( + data=running_config + ) + else: + changed_static_routes_facts = [] + + if self.state in self.ACTION_STATES: + result["before"] = existing_static_routes_facts + if result["changed"]: + result["after"] = changed_static_routes_facts + elif self.state == "gathered": + result["gathered"] = changed_static_routes_facts + + result["warnings"] = warnings + return result + + def set_config(self, existing_static_routes_facts): + """Collect the configuration from the args passed to the module, + collect the current configuration (as a dict from facts) + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + want = self._module.params["config"] + have = existing_static_routes_facts + resp = self.set_state(want, have) + return to_list(resp) + + def set_state(self, want, have): + """Select the appropriate function based on the state provided + + :param want: the desired configuration as a dictionary + :param have: the current configuration as a dictionary + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not want + ): + self._module.fail_json( + msg="value of config parameter must not be empty for state {0}".format( + self.state + ) + ) + if self.state == "overridden": + commands.extend(self._state_overridden(want=want, have=have)) + elif self.state == "deleted": + commands.extend(self._state_deleted(want=want, have=have)) + elif want: + routes = self._get_routes(want) + for r in routes: + h_item = self.search_route_in_have(have, r["dest"]) + if self.state in ("merged", "rendered"): + commands.extend(self._state_merged(want=r, have=h_item)) + elif self.state == "replaced": + commands.extend(self._state_replaced(want=r, have=h_item)) + return commands + + def search_route_in_have(self, have, want_dest): + """ + This function returns the route if its found in + have config. + :param have: + :param dest: + :return: the matched route + """ + routes = self._get_routes(have) + for r in routes: + if r["dest"] == want_dest: + return r + return None + + def _state_replaced(self, want, have): + """The command generator when state is replaced + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + if have: + for key, value in iteritems(want): + if value: + if key == "next_hops": + commands.extend(self._update_next_hop(want, have)) + elif key == "blackhole_config": + commands.extend( + self._update_blackhole(key, want, have) + ) + commands.extend(self._state_merged(want, have)) + return commands + + def _state_overridden(self, want, have): + """The command generator when state is overridden + + :rtype: A list + :returns: the commands necessary to migrate the current configuration + to the desired configuration + """ + commands = [] + routes = self._get_routes(have) + for r in routes: + route_in_want = self.search_route_in_have(want, r["dest"]) + if not route_in_want: + commands.append(self._compute_command(r["dest"], remove=True)) + routes = self._get_routes(want) + for r in routes: + route_in_have = self.search_route_in_have(have, r["dest"]) + commands.extend(self._state_replaced(r, route_in_have)) + return commands + + def _state_merged(self, want, have, opr=True): + """The command generator when state is merged + + :rtype: A list + :returns: the commands necessary to merge the provided into + the current configuration + """ + commands = [] + if have: + commands.extend(self._render_updates(want, have)) + else: + commands.extend(self._render_set_commands(want)) + return commands + + def _state_deleted(self, want, have): + """The command generator when state is deleted + + :rtype: A list + :returns: the commands necessary to remove the current configuration + of the provided objects + """ + commands = [] + if want: + routes = self._get_routes(want) + if not routes: + for w in want: + af = w["address_families"] + for item in af: + if self.afi_in_have(have, item): + commands.append( + self._compute_command( + afi=item["afi"], remove=True + ) + ) + else: + routes = self._get_routes(have) + if self._is_ip_route_exist(routes): + commands.append(self._compute_command(afi="ipv4", remove=True)) + if self._is_ip_route_exist(routes, "route6"): + commands.append(self._compute_command(afi="ipv6", remove=True)) + return commands + + def _render_set_commands(self, want): + """ + This function returns the list of commands to add attributes which are + present in want + :param want: + :return: list of commands. + """ + commands = [] + have = {} + for key, value in iteritems(want): + if value: + if key == "dest": + commands.append(self._compute_command(dest=want["dest"])) + elif key == "blackhole_config": + commands.extend(self._add_blackhole(key, want, have)) + + elif key == "next_hops": + commands.extend(self._add_next_hop(want, have)) + + return commands + + def _add_blackhole(self, key, want, have): + """ + This function gets the diff for blackhole config specific attributes + and form the commands for attributes which are present in want but not in have. + :param key: + :param want: + :param have: + :return: list of commands + """ + commands = [] + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(remove_empties(have)) + + want_blackhole = want_copy.get(key) or {} + have_blackhole = have_copy.get(key) or {} + + updates = dict_delete(want_blackhole, have_blackhole) + if updates: + for attrib, value in iteritems(updates): + if value: + if attrib == "distance": + commands.append( + self._compute_command( + dest=want["dest"], + key="blackhole", + attrib=attrib, + remove=False, + value=str(value), + ) + ) + elif attrib == "type": + commands.append( + self._compute_command( + dest=want["dest"], key="blackhole" + ) + ) + return commands + + def _add_next_hop(self, want, have, opr=True): + """ + This function gets the diff for next hop specific attributes + and form the commands to add attributes which are present in want but not in have. + :param want: + :param have: + :return: list of commands. + """ + commands = [] + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(remove_empties(have)) + if not opr: + diff_next_hops = get_lst_same_for_dicts( + want_copy, have_copy, "next_hops" + ) + else: + diff_next_hops = get_lst_diff_for_dicts( + want_copy, have_copy, "next_hops" + ) + if diff_next_hops: + for hop in diff_next_hops: + for element in hop: + if element == "forward_router_address": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + value=hop[element], + opr=opr, + ) + ) + elif element == "enabled" and not hop[element]: + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + attrib=hop["forward_router_address"], + value="disable", + opr=opr, + ) + ) + elif element == "admin_distance": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + attrib=hop["forward_router_address"] + + " " + + element, + value=str(hop[element]), + opr=opr, + ) + ) + elif element == "interface": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + attrib=hop["forward_router_address"] + + " " + + element, + value=hop[element], + opr=opr, + ) + ) + return commands + + def _update_blackhole(self, key, want, have): + """ + This function gets the difference for blackhole dict and + form the commands to delete the attributes which are present in have but not in want. + :param want: + :param have: + :return: list of commands + :param key: + :param want: + :param have: + :return: list of commands + """ + commands = [] + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(remove_empties(have)) + + want_blackhole = want_copy.get(key) or {} + have_blackhole = have_copy.get(key) or {} + updates = dict_delete(have_blackhole, want_blackhole) + if updates: + for attrib, value in iteritems(updates): + if value: + if attrib == "distance": + commands.append( + self._compute_command( + dest=want["dest"], + key="blackhole", + attrib=attrib, + remove=True, + value=str(value), + ) + ) + elif ( + attrib == "type" + and "distance" not in want_blackhole.keys() + ): + commands.append( + self._compute_command( + dest=want["dest"], key="blackhole", remove=True + ) + ) + return commands + + def _update_next_hop(self, want, have, opr=True): + """ + This function gets the difference for next_hops list and + form the commands to delete the attributes which are present in have but not in want. + :param want: + :param have: + :return: list of commands + """ + commands = [] + + want_copy = deepcopy(remove_empties(want)) + have_copy = deepcopy(remove_empties(have)) + + diff_next_hops = get_lst_diff_for_dicts( + have_copy, want_copy, "next_hops" + ) + if diff_next_hops: + for hop in diff_next_hops: + for element in hop: + if element == "forward_router_address": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + value=hop[element], + remove=True, + ) + ) + elif element == "enabled": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + attrib=hop["forward_router_address"], + value="disable", + remove=True, + ) + ) + elif element == "admin_distance": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + attrib=hop["forward_router_address"] + + " " + + element, + value=str(hop[element]), + remove=True, + ) + ) + elif element == "interface": + commands.append( + self._compute_command( + dest=want["dest"], + key="next-hop", + attrib=hop["forward_router_address"] + + " " + + element, + value=hop[element], + remove=True, + ) + ) + return commands + + def _render_updates(self, want, have, opr=True): + """ + This function takes the diff between want and have and + invokes the appropriate functions to create the commands + to update the attributes. + :param want: + :param have: + :return: list of commands + """ + commands = [] + want_nh = want.get("next_hops") or [] + # delete static route operation per destination + if not opr and not want_nh: + commands.append( + self._compute_command(dest=want["dest"], remove=True) + ) + + else: + temp_have_next_hops = have.pop("next_hops", None) + temp_want_next_hops = want.pop("next_hops", None) + updates = dict_diff(have, want) + if temp_have_next_hops: + have["next_hops"] = temp_have_next_hops + if temp_want_next_hops: + want["next_hops"] = temp_want_next_hops + commands.extend(self._add_next_hop(want, have, opr=opr)) + + if opr and updates: + for key, value in iteritems(updates): + if value: + if key == "blackhole_config": + commands.extend( + self._add_blackhole(key, want, have) + ) + return commands + + def _compute_command( + self, + dest=None, + key=None, + attrib=None, + value=None, + remove=False, + afi=None, + opr=True, + ): + """ + This functions construct the required command based on the passed arguments. + :param dest: + :param key: + :param attrib: + :param value: + :param remove: + :return: constructed command + """ + if remove or not opr: + cmd = "delete protocols static " + self.get_route_type(dest, afi) + else: + cmd = "set protocols static " + self.get_route_type(dest, afi) + if dest: + cmd += " " + dest + if key: + cmd += " " + key + if attrib: + cmd += " " + attrib + if value: + cmd += " '" + value + "'" + return cmd + + def afi_in_have(self, have, w_item): + """ + This functions checks for the afi + list in have + :param have: + :param w_item: + :return: + """ + if have: + for h in have: + af = h.get("address_families") or [] + for item in af: + if w_item["afi"] == item["afi"]: + return True + return False + + def get_route_type(self, dest=None, afi=None): + """ + This function returns the route type based on + destination ip address or afi + :param address: + :return: + """ + if dest: + return get_route_type(dest) + elif afi == "ipv4": + return "route" + elif afi == "ipv6": + return "route6" + + def _is_ip_route_exist(self, routes, type="route"): + """ + This functions checks for the type of route. + :param routes: + :param type: + :return: True/False + """ + for r in routes: + if type == self.get_route_type(r["dest"]): + return True + return False + + def _get_routes(self, lst): + """ + This function returns the list of routes + :param lst: list of address families + :return: list of routes + """ + r_list = [] + for item in lst: + af = item["address_families"] + for element in af: + routes = element.get("routes") or [] + for r in routes: + r_list.append(r) + return r_list diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py new file mode 100644 index 00000000..c2766ded --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py @@ -0,0 +1,103 @@ +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The facts class for vyos +this file validates each subset of facts and selectively +calls the appropriate facts gathering function +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts import ( + FactsBase, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.interfaces.interfaces import ( + InterfacesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.l3_interfaces.l3_interfaces import ( + L3_interfacesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.lag_interfaces.lag_interfaces import ( + Lag_interfacesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.lldp_global.lldp_global import ( + Lldp_globalFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.lldp_interfaces.lldp_interfaces import ( + Lldp_interfacesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_rules.firewall_rules import ( + Firewall_rulesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes import ( + Static_routesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global import ( + Firewall_globalFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_interfaces.firewall_interfaces import ( + Firewall_interfacesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3 import ( + Ospfv3Facts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2 import ( + Ospfv2Facts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces import ( + Ospf_interfacesFacts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base import ( + Default, + Neighbors, + Config, +) + + +FACT_LEGACY_SUBSETS = dict(default=Default, neighbors=Neighbors, config=Config) +FACT_RESOURCE_SUBSETS = dict( + interfaces=InterfacesFacts, + l3_interfaces=L3_interfacesFacts, + lag_interfaces=Lag_interfacesFacts, + lldp_global=Lldp_globalFacts, + lldp_interfaces=Lldp_interfacesFacts, + static_routes=Static_routesFacts, + firewall_rules=Firewall_rulesFacts, + firewall_global=Firewall_globalFacts, + firewall_interfaces=Firewall_interfacesFacts, + ospfv3=Ospfv3Facts, + ospfv2=Ospfv2Facts, + ospf_interfaces=Ospf_interfacesFacts, +) + + +class Facts(FactsBase): + """The fact class for vyos""" + + VALID_LEGACY_GATHER_SUBSETS = frozenset(FACT_LEGACY_SUBSETS.keys()) + VALID_RESOURCE_SUBSETS = frozenset(FACT_RESOURCE_SUBSETS.keys()) + + def __init__(self, module): + super(Facts, self).__init__(module) + + def get_facts( + self, legacy_facts_type=None, resource_facts_type=None, data=None + ): + """Collect the facts for vyos + :param legacy_facts_type: List of legacy facts types + :param resource_facts_type: List of resource fact types + :param data: previously collected conf + :rtype: dict + :return: the facts gathered + """ + if self.VALID_RESOURCE_SUBSETS: + self.get_network_resources_facts( + FACT_RESOURCE_SUBSETS, resource_facts_type, data + ) + if self.VALID_LEGACY_GATHER_SUBSETS: + self.get_network_legacy_facts( + FACT_LEGACY_SUBSETS, legacy_facts_type + ) + return self.ansible_facts, self._warnings diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_global/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_global/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_global/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py new file mode 100644 index 00000000..e6e42d70 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py @@ -0,0 +1,387 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos firewall_global fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from copy import deepcopy +from re import findall, search, M +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_global.firewall_global import ( + Firewall_globalArgs, +) + + +class Firewall_globalFacts(object): + """The vyos firewall_global fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Firewall_globalArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + return connection.get_config() + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for firewall_global + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + # typically data is populated from the current device configuration + # data = connection.get('show running-config | section ^interface') + # using mock data instead + data = self.get_device_data(connection) + objs = {} + firewalls = findall(r"^set firewall .*$", data, M) + if firewalls: + objs = self.render_config(firewalls) + facts = {} + params = utils.validate_config(self.argument_spec, {"config": objs}) + facts["firewall_global"] = utils.remove_empties(params["config"]) + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + conf = "\n".join( + filter( + lambda x: ("firewall ipv6-name" and "firewall name" not in x), + conf, + ) + ) + + a_lst = [ + "config_trap", + "validation", + "log_martians", + "syn_cookies", + "twa_hazards_protection", + ] + firewall = self.parse_attr(conf, a_lst) + f_sub = { + "ping": self.parse_ping(conf), + "group": self.parse_group(conf), + "route_redirects": self.route_redirects(conf), + "state_policy": self.parse_state_policy(conf), + } + firewall.update(f_sub) + return firewall + + def route_redirects(self, conf): + """ + This function forms the regex to fetch the afi and invoke + functions to fetch route redirects and source routes + :param conf: configuration data. + :return: generated rule list configuration. + """ + rr_lst = [] + + v6_attr = findall( + r"^set firewall (?:ipv6-src-route|ipv6-receive-redirects) (\S+)", + conf, + M, + ) + if v6_attr: + obj = self.parse_rr_attrib(conf, "ipv6") + if obj: + rr_lst.append(obj) + + v4_attr = findall( + r"^set firewall (?:ip-src-route|receive-redirects|send-redirects) (\S+)", + conf, + M, + ) + if v4_attr: + obj = self.parse_rr_attrib(conf, "ipv4") + if obj: + rr_lst.append(obj) + return rr_lst + + def parse_rr_attrib(self, conf, attrib=None): + """ + This function fetches the 'ip_src_route' + invoke function to parse icmp redirects. + :param conf: configuration to be parsed. + :param attrib: 'ipv4/ipv6'. + :return: generated config dictionary. + """ + + cfg_dict = self.parse_attr(conf, ["ip_src_route"], type=attrib) + cfg_dict["icmp_redirects"] = self.parse_icmp_redirects(conf, attrib) + cfg_dict["afi"] = attrib + return cfg_dict + + def parse_icmp_redirects(self, conf, attrib=None): + """ + This function triggers the parsing of 'icmp_redirects' attributes. + :param conf: configuration to be parsed. + :param attrib: 'ipv4/ipv6'. + :return: generated config dictionary. + """ + a_lst = ["send", "receive"] + cfg_dict = self.parse_attr(conf, a_lst, type=attrib) + return cfg_dict + + def parse_ping(self, conf): + """ + This function triggers the parsing of 'ping' attributes. + :param conf: configuration to be parsed. + :return: generated config dictionary. + """ + a_lst = ["all", "broadcast"] + cfg_dict = self.parse_attr(conf, a_lst) + return cfg_dict + + def parse_state_policy(self, conf): + """ + This function fetched the connecton type and invoke + function to parse other state-policy attributes. + :param conf: configuration data. + :return: generated rule list configuration. + """ + sp_lst = [] + attrib = "state-policy" + policies = findall(r"^set firewall " + attrib + " (\\S+)", conf, M) + + if policies: + rules_lst = [] + for sp in set(policies): + sp_regex = r" %s .+$" % sp + cfg = "\n".join(findall(sp_regex, conf, M)) + obj = self.parse_policies(cfg, sp) + obj["connection_type"] = sp + if obj: + rules_lst.append(obj) + sp_lst = sorted(rules_lst, key=lambda i: i["connection_type"]) + return sp_lst + + def parse_policies(self, conf, attrib=None): + """ + This function triggers the parsing of policy attributes + action and log. + :param conf: configuration + :param attrib: connection type. + :return: generated rule configuration dictionary. + """ + a_lst = ["action", "log"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_group(self, conf): + """ + This function triggers the parsing of 'group' attributes. + :param conf: configuration. + :return: generated config dictionary. + """ + cfg_dict = {} + cfg_dict["port_group"] = self.parse_group_lst(conf, "port-group") + cfg_dict["address_group"] = self.parse_group_lst(conf, "address-group") + cfg_dict["network_group"] = self.parse_group_lst(conf, "network-group") + return cfg_dict + + def parse_group_lst(self, conf, type): + """ + This function fetches the name of group and invoke function to + parse group attributes'. + :param conf: configuration data. + :param type: type of group. + :return: generated group list configuration. + """ + g_lst = [] + + groups = findall(r"^set firewall group " + type + " (\\S+)", conf, M) + if groups: + rules_lst = [] + for gr in set(groups): + gr_regex = r" %s .+$" % gr + cfg = "\n".join(findall(gr_regex, conf, M)) + obj = self.parse_groups(cfg, type, gr) + obj["name"] = gr.strip("'") + if obj: + rules_lst.append(obj) + g_lst = sorted(rules_lst, key=lambda i: i["name"]) + return g_lst + + def parse_groups(self, conf, type, name): + """ + This function fetches the description and invoke + the parsing of group members. + :param conf: configuration. + :param type: type of group. + :param name: name of group. + :return: generated configuration dictionary. + """ + a_lst = ["name", "description"] + group = self.parse_attr(conf, a_lst) + key = self.get_key(type) + r_sub = {key[0]: self.parse_address_port_lst(conf, name, key[1])} + group.update(r_sub) + return group + + def parse_address_port_lst(self, conf, name, key): + """ + This function forms the regex to fetch the + group members attributes. + :param conf: configuration data. + :param name: name of group. + :param key: key value. + :return: generated member list configuration. + """ + l_lst = [] + attribs = findall(r"^.*" + name + " " + key + " (\\S+)", conf, M) + if attribs: + for attr in attribs: + if key == "port": + l_lst.append({"port": attr.strip("'")}) + else: + l_lst.append({"address": attr.strip("'")}) + return l_lst + + def parse_attr(self, conf, attr_list, match=None, type=None): + """ + This function peforms the following: + - Form the regex to fetch the required attribute config. + - Type cast the output in desired format. + :param conf: configuration. + :param attr_list: list of attributes. + :param match: parent node/attribute name. + :return: generated config dictionary. + """ + config = {} + for attrib in attr_list: + regex = self.map_regex(attrib, type) + if match: + regex = match + " " + regex + if conf: + if self.is_bool(attrib): + attr = self.map_regex(attrib, type) + out = conf.find(attr.replace("_", "-")) + dis = conf.find(attr.replace("_", "-") + " 'disable'") + if out >= 1: + if dis >= 1: + config[attrib] = False + else: + config[attrib] = True + else: + out = search(r"^.*" + regex + " (.+)", conf, M) + if out: + val = out.group(1).strip("'") + if self.is_num(attrib): + val = int(val) + config[attrib] = val + return config + + def get_key(self, type): + """ + This function map the group type to + member type + :param type: + :return: + """ + key = () + if type == "port-group": + key = ("members", "port") + elif type == "address-group": + key = ("members", "address") + elif type == "network-group": + key = ("members", "network") + return key + + def map_regex(self, attrib, type=None): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + regex = attrib.replace("_", "-") + if attrib == "all": + regex = "all-ping" + elif attrib == "disabled": + regex = "disable" + elif attrib == "broadcast": + regex = "broadcast-ping" + elif attrib == "send": + if type == "ipv6": + regex = "ipv6-send-redirects" + else: + regex = "send-redirects" + elif attrib == "ip_src_route": + if type == "ipv6": + regex = "ipv6-src-route" + elif attrib == "receive": + if type == "ipv6": + regex = "ipv6-receive-redirects" + else: + regex = "receive-redirects" + return regex + + def is_num(self, attrib): + """ + This function looks for the attribute in predefined integer type set. + :param attrib: attribute. + :return: True/false. + """ + num_set = ("time", "code", "type", "count", "burst", "number") + return True if attrib in num_set else False + + def get_src_route(self, attrib): + """ + This function looks for the attribute in predefined integer type set. + :param attrib: attribute. + :return: True/false. + """ + return "ipv6_src_route" if attrib == "ipv6" else "ip_src_route" + + def is_bool(self, attrib): + """ + This function looks for the attribute in predefined bool type set. + :param attrib: attribute. + :return: True/False + """ + bool_set = ( + "all", + "log", + "send", + "receive", + "broadcast", + "config_trap", + "log_martians", + "syn_cookies", + "ip_src_route", + "twa_hazards_protection", + ) + return True if attrib in bool_set else False diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py new file mode 100644 index 00000000..d0cfb533 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py @@ -0,0 +1,195 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos firewall_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from re import findall, search, M +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_interfaces.firewall_interfaces import ( + Firewall_interfacesArgs, +) + + +class Firewall_interfacesFacts(object): + """The vyos firewall_interfaces fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Firewall_interfacesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + return connection.get_config() + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for firewall_interfaces + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + # typically data is populated from the current device configuration + # data = connection.get('show running-config | section ^interface') + # using mock data instead + data = self.get_device_data(connection) + objs = [] + interfaces = findall( + r"^set interfaces ethernet (?:\'*)(\S+)(?:\'*)", data, M + ) + if interfaces: + objs = self.get_names(data, interfaces) + ansible_facts["ansible_network_resources"].pop( + "firewall_interfaces", None + ) + facts = {} + if objs: + facts["firewall_interfaces"] = [] + params = utils.validate_config( + self.argument_spec, {"config": objs} + ) + for cfg in params["config"]: + facts["firewall_interfaces"].append(utils.remove_empties(cfg)) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def get_names(self, data, interfaces): + """ + This function performs following: + - Form regex to fetch 'interface name' from interfaces firewall data. + - Form the name list. + :param data: configuration. + :param rules: list of interfaces. + :return: generated firewall interfaces configuration. + """ + names = [] + for r in set(interfaces): + int_regex = r" %s .+$" % r.strip("'") + cfg = findall(int_regex, data, M) + fi = self.render_config(cfg) + fi["name"] = r.strip("'") + names.append(fi) + if names: + names = sorted(names, key=lambda i: i["name"]) + return names + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + conf = "\n".join(filter(lambda x: "firewall" in x, conf)) + config = {"access_rules": self.parse_access_rules(conf)} + return config + + def parse_access_rules(self, conf): + """ + This function forms the regex to fetch the 'access-rules' + for specific interface. + :param conf: configuration data. + :return: generated access-rules list configuration. + """ + ar_lst = [] + v4_ar = findall(r"^.*(in|out|local) name .*$", conf, M) + v6_ar = findall(r"^.*(in|out|local) ipv6-name .*$", conf, M) + if v4_ar: + v4_conf = "\n".join(findall(r"(^.*?%s.*?$)" % " name", conf, M)) + config = self.parse_int_rules(v4_conf, "ipv4") + if config: + ar_lst.append(config) + if v6_ar: + v6_conf = "\n".join( + findall(r"(^.*?%s.*?$)" % " ipv6-name", conf, M) + ) + config = self.parse_int_rules(v6_conf, "ipv6") + if config: + ar_lst.append(config) + if ar_lst: + ar_lst = sorted(ar_lst, key=lambda i: i["afi"]) + else: + empty_rules = findall(r"^.*(in|out|local).*", conf, M) + if empty_rules: + ar_lst.append({"afi": "ipv4", "rules": []}) + ar_lst.append({"afi": "ipv6", "rules": []}) + return ar_lst + + def parse_int_rules(self, conf, afi): + """ + This function forms the regex to fetch the 'access-rules' + for specific interface based on ip-type. + :param conf: configuration data. + :param rules: rules configured per interface. + :param afi: ip address type. + :return: generated rule configuration dictionary. + """ + r_lst = [] + config = {} + rules = ["in", "out", "local"] + for r in set(rules): + fr = {} + r_regex = r" %s .+$" % r + cfg = "\n".join(findall(r_regex, conf, M)) + if cfg: + fr = self.parse_rules(cfg, afi) + else: + out = search(r"^.*firewall " + "'" + r + "'" + "(.*)", conf, M) + if out: + fr = {"direction": r} + if fr: + r_lst.append(fr) + if r_lst: + r_lst = sorted(r_lst, key=lambda i: i["direction"]) + config = {"afi": afi, "rules": r_lst} + return config + + def parse_rules(self, conf, afi): + """ + This function triggers the parsing of 'rule' attributes. + a_lst is a list having rule attributes which doesn't + have further sub attributes. + :param conf: configuration. + :param afi: ip address type. + :return: generated rule configuration dictionary. + """ + cfg = {} + out = findall(r"[^\s]+", conf, M) + if out: + cfg["direction"] = out[0].strip("'") + if afi == "ipv6": + out = findall(r"[^\s]+ ipv6-name (?:\'*)(\S+)(?:\'*)", conf, M) + if out: + cfg["name"] = str(out[0]).strip("'") + else: + out = findall(r"[^\s]+ name (?:\'*)(\S+)(?:\'*)", conf, M) + if out: + cfg["name"] = out[-1].strip("'") + return cfg diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py new file mode 100644 index 00000000..44242929 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py @@ -0,0 +1,379 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos firewall_rules fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from re import findall, search, M +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_rules.firewall_rules import ( + Firewall_rulesArgs, +) + + +class Firewall_rulesFacts(object): + """The vyos firewall_rules fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Firewall_rulesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + return connection.get_config() + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for firewall_rules + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + # typically data is populated from the current device configuration + # data = connection.get('show running-config | section ^interface') + # using mock data instead + data = self.get_device_data(connection) + # split the config into instances of the resource + objs = [] + v6_rules = findall( + r"^set firewall ipv6-name (?:\'*)(\S+)(?:\'*)", data, M + ) + v4_rules = findall(r"^set firewall name (?:\'*)(\S+)(?:\'*)", data, M) + if v6_rules: + config = self.get_rules(data, v6_rules, type="ipv6") + if config: + config = utils.remove_empties(config) + objs.append(config) + if v4_rules: + config = self.get_rules(data, v4_rules, type="ipv4") + if config: + config = utils.remove_empties(config) + objs.append(config) + + ansible_facts["ansible_network_resources"].pop("firewall_rules", None) + facts = {} + if objs: + facts["firewall_rules"] = [] + params = utils.validate_config( + self.argument_spec, {"config": objs} + ) + for cfg in params["config"]: + facts["firewall_rules"].append(utils.remove_empties(cfg)) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def get_rules(self, data, rules, type): + """ + This function performs following: + - Form regex to fetch 'rule-sets' specific config from data. + - Form the rule-set list based on ip address. + :param data: configuration. + :param rules: list of rule-sets. + :param type: ip address type. + :return: generated rule-sets configuration. + """ + r_v4 = [] + r_v6 = [] + for r in set(rules): + rule_regex = r" %s .+$" % r.strip("'") + cfg = findall(rule_regex, data, M) + fr = self.render_config(cfg, r.strip("'")) + fr["name"] = r.strip("'") + if type == "ipv6": + r_v6.append(fr) + else: + r_v4.append(fr) + if r_v4: + config = {"afi": "ipv4", "rule_sets": r_v4} + if r_v6: + config = {"afi": "ipv6", "rule_sets": r_v6} + return config + + def render_config(self, conf, match): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + conf = "\n".join(filter(lambda x: x, conf)) + a_lst = ["description", "default_action", "enable_default_log"] + config = self.parse_attr(conf, a_lst, match) + if not config: + config = {} + config["rules"] = self.parse_rules_lst(conf) + return config + + def parse_rules_lst(self, conf): + """ + This function forms the regex to fetch the 'rules' with in + 'rule-sets' + :param conf: configuration data. + :return: generated rule list configuration. + """ + r_lst = [] + rules = findall(r"rule (?:\'*)(\d+)(?:\'*)", conf, M) + if rules: + rules_lst = [] + for r in set(rules): + r_regex = r" %s .+$" % r + cfg = "\n".join(findall(r_regex, conf, M)) + obj = self.parse_rules(cfg) + obj["number"] = int(r) + if obj: + rules_lst.append(obj) + r_lst = sorted(rules_lst, key=lambda i: i["number"]) + return r_lst + + def parse_rules(self, conf): + """ + This function triggers the parsing of 'rule' attributes. + a_lst is a list having rule attributes which doesn't + have further sub attributes. + :param conf: configuration + :return: generated rule configuration dictionary. + """ + a_lst = [ + "ipsec", + "action", + "protocol", + "fragment", + "disabled", + "description", + ] + rule = self.parse_attr(conf, a_lst) + r_sub = { + "p2p": self.parse_p2p(conf), + "tcp": self.parse_tcp(conf, "tcp"), + "icmp": self.parse_icmp(conf, "icmp"), + "time": self.parse_time(conf, "time"), + "limit": self.parse_limit(conf, "limit"), + "state": self.parse_state(conf, "state"), + "recent": self.parse_recent(conf, "recent"), + "source": self.parse_src_or_dest(conf, "source"), + "destination": self.parse_src_or_dest(conf, "destination"), + } + rule.update(r_sub) + return rule + + def parse_p2p(self, conf): + """ + This function forms the regex to fetch the 'p2p' with in + 'rules' + :param conf: configuration data. + :return: generated rule list configuration. + """ + a_lst = [] + applications = findall(r"p2p (?:\'*)(\d+)(?:\'*)", conf, M) + if applications: + app_lst = [] + for r in set(applications): + obj = {"application": r.strip("'")} + app_lst.append(obj) + a_lst = sorted(app_lst, key=lambda i: i["application"]) + return a_lst + + def parse_src_or_dest(self, conf, attrib=None): + """ + This function triggers the parsing of 'source or + destination' attributes. + :param conf: configuration. + :param attrib:'source/destination'. + :return:generated source/destination configuration dictionary. + """ + a_lst = ["port", "address", "mac_address"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + cfg_dict["group"] = self.parse_group(conf, attrib + " group") + return cfg_dict + + def parse_recent(self, conf, attrib=None): + """ + This function triggers the parsing of 'recent' attributes + :param conf: configuration. + :param attrib: 'recent'. + :return: generated config dictionary. + """ + a_lst = ["time", "count"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_tcp(self, conf, attrib=None): + """ + This function triggers the parsing of 'tcp' attributes. + :param conf: configuration. + :param attrib: 'tcp'. + :return: generated config dictionary. + """ + cfg_dict = self.parse_attr(conf, ["flags"], match=attrib) + return cfg_dict + + def parse_time(self, conf, attrib=None): + """ + This function triggers the parsing of 'time' attributes. + :param conf: configuration. + :param attrib: 'time'. + :return: generated config dictionary. + """ + a_lst = [ + "stopdate", + "stoptime", + "weekdays", + "monthdays", + "startdate", + "starttime", + ] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_state(self, conf, attrib=None): + """ + This function triggers the parsing of 'state' attributes. + :param conf: configuration + :param attrib: 'state'. + :return: generated config dictionary. + """ + a_lst = ["new", "invalid", "related", "established"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_group(self, conf, attrib=None): + """ + This function triggers the parsing of 'group' attributes. + :param conf: configuration. + :param attrib: 'group'. + :return: generated config dictionary. + """ + a_lst = ["port_group", "address_group", "network_group"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_icmp(self, conf, attrib=None): + """ + This function triggers the parsing of 'icmp' attributes. + :param conf: configuration to be parsed. + :param attrib: 'icmp'. + :return: generated config dictionary. + """ + a_lst = ["code", "type", "type_name"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_limit(self, conf, attrib=None): + """ + This function triggers the parsing of 'limit' attributes. + :param conf: configuration to be parsed. + :param attrib: 'limit' + :return: generated config dictionary. + """ + cfg_dict = self.parse_attr(conf, ["burst"], match=attrib) + cfg_dict["rate"] = self.parse_rate(conf, "rate") + return cfg_dict + + def parse_rate(self, conf, attrib=None): + """ + This function triggers the parsing of 'rate' attributes. + :param conf: configuration. + :param attrib: 'rate' + :return: generated config dictionary. + """ + a_lst = ["unit", "number"] + cfg_dict = self.parse_attr(conf, a_lst, match=attrib) + return cfg_dict + + def parse_attr(self, conf, attr_list, match=None): + """ + This function peforms the following: + - Form the regex to fetch the required attribute config. + - Type cast the output in desired format. + :param conf: configuration. + :param attr_list: list of attributes. + :param match: parent node/attribute name. + :return: generated config dictionary. + """ + config = {} + for attrib in attr_list: + regex = self.map_regex(attrib) + if match: + regex = match + " " + regex + if conf: + if self.is_bool(attrib): + out = conf.find(attrib.replace("_", "-")) + + dis = conf.find(attrib.replace("_", "-") + " 'disable'") + if out >= 1: + if dis >= 1: + config[attrib] = False + else: + config[attrib] = True + else: + out = search(r"^.*" + regex + " (.+)", conf, M) + if out: + val = out.group(1).strip("'") + if self.is_num(attrib): + val = int(val) + config[attrib] = val + return config + + def map_regex(self, attrib): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + regex = attrib.replace("_", "-") + if attrib == "disabled": + regex = "disable" + return regex + + def is_bool(self, attrib): + """ + This function looks for the attribute in predefined bool type set. + :param attrib: attribute. + :return: True/False + """ + bool_set = ( + "new", + "invalid", + "related", + "disabled", + "established", + "enable_default_log", + ) + return True if attrib in bool_set else False + + def is_num(self, attrib): + """ + This function looks for the attribute in predefined integer type set. + :param attrib: attribute. + :return: True/false. + """ + num_set = ("time", "code", "type", "count", "burst", "number") + return True if attrib in num_set else False diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py new file mode 100644 index 00000000..13f22e1b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py @@ -0,0 +1,138 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +from re import findall, M +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.interfaces.interfaces import ( + InterfacesArgs, +) + + +class InterfacesFacts(object): + """The vyos interfaces fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = InterfacesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + + data = connection.get_config(flags=["| grep interfaces"]) + return data + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for interfaces + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = self.get_device_data(connection) + + objs = [] + interface_names = findall( + r"^set interfaces (?:ethernet|bonding|vti|loopback|vxlan|openvpn) (?:\'*)(\S+)(?:\'*)", + data, + M, + ) + if interface_names: + for interface in set(interface_names): + intf_regex = r" %s .+$" % interface.strip("'") + cfg = findall(intf_regex, data, M) + obj = self.render_config(cfg) + obj["name"] = interface.strip("'") + if obj: + objs.append(obj) + facts = {} + if objs: + facts["interfaces"] = [] + params = utils.validate_config( + self.argument_spec, {"config": objs} + ) + for cfg in params["config"]: + facts["interfaces"].append(utils.remove_empties(cfg)) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + vif_conf = "\n".join(filter(lambda x: ("vif" in x), conf)) + eth_conf = "\n".join(filter(lambda x: ("vif" not in x), conf)) + config = self.parse_attribs( + ["description", "speed", "mtu", "duplex"], eth_conf + ) + config["vifs"] = self.parse_vifs(vif_conf) + + return utils.remove_empties(config) + + def parse_vifs(self, conf): + vif_names = findall(r"vif (?:\'*)(\d+)(?:\'*)", conf, M) + vifs_list = None + + if vif_names: + vifs_list = [] + for vif in set(vif_names): + vif_regex = r" %s .+$" % vif + cfg = "\n".join(findall(vif_regex, conf, M)) + obj = self.parse_attribs(["description", "mtu"], cfg) + obj["vlan_id"] = int(vif) + if obj: + vifs_list.append(obj) + vifs_list = sorted(vifs_list, key=lambda i: i["vlan_id"]) + + return vifs_list + + def parse_attribs(self, attribs, conf): + config = {} + for item in attribs: + value = utils.parse_conf_arg(conf, item) + if value and item == "mtu": + config[item] = int(value.strip("'")) + elif value: + config[item] = value.strip("'") + else: + config[item] = None + if "disable" in conf: + config["enabled"] = False + else: + config["enabled"] = True + + return utils.remove_empties(config) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py new file mode 100644 index 00000000..09ab994c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py @@ -0,0 +1,142 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos l3_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +import re +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + get_ip_address_version, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.l3_interfaces.l3_interfaces import ( + L3_interfacesArgs, +) + + +class L3_interfacesFacts(object): + """The vyos l3_interfaces fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = L3_interfacesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for l3_interfaces + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = connection.get_config() + + # operate on a collection of resource x + objs = [] + interface_names = re.findall( + r"set interfaces (?:ethernet|bonding|vti|vxlan) (?:\'*)(\S+)(?:\'*)", + data, + re.M, + ) + if interface_names: + for interface in set(interface_names): + intf_regex = r" %s .+$" % interface + cfg = re.findall(intf_regex, data, re.M) + obj = self.render_config(cfg) + obj["name"] = interface.strip("'") + if obj: + objs.append(obj) + + ansible_facts["ansible_network_resources"].pop("l3_interfaces", None) + facts = {} + if objs: + facts["l3_interfaces"] = [] + params = utils.validate_config( + self.argument_spec, {"config": objs} + ) + for cfg in params["config"]: + facts["l3_interfaces"].append(utils.remove_empties(cfg)) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys from spec for null values + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + vif_conf = "\n".join(filter(lambda x: ("vif" in x), conf)) + eth_conf = "\n".join(filter(lambda x: ("vif" not in x), conf)) + config = self.parse_attribs(eth_conf) + config["vifs"] = self.parse_vifs(vif_conf) + + return utils.remove_empties(config) + + def parse_vifs(self, conf): + vif_names = re.findall(r"vif (\d+)", conf, re.M) + vifs_list = None + if vif_names: + vifs_list = [] + for vif in set(vif_names): + vif_regex = r" %s .+$" % vif + cfg = "\n".join(re.findall(vif_regex, conf, re.M)) + obj = self.parse_attribs(cfg) + obj["vlan_id"] = vif + if obj: + vifs_list.append(obj) + + return vifs_list + + def parse_attribs(self, conf): + config = {} + ipaddrs = re.findall(r"address (\S+)", conf, re.M) + config["ipv4"] = [] + config["ipv6"] = [] + + for item in ipaddrs: + item = item.strip("'") + if item == "dhcp": + config["ipv4"].append({"address": item}) + elif item == "dhcpv6": + config["ipv6"].append({"address": item}) + else: + ip_version = get_ip_address_version(item.split("/")[0]) + if ip_version == 4: + config["ipv4"].append({"address": item}) + else: + config["ipv6"].append({"address": item}) + + for key, value in iteritems(config): + if value == []: + config[key] = None + + return utils.remove_empties(config) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py new file mode 100644 index 00000000..ff02cb03 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py @@ -0,0 +1,143 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos lag_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from re import findall, search, M +from copy import deepcopy + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.lag_interfaces.lag_interfaces import ( + Lag_interfacesArgs, +) + + +class Lag_interfacesFacts(object): + """The vyos lag_interfaces fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Lag_interfacesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for lag_interfaces + :param module: the module instance + :param connection: the device connection + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = connection.get_config() + + objs = [] + lag_names = findall(r"^set interfaces bonding (\S+)", data, M) + if lag_names: + for lag in set(lag_names): + lag_regex = r" %s .+$" % lag + cfg = findall(lag_regex, data, M) + obj = self.render_config(cfg) + members = [] + member = {} + + group_regex = r".*eth.* '%s'" % lag + g_cfg = findall(group_regex, data, M) + for item in g_cfg: + output = search("^set interfaces ethernet (\\S+)", item, M) + if output: + member["member"] = output.group(1).strip("'") + members.append(member) + obj["name"] = lag.strip("'") + if members: + obj["members"] = members + if obj: + objs.append(obj) + facts = {} + if objs: + facts["lag_interfaces"] = [] + params = utils.validate_config( + self.argument_spec, {"config": objs} + ) + for cfg in params["config"]: + facts["lag_interfaces"].append(utils.remove_empties(cfg)) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + arp_monitor_conf = "\n".join( + filter(lambda x: ("arp-monitor" in x), conf) + ) + hash_policy_conf = "\n".join( + filter(lambda x: ("hash-policy" in x), conf) + ) + lag_conf = "\n".join(filter(lambda x: ("bond" in x), conf)) + config = self.parse_attribs(["mode", "primary"], lag_conf) + config["arp_monitor"] = self.parse_arp_monitor(arp_monitor_conf) + config["hash_policy"] = self.parse_hash_policy(hash_policy_conf) + + return utils.remove_empties(config) + + def parse_attribs(self, attribs, conf): + config = {} + for item in attribs: + value = utils.parse_conf_arg(conf, item) + if value: + config[item] = value.strip("'") + else: + config[item] = None + return utils.remove_empties(config) + + def parse_arp_monitor(self, conf): + arp_monitor = None + if conf: + arp_monitor = {} + target_list = [] + interval = search(r"^.*arp-monitor interval (.+)", conf, M) + targets = findall(r"^.*arp-monitor target '(.+)'", conf, M) + if targets: + for target in targets: + target_list.append(target) + arp_monitor["target"] = target_list + if interval: + value = interval.group(1).strip("'") + arp_monitor["interval"] = int(value) + return arp_monitor + + def parse_hash_policy(self, conf): + hash_policy = None + if conf: + hash_policy = search(r"^.*hash-policy (.+)", conf, M) + hash_policy = hash_policy.group(1).strip("'") + return hash_policy diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py new file mode 100644 index 00000000..a4934217 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py @@ -0,0 +1,162 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The VyOS interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import platform +import re +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + run_commands, + get_capabilities, +) + + +class LegacyFactsBase(object): + + COMMANDS = frozenset() + + def __init__(self, module): + self.module = module + self.facts = dict() + self.warnings = list() + self.responses = None + + def populate(self): + self.responses = run_commands(self.module, list(self.COMMANDS)) + + +class Default(LegacyFactsBase): + + COMMANDS = [ + "show version", + ] + + def populate(self): + super(Default, self).populate() + data = self.responses[0] + self.facts["serialnum"] = self.parse_serialnum(data) + self.facts.update(self.platform_facts()) + + def parse_serialnum(self, data): + match = re.search(r"HW S/N:\s+(\S+)", data) + if match: + return match.group(1) + + def platform_facts(self): + platform_facts = {} + + resp = get_capabilities(self.module) + device_info = resp["device_info"] + + platform_facts["system"] = device_info["network_os"] + + for item in ("model", "image", "version", "platform", "hostname"): + val = device_info.get("network_os_%s" % item) + if val: + platform_facts[item] = val + + platform_facts["api"] = resp["network_api"] + platform_facts["python_version"] = platform.python_version() + + return platform_facts + + +class Config(LegacyFactsBase): + + COMMANDS = [ + "show configuration commands", + "show system commit", + ] + + def populate(self): + super(Config, self).populate() + + self.facts["config"] = self.responses + + commits = self.responses[1] + entries = list() + entry = None + + for line in commits.split("\n"): + match = re.match(r"(\d+)\s+(.+)by(.+)via(.+)", line) + if match: + if entry: + entries.append(entry) + + entry = dict( + revision=match.group(1), + datetime=match.group(2), + by=str(match.group(3)).strip(), + via=str(match.group(4)).strip(), + comment=None, + ) + else: + entry["comment"] = line.strip() + + self.facts["commits"] = entries + + +class Neighbors(LegacyFactsBase): + + COMMANDS = [ + "show lldp neighbors", + "show lldp neighbors detail", + ] + + def populate(self): + super(Neighbors, self).populate() + + all_neighbors = self.responses[0] + if "LLDP not configured" not in all_neighbors: + neighbors = self.parse(self.responses[1]) + self.facts["neighbors"] = self.parse_neighbors(neighbors) + + def parse(self, data): + parsed = list() + values = None + for line in data.split("\n"): + if not line: + continue + if line[0] == " ": + values += "\n%s" % line + elif line.startswith("Interface"): + if values: + parsed.append(values) + values = line + if values: + parsed.append(values) + return parsed + + def parse_neighbors(self, data): + facts = dict() + for item in data: + interface = self.parse_interface(item) + host = self.parse_host(item) + port = self.parse_port(item) + if interface not in facts: + facts[interface] = list() + facts[interface].append(dict(host=host, port=port)) + return facts + + def parse_interface(self, data): + match = re.search(r"^Interface:\s+(\S+),", data) + return match.group(1) + + def parse_host(self, data): + match = re.search(r"SysName:\s+(.+)$", data, re.M) + if match: + return match.group(1) + + def parse_port(self, data): + match = re.search(r"PortDescr:\s+(.+)$", data, re.M) + if match: + return match.group(1) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py new file mode 100644 index 00000000..22b6bc86 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py @@ -0,0 +1,115 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos lldp_global fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from re import findall, M +from copy import deepcopy + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.lldp_global.lldp_global import ( + Lldp_globalArgs, +) + + +class Lldp_globalFacts(object): + """The vyos lldp_global fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Lldp_globalArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for lldp_global + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = connection.get_config() + + objs = {} + lldp_output = findall(r"^set service lldp (\S+)", data, M) + if lldp_output: + for item in set(lldp_output): + lldp_regex = r" %s .+$" % item + cfg = findall(lldp_regex, data, M) + obj = self.render_config(cfg) + if obj: + objs.update(obj) + lldp_service = findall(r"^set service (lldp)?('lldp')", data, M) + if lldp_service or lldp_output: + lldp_obj = {} + lldp_obj["enable"] = True + objs.update(lldp_obj) + + facts = {} + params = utils.validate_config(self.argument_spec, {"config": objs}) + facts["lldp_global"] = utils.remove_empties(params["config"]) + + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + protocol_conf = "\n".join( + filter(lambda x: ("legacy-protocols" in x), conf) + ) + att_conf = "\n".join( + filter(lambda x: ("legacy-protocols" not in x), conf) + ) + config = self.parse_attribs(["snmp", "address"], att_conf) + config["legacy_protocols"] = self.parse_protocols(protocol_conf) + return utils.remove_empties(config) + + def parse_protocols(self, conf): + protocol_support = None + if conf: + protocols = findall(r"^.*legacy-protocols (.+)", conf, M) + if protocols: + protocol_support = [] + for protocol in protocols: + protocol_support.append(protocol.strip("'")) + return protocol_support + + def parse_attribs(self, attribs, conf): + config = {} + for item in attribs: + value = utils.parse_conf_arg(conf, item) + if value: + config[item] = value.strip("'") + else: + config[item] = None + return utils.remove_empties(config) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py new file mode 100644 index 00000000..64d6a793 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py @@ -0,0 +1,154 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos lldp_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +from re import findall, search, M +from copy import deepcopy + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.lldp_interfaces.lldp_interfaces import ( + Lldp_interfacesArgs, +) + + +class Lldp_interfacesFacts(object): + """The vyos lldp_interfaces fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Lldp_interfacesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for lldp_interfaces + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = connection.get_config() + + objs = [] + lldp_names = findall(r"^set service lldp interface (\S+)", data, M) + if lldp_names: + for lldp in set(lldp_names): + lldp_regex = r" %s .+$" % lldp + cfg = findall(lldp_regex, data, M) + obj = self.render_config(cfg) + obj["name"] = lldp.strip("'") + if obj: + objs.append(obj) + facts = {} + if objs: + facts["lldp_interfaces"] = objs + ansible_facts["ansible_network_resources"].update(facts) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + config = {} + location = {} + + civic_conf = "\n".join(filter(lambda x: ("civic-based" in x), conf)) + elin_conf = "\n".join(filter(lambda x: ("elin" in x), conf)) + coordinate_conf = "\n".join( + filter(lambda x: ("coordinate-based" in x), conf) + ) + disable = "\n".join(filter(lambda x: ("disable" in x), conf)) + + coordinate_based_conf = self.parse_attribs( + ["altitude", "datum", "longitude", "latitude"], coordinate_conf + ) + elin_based_conf = self.parse_lldp_elin_based(elin_conf) + civic_based_conf = self.parse_lldp_civic_based(civic_conf) + if disable: + config["enable"] = False + if coordinate_conf: + location["coordinate_based"] = coordinate_based_conf + config["location"] = location + elif civic_based_conf: + location["civic_based"] = civic_based_conf + config["location"] = location + elif elin_conf: + location["elin"] = elin_based_conf + config["location"] = location + + return utils.remove_empties(config) + + def parse_attribs(self, attribs, conf): + config = {} + for item in attribs: + value = utils.parse_conf_arg(conf, item) + if value: + value = value.strip("'") + if item == "altitude": + value = int(value) + config[item] = value + else: + config[item] = None + return utils.remove_empties(config) + + def parse_lldp_civic_based(self, conf): + civic_based = None + if conf: + civic_info_list = [] + civic_add_list = findall(r"^.*civic-based ca-type (.+)", conf, M) + if civic_add_list: + for civic_add in civic_add_list: + ca = civic_add.split(" ") + c_add = {} + c_add["ca_type"] = int(ca[0].strip("'")) + c_add["ca_value"] = ca[2].strip("'") + civic_info_list.append(c_add) + + country_code = search( + r"^.*civic-based country-code (.+)", conf, M + ) + civic_based = {} + civic_based["ca_info"] = civic_info_list + civic_based["country_code"] = country_code.group(1).strip("'") + return civic_based + + def parse_lldp_elin_based(self, conf): + elin_based = None + if conf: + e_num = search(r"^.* elin (.+)", conf, M) + elin_based = e_num.group(1).strip("'") + + return elin_based diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospf_interfaces/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospf_interfaces/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospf_interfaces/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py new file mode 100644 index 00000000..15ac92a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +""" +The vyos ospf_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.rm_templates.ospf_interfaces import ( + Ospf_interfacesTemplate, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospf_interfaces.ospf_interfaces import ( + Ospf_interfacesArgs, +) + + +class Ospf_interfacesFacts(object): + """The vyos ospf_interfaces facts class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Ospf_interfacesArgs.argument_spec + + def get_device_data(self, connection): + return connection.get( + 'show configuration commands | match "set interfaces"' + ) + + def get_config_set(self, data): + """ To classify the configurations beased on interface """ + interface_list = [] + config_set = [] + int_string = "" + for config_line in data.splitlines(): + ospf_int = re.search(r"set interfaces \S+ (\S+) .*", config_line) + if ospf_int: + if ospf_int.group(1) not in interface_list: + if int_string: + config_set.append(int_string) + interface_list.append(ospf_int.group(1)) + int_string = "" + int_string = int_string + config_line + "\n" + if int_string: + config_set.append(int_string) + return config_set + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for Ospf_interfaces network resource + + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + + :rtype: dictionary + :returns: facts + """ + facts = {} + objs = [] + + if not data: + data = self.get_device_data(connection) + + # parse native config using the Ospf_interfaces template + ospf_interfaces_facts = [] + resources = self.get_config_set(data) + for resource in resources: + ospf_interfaces_parser = Ospf_interfacesTemplate( + lines=resource.split("\n") + ) + objs = ospf_interfaces_parser.parse() + for key, sortv in [("address_family", "afi")]: + if key in objs and objs[key]: + objs[key] = list(objs[key].values()) + ospf_interfaces_facts.append(objs) + + ansible_facts["ansible_network_resources"].pop("ospf_interfaces", None) + facts = {"ospf_interfaces": []} + params = utils.remove_empties( + utils.validate_config( + self.argument_spec, {"config": ospf_interfaces_facts} + ) + ) + if params.get("config"): + for cfg in params["config"]: + facts["ospf_interfaces"].append(utils.remove_empties(cfg)) + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv2/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv2/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv2/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py new file mode 100644 index 00000000..b0c9df2a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py @@ -0,0 +1,501 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos ospfv2 fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from re import findall, search, M +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) + +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospfv2.ospfv2 import ( + Ospfv2Args, +) + + +class Ospfv2Facts(object): + + """The vyos ospfv2 fact class""" + + def __init__( + self, + module, + subspec="config", + options="options", + ): + + self._module = module + self.argument_spec = Ospfv2Args.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + return connection.get_config() + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for ospfv2 + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + + if not data: + data = self.get_device_data(connection) + + # typically data is populated from the current device configuration + # data = connection.get('show running-config | section ^interface') + # using mock data instead + + objs = {} + ospfv2 = findall(r"^set protocols ospf (.+)", data, M) + if ospfv2: + objs = self.render_config(ospfv2) + facts = {} + params = utils.validate_config(self.argument_spec, {"config": objs}) + facts["ospfv2"] = utils.remove_empties(params["config"]) + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure + + :param conf: The configuration + :returns: The generated config + """ + + conf = "\n".join(filter(lambda x: x, conf)) + a_lst = ["default_metric", "log_adjacency_changes"] + config = self.parse_attr(conf, a_lst) + + if not config: + config = {} + config["timers"] = self.parse_timers(conf) + config["auto_cost"] = self.parse_auto_cost(conf) + config["distance"] = self.parse_distance(conf) + config["max_metric"] = self.parse_max_metric(conf) + config["default_information"] = self.parse_def_info(conf) + config["route_map"] = self.parse_leaf_list(conf, "route-map") + config["mpls_te"] = self.parse_attrib(conf, "mpls_te", "mpls-te") + config["areas"] = self.parse_attrib_list(conf, "area", "area_id") + config["parameters"] = self.parse_attrib( + conf, "parameters", "parameters" + ) + config["neighbor"] = self.parse_attrib_list( + conf, "neighbor", "neighbor_id" + ) + config["passive_interface"] = self.parse_leaf_list( + conf, "passive-interface" + ) + config["redistribute"] = self.parse_attrib_list( + conf, "redistribute", "route_type" + ) + config["passive_interface_exclude"] = self.parse_leaf_list( + conf, "passive-interface-exclude" + ) + return config + + def parse_timers(self, conf): + """ + This function triggers the parsing of 'timers' attributes + :param conf: configuration + :return: generated config dictionary + """ + + cfg_dict = {} + cfg_dict["refresh"] = self.parse_refresh(conf, "refresh") + cfg_dict["throttle"] = self.parse_throttle(conf, "spf") + return cfg_dict + + def parse_throttle(self, conf, attrib=None): + """ + This function triggers the parsing of 'throttle' attributes + :param conf: configuration + :param attrib: 'spf' + :return: generated config dictionary + """ + + cfg_dict = {} + cfg_dict[attrib] = self.parse_attrib(conf, attrib, match=attrib) + return cfg_dict + + def parse_refresh(self, conf, attrib=None): + """ + This function triggers the parsing of 'refresh' attributes + :param conf: configuration + :param attrib: 'refresh' + :return: generated config dictionary + """ + + cfg_dict = self.parse_attr(conf, ["timers"], match=attrib) + return cfg_dict + + def parse_leaf_list(self, conf, attrib): + """ + This function forms the regex to fetch the listed attributes + from the configuration data + :param conf: configuration data + :param attrib: attribute name + :return: generated rule list configuration + """ + + lst = [] + items = findall(r"^" + attrib + " (?:'*)(\\S+)(?:'*)", conf, M) + if items: + for i in set(items): + lst.append(i.strip("'")) + lst.sort() + return lst + + def parse_distance(self, conf, attrib=None): + """ + This function triggers the parsing of 'distance' attributes + :param conf: configuration + :param attrib: attribute name + :return: generated config dictionary + """ + + cfg_dict = self.parse_attr(conf, ["global"], match=attrib) + cfg_dict["ospf"] = self.parse_ospf(conf, "ospf") + return cfg_dict + + def parse_ospf(self, conf, attrib=None): + """ + This function triggers the parsing of 'distance ospf' attributes + :param conf: configuration + :param attrib: 'ospf' + :return: generated config dictionary + """ + + cfg_dict = self.parse_attrib(conf, "ospf", match=attrib) + return cfg_dict + + def parse_max_metric(self, conf): + """ + This function triggers the parsing of 'max_metric' attributes + :param conf: configuration + :return: generated config dictionary + """ + + cfg_dict = {} + cfg_dict["router_lsa"] = self.parse_attrib( + conf, "router_lsa", match="router-lsa" + ) + return cfg_dict + + def parse_auto_cost(self, conf, attrib=None): + """ + This function triggers the parsing of 'auto_cost' attributes + :param conf: configuration + :param attrib: attribute name + :return: generated config dictionary + """ + + cfg_dict = self.parse_attr(conf, ["reference_bandwidth"], match=attrib) + return cfg_dict + + def parse_def_info(self, conf): + """ + This function triggers the parsing of 'default_information' attributes + :param conf: configuration + :return: generated config dictionary + """ + + cfg_dict = {} + cfg_dict["originate"] = self.parse_attrib( + conf, "originate", "originate" + ) + return cfg_dict + + def parse_area(self, conf, area_id): + """ + This function triggers the parsing of 'area' attributes. + :param conf: configuration data + :param area_id: area identity + :return: generated rule configuration dictionary. + """ + + rule = self.parse_attrib(conf, "area_id", match=area_id) + r_sub = { + "area_type": self.parse_area_type(conf, "area-type"), + "network": self.parse_network(conf), + "range": self.parse_attrib_list(conf, "range", "address"), + "virtual_link": self.parse_attrib_list( + conf, "virtual-link", "address" + ), + } + rule.update(r_sub) + return rule + + def parse_key(self, conf, key_id): + """ + This function triggers the parsing of 'area' attributes. + :param conf: configuration data + :param area_id: area identity + :return: generated rule configuration dictionary. + """ + + rule = self.parse_attrib(conf, "key_id", match=key_id) + return rule + + def parse_area_type(self, conf, attrib=None): + """ + This function triggers the parsing of 'area_type' attributes + :param conf: configuration + :param attrib: 'area-type' + :return: generated config dictionary + """ + + cfg_dict = self.parse_attr(conf, ["normal"], match=attrib) + cfg_dict["nssa"] = self.parse_attrib(conf, "nssa", match="nssa") + cfg_dict["stub"] = self.parse_attrib(conf, "stub", match="stub") + return cfg_dict + + def parse_network(self, conf): + """ + This function forms the regex to fetch the 'network' + :param conf: configuration data + :return: generated rule list configuration + """ + + a_lst = [] + applications = findall(r"network (.+)", conf, M) + if applications: + app_lst = [] + for r in set(applications): + obj = {"address": r.strip("'")} + app_lst.append(obj) + a_lst = sorted(app_lst, key=lambda i: i["address"]) + return a_lst + + def parse_vlink(self, conf): + """ + This function triggers the parsing of 'virtual_link' attributes + :param conf: configuration data + :return: generated rule configuration dictionary + """ + + rule = self.parse_attrib(conf, "vlink") + r_sub = { + "authentication": self.parse_authentication(conf, "authentication") + } + rule.update(r_sub) + return rule + + def parse_authentication(self, conf, attrib=None): + """ + This function triggers the parsing of 'authentication' attributes. + :param conf: configuration + :param attrib: 'authentication' + :return: generated config dictionary + """ + + cfg_dict = self.parse_attr(conf, ["plaintext_password"], match=attrib) + cfg_dict["md5"] = self.parse_attrib_list(conf, "key-id", "key_id") + return cfg_dict + + def parse_attrib_list(self, conf, attrib, param): + """ + This function forms the regex to fetch the listed attributes + from config + :param conf: configuration data + :param attrib: attribute name + :param param: parameter data + :return: generated rule list configuration + """ + + r_lst = [] + if attrib == "area": + items = findall( + r"^" + attrib.replace("_", "-") + " (?:'*)(\\S+)(?:'*)", + conf, + M, + ) + elif attrib == "key-id": + items = findall( + r"^.*" + attrib.replace("_", "-") + " (?:'*)(\\S+)(?:'*)", + conf, + M, + ) + else: + items = findall(r"" + attrib + " (?:'*)(\\S+)(?:'*)", conf, M) + if items: + a_lst = [] + for item in set(items): + i_regex = r" %s .+$" % item + cfg = "\n".join(findall(i_regex, conf, M)) + if attrib == "area": + obj = self.parse_area(cfg, item) + elif attrib == "virtual-link": + obj = self.parse_vlink(cfg) + elif attrib == "key-id": + obj = self.parse_key(cfg, item) + else: + obj = self.parse_attrib(cfg, attrib) + obj[param] = item.strip("'") + if obj: + a_lst.append(obj) + r_lst = sorted(a_lst, key=lambda i: i[param]) + return r_lst + + def parse_attrib(self, conf, param, match=None): + """ + This function triggers the parsing of 'ospf' attributes + :param conf: configuration data + :return: generated configuration dictionary + """ + + param_lst = { + "key_id": ["md5_key"], + "mpls_te": ["enabled", "router_address"], + "area_id": ["shortcut", "authentication"], + "neighbor": ["priority", "poll_interval"], + "stub": ["set", "default_cost", "no_summary"], + "range": ["cost", "substitute", "not_advertise"], + "ospf": ["external", "inter_area", "intra_area"], + "spf": ["delay", "max_holdtime", "initial_holdtime"], + "redistribute": ["metric", "metric_type", "route_map"], + "nssa": ["set", "translate", "default_cost", "no_summary"], + "config_routes": ["default_metric", "log_adjacency_changes"], + "originate": ["always", "metric", "metric_type", "route_map"], + "router_lsa": ["administrative", "on_shutdown", "on_startup"], + "parameters": [ + "abr_type", + "opaque_lsa", + "router_id", + "rfc1583_compatibility", + ], + "vlink": [ + "dead_interval", + "hello_interval", + "transmit_delay", + "retransmit_interval", + ], + } + cfg_dict = self.parse_attr(conf, param_lst[param], match) + return cfg_dict + + def parse_attr(self, conf, attr_list, match=None): + """ + This function peforms the following: + - Form the regex to fetch the required attribute config. + - Type cast the output in desired format. + :param conf: configuration. + :param attr_list: list of attributes. + :param match: parent node/attribute name. + :return: generated config dictionary. + """ + + config = {} + for attrib in attr_list: + regex = self.map_regex(attrib) + + if match: + regex = match.replace("_", "-") + " " + regex + if conf: + if self.is_bool(attrib): + out = conf.find(attrib.replace("_", "-")) + dis = conf.find(attrib.replace("_", "-") + " 'disable'") + if match: + if attrib == "set" and conf.find(match) >= 1: + config[attrib] = True + en = conf.find(match + " 'enable'") + if out >= 1: + if dis >= 1: + config[attrib] = False + else: + config[attrib] = True + elif match and en >= 1: + config[attrib] = True + else: + out = search(r"^.*" + regex + " (.+)", conf, M) + if out: + val = out.group(1).strip("'") + if self.is_num(attrib): + val = int(val) + config[attrib] = val + return config + + def map_regex(self, attrib): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + + return ( + "disable" + if attrib == "disabled" + else ( + "enable" + if attrib == "enabled" + else ( + "area" if attrib == "area_id" else attrib.replace("_", "-") + ) + ) + ) + + def is_bool(self, attrib): + """ + This function looks for the attribute in predefined bool type set. + :param attrib: attribute. + :return: True/False + """ + + bool_set = ( + "set", + "always", + "normal", + "enabled", + "opaque_lsa", + "not_advertise", + "administrative", + "rfc1583_compatibility", + ) + return True if attrib in bool_set else False + + def is_num(self, attrib): + """ + This function looks for the attribute in predefined integer type set. + :param attrib: attribute. + :return: True/false. + """ + + num_set = ( + "ospf", + "delay", + "metric", + "inter_area", + "intra_area", + "on_startup", + "metric_type", + "on_shutdown", + "max_holdtime", + "poll_interval", + "default_metric", + "initial_holdtime", + "key_id", + ) + return True if attrib in num_set else False diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv3/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv3/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv3/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py new file mode 100644 index 00000000..414c65e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py @@ -0,0 +1,212 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos ospfv3 fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from re import findall, search, M +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospfv3.ospfv3 import ( + Ospfv3Args, +) + + +class Ospfv3Facts(object): + """The vyos ospfv3 fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Ospfv3Args.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + return connection.get_config() + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for ospfv3 + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = self.get_device_data(connection) + # typically data is populated from the current device configuration + # data = connection.get('show running-config | section ^interface') + # using mock data instead + objs = {} + ospfv3 = findall(r"^set protocols ospfv3 (.+)", data, M) + if ospfv3: + objs = self.render_config(ospfv3) + facts = {} + params = utils.validate_config(self.argument_spec, {"config": objs}) + facts["ospfv3"] = utils.remove_empties(params["config"]) + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure + + :param conf: The configuration + :returns: The generated config + """ + conf = "\n".join(filter(lambda x: x, conf)) + config = {} + config["parameters"] = self.parse_attrib( + conf, "parameters", "parameters" + ) + config["areas"] = self.parse_attrib_list(conf, "area", "area_id") + config["redistribute"] = self.parse_attrib_list( + conf, "redistribute", "route_type" + ) + return config + + def parse_attrib_list(self, conf, attrib, param): + """ + This function forms the regex to fetch the listed attributes + from config + :param conf: configuration data + :param attrib: attribute name + :param param: parameter data + :return: generated rule list configuration + """ + r_lst = [] + if attrib == "area": + items = findall(r"^" + attrib + " (?:'*)(\\S+)(?:'*)", conf, M) + else: + items = findall(r"" + attrib + " (?:'*)(\\S+)(?:'*)", conf, M) + if items: + a_lst = [] + for item in set(items): + i_regex = r" %s .+$" % item + cfg = "\n".join(findall(i_regex, conf, M)) + if attrib == "area": + obj = self.parse_area(cfg, item) + else: + obj = self.parse_attrib(cfg, attrib) + obj[param] = item.strip("'") + if obj: + a_lst.append(obj) + r_lst = sorted(a_lst, key=lambda i: i[param]) + return r_lst + + def parse_area(self, conf, area_id): + """ + This function triggers the parsing of 'area' attributes. + :param conf: configuration data + :param area_id: area identity + :return: generated rule configuration dictionary. + """ + + rule = self.parse_attrib(conf, "area_id", match=area_id) + r_sub = {"range": self.parse_attrib_list(conf, "range", "address")} + rule.update(r_sub) + return rule + + def parse_attrib(self, conf, param, match=None): + """ + This function triggers the parsing of 'ospf' attributes + :param conf: configuration data + :return: generated configuration dictionary + """ + param_lst = { + "area_id": ["export_list", "import_list"], + "redistribute": ["route_map"], + "range": ["advertise", "not_advertise"], + "parameters": ["router_id"], + } + cfg_dict = self.parse_attr(conf, param_lst[param], match) + return cfg_dict + + def parse_attr(self, conf, attr_list, match=None): + """ + This function peforms the following: + - Form the regex to fetch the required attribute config. + - Type cast the output in desired format. + :param conf: configuration. + :param attr_list: list of attributes. + :param match: parent node/attribute name. + :return: generated config dictionary. + """ + config = {} + for attrib in attr_list: + regex = self.map_regex(attrib) + if match: + regex = match.replace("_", "-") + " " + regex + if conf: + if self.is_bool(attrib): + out = conf.find(attrib.replace("_", "-")) + dis = conf.find(attrib.replace("_", "-") + " 'disable'") + if match: + en = conf.find(match + " 'enable'") + if out >= 1: + if dis >= 1: + config[attrib] = False + else: + config[attrib] = True + elif match and en >= 1: + config[attrib] = True + else: + out = search(r"^.*" + regex + " (.+)", conf, M) + if out: + val = out.group(1).strip("'") + if self.is_num(attrib): + val = int(val) + config[attrib] = val + return config + + def map_regex(self, attrib): + """ + - This function construct the regex string. + - replace the underscore with hyphen. + :param attrib: attribute + :return: regex string + """ + return ( + "disable" + if attrib == "disabled" + else "enable" + if attrib == "enabled" + else attrib.replace("_", "-") + ) + + def is_bool(self, attrib): + """ + This function looks for the attribute in predefined bool type set. + :param attrib: attribute. + :return: True/False + """ + bool_set = ("enabled", "advertise", "not_advertise") + return True if attrib in bool_set else False + + def is_num(self, attrib): + """ + This function looks for the attribute in predefined integer type set. + :param attrib: attribute. + :return: True/false. + """ + num_set = "ospf" + return True if attrib in num_set else False diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py new file mode 100644 index 00000000..bce27311 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py @@ -0,0 +1,180 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The vyos static_routes fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from re import findall, search, M +from copy import deepcopy +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import ( + utils, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.static_routes.static_routes import ( + Static_routesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + get_route_type, +) + + +class Static_routesFacts(object): + """The vyos static_routes fact class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Static_routesArgs.argument_spec + spec = deepcopy(self.argument_spec) + if subspec: + if options: + facts_argument_spec = spec[subspec][options] + else: + facts_argument_spec = spec[subspec] + else: + facts_argument_spec = spec + + self.generated_spec = utils.generate_dict(facts_argument_spec) + + def get_device_data(self, connection): + return connection.get_config() + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for static_routes + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + :rtype: dictionary + :returns: facts + """ + if not data: + data = self.get_device_data(connection) + # typically data is populated from the current device configuration + # data = connection.get('show running-config | section ^interface') + # using mock data instead + objs = [] + r_v4 = [] + r_v6 = [] + af = [] + static_routes = findall( + r"set protocols static route(6)? (\S+)", data, M + ) + if static_routes: + for route in set(static_routes): + route_regex = r" %s .+$" % route[1] + cfg = findall(route_regex, data, M) + sr = self.render_config(cfg) + sr["dest"] = route[1].strip("'") + afi = self.get_afi(sr["dest"]) + if afi == "ipv4": + r_v4.append(sr) + else: + r_v6.append(sr) + if r_v4: + afi_v4 = {"afi": "ipv4", "routes": r_v4} + af.append(afi_v4) + if r_v6: + afi_v6 = {"afi": "ipv6", "routes": r_v6} + af.append(afi_v6) + config = {"address_families": af} + if config: + objs.append(config) + + ansible_facts["ansible_network_resources"].pop("static_routes", None) + facts = {} + if objs: + facts["static_routes"] = [] + params = utils.validate_config( + self.argument_spec, {"config": objs} + ) + for cfg in params["config"]: + facts["static_routes"].append(utils.remove_empties(cfg)) + + ansible_facts["ansible_network_resources"].update(facts) + return ansible_facts + + def render_config(self, conf): + """ + Render config as dictionary structure and delete keys + from spec for null values + + :param spec: The facts tree, generated from the argspec + :param conf: The configuration + :rtype: dictionary + :returns: The generated config + """ + next_hops_conf = "\n".join(filter(lambda x: ("next-hop" in x), conf)) + blackhole_conf = "\n".join(filter(lambda x: ("blackhole" in x), conf)) + routes_dict = { + "blackhole_config": self.parse_blackhole(blackhole_conf), + "next_hops": self.parse_next_hop(next_hops_conf), + } + return routes_dict + + def parse_blackhole(self, conf): + blackhole = None + if conf: + distance = search(r"^.*blackhole distance (.\S+)", conf, M) + bh = conf.find("blackhole") + if distance is not None: + blackhole = {} + value = distance.group(1).strip("'") + blackhole["distance"] = int(value) + elif bh: + blackhole = {} + blackhole["type"] = "blackhole" + return blackhole + + def get_afi(self, address): + route_type = get_route_type(address) + if route_type == "route": + return "ipv4" + elif route_type == "route6": + return "ipv6" + + def parse_next_hop(self, conf): + nh_list = None + if conf: + nh_list = [] + hop_list = findall(r"^.*next-hop (.+)", conf, M) + if hop_list: + for hop in hop_list: + distance = search(r"^.*distance (.\S+)", hop, M) + interface = search(r"^.*interface (.\S+)", hop, M) + + dis = hop.find("disable") + hop_info = hop.split(" ") + nh_info = { + "forward_router_address": hop_info[0].strip("'") + } + if interface: + nh_info["interface"] = interface.group(1).strip("'") + if distance: + value = distance.group(1).strip("'") + nh_info["admin_distance"] = int(value) + elif dis >= 1: + nh_info["enabled"] = False + for element in nh_list: + if ( + element["forward_router_address"] + == nh_info["forward_router_address"] + ): + if "interface" in nh_info.keys(): + element["interface"] = nh_info["interface"] + if "admin_distance" in nh_info.keys(): + element["admin_distance"] = nh_info[ + "admin_distance" + ] + if "enabled" in nh_info.keys(): + element["enabled"] = nh_info["enabled"] + nh_info = None + if nh_info is not None: + nh_list.append(nh_info) + return nh_list diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/rm_templates/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/rm_templates/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/rm_templates/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py new file mode 100644 index 00000000..460e6b0a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py @@ -0,0 +1,743 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +""" +The Ospf_interfaces parser templates file. This contains +a list of parser definitions and associated functions that +facilitates both facts gathering and native command generation for +the given network resource. +""" + +import re +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( + NetworkTemplate, +) + +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils import ( + get_interface_type, +) + + +def _get_parameters(data): + if data["afi"] == "ipv6": + val = ["ospfv3", "ipv6"] + else: + val = ["ospf", "ip"] + return val + + +def _tmplt_ospf_int_delete(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + ) + + return command + + +def _tmplt_ospf_int_cost(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " cost {cost}".format(**config_data["address_family"]) + ) + + return command + + +def _tmplt_ospf_int_auth_password(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " authentication plaintext-password {plaintext_password}".format( + **config_data["address_family"]["authentication"] + ) + ) + return command + + +def _tmplt_ospf_int_auth_md5(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " authentication md5 key-id {key_id} ".format( + **config_data["address_family"]["authentication"]["md5_key"] + ) + + "md5-key {key}".format( + **config_data["address_family"]["authentication"]["md5_key"] + ) + ) + + return command + + +def _tmplt_ospf_int_auth_md5_delete(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " authentication" + ) + + return command + + +def _tmplt_ospf_int_bw(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " bandwidth {bandwidth}".format(**config_data["address_family"]) + ) + + return command + + +def _tmplt_ospf_int_hello_interval(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " hello-interval {hello_interval}".format( + **config_data["address_family"] + ) + ) + + return command + + +def _tmplt_ospf_int_dead_interval(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " dead-interval {dead_interval}".format( + **config_data["address_family"] + ) + ) + + return command + + +def _tmplt_ospf_int_mtu_ignore(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " mtu-ignore" + ) + + return command + + +def _tmplt_ospf_int_network(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " network {network}".format(**config_data["address_family"]) + ) + + return command + + +def _tmplt_ospf_int_priority(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " priority {priority}".format(**config_data["address_family"]) + ) + + return command + + +def _tmplt_ospf_int_retransmit_interval(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " retransmit-interval {retransmit_interval}".format( + **config_data["address_family"] + ) + ) + + return command + + +def _tmplt_ospf_int_transmit_delay(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " transmit-delay {transmit_delay}".format( + **config_data["address_family"] + ) + ) + + return command + + +def _tmplt_ospf_int_ifmtu(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " ifmtu {ifmtu}".format(**config_data["address_family"]) + ) + + return command + + +def _tmplt_ospf_int_instance(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " instance-id {instance}".format(**config_data["address_family"]) + ) + + return command + + +def _tmplt_ospf_int_passive(config_data): + int_type = get_interface_type(config_data["name"]) + params = _get_parameters(config_data["address_family"]) + command = ( + "interfaces " + + int_type + + " {name} ".format(**config_data) + + params[1] + + " " + + params[0] + + " passive" + ) + + return command + + +class Ospf_interfacesTemplate(NetworkTemplate): + def __init__(self, lines=None): + prefix = {"set": "set", "remove": "delete"} + super(Ospf_interfacesTemplate, self).__init__( + lines=lines, tmplt=self, prefix=prefix + ) + + # fmt: off + PARSERS = [ + { + "name": "ip_ospf", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + *$""", + re.VERBOSE, + ), + "remval": _tmplt_ospf_int_delete, + "compval": "address_family", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + } + } + } + }, + { + "name": "authentication_password", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+authentication + \s+plaintext-password + \s+(?P<text>\S+) + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_auth_password, + "compval": "address_family.authentication", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "authentication": { + "plaintext_password": "{{ text }}" + } + } + } + } + }, + { + "name": "authentication_md5", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+authentication + \s+md5 + \s+key-id + \s+(?P<id>\d+) + \s+md5-key + \s+(?P<text>\S+) + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_auth_md5, + "remval": _tmplt_ospf_int_auth_md5_delete, + "compval": "address_family.authentication", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "authentication": { + "md5_key": { + "key_id": "{{ id }}", + "key": "{{ text }}" + } + } + } + } + } + }, + { + "name": "bandwidth", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+bandwidth + \s+(?P<bw>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_bw, + "compval": "address_family.bandwidth", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "bandwidth": "{{ bw }}" + } + } + } + }, + { + "name": "cost", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+cost + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_cost, + "compval": "address_family.cost", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "cost": "{{ val }}" + } + } + } + }, + { + "name": "hello_interval", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+hello-interval + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_hello_interval, + "compval": "address_family.hello_interval", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "hello_interval": "{{ val }}" + } + } + } + }, + { + "name": "dead_interval", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+dead-interval + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_dead_interval, + "compval": "address_family.dead_interval", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "dead_interval": "{{ val }}" + } + } + } + }, + { + "name": "mtu_ignore", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+(?P<mtu>\'mtu-ignore\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_mtu_ignore, + "compval": "address_family.mtu_ignore", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "mtu_ignore": "{{ True if mtu is defined }}" + } + } + } + }, + { + "name": "network", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+network + \s+(?P<val>\S+) + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_network, + "compval": "address_family.network", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "network": "{{ val }}" + } + } + } + }, + { + "name": "priority", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+priority + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_priority, + "compval": "address_family.priority", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "priority": "{{ val }}" + } + } + } + }, + { + "name": "retransmit_interval", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+retransmit-interval + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_retransmit_interval, + "compval": "address_family.retransmit_interval", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "retransmit_interval": "{{ val }}" + } + } + } + }, + { + "name": "transmit_delay", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+transmit-delay + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_transmit_delay, + "compval": "address_family.transmit_delay", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "transmit_delay": "{{ val }}" + } + } + } + }, + { + "name": "ifmtu", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+ifmtu + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_ifmtu, + "compval": "address_family.ifmtu", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "ifmtu": "{{ val }}" + } + } + } + }, + { + "name": "instance", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+instance-id + \s+(?P<val>\'\d+\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_instance, + "compval": "address_family.instance", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "instance": "{{ val }}" + } + } + } + }, + { + "name": "passive", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + \s+(?P<afi>ip|ipv6) + \s+(?P<proto>ospf|ospfv3) + \s+(?P<pass>\'passive\') + *$""", + re.VERBOSE, + ), + "setval": _tmplt_ospf_int_passive, + "compval": "address_family.passive", + "result": { + "name": "{{ name }}", + "address_family": { + "{{ afi }}": { + "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', + "passive": "{{ True if pass is defined }}" + } + } + } + }, + { + "name": "interface_name", + "getval": re.compile( + r""" + ^set + \s+interfaces + \s+(?P<type>\S+) + \s+(?P<name>\S+) + .*$""", + re.VERBOSE, + ), + "setval": "set interface {{ type }} {{ name }}", + "result": { + "name": "{{ name }}", + } + }, + ] + # fmt: on diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py new file mode 100644 index 00000000..7ce46883 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py @@ -0,0 +1,270 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# utils +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.compat import ( + ipaddress, +) + + +def search_obj_in_list(name, lst, key="name"): + if lst: + for item in lst: + if item[key] == name: + return item + return None + + +def get_interface_type(interface): + """Gets the type of interface""" + if interface.startswith("eth"): + return "ethernet" + elif interface.startswith("bond"): + return "bonding" + elif interface.startswith("vti"): + return "vti" + elif interface.startswith("lo"): + return "loopback" + elif interface.startswith("vtun"): + return "openvpn" + + +def dict_delete(base, comparable): + """ + This function generates a dict containing key, value pairs for keys + that are present in the `base` dict but not present in the `comparable` + dict. + + :param base: dict object to base the diff on + :param comparable: dict object to compare against base + :returns: new dict object with key, value pairs that needs to be deleted. + + """ + to_delete = dict() + + for key in base: + if isinstance(base[key], dict): + sub_diff = dict_delete(base[key], comparable.get(key, {})) + if sub_diff: + to_delete[key] = sub_diff + else: + if key not in comparable: + to_delete[key] = base[key] + + return to_delete + + +def diff_list_of_dicts(want, have): + diff = [] + + set_w = set(tuple(d.items()) for d in want) + set_h = set(tuple(d.items()) for d in have) + difference = set_w.difference(set_h) + + for element in difference: + diff.append(dict((x, y) for x, y in element)) + + return diff + + +def get_lst_diff_for_dicts(want, have, lst): + """ + This function generates a list containing values + that are only in want and not in list in have dict + :param want: dict object to want + :param have: dict object to have + :param lst: list the diff on + :return: new list object with values which are only in want. + """ + if not have: + diff = want.get(lst) or [] + + else: + want_elements = want.get(lst) or {} + have_elements = have.get(lst) or {} + diff = list_diff_want_only(want_elements, have_elements) + return diff + + +def get_lst_same_for_dicts(want, have, lst): + """ + This function generates a list containing values + that are common for list in want and list in have dict + :param want: dict object to want + :param have: dict object to have + :param lst: list the comparison on + :return: new list object with values which are common in want and have. + """ + diff = None + if want and have: + want_list = want.get(lst) or {} + have_list = have.get(lst) or {} + diff = [ + i + for i in want_list and have_list + if i in have_list and i in want_list + ] + return diff + + +def list_diff_have_only(want_list, have_list): + """ + This function generated the list containing values + that are only in have list. + :param want_list: + :param have_list: + :return: new list with values which are only in have list + """ + if have_list and not want_list: + diff = have_list + elif not have_list: + diff = None + else: + diff = [ + i + for i in have_list + want_list + if i in have_list and i not in want_list + ] + return diff + + +def list_diff_want_only(want_list, have_list): + """ + This function generated the list containing values + that are only in want list. + :param want_list: + :param have_list: + :return: new list with values which are only in want list + """ + if have_list and not want_list: + diff = None + elif not have_list: + diff = want_list + else: + diff = [ + i + for i in have_list + want_list + if i in want_list and i not in have_list + ] + return diff + + +def search_dict_tv_in_list(d_val1, d_val2, lst, key1, key2): + """ + This function return the dict object if it exist in list. + :param d_val1: + :param d_val2: + :param lst: + :param key1: + :param key2: + :return: + """ + obj = next( + ( + item + for item in lst + if item[key1] == d_val1 and item[key2] == d_val2 + ), + None, + ) + if obj: + return obj + else: + return None + + +def key_value_in_dict(have_key, have_value, want_dict): + """ + This function checks whether the key and values exist in dict + :param have_key: + :param have_value: + :param want_dict: + :return: + """ + for key, value in iteritems(want_dict): + if key == have_key and value == have_value: + return True + return False + + +def is_dict_element_present(dict, key): + """ + This function checks whether the key is present in dict. + :param dict: + :param key: + :return: + """ + for item in dict: + if item == key: + return True + return False + + +def get_ip_address_version(address): + """ + This function returns the version of IP address + :param address: IP address + :return: + """ + try: + address = unicode(address) + except NameError: + address = str(address) + version = ipaddress.ip_address(address.split("/")[0]).version + return version + + +def get_route_type(address): + """ + This function returns the route type based on IP address + :param address: + :return: + """ + version = get_ip_address_version(address) + if version == 6: + return "route6" + elif version == 4: + return "route" + + +def _bool_to_str(val): + """ + This function converts the bool value into string. + :param val: bool value. + :return: enable/disable. + """ + return ( + "enable" + if str(val) == "True" + else "disable" + if str(val) == "False" + else val + ) + + +def _is_w_same(w, h, key): + """ + This function checks whether the key value is same in desired and + target config dictionary. + :param w: base config. + :param h: target config. + :param key:attribute name. + :return: True/False. + """ + return True if h and key in h and h[key] == w[key] else False + + +def _in_target(h, key): + """ + This function checks whether the target exist and key present in target config. + :param h: target config. + :param key: attribute name. + :return: True/False. + """ + return True if h and key in h else False diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py new file mode 100644 index 00000000..4ab36b9a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py @@ -0,0 +1,130 @@ +# This code is part of Ansible, but is an independent component. +# This particular file snippet, and this file snippet only, is BSD licensed. +# Modules you write using this snippet, which is embedded dynamically by Ansible +# still belong to the author of the module, and may assign their own license +# to the complete work. +# +# (c) 2016 Red Hat Inc. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import json + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import env_fallback +from ansible.module_utils.connection import Connection, ConnectionError + +_DEVICE_CONFIGS = {} + +vyos_provider_spec = { + "host": dict(), + "port": dict(type="int"), + "username": dict(fallback=(env_fallback, ["ANSIBLE_NET_USERNAME"])), + "password": dict( + fallback=(env_fallback, ["ANSIBLE_NET_PASSWORD"]), no_log=True + ), + "ssh_keyfile": dict( + fallback=(env_fallback, ["ANSIBLE_NET_SSH_KEYFILE"]), type="path" + ), + "timeout": dict(type="int"), +} +vyos_argument_spec = { + "provider": dict( + type="dict", + options=vyos_provider_spec, + removed_at_date="2022-06-01", + removed_from_collection="vyos.vyos", + ) +} + + +def get_provider_argspec(): + return vyos_provider_spec + + +def get_connection(module): + if hasattr(module, "_vyos_connection"): + return module._vyos_connection + + capabilities = get_capabilities(module) + network_api = capabilities.get("network_api") + if network_api == "cliconf": + module._vyos_connection = Connection(module._socket_path) + else: + module.fail_json(msg="Invalid connection type %s" % network_api) + + return module._vyos_connection + + +def get_capabilities(module): + if hasattr(module, "_vyos_capabilities"): + return module._vyos_capabilities + + try: + capabilities = Connection(module._socket_path).get_capabilities() + except ConnectionError as exc: + module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) + + module._vyos_capabilities = json.loads(capabilities) + return module._vyos_capabilities + + +def get_config(module, flags=None, format=None): + flags = [] if flags is None else flags + global _DEVICE_CONFIGS + + if _DEVICE_CONFIGS != {}: + return _DEVICE_CONFIGS + else: + connection = get_connection(module) + try: + out = connection.get_config(flags=flags, format=format) + except ConnectionError as exc: + module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) + cfg = to_text(out, errors="surrogate_then_replace").strip() + _DEVICE_CONFIGS = cfg + return cfg + + +def run_commands(module, commands, check_rc=True): + connection = get_connection(module) + try: + response = connection.run_commands( + commands=commands, check_rc=check_rc + ) + except ConnectionError as exc: + module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) + return response + + +def load_config(module, commands, commit=False, comment=None): + connection = get_connection(module) + + try: + response = connection.edit_config( + candidate=commands, commit=commit, comment=comment + ) + except ConnectionError as exc: + module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) + + return response.get("diff") diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_banner.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_banner.py new file mode 100644 index 00000000..9fcaf87b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_banner.py @@ -0,0 +1,198 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + + +DOCUMENTATION = """ +module: vyos_banner +author: Trishna Guha (@trishnaguha) +short_description: Manage multiline banners on VyOS devices +description: +- This will configure both pre-login and post-login banners on remote devices running + VyOS. It allows playbooks to add or remote banner text from the active running configuration. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + banner: + description: + - Specifies which banner that should be configured on the remote device. + required: true + choices: + - pre-login + - post-login + type: str + text: + description: + - The banner text that should be present in the remote device running configuration. + This argument accepts a multiline string, with no empty lines. Requires I(state=present). + type: str + state: + description: + - Specifies whether or not the configuration is present in the current devices + active running configuration. + default: present + type: str + choices: + - present + - absent +extends_documentation_fragment: +- vyos.vyos.vyos +""" + +EXAMPLES = """ +- name: configure the pre-login banner + vyos.vyos.vyos_banner: + banner: pre-login + text: | + this is my pre-login banner + that contains a multiline + string + state: present +- name: remove the post-login banner + vyos.vyos.vyos_banner: + banner: post-login + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always + type: list + sample: + - banner pre-login + - this is my pre-login banner + - that contains a multiline + - string +""" + +import re + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def spec_to_commands(updates, module): + commands = list() + want, have = updates + state = module.params["state"] + + if state == "absent": + if have.get("state") != "absent" or ( + have.get("state") != "absent" + and "text" in have.keys() + and have["text"] + ): + commands.append( + "delete system login banner %s" % module.params["banner"] + ) + + elif state == "present": + if want["text"] and want["text"].encode().decode( + "unicode_escape" + ) != have.get("text"): + banner_cmd = ( + "set system login banner %s " % module.params["banner"] + ) + banner_cmd += want["text"].strip() + commands.append(banner_cmd) + + return commands + + +def config_to_dict(module): + data = get_config(module) + output = None + obj = {"banner": module.params["banner"], "state": "absent"} + + for line in data.split("\n"): + if line.startswith("set system login banner %s" % obj["banner"]): + match = re.findall(r"%s (.*)" % obj["banner"], line, re.M) + output = match + if output: + obj["text"] = output[0].encode().decode("unicode_escape") + obj["state"] = "present" + + return obj + + +def map_params_to_obj(module): + text = module.params["text"] + if text: + text = "%r" % (str(text).strip()) + + return { + "banner": module.params["banner"], + "text": text, + "state": module.params["state"], + } + + +def main(): + """main entry point for module execution""" + argument_spec = dict( + banner=dict(required=True, choices=["pre-login", "post-login"]), + text=dict(), + state=dict(default="present", choices=["present", "absent"]), + ) + + argument_spec.update(vyos_argument_spec) + + required_if = [("state", "present", ("text",))] + + module = AnsibleModule( + argument_spec=argument_spec, + required_if=required_if, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + if warnings: + result["warnings"] = warnings + + want = map_params_to_obj(module) + have = config_to_dict(module) + + commands = spec_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py new file mode 100644 index 00000000..cb1fd476 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py @@ -0,0 +1,232 @@ +#!/usr/bin/python +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_command +author: Nathaniel Case (@Qalthos) +short_description: Run one or more commands on VyOS devices +description: +- The command module allows running one or more commands on remote devices running + VyOS. This module can also be introspected to validate key parameters before returning + successfully. If the conditional statements are not met in the wait period, the + task fails. +- Certain C(show) commands in VyOS produce many lines of output and use a custom pager + that can cause this module to hang. If the value of the environment variable C(ANSIBLE_VYOS_TERMINAL_LENGTH) + is not set, the default number of 10000 is used. +version_added: 1.0.0 +extends_documentation_fragment: +- vyos.vyos.vyos +options: + commands: + description: + - The ordered set of commands to execute on the remote device running VyOS. The + output from the command execution is returned to the playbook. If the I(wait_for) + argument is provided, the module is not returned until the condition is satisfied + or the number of retries has been exceeded. + - If a command sent to the device requires answering a prompt, it is possible to pass + a dict containing command, answer and prompt. Common answers are 'y' or "\\r" + (carriage return, must be double quotes). Refer below examples. + required: true + type: list + elements: raw + wait_for: + description: + - Specifies what to evaluate from the output of the command and what conditionals + to apply. This argument will cause the task to wait for a particular conditional + to be true before moving forward. If the conditional is not true by the configured + I(retries), the task fails. See examples. + type: list + elements: str + aliases: + - waitfor + match: + description: + - The I(match) argument is used in conjunction with the I(wait_for) argument to + specify the match policy. Valid values are C(all) or C(any). If the value is + set to C(all) then all conditionals in the wait_for must be satisfied. If the + value is set to C(any) then only one of the values must be satisfied. + default: all + type: str + choices: + - any + - all + retries: + description: + - Specifies the number of retries a command should be tried before it is considered + failed. The command is run on the target device every retry and evaluated against + the I(wait_for) conditionals. + default: 10 + type: int + interval: + description: + - Configures the interval in seconds to wait between I(retries) of the command. + If the command does not pass the specified conditions, the interval indicates + how long to wait before trying the command again. + default: 1 + type: int +notes: +- Tested against VyOS 1.1.8 (helium). +- Running C(show system boot-messages all) will cause the module to hang since VyOS + is using a custom pager setting to display the output of that command. +- If a command sent to the device requires answering a prompt, it is possible to pass + a dict containing I(command), I(answer) and I(prompt). See examples. +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +""" + +EXAMPLES = """ +- name: show configuration on ethernet devices eth0 and eth1 + vyos.vyos.vyos_command: + commands: + - show interfaces ethernet {{ item }} + with_items: + - eth0 + - eth1 + +- name: run multiple commands and check if version output contains specific version + string + vyos.vyos.vyos_command: + commands: + - show version + - show hardware cpu + wait_for: + - result[0] contains 'VyOS 1.1.7' + +- name: run command that requires answering a prompt + vyos.vyos.vyos_command: + commands: + - command: rollback 1 + prompt: Proceed with reboot? [confirm][y] + answer: y +""" + +RETURN = """ +stdout: + description: The set of responses from the commands + returned: always apart from low level errors (such as action plugin) + type: list + sample: ['...', '...'] +stdout_lines: + description: The value of stdout split into a list + returned: always + type: list + sample: [['...', '...'], ['...'], ['...']] +failed_conditions: + description: The list of conditionals that have failed + returned: failed + type: list + sample: ['...', '...'] +warnings: + description: The list of warnings (if any) generated by module based on arguments + returned: always + type: list + sample: ['...', '...'] +""" +import time + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.parsing import ( + Conditional, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + transform_commands, + to_lines, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + run_commands, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def parse_commands(module, warnings): + commands = transform_commands(module) + + if module.check_mode: + for item in list(commands): + if not item["command"].startswith("show"): + warnings.append( + "Only show commands are supported when using check mode, not " + "executing %s" % item["command"] + ) + commands.remove(item) + + return commands + + +def main(): + spec = dict( + commands=dict(type="list", required=True, elements="raw"), + wait_for=dict(type="list", aliases=["waitfor"], elements="str"), + match=dict(default="all", choices=["all", "any"]), + retries=dict(default=10, type="int"), + interval=dict(default=1, type="int"), + ) + + spec.update(vyos_argument_spec) + + module = AnsibleModule(argument_spec=spec, supports_check_mode=True) + + warnings = list() + result = {"changed": False, "warnings": warnings} + commands = parse_commands(module, warnings) + wait_for = module.params["wait_for"] or list() + + try: + conditionals = [Conditional(c) for c in wait_for] + except AttributeError as exc: + module.fail_json(msg=to_text(exc)) + + retries = module.params["retries"] + interval = module.params["interval"] + match = module.params["match"] + + for item in range(retries): + responses = run_commands(module, commands) + + for item in list(conditionals): + if item(responses): + if match == "any": + conditionals = list() + break + conditionals.remove(item) + + if not conditionals: + break + + time.sleep(interval) + + if conditionals: + failed_conditions = [item.raw for item in conditionals] + msg = "One or more conditional statements have not been satisfied" + module.fail_json(msg=msg, failed_conditions=failed_conditions) + + result.update( + {"stdout": responses, "stdout_lines": list(to_lines(responses))} + ) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py new file mode 100644 index 00000000..8efad382 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py @@ -0,0 +1,365 @@ +#!/usr/bin/python +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_config +author: Nathaniel Case (@Qalthos) +short_description: Manage VyOS configuration on remote device +description: +- This module provides configuration file management of VyOS devices. It provides + arguments for managing both the configuration file and state of the active configuration. + All configuration statements are based on `set` and `delete` commands in the device + configuration. +version_added: 1.0.0 +extends_documentation_fragment: +- vyos.vyos.vyos +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + lines: + description: + - The ordered set of configuration lines to be managed and compared with the existing + configuration on the remote device. + type: list + elements: str + src: + description: + - The C(src) argument specifies the path to the source config file to load. The + source config file can either be in bracket format or set format. The source + file can include Jinja2 template variables. + type: path + match: + description: + - The C(match) argument controls the method used to match against the current + active configuration. By default, the desired config is matched against the + active config and the deltas are loaded. If the C(match) argument is set to + C(none) the active configuration is ignored and the configuration is always + loaded. + type: str + default: line + choices: + - line + - none + backup: + description: + - The C(backup) argument will backup the current devices active configuration + to the Ansible control host prior to making any changes. If the C(backup_options) + value is not given, the backup file will be located in the backup folder in + the playbook root directory or role root directory, if playbook is part of an + ansible role. If the directory does not exist, it is created. + type: bool + default: no + comment: + description: + - Allows a commit description to be specified to be included when the configuration + is committed. If the configuration is not changed or committed, this argument + is ignored. + default: configured by vyos_config + type: str + config: + description: + - The C(config) argument specifies the base configuration to use to compare against + the desired configuration. If this value is not specified, the module will + automatically retrieve the current active configuration from the remote device. + type: str + save: + description: + - The C(save) argument controls whether or not changes made to the active configuration + are saved to disk. This is independent of committing the config. When set + to True, the active configuration is saved. + type: bool + default: no + backup_options: + description: + - This is a dict object containing configurable options related to backup file + path. The value of this option is read only when C(backup) is set to I(yes), + if C(backup) is set to I(no) this option will be silently ignored. + suboptions: + filename: + description: + - The filename to be used to store the backup configuration. If the filename + is not given it will be generated based on the hostname, current time and + date in format defined by <hostname>_config.<current-date>@<current-time> + type: str + dir_path: + description: + - This option provides the path ending with directory name in which the backup + configuration file will be stored. If the directory does not exist it will + be first created and the filename is either the value of C(filename) or + default filename as described in C(filename) options description. If the + path value is not given in that case a I(backup) directory will be created + in the current working directory and backup configuration will be copied + in C(filename) within I(backup) directory. + type: path + type: dict +""" + +EXAMPLES = """ +- name: configure the remote device + vyos.vyos.vyos_config: + lines: + - set system host-name {{ inventory_hostname }} + - set service lldp + - delete service dhcp-server + +- name: backup and load from file + vyos.vyos.vyos_config: + src: vyos.cfg + backup: yes + +- name: render a Jinja2 template onto the VyOS router + vyos.vyos.vyos_config: + src: vyos_template.j2 + +- name: for idempotency, use full-form commands + vyos.vyos.vyos_config: + lines: + # - set int eth eth2 description 'OUTSIDE' + - set interface ethernet eth2 description 'OUTSIDE' + +- name: configurable backup path + vyos.vyos.vyos_config: + backup: yes + backup_options: + filename: backup.cfg + dir_path: /home/user +""" + +RETURN = """ +commands: + description: The list of configuration commands sent to the device + returned: always + type: list + sample: ['...', '...'] +filtered: + description: The list of configuration commands removed to avoid a load failure + returned: always + type: list + sample: ['...', '...'] +backup_path: + description: The full path to the backup file + returned: when backup is yes + type: str + sample: /playbooks/ansible/backup/vyos_config.2016-07-16@22:28:34 +filename: + description: The name of the backup file + returned: when backup is yes and filename is not specified in backup options + type: str + sample: vyos_config.2016-07-16@22:28:34 +shortname: + description: The full path to the backup file excluding the timestamp + returned: when backup is yes and filename is not specified in backup options + type: str + sample: /playbooks/ansible/backup/vyos_config +date: + description: The date extracted from the backup file name + returned: when backup is yes + type: str + sample: "2016-07-16" +time: + description: The time extracted from the backup file name + returned: when backup is yes + type: str + sample: "22:28:34" +""" +import re + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.connection import ConnectionError +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + load_config, + get_config, + run_commands, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, + get_connection, +) + + +DEFAULT_COMMENT = "configured by vyos_config" + +CONFIG_FILTERS = [ + re.compile(r"set system login user \S+ authentication encrypted-password") +] + + +def get_candidate(module): + contents = module.params["src"] or module.params["lines"] + + if module.params["src"]: + contents = contents.splitlines() + if len(contents) > 0: + line = contents[0].split() + if len(line) > 0 and line[0] in ("set", "delete"): + contents = format_commands(contents) + + contents = "\n".join(contents) + return contents + + +def format_commands(commands): + """ + This function format the input commands and removes the prepend white spaces + for command lines having 'set' or 'delete' and it skips empty lines. + :param commands: + :return: list of commands + """ + return [ + line.strip() if line.split()[0] in ("set", "delete") else line + for line in commands + if len(line.strip()) > 0 + ] + + +def diff_config(commands, config): + config = [str(c).replace("'", "") for c in config.splitlines()] + + updates = list() + visited = set() + + for line in commands: + item = str(line).replace("'", "") + + if not item.startswith("set") and not item.startswith("delete"): + raise ValueError("line must start with either `set` or `delete`") + + elif item.startswith("set") and item not in config: + updates.append(line) + + elif item.startswith("delete"): + if not config: + updates.append(line) + else: + item = re.sub(r"delete", "set", item) + for entry in config: + if entry.startswith(item) and line not in visited: + updates.append(line) + visited.add(line) + + return list(updates) + + +def sanitize_config(config, result): + result["filtered"] = list() + index_to_filter = list() + for regex in CONFIG_FILTERS: + for index, line in enumerate(list(config)): + if regex.search(line): + result["filtered"].append(line) + index_to_filter.append(index) + # Delete all filtered configs + for filter_index in sorted(index_to_filter, reverse=True): + del config[filter_index] + + +def run(module, result): + # get the current active config from the node or passed in via + # the config param + config = module.params["config"] or get_config(module) + + # create the candidate config object from the arguments + candidate = get_candidate(module) + + # create loadable config that includes only the configuration updates + connection = get_connection(module) + try: + response = connection.get_diff( + candidate=candidate, + running=config, + diff_match=module.params["match"], + ) + except ConnectionError as exc: + module.fail_json(msg=to_text(exc, errors="surrogate_then_replace")) + + commands = response.get("config_diff") + sanitize_config(commands, result) + + result["commands"] = commands + + commit = not module.check_mode + comment = module.params["comment"] + + diff = None + if commands: + diff = load_config(module, commands, commit=commit, comment=comment) + + if result.get("filtered"): + result["warnings"].append( + "Some configuration commands were " + "removed, please see the filtered key" + ) + + result["changed"] = True + + if module._diff: + result["diff"] = {"prepared": diff} + + +def main(): + backup_spec = dict(filename=dict(), dir_path=dict(type="path")) + argument_spec = dict( + src=dict(type="path"), + lines=dict(type="list", elements="str"), + match=dict(default="line", choices=["line", "none"]), + comment=dict(default=DEFAULT_COMMENT), + config=dict(), + backup=dict(type="bool", default=False), + backup_options=dict(type="dict", options=backup_spec), + save=dict(type="bool", default=False), + ) + + argument_spec.update(vyos_argument_spec) + + mutually_exclusive = [("lines", "src")] + + module = AnsibleModule( + argument_spec=argument_spec, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + ) + + warnings = list() + + result = dict(changed=False, warnings=warnings) + + if module.params["backup"]: + result["__backup__"] = get_config(module=module) + + if any((module.params["src"], module.params["lines"])): + run(module, result) + + if module.params["save"]: + diff = run_commands(module, commands=["configure", "compare saved"])[1] + if diff != "[edit]": + if not module.check_mode: + run_commands(module, commands=["save"]) + result["changed"] = True + run_commands(module, commands=["exit"]) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py new file mode 100644 index 00000000..01c43c2e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py @@ -0,0 +1,177 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +""" +The module file for vyos_facts +""" + + +DOCUMENTATION = """ +module: vyos_facts +short_description: Get facts about vyos devices. +description: +- Collects facts from network devices running the vyos operating system. This module + places the facts gathered in the fact tree keyed by the respective resource name. The + facts module will always collect a base set of facts from the device and can enable + or disable collection of additional facts. +version_added: 1.0.0 +author: +- Nathaniel Case (@qalthos) +- Nilashish Chakraborty (@Nilashishc) +- Rohit Thakur (@rohitthakur2590) +extends_documentation_fragment: +- vyos.vyos.vyos +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + gather_subset: + description: + - When supplied, this argument will restrict the facts collected to a given subset. Possible + values for this argument include all, default, config, and neighbors. Can specify + a list of values to include a larger subset. Values can also be used with an + initial C(M(!)) to specify that a specific subset should not be collected. + required: false + default: '!config' + type: list + elements: str + gather_network_resources: + description: + - When supplied, this argument will restrict the facts collected to a given subset. + Possible values for this argument include all and the resources like interfaces. + Can specify a list of values to include a larger subset. Values can also be + used with an initial C(M(!)) to specify that a specific subset should not be + collected. Valid subsets are 'all', 'interfaces', 'l3_interfaces', 'lag_interfaces', + 'lldp_global', 'lldp_interfaces', 'static_routes', 'firewall_rules', 'firewall_global', + 'firewall_interfaces', 'ospfv3', 'ospfv2'. + required: false + type: list + elements: str +""" + +EXAMPLES = """ +# Gather all facts +- vyos.vyos.vyos_facts: + gather_subset: all + gather_network_resources: all + +# collect only the config and default facts +- vyos.vyos.vyos_facts: + gather_subset: config + +# collect everything exception the config +- vyos.vyos.vyos_facts: + gather_subset: '!config' + +# Collect only the interfaces facts +- vyos.vyos.vyos_facts: + gather_subset: + - '!all' + - '!min' + gather_network_resources: + - interfaces + +# Do not collect interfaces facts +- vyos.vyos.vyos_facts: + gather_network_resources: + - '!interfaces' + +# Collect interfaces and minimal default facts +- vyos.vyos.vyos_facts: + gather_subset: min + gather_network_resources: interfaces +""" + +RETURN = """ +ansible_net_config: + description: The running-config from the device + returned: when config is configured + type: str +ansible_net_commits: + description: The set of available configuration revisions + returned: when present + type: list +ansible_net_hostname: + description: The configured system hostname + returned: always + type: str +ansible_net_model: + description: The device model string + returned: always + type: str +ansible_net_serialnum: + description: The serial number of the device + returned: always + type: str +ansible_net_version: + description: The version of the software running + returned: always + type: str +ansible_net_neighbors: + description: The set of LLDP neighbors + returned: when interface is configured + type: list +ansible_net_gather_subset: + description: The list of subsets gathered by the module + returned: always + type: list +ansible_net_api: + description: The name of the transport + returned: always + type: str +ansible_net_python_version: + description: The Python version Ansible controller is using + returned: always + type: str +ansible_net_gather_network_resources: + description: The list of fact resource subsets collected from the device + returned: always + type: list +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.facts.facts import ( + FactsArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.facts import ( + Facts, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def main(): + """ + Main entry point for module execution + + :returns: ansible_facts + """ + argument_spec = FactsArgs.argument_spec + argument_spec.update(vyos_argument_spec) + + module = AnsibleModule( + argument_spec=argument_spec, supports_check_mode=True + ) + + warnings = [] + if module.params["gather_subset"] == "!config": + warnings.append( + "default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards" + ) + + result = Facts(module).get_facts() + + ansible_facts, additional_warnings = result + warnings.extend(additional_warnings) + + module.exit_json(ansible_facts=ansible_facts, warnings=warnings) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_global.py new file mode 100644 index 00000000..6ff30719 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_global.py @@ -0,0 +1,1202 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_firewall_global +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_firewall_global +short_description: FIREWALL global resource module +description: This module manage global policies or configurations for firewall on + VyOS devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: + - A dictionary of Firewall global configuration options. + type: dict + suboptions: + route_redirects: + description: -A dictionary of Firewall icmp redirect and source route global + configuration options. + type: list + elements: dict + suboptions: + afi: + description: + - Specifies IP address type + type: str + choices: + - ipv4 + - ipv6 + required: true + icmp_redirects: + description: + - Specifies whether to allow sending/receiving of IPv4/v6 ICMP redirect + messages. + type: dict + suboptions: + send: + description: + - Permits or denies transmitting packets ICMP redirect messages. + type: bool + receive: + description: + - Permits or denies receiving packets ICMP redirect messages. + type: bool + ip_src_route: + description: + - Specifies whether or not to process source route IP options. + type: bool + ping: + description: + - Policy for handling of all IPv4 ICMP echo requests. + type: dict + suboptions: + all: + description: + - Enables or disables response to all IPv4 ICMP Echo Request (ping) messages. + - The system responds to IPv4 ICMP Echo Request messages. + type: bool + broadcast: + description: + - Enables or disables response to broadcast IPv4 ICMP Echo Request and + Timestamp Request messages. + - IPv4 ICMP Echo and Timestamp Request messages are not processed. + type: bool + config_trap: + description: + - SNMP trap generation on firewall configuration changes. + type: bool + validation: + description: + - Specifies a policy for source validation by reversed path, as defined in + RFC 3704. + - (disable) No source validation is performed. + - (loose) Enable Loose Reverse Path Forwarding as defined in RFC3704. + - (strict) Enable Strict Reverse Path Forwarding as defined in RFC3704. + type: str + choices: + - strict + - loose + - disable + group: + description: + - Defines a group of objects for referencing in firewall rules. + type: dict + suboptions: + address_group: + description: + - Defines a group of IP addresses for referencing in firewall rules. + type: list + elements: dict + suboptions: + name: + description: + - Name of the firewall address group. + type: str + required: true + description: + description: + - Allows you to specify a brief description for the address group. + type: str + members: + description: + - Address-group members. + - IPv4 address to match. + - IPv4 range to match. + type: list + elements: dict + suboptions: + address: + description: IP address. + type: str + network_group: + description: + - Defines a group of networks for referencing in firewall rules. + type: list + elements: dict + suboptions: + name: + description: + - Name of the firewall network group. + type: str + required: true + description: + description: + - Allows you to specify a brief description for the network group. + type: str + members: + description: + - Adds an IPv4 network to the specified network group. + - The format is ip-address/prefix. + type: list + elements: dict + suboptions: + address: + description: IP address. + type: str + port_group: + description: + - Defines a group of ports for referencing in firewall rules. + type: list + elements: dict + suboptions: + name: + description: + - Name of the firewall port group. + type: str + required: true + description: + description: + - Allows you to specify a brief description for the port group. + type: str + members: + description: + - Port-group member. + type: list + elements: dict + suboptions: + port: + description: Defines the number. + type: str + log_martians: + description: + - Specifies whether or not to record packets with invalid addresses in the + log. + - (True) Logs packets with invalid addresses. + - (False) Does not log packets with invalid addresses. + type: bool + syn_cookies: + description: + - Specifies policy for using TCP SYN cookies with IPv4. + - (True) Enables TCP SYN cookies with IPv4. + - (False) Disables TCP SYN cookies with IPv4. + type: bool + twa_hazards_protection: + description: + - RFC1337 TCP TIME-WAIT assasination hazards protection. + type: bool + state_policy: + description: + - Specifies global firewall state-policy. + type: list + elements: dict + suboptions: + connection_type: + description: Specifies connection type. + type: str + choices: + - established + - invalid + - related + action: + description: + - Action for packets part of an established connection. + type: str + choices: + - accept + - drop + - reject + log: + description: + - Enable logging of packets part of an established connection. + type: bool + running_config: + description: + - The module, by default, will connect to the remote device and retrieve the current + running-config to use as a base for comparing against the contents of source. + There are times when it is not desirable to have the task get the current running-config + for every task in a playbook. The I(running_config) argument allows the implementer + to pass in the configuration to use as the base config for comparison. This + value of this option should be the output received from device by executing + command C(show configuration commands | grep 'firewall') + type: str + state: + description: + - The state the configuration should be left in. + type: str + choices: + - merged + - replaced + - deleted + - gathered + - rendered + - parsed + default: merged + +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos# run show configuration commands | grep firewall +# +# +- name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": [] +# +# "commands": [ +# "set firewall group address-group MGMT-HOSTS address 192.0.1.1", +# "set firewall group address-group MGMT-HOSTS address 192.0.1.3", +# "set firewall group address-group MGMT-HOSTS address 192.0.1.5", +# "set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list'", +# "set firewall group address-group MGMT-HOSTS", +# "set firewall group network-group MGMT network 192.0.1.0/24", +# "set firewall group network-group MGMT description 'This group has the Management network addresses'", +# "set firewall group network-group MGMT", +# "set firewall ip-src-route 'enable'", +# "set firewall receive-redirects 'disable'", +# "set firewall send-redirects 'enable'", +# "set firewall config-trap 'enable'", +# "set firewall state-policy established action 'accept'", +# "set firewall state-policy established log 'enable'", +# "set firewall state-policy invalid action 'reject'", +# "set firewall broadcast-ping 'enable'", +# "set firewall all-ping 'enable'", +# "set firewall log-martians 'enable'", +# "set firewall twa-hazards-protection 'enable'", +# "set firewall syn-cookies 'enable'", +# "set firewall source-validation 'strict'" +# ] +# +# "after": { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "This group has the Management hosts address list", +# "members": [ +# { +# "address": "192.0.1.1" +# }, +# { +# "address": "192.0.1.3" +# }, +# { +# "address": "192.0.1.5" +# } +# ], +# "name": "MGMT-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep firewall +# set firewall all-ping 'enable' +# set firewall broadcast-ping 'enable' +# set firewall config-trap 'enable' +# set firewall group address-group MGMT-HOSTS address '192.0.1.1' +# set firewall group address-group MGMT-HOSTS address '192.0.1.3' +# set firewall group address-group MGMT-HOSTS address '192.0.1.5' +# set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' +# set firewall group network-group MGMT description 'This group has the Management network addresses' +# set firewall group network-group MGMT network '192.0.1.0/24' +# set firewall ip-src-route 'enable' +# set firewall log-martians 'enable' +# set firewall receive-redirects 'disable' +# set firewall send-redirects 'enable' +# set firewall source-validation 'strict' +# set firewall state-policy established action 'accept' +# set firewall state-policy established log 'enable' +# set firewall state-policy invalid action 'reject' +# set firewall syn-cookies 'enable' +# set firewall twa-hazards-protection 'enable' +# +# +# Using parsed +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_global: + running_config: + "set firewall all-ping 'enable' + set firewall broadcast-ping 'enable' + set firewall config-trap 'enable' + set firewall group address-group ENG-HOSTS address '192.0.3.1' + set firewall group address-group ENG-HOSTS address '192.0.3.2' + set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' + set firewall group address-group SALES-HOSTS address '192.0.2.1' + set firewall group address-group SALES-HOSTS address '192.0.2.2' + set firewall group address-group SALES-HOSTS address '192.0.2.3' + set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' + set firewall group network-group MGMT description 'This group has the Management network addresses' + set firewall group network-group MGMT network '192.0.1.0/24' + set firewall ip-src-route 'enable' + set firewall log-martians 'enable' + set firewall receive-redirects 'disable' + set firewall send-redirects 'enable' + set firewall source-validation 'strict' + set firewall state-policy established action 'accept' + set firewall state-policy established log 'enable' + set firewall state-policy invalid action 'reject' + set firewall syn-cookies 'enable' + set firewall twa-hazards-protection 'enable'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.3.1" +# }, +# { +# "address": "192.0.3.2" +# } +# ], +# "name": "ENG-HOSTS" +# }, +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.2.1" +# }, +# { +# "address": "192.0.2.2" +# }, +# { +# "address": "192.0.2.3" +# } +# ], +# "name": "SALES-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# } +# +# +# Using deleted +# +# Before state +# ------------- +# +# vyos@192# run show configuration commands | grep firewall +# set firewall all-ping 'enable' +# set firewall broadcast-ping 'enable' +# set firewall config-trap 'enable' +# set firewall group address-group MGMT-HOSTS address '192.0.1.1' +# set firewall group address-group MGMT-HOSTS address '192.0.1.3' +# set firewall group address-group MGMT-HOSTS address '192.0.1.5' +# set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' +# set firewall group network-group MGMT description 'This group has the Management network addresses' +# set firewall group network-group MGMT network '192.0.1.0/24' +# set firewall ip-src-route 'enable' +# set firewall log-martians 'enable' +# set firewall receive-redirects 'disable' +# set firewall send-redirects 'enable' +# set firewall source-validation 'strict' +# set firewall state-policy established action 'accept' +# set firewall state-policy established log 'enable' +# set firewall state-policy invalid action 'reject' +# set firewall syn-cookies 'enable' +# set firewall twa-hazards-protection 'enable' +- name: Delete attributes of firewall. + vyos.vyos.vyos_firewall_global: + config: + state_policy: + config_trap: + log_martians: + syn_cookies: + twa_hazards_protection: + route_redirects: + ping: + group: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "This group has the Management hosts address list", +# "members": [ +# { +# "address": "192.0.1.1" +# }, +# { +# "address": "192.0.1.3" +# }, +# { +# "address": "192.0.1.5" +# } +# ], +# "name": "MGMT-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# "commands": [ +# "delete firewall source-validation", +# "delete firewall group", +# "delete firewall log-martians", +# "delete firewall ip-src-route", +# "delete firewall receive-redirects", +# "delete firewall send-redirects", +# "delete firewall config-trap", +# "delete firewall state-policy", +# "delete firewall syn-cookies", +# "delete firewall broadcast-ping", +# "delete firewall all-ping", +# "delete firewall twa-hazards-protection" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@192# run show configuration commands | grep firewall +# set 'firewall' +# +# +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall all-ping 'enable' +# set firewall broadcast-ping 'enable' +# set firewall config-trap 'enable' +# set firewall group address-group MGMT-HOSTS address '192.0.1.1' +# set firewall group address-group MGMT-HOSTS address '192.0.1.3' +# set firewall group address-group MGMT-HOSTS address '192.0.1.5' +# set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' +# set firewall group network-group MGMT description 'This group has the Management network addresses' +# set firewall group network-group MGMT network '192.0.1.0/24' +# set firewall ip-src-route 'enable' +# set firewall log-martians 'enable' +# set firewall receive-redirects 'disable' +# set firewall send-redirects 'enable' +# set firewall source-validation 'strict' +# set firewall state-policy established action 'accept' +# set firewall state-policy established log 'enable' +# set firewall state-policy invalid action 'reject' +# set firewall syn-cookies 'enable' +# set firewall twa-hazards-protection 'enable' +# +- name: Replace firewall global attributes configuration. + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "This group has the Management hosts address list", +# "members": [ +# { +# "address": "192.0.1.1" +# }, +# { +# "address": "192.0.1.3" +# }, +# { +# "address": "192.0.1.5" +# } +# ], +# "name": "MGMT-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# +# "commands": [ +# "delete firewall group address-group MGMT-HOSTS", +# "set firewall group address-group SALES-HOSTS address 192.0.2.1", +# "set firewall group address-group SALES-HOSTS address 192.0.2.2", +# "set firewall group address-group SALES-HOSTS address 192.0.2.3", +# "set firewall group address-group SALES-HOSTS description 'Sales office hosts address list'", +# "set firewall group address-group SALES-HOSTS", +# "set firewall group address-group ENG-HOSTS address 192.0.3.1", +# "set firewall group address-group ENG-HOSTS address 192.0.3.2", +# "set firewall group address-group ENG-HOSTS description 'Sales office hosts address list'", +# "set firewall group address-group ENG-HOSTS" +# ] +# +# "after": { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.3.1" +# }, +# { +# "address": "192.0.3.2" +# } +# ], +# "name": "ENG-HOSTS" +# }, +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.2.1" +# }, +# { +# "address": "192.0.2.2" +# }, +# { +# "address": "192.0.2.3" +# } +# ], +# "name": "SALES-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep firewall +# set firewall all-ping 'enable' +# set firewall broadcast-ping 'enable' +# set firewall config-trap 'enable' +# set firewall group address-group ENG-HOSTS address '192.0.3.1' +# set firewall group address-group ENG-HOSTS address '192.0.3.2' +# set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' +# set firewall group address-group SALES-HOSTS address '192.0.2.1' +# set firewall group address-group SALES-HOSTS address '192.0.2.2' +# set firewall group address-group SALES-HOSTS address '192.0.2.3' +# set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' +# set firewall group network-group MGMT description 'This group has the Management network addresses' +# set firewall group network-group MGMT network '192.0.1.0/24' +# set firewall ip-src-route 'enable' +# set firewall log-martians 'enable' +# set firewall receive-redirects 'disable' +# set firewall send-redirects 'enable' +# set firewall source-validation 'strict' +# set firewall state-policy established action 'accept' +# set firewall state-policy established log 'enable' +# set firewall state-policy invalid action 'reject' +# set firewall syn-cookies 'enable' +# set firewall twa-hazards-protection 'enable' +# +# +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep firewall +# set firewall all-ping 'enable' +# set firewall broadcast-ping 'enable' +# set firewall config-trap 'enable' +# set firewall group address-group ENG-HOSTS address '192.0.3.1' +# set firewall group address-group ENG-HOSTS address '192.0.3.2' +# set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' +# set firewall group address-group SALES-HOSTS address '192.0.2.1' +# set firewall group address-group SALES-HOSTS address '192.0.2.2' +# set firewall group address-group SALES-HOSTS address '192.0.2.3' +# set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' +# set firewall group network-group MGMT description 'This group has the Management network addresses' +# set firewall group network-group MGMT network '192.0.1.0/24' +# set firewall ip-src-route 'enable' +# set firewall log-martians 'enable' +# set firewall receive-redirects 'disable' +# set firewall send-redirects 'enable' +# set firewall source-validation 'strict' +# set firewall state-policy established action 'accept' +# set firewall state-policy established log 'enable' +# set firewall state-policy invalid action 'reject' +# set firewall syn-cookies 'enable' +# set firewall twa-hazards-protection 'enable' +# +- name: Gather firewall global config with provided configurations + vyos.vyos.vyos_firewall_global: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.3.1" +# }, +# { +# "address": "192.0.3.2" +# } +# ], +# "name": "ENG-HOSTS" +# }, +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.2.1" +# }, +# { +# "address": "192.0.2.2" +# }, +# { +# "address": "192.0.2.3" +# } +# ], +# "name": "SALES-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep firewall +# set firewall all-ping 'enable' +# set firewall broadcast-ping 'enable' +# set firewall config-trap 'enable' +# set firewall group address-group ENG-HOSTS address '192.0.3.1' +# set firewall group address-group ENG-HOSTS address '192.0.3.2' +# set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' +# set firewall group address-group SALES-HOSTS address '192.0.2.1' +# set firewall group address-group SALES-HOSTS address '192.0.2.2' +# set firewall group address-group SALES-HOSTS address '192.0.2.3' +# set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' +# set firewall group network-group MGMT description 'This group has the Management network addresses' +# set firewall group network-group MGMT network '192.0.1.0/24' +# set firewall ip-src-route 'enable' +# set firewall log-martians 'enable' +# set firewall receive-redirects 'disable' +# set firewall send-redirects 'enable' +# set firewall source-validation 'strict' +# set firewall state-policy established action 'accept' +# set firewall state-policy established log 'enable' +# set firewall state-policy invalid action 'reject' +# set firewall syn-cookies 'enable' +# set firewall twa-hazards-protection 'enable' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set firewall group address-group SALES-HOSTS address 192.0.2.1", +# "set firewall group address-group SALES-HOSTS address 192.0.2.2", +# "set firewall group address-group SALES-HOSTS address 192.0.2.3", +# "set firewall group address-group SALES-HOSTS description 'Sales office hosts address list'", +# "set firewall group address-group SALES-HOSTS", +# "set firewall group address-group ENG-HOSTS address 192.0.3.1", +# "set firewall group address-group ENG-HOSTS address 192.0.3.2", +# "set firewall group address-group ENG-HOSTS description 'Sales office hosts address list'", +# "set firewall group address-group ENG-HOSTS", +# "set firewall group network-group MGMT network 192.0.1.0/24", +# "set firewall group network-group MGMT description 'This group has the Management network addresses'", +# "set firewall group network-group MGMT", +# "set firewall ip-src-route 'enable'", +# "set firewall receive-redirects 'disable'", +# "set firewall send-redirects 'enable'", +# "set firewall config-trap 'enable'", +# "set firewall state-policy established action 'accept'", +# "set firewall state-policy established log 'enable'", +# "set firewall state-policy invalid action 'reject'", +# "set firewall broadcast-ping 'enable'", +# "set firewall all-ping 'enable'", +# "set firewall log-martians 'enable'", +# "set firewall twa-hazards-protection 'enable'", +# "set firewall syn-cookies 'enable'", +# "set firewall source-validation 'strict'" +# ] +# +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['set firewall group address-group ENG-HOSTS', + 'set firewall group address-group ENG-HOSTS address 192.0.3.1'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_global.firewall_global import ( + Firewall_globalArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_global.firewall_global import ( + Firewall_global, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + module = AnsibleModule( + argument_spec=Firewall_globalArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Firewall_global(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_interfaces.py new file mode 100644 index 00000000..7ca936dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_interfaces.py @@ -0,0 +1,1288 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_firewall_interfaces +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_firewall_interfaces +short_description: FIREWALL interfaces resource module +description: Manage firewall rules of interfaces on VyOS network devices. +version_added: 1.0.0 +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: A list of firewall rules options for interfaces. + type: list + elements: dict + suboptions: + name: + description: + - Name/Identifier for the interface. + type: str + required: true + access_rules: + description: + - Specifies firewall rules attached to the interfaces. + type: list + elements: dict + suboptions: + afi: + description: + - Specifies the AFI for the Firewall rules to be configured on this interface. + type: str + choices: + - ipv4 + - ipv6 + required: true + rules: + description: + - Specifies the firewall rules for the provided AFI. + type: list + elements: dict + suboptions: + name: + description: + - Specifies the name of the IPv4/IPv6 Firewall rule for the interface. + type: str + direction: + description: + - Specifies the direction of packets that the firewall rule will be + applied on. + type: str + choices: + - in + - local + - out + required: true + running_config: + description: + - The module, by default, will connect to the remote device and retrieve the current + running-config to use as a base for comparing against the contents of source. + There are times when it is not desirable to have the task get the current running-config + for every task in a playbook. The I(running_config) argument allows the implementer + to pass in the configuration to use as the base config for comparison. This + value of this option should be the output received from device by executing + command C(show configuration commands | grep 'firewall' + type: str + state: + description: + - The state the configuration should be left in. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - parsed + - rendered + - gathered + default: merged + +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# +- name: Merge the provided configuration with the existing running configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth3 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": [ +# { +# "name": "eth0" +# }, +# { +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ] +# +# "commands": [ +# "set interfaces ethernet eth1 firewall in name 'INBOUND'", +# "set interfaces ethernet eth1 firewall out name 'OUTBOUND'", +# "set interfaces ethernet eth1 firewall local name 'LOCAL'", +# "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'", +# "set interfaces ethernet eth3 firewall in name 'INBOUND'", +# "set interfaces ethernet eth3 firewall out name 'OUTBOUND'", +# "set interfaces ethernet eth3 firewall local name 'LOCAL'", +# "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'" +# ] +# +# "after": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'INBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' + + +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'INBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' +# +- name: Merge the provided configuration with the existing running configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: in + - name: INBOUND + direction: out + name: eth1 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# "commands": [ +# "set interfaces ethernet eth1 firewall in name 'OUTBOUND'", +# "set interfaces ethernet eth1 firewall out name 'INBOUND'" +# ] +# +# "after": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "OUTBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "INBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'OUTBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'INBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'INBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' +# +- name: Replace device configurations of listed firewall interfaces with provided + configurations + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth1 + access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: out + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# "commands": [ +# "delete interfaces ethernet eth1 firewall in name", +# "delete interfaces ethernet eth1 firewall local name", +# "delete interfaces ethernet eth3 firewall local name", +# "delete interfaces ethernet eth3 firewall out name", +# "delete interfaces ethernet eth3 firewall local ipv6-name" +# ] +# +# "after": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall 'in' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall 'local' +# set interfaces ethernet eth3 firewall 'out' + + +# Using overridden +# +# Before state +# -------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall 'in' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall 'local' +# set interfaces ethernet eth3 firewall 'out' +# +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: out + state: overridden +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before":[ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# "commands": [ +# "delete interfaces ethernet eth1 firewall", +# "delete interfaces ethernet eth3 firewall in name", +# "set interfaces ethernet eth3 firewall out name 'INBOUND'" +# +# +# "after": [ +# { +# "name": "eth0" +# }, +# { +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "out", +# "name": "INBOUND" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# +# After state +# ------------ +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth3 firewall 'in' +# set interfaces ethernet eth3 firewall 'local' +# set interfaces ethernet eth3 firewall out name 'INBOUND' + + +# Using deleted per interface name +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'INBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' +# +- name: Delete firewall interfaces based on interface name. + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth1 + - name: eth3 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# "commands": [ +# "delete interfaces ethernet eth1 firewall", +# "delete interfaces ethernet eth3 firewall" +# ] +# +# "after": [ +# { +# "name": "eth0" +# }, +# { +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ] +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' + + +# Using deleted per afi +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'INBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' +# +- name: Delete firewall interfaces config per afi. + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth1 + access_rules: + - afi: ipv4 + - afi: ipv6 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "commands": [ +# "delete interfaces ethernet eth1 firewall in name", +# "delete interfaces ethernet eth1 firewall out name", +# "delete interfaces ethernet eth1 firewall local name", +# "delete interfaces ethernet eth1 firewall local ipv6-name" +# ] +# +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' + + +# Using deleted without config +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall in name 'INBOUND' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall local name 'LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth3 firewall local name 'LOCAL' +# set interfaces ethernet eth3 firewall out name 'OUTBOUND' +# +- name: Delete firewall interfaces config when empty config provided. + vyos.vyos.vyos_firewall_interfaces: + config: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "commands": [ +# "delete interfaces ethernet eth1 firewall", +# "delete interfaces ethernet eth1 firewall" +# ] +# +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' + + +# Using parsed +# +# +- name: Parse the provided configuration + vyos.vyos.vyos_firewall_interfaces: + running_config: + "set interfaces ethernet eth1 firewall in name 'INBOUND' + set interfaces ethernet eth1 firewall out name 'OUTBOUND' + set interfaces ethernet eth1 firewall local name 'LOCAL' + set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + set interfaces ethernet eth2 firewall in name 'INBOUND' + set interfaces ethernet eth2 firewall out name 'OUTBOUND' + set interfaces ethernet eth2 firewall local name 'LOCAL' + set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# }, +# { +# "direction": "local", +# "name": "LOCAL" +# }, +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ] + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall 'in' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall 'local' +# set interfaces ethernet eth3 firewall 'out' +# +- name: Gather listed firewall interfaces. + vyos.vyos.vyos_firewall_interfaces: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "name": "eth0" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "out", +# "name": "OUTBOUND" +# } +# ] +# }, +# { +# "afi": "ipv6", +# "rules": [ +# { +# "direction": "local", +# "name": "V6-LOCAL" +# } +# ] +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "access_rules": [ +# { +# "afi": "ipv4", +# "rules": [ +# { +# "direction": "in", +# "name": "INBOUND" +# } +# ] +# } +# ], +# "name": "eth3" +# } +# ] +# +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name 'V6-LOCAL' +# set firewall name 'INBOUND' +# set firewall name 'LOCAL' +# set firewall name 'OUTBOUND' +# set interfaces ethernet eth1 firewall 'in' +# set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +# set interfaces ethernet eth1 firewall out name 'OUTBOUND' +# set interfaces ethernet eth3 firewall in name 'INBOUND' +# set interfaces ethernet eth3 firewall 'local' +# set interfaces ethernet eth3 firewall 'out' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_interfaces: + config: + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INGRESS + - direction: out + name: OUTGRESS + - direction: local + name: DROP + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set interfaces ethernet eth2 firewall in name 'INGRESS'", +# "set interfaces ethernet eth2 firewall out name 'OUTGRESS'", +# "set interfaces ethernet eth2 firewall local name 'DROP'", +# "set interfaces ethernet eth2 firewall local ipv6-name 'LOCAL'" +# ] + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'" + - "set interfaces ethernet eth3 firewall in name 'INBOUND'" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_interfaces.firewall_interfaces import ( + Firewall_interfacesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_interfaces.firewall_interfaces import ( + Firewall_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + + module = AnsibleModule( + argument_spec=Firewall_interfacesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Firewall_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_rules.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_rules.py new file mode 100644 index 00000000..3bd6451d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_firewall_rules.py @@ -0,0 +1,1514 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_firewall_rules +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_firewall_rules +short_description: FIREWALL rules resource module +description: This module manages firewall rule-set attributes on VyOS devices +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: A dictionary of Firewall rule-set options. + type: list + elements: dict + suboptions: + afi: + description: + - Specifies the type of rule-set. + type: str + choices: + - ipv4 + - ipv6 + required: true + rule_sets: + description: + - The Firewall rule-set list. + type: list + elements: dict + suboptions: + name: + description: + - Firewall rule set name. + type: str + default_action: + description: + - Default action for rule-set. + - drop (Drop if no prior rules are hit (default)) + - reject (Drop and notify source if no prior rules are hit) + - accept (Accept if no prior rules are hit) + type: str + choices: + - drop + - reject + - accept + description: + description: + - Rule set description. + type: str + enable_default_log: + description: + - Option to log packets hitting default-action. + type: bool + rules: + description: + - A ditionary that specifies the rule-set configurations. + type: list + elements: dict + suboptions: + number: + description: + - Rule number. + type: int + required: true + description: + description: + - Description of this rule. + type: str + action: + description: + - Specifying the action. + type: str + choices: + - drop + - reject + - accept + - inspect + destination: + description: + - Specifying the destination parameters. + type: dict + suboptions: + address: + description: + - Destination ip address subnet or range. + - IPv4/6 address, subnet or range to match. + - Match everything except the specified address, subnet or range. + - Destination ip address subnet or range. + type: str + group: + description: + - Destination group. + type: dict + suboptions: + address_group: + description: + - Group of addresses. + type: str + network_group: + description: + - Group of networks. + type: str + port_group: + description: + - Group of ports. + type: str + port: + description: + - Multiple destination ports can be specified as a comma-separated + list. + - The whole list can also be "negated" using '!'. + - For example:'!22,telnet,http,123,1001-1005'. + type: str + disabled: + description: + - Option to disable firewall rule. + type: bool + fragment: + description: + - IP fragment match. + type: str + choices: + - match-frag + - match-non-frag + icmp: + description: + - ICMP type and code information. + type: dict + suboptions: + type_name: + description: + - ICMP type-name. + type: str + choices: + - any + - echo-reply + - destination-unreachable + - network-unreachable + - host-unreachable + - protocol-unreachable + - port-unreachable + - fragmentation-needed + - source-route-failed + - network-unknown + - host-unknown + - network-prohibited + - host-prohibited + - TOS-network-unreachable + - TOS-host-unreachable + - communication-prohibited + - host-precedence-violation + - precedence-cutoff + - source-quench + - redirect + - network-redirect + - host-redirect + - TOS-network-redirect + - TOS-host-redirect + - echo-request + - router-advertisement + - router-solicitation + - time-exceeded + - ttl-zero-during-transit + - ttl-zero-during-reassembly + - parameter-problem + - ip-header-bad + - required-option-missing + - timestamp-request + - timestamp-reply + - address-mask-request + - address-mask-reply + - ping + - pong + - ttl-exceeded + code: + description: + - ICMP code. + type: int + type: + description: + - ICMP type. + type: int + ipsec: + description: + - Inboud ip sec packets. + type: str + choices: + - match-ipsec + - match-none + limit: + description: + - Rate limit using a token bucket filter. + type: dict + suboptions: + burst: + description: + - Maximum number of packets to allow in excess of rate. + type: int + rate: + description: + - format for rate (integer/time unit). + - any one of second, minute, hour or day may be used to specify + time unit. + - eg. 1/second implies rule to be matched at an average of once + per second. + type: dict + suboptions: + number: + description: + - This is the integer value. + type: int + unit: + description: + - This is the time unit. + type: str + p2p: + description: + - P2P application packets. + type: list + elements: dict + suboptions: + application: + description: + - Name of the application. + type: str + choices: + - all + - applejuice + - bittorrent + - directconnect + - edonkey + - gnutella + - kazaa + protocol: + description: + - Protocol to match (protocol name in /etc/protocols or protocol number + or all). + - <text> IP protocol name from /etc/protocols (e.g. "tcp" or "udp"). + - <0-255> IP protocol number. + - tcp_udp Both TCP and UDP. + - all All IP protocols. + - (!)All IP protocols except for the specified name or number. + type: str + recent: + description: + - Parameters for matching recently seen sources. + type: dict + suboptions: + count: + description: + - Source addresses seen more than N times. + type: int + time: + description: + - Source addresses seen in the last N seconds. + type: int + source: + description: + - Source parameters. + type: dict + suboptions: + address: + description: + - Source ip address subnet or range. + - IPv4/6 address, subnet or range to match. + - Match everything except the specified address, subnet or range. + - Source ip address subnet or range. + type: str + group: + description: + - Source group. + type: dict + suboptions: + address_group: + description: + - Group of addresses. + type: str + network_group: + description: + - Group of networks. + type: str + port_group: + description: + - Group of ports. + type: str + port: + description: + - Multiple source ports can be specified as a comma-separated + list. + - The whole list can also be "negated" using '!'. + - For example:'!22,telnet,http,123,1001-1005'. + type: str + mac_address: + description: + - <MAC address> MAC address to match. + - <!MAC address> Match everything except the specified MAC address. + type: str + state: + description: + - Session state. + type: dict + suboptions: + established: + description: + - Established state. + type: bool + invalid: + description: + - Invalid state. + type: bool + new: + description: + - New state. + type: bool + related: + description: + - Related state. + type: bool + tcp: + description: + - TCP flags to match. + type: dict + suboptions: + flags: + description: + - TCP flags to be matched. + type: str + time: + description: + - Time to match rule. + type: dict + suboptions: + utc: + description: + - Interpret times for startdate, stopdate, starttime and stoptime + to be UTC. + type: bool + monthdays: + description: + - Monthdays to match rule on. + type: str + startdate: + description: + - Date to start matching rule. + type: str + starttime: + description: + - Time of day to start matching rule. + type: str + stopdate: + description: + - Date to stop matching rule. + type: str + stoptime: + description: + - Time of day to stop matching rule. + type: str + weekdays: + description: + - Weekdays to match rule on. + type: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep firewall). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state the configuration should be left in + type: str + choices: + - merged + - replaced + - overridden + - deleted + - gathered + - rendered + - parsed + default: merged + +""" +EXAMPLES = """ +# Using deleted to delete firewall rules based on rule-set name +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall name Downlink default-action 'accept' +# set firewall name Downlink description 'IPv4 INBOUND rule set' +# set firewall name Downlink rule 501 action 'accept' +# set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' +# set firewall name Downlink rule 501 ipsec 'match-ipsec' +# set firewall name Downlink rule 502 action 'reject' +# set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' +# set firewall name Downlink rule 502 ipsec 'match-ipsec' +# +- name: Delete attributes of given firewall rules. + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv4 + rule_sets: + - name: Downlink + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "Downlink", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 501 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 501 +# }, +# { +# "action": "reject", +# "description": "Rule 502 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 502 +# } +# ] +# } +# ] +# } +# ] +# "commands": [ +# "delete firewall name Downlink" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep firewall +# set firewall group address-group 'inbound' + + +# Using deleted to delete firewall rules based on afi +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall ipv6-name UPLINK rule 1 action 'accept' +# set firewall ipv6-name UPLINK rule 1 +# set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +# set firewall ipv6-name UPLINK rule 2 action 'accept' +# set firewall ipv6-name UPLINK rule 2 +# set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' +# set firewall group address-group 'inbound' +# set firewall name Downlink default-action 'accept' +# set firewall name Downlink description 'IPv4 INBOUND rule set' +# set firewall name Downlink rule 501 action 'accept' +# set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' +# set firewall name Downlink rule 501 ipsec 'match-ipsec' +# set firewall name Downlink rule 502 action 'reject' +# set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' +# set firewall name Downlink rule 502 ipsec 'match-ipsec' + +# +- name: Delete attributes of given firewall rules. + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv4 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK", +# "rules": [ +# { +# "action": "accept", +# "description": "Fwipv6-Rule 1 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 1 +# }, +# { +# "action": "accept", +# "description": "Fwipv6-Rule 2 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 2 +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "Downlink", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 501 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 501 +# }, +# { +# "action": "reject", +# "description": "Rule 502 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 502 +# } +# ] +# } +# ] +# } +# ] +# "commands": [ +# "delete firewall name" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall ipv6-name UPLINK rule 1 action 'accept' +# set firewall ipv6-name UPLINK rule 1 +# set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +# set firewall ipv6-name UPLINK rule 2 action 'accept' +# set firewall ipv6-name UPLINK rule 2 +# set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + + +# Using deleted to delete all the the firewall rules when provided config is empty +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall name Downlink default-action 'accept' +# set firewall name Downlink description 'IPv4 INBOUND rule set' +# set firewall name Downlink rule 501 action 'accept' +# set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' +# set firewall name Downlink rule 501 ipsec 'match-ipsec' +# set firewall name Downlink rule 502 action 'reject' +# set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' +# set firewall name Downlink rule 502 ipsec 'match-ipsec' +# +- name: Delete attributes of given firewall rules. + vyos.vyos.vyos_firewall_rules: + config: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "Downlink", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 501 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 501 +# }, +# { +# "action": "reject", +# "description": "Rule 502 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 502 +# } +# ] +# } +# ] +# } +# ] +# "commands": [ +# "delete firewall name" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep firewall +# set firewall group address-group 'inbound' + + +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos# run show configuration commands | grep firewall +# set firewall group address-group 'inbound' +# +- name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": [] +# +# "commands": [ +# "set firewall ipv6-name UPLINK default-action 'accept'", +# "set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set'", +# "set firewall ipv6-name UPLINK rule 1 action 'accept'", +# "set firewall ipv6-name UPLINK rule 1", +# "set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible'", +# "set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec'", +# "set firewall ipv6-name UPLINK rule 2 action 'accept'", +# "set firewall ipv6-name UPLINK rule 2", +# "set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible'", +# "set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec'", +# "set firewall name INBOUND default-action 'accept'", +# "set firewall name INBOUND description 'IPv4 INBOUND rule set'", +# "set firewall name INBOUND rule 101 action 'accept'", +# "set firewall name INBOUND rule 101", +# "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", +# "set firewall name INBOUND rule 101 ipsec 'match-ipsec'", +# "set firewall name INBOUND rule 102 action 'reject'", +# "set firewall name INBOUND rule 102", +# "set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible'", +# "set firewall name INBOUND rule 102 ipsec 'match-ipsec'", +# "set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible'", +# "set firewall name INBOUND rule 103 destination group address-group inbound", +# "set firewall name INBOUND rule 103", +# "set firewall name INBOUND rule 103 source address 192.0.2.0", +# "set firewall name INBOUND rule 103 state established enable", +# "set firewall name INBOUND rule 103 state related enable", +# "set firewall name INBOUND rule 103 state invalid disable", +# "set firewall name INBOUND rule 103 state new disable", +# "set firewall name INBOUND rule 103 action 'accept'" +# ] +# +# "after": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK", +# "rules": [ +# { +# "action": "accept", +# "description": "Fwipv6-Rule 1 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 1 +# }, +# { +# "action": "accept", +# "description": "Fwipv6-Rule 2 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 2 +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "INBOUND", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 101 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 101 +# }, +# { +# "action": "reject", +# "description": "Rule 102 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 102 +# }, +# { +# "action": "accept", +# "description": "Rule 103 is configured by Ansible", +# "destination": { +# "group": { +# "address_group": "inbound" +# } +# }, +# "number": 103, +# "source": { +# "address": "192.0.2.0" +# }, +# "state": { +# "established": true, +# "invalid": false, +# "new": false, +# "related": true +# } +# } +# ] +# } +# ] +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall ipv6-name UPLINK rule 1 action 'accept' +# set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +# set firewall ipv6-name UPLINK rule 2 action 'accept' +# set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' +# set firewall name INBOUND default-action 'accept' +# set firewall name INBOUND description 'IPv4 INBOUND rule set' +# set firewall name INBOUND rule 101 action 'accept' +# set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +# set firewall name INBOUND rule 101 ipsec 'match-ipsec' +# set firewall name INBOUND rule 102 action 'reject' +# set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' +# set firewall name INBOUND rule 102 ipsec 'match-ipsec' +# set firewall name INBOUND rule 103 action 'accept' +# set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' +# set firewall name INBOUND rule 103 destination group address-group 'inbound' +# set firewall name INBOUND rule 103 source address '192.0.2.0' +# set firewall name INBOUND rule 103 state established 'enable' +# set firewall name INBOUND rule 103 state invalid 'disable' +# set firewall name INBOUND rule 103 state new 'disable' +# set firewall name INBOUND rule 103 state related 'enable' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall ipv6-name UPLINK rule 1 action 'accept' +# set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +# set firewall ipv6-name UPLINK rule 2 action 'accept' +# set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' +# set firewall name INBOUND default-action 'accept' +# set firewall name INBOUND description 'IPv4 INBOUND rule set' +# set firewall name INBOUND rule 101 action 'accept' +# set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +# set firewall name INBOUND rule 101 ipsec 'match-ipsec' +# set firewall name INBOUND rule 102 action 'reject' +# set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' +# set firewall name INBOUND rule 102 ipsec 'match-ipsec' +# set firewall name INBOUND rule 103 action 'accept' +# set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' +# set firewall name INBOUND rule 103 destination group address-group 'inbound' +# set firewall name INBOUND rule 103 source address '192.0.2.0' +# set firewall name INBOUND rule 103 state established 'enable' +# set firewall name INBOUND rule 103 state invalid 'disable' +# set firewall name INBOUND rule 103 state new 'disable' +# set firewall name INBOUND rule 103 state related 'enable' +# +- name: Replace device configurations of listed firewall rules with provided configurations + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK", +# "rules": [ +# { +# "action": "accept", +# "description": "Fwipv6-Rule 1 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 1 +# }, +# { +# "action": "accept", +# "description": "Fwipv6-Rule 2 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 2 +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "INBOUND", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 101 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 101 +# }, +# { +# "action": "reject", +# "description": "Rule 102 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 102 +# }, +# { +# "action": "accept", +# "description": "Rule 103 is configured by Ansible", +# "destination": { +# "group": { +# "address_group": "inbound" +# } +# }, +# "number": 103, +# "source": { +# "address": "192.0.2.0" +# }, +# "state": { +# "established": true, +# "invalid": false, +# "new": false, +# "related": true +# } +# } +# ] +# } +# ] +# } +# ] +# +# "commands": [ +# "delete firewall ipv6-name UPLINK rule 1", +# "delete firewall ipv6-name UPLINK rule 2", +# "delete firewall name INBOUND rule 102", +# "delete firewall name INBOUND rule 103", +# "set firewall name INBOUND rule 104 action 'reject'", +# "set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible'", +# "set firewall name INBOUND rule 104", +# "set firewall name INBOUND rule 104 ipsec 'match-none'" +# ] +# +# "after": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK" +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "INBOUND", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 101 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 101 +# }, +# { +# "action": "reject", +# "description": "Rule 104 is configured by Ansible", +# "ipsec": "match-none", +# "number": 104 +# } +# ] +# } +# ] +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall name INBOUND default-action 'accept' +# set firewall name INBOUND description 'IPv4 INBOUND rule set' +# set firewall name INBOUND rule 101 action 'accept' +# set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +# set firewall name INBOUND rule 101 ipsec 'match-ipsec' +# set firewall name INBOUND rule 104 action 'reject' +# set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible' +# set firewall name INBOUND rule 104 ipsec 'match-none' + + +# Using overridden +# +# Before state +# -------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall name INBOUND default-action 'accept' +# set firewall name INBOUND description 'IPv4 INBOUND rule set' +# set firewall name INBOUND rule 101 action 'accept' +# set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +# set firewall name INBOUND rule 101 ipsec 'match-ipsec' +# set firewall name INBOUND rule 104 action 'reject' +# set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible' +# set firewall name INBOUND rule 104 ipsec 'match-none' +# +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv4 + rule_sets: + - name: Downlink + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 501 + action: accept + description: Rule 501 is configured by Ansible + ipsec: match-ipsec + - number: 502 + action: reject + description: Rule 502 is configured by Ansible + ipsec: match-ipsec + state: overridden +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK" +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "INBOUND", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 101 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 101 +# }, +# { +# "action": "reject", +# "description": "Rule 104 is configured by Ansible", +# "ipsec": "match-none", +# "number": 104 +# } +# ] +# } +# ] +# } +# ] +# +# "commands": [ +# "delete firewall ipv6-name UPLINK", +# "delete firewall name INBOUND", +# "set firewall name Downlink default-action 'accept'", +# "set firewall name Downlink description 'IPv4 INBOUND rule set'", +# "set firewall name Downlink rule 501 action 'accept'", +# "set firewall name Downlink rule 501", +# "set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible'", +# "set firewall name Downlink rule 501 ipsec 'match-ipsec'", +# "set firewall name Downlink rule 502 action 'reject'", +# "set firewall name Downlink rule 502", +# "set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'", +# "set firewall name Downlink rule 502 ipsec 'match-ipsec'" +# +# +# "after": [ +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "Downlink", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 501 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 501 +# }, +# { +# "action": "reject", +# "description": "Rule 502 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 502 +# } +# ] +# } +# ] +# } +# ] +# +# +# After state +# ------------ +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall name Downlink default-action 'accept' +# set firewall name Downlink description 'IPv4 INBOUND rule set' +# set firewall name Downlink rule 501 action 'accept' +# set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' +# set firewall name Downlink rule 501 ipsec 'match-ipsec' +# set firewall name Downlink rule 502 action 'reject' +# set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' +# set firewall name Downlink rule 502 ipsec 'match-ipsec' + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall ipv6-name UPLINK rule 1 action 'accept' +# set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +# set firewall ipv6-name UPLINK rule 2 action 'accept' +# set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' +# set firewall name INBOUND default-action 'accept' +# set firewall name INBOUND description 'IPv4 INBOUND rule set' +# set firewall name INBOUND rule 101 action 'accept' +# set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +# set firewall name INBOUND rule 101 ipsec 'match-ipsec' +# set firewall name INBOUND rule 102 action 'reject' +# set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' +# set firewall name INBOUND rule 102 ipsec 'match-ipsec' +# set firewall name INBOUND rule 103 action 'accept' +# set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' +# set firewall name INBOUND rule 103 destination group address-group 'inbound' +# set firewall name INBOUND rule 103 source address '192.0.2.0' +# set firewall name INBOUND rule 103 state established 'enable' +# set firewall name INBOUND rule 103 state invalid 'disable' +# set firewall name INBOUND rule 103 state new 'disable' +# set firewall name INBOUND rule 103 state related 'enable' +# +- name: Gather listed firewall rules with provided configurations + vyos.vyos.vyos_firewall_rules: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK", +# "rules": [ +# { +# "action": "accept", +# "description": "Fwipv6-Rule 1 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 1 +# }, +# { +# "action": "accept", +# "description": "Fwipv6-Rule 2 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 2 +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "INBOUND", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 101 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 101 +# }, +# { +# "action": "reject", +# "description": "Rule 102 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 102 +# }, +# { +# "action": "accept", +# "description": "Rule 103 is configured by Ansible", +# "destination": { +# "group": { +# "address_group": "inbound" +# } +# }, +# "number": 103, +# "source": { +# "address": "192.0.2.0" +# }, +# "state": { +# "established": true, +# "invalid": false, +# "new": false, +# "related": true +# } +# } +# ] +# } +# ] +# } +# ] +# +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep firewall +# set firewall group address-group 'inbound' +# set firewall ipv6-name UPLINK default-action 'accept' +# set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +# set firewall ipv6-name UPLINK rule 1 action 'accept' +# set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +# set firewall ipv6-name UPLINK rule 2 action 'accept' +# set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +# set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' +# set firewall name INBOUND default-action 'accept' +# set firewall name INBOUND description 'IPv4 INBOUND rule set' +# set firewall name INBOUND rule 101 action 'accept' +# set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +# set firewall name INBOUND rule 101 ipsec 'match-ipsec' +# set firewall name INBOUND rule 102 action 'reject' +# set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' +# set firewall name INBOUND rule 102 ipsec 'match-ipsec' +# set firewall name INBOUND rule 103 action 'accept' +# set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' +# set firewall name INBOUND rule 103 destination group address-group 'inbound' +# set firewall name INBOUND rule 103 source address '192.0.2.0' +# set firewall name INBOUND rule 103 state established 'enable' +# set firewall name INBOUND rule 103 state invalid 'disable' +# set firewall name INBOUND rule 103 state new 'disable' +# set firewall name INBOUND rule 103 state related 'enable' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_firewall_rules: + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set firewall ipv6-name UPLINK default-action 'accept'", +# "set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set'", +# "set firewall name INBOUND default-action 'accept'", +# "set firewall name INBOUND description 'IPv4 INBOUND rule set'", +# "set firewall name INBOUND rule 101 action 'accept'", +# "set firewall name INBOUND rule 101", +# "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", +# "set firewall name INBOUND rule 101 ipsec 'match-ipsec'", +# "set firewall name INBOUND rule 102 action 'reject'", +# "set firewall name INBOUND rule 102", +# "set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible'", +# "set firewall name INBOUND rule 102 ipsec 'match-ipsec'", +# "set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible'", +# "set firewall name INBOUND rule 103 destination group address-group inbound", +# "set firewall name INBOUND rule 103", +# "set firewall name INBOUND rule 103 source address 192.0.2.0", +# "set firewall name INBOUND rule 103 state established enable", +# "set firewall name INBOUND rule 103 state related enable", +# "set firewall name INBOUND rule 103 state invalid disable", +# "set firewall name INBOUND rule 103 state new disable", +# "set firewall name INBOUND rule 103 action 'accept'" +# ] + + +# Using parsed +# +# +- name: Parsed the provided input commands. + vyos.vyos.vyos_firewall_rules: + running_config: + "set firewall group address-group 'inbound' + set firewall name Downlink default-action 'accept' + set firewall name Downlink description 'IPv4 INBOUND rule set' + set firewall name Downlink rule 501 action 'accept' + set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + set firewall name Downlink rule 501 ipsec 'match-ipsec' + set firewall name Downlink rule 502 action 'reject' + set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + set firewall name Downlink rule 502 ipsec 'match-ipsec'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "Downlink", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 501 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 501 +# }, +# { +# "action": "reject", +# "description": "Rule 502 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 502 +# } +# ] +# } +# ] +# } +# ] + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - "set firewall name Downlink default-action 'accept'" + - "set firewall name Downlink description 'IPv4 INBOUND rule set'" + - "set firewall name Downlink rule 501 action 'accept'" + - "set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'" + - "set firewall name Downlink rule 502 ipsec 'match-ipsec'" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.firewall_rules.firewall_rules import ( + Firewall_rulesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_rules.firewall_rules import ( + Firewall_rules, +) + + +def main(): + """ + Main entry point for module execution + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + + module = AnsibleModule( + argument_spec=Firewall_rulesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + result = Firewall_rules(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_interface.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_interface.py new file mode 100644 index 00000000..04fd85de --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_interface.py @@ -0,0 +1,554 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +module: vyos_interface +author: Ganesh Nalawade (@ganeshrn) +short_description: (deprecated, removed after 2022-06-01) Manage Interface on VyOS + network devices +description: +- This module provides declarative management of Interfaces on VyOS network devices. +version_added: 1.0.0 +deprecated: + alternative: vyos_interfaces + why: Updated modules released with more functionality. + removed_at_date: '2022-06-01' +notes: +- Tested against VYOS 1.1.7 +options: + name: + description: + - Name of the Interface. + type: str + description: + description: + - Description of Interface. + type: str + enabled: + description: + - Interface link status. + type: bool + default: True + speed: + description: + - Interface link speed. + type: str + mtu: + description: + - Maximum size of transmit packet. + type: int + duplex: + description: + - Interface link status. + type: str + choices: + - full + - half + - auto + delay: + description: + - Time in seconds to wait before checking for the operational state on remote + device. This wait is applicable for operational state argument which are I(state) + with values C(up)/C(down) and I(neighbors). + default: 10 + type: int + neighbors: + description: + - Check the operational state of given interface C(name) for LLDP neighbor. + - The following suboptions are available. + type: list + elements: dict + suboptions: + host: + description: + - LLDP neighbor host for given interface C(name). + type: str + port: + description: + - LLDP neighbor port to which given interface C(name) is connected. + type: str + aggregate: + description: List of Interfaces definitions. + type: list + elements: dict + suboptions: + name: + description: + - Name of the Interface. + required: true + type: str + description: + description: + - Description of Interface. + type: str + enabled: + description: + - Interface link status. + type: bool + speed: + description: + - Interface link speed. + type: str + mtu: + description: + - Maximum size of transmit packet. + type: int + duplex: + description: + - Interface link status. + type: str + choices: + - full + - half + - auto + delay: + description: + - Time in seconds to wait before checking for the operational state on remote + device. This wait is applicable for operational state argument which are I(state) + with values C(up)/C(down) and I(neighbors). + type: int + neighbors: + description: + - Check the operational state of given interface C(name) for LLDP neighbor. + - The following suboptions are available. + type: list + elements: dict + suboptions: + host: + description: + - LLDP neighbor host for given interface C(name). + type: str + port: + description: + - LLDP neighbor port to which given interface C(name) is connected. + type: str + state: + description: + - State of the Interface configuration, C(up) means present and operationally + up and C(down) means present and operationally C(down) + type: str + choices: + - present + - absent + - up + - down + state: + description: + - State of the Interface configuration, C(up) means present and operationally + up and C(down) means present and operationally C(down) + default: present + type: str + choices: + - present + - absent + - up + - down +extends_documentation_fragment: +- vyos.vyos.vyos + + +""" + +EXAMPLES = """ +- name: configure interface + vyos.vyos.vyos_interface: + name: eth0 + description: test-interface + +- name: remove interface + vyos.vyos.vyos_interface: + name: eth0 + state: absent + +- name: make interface down + vyos.vyos.vyos_interface: + name: eth0 + enabled: false + +- name: make interface up + vyos.vyos.vyos_interface: + name: eth0 + enabled: true + +- name: Configure interface speed, mtu, duplex + vyos.vyos.vyos_interface: + name: eth5 + state: present + speed: 100 + mtu: 256 + duplex: full + +- name: Set interface using aggregate + vyos.vyos.vyos_interface: + aggregate: + - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512} + - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256} + +- name: Disable interface on aggregate + net_interface: + aggregate: + - name: eth1 + - name: eth2 + enabled: false + +- name: Delete interface using aggregate + net_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + +- name: Check lldp neighbors intent arguments + vyos.vyos.vyos_interface: + name: eth0 + neighbors: + - port: eth0 + host: netdev + +- name: Config + intent + vyos.vyos.vyos_interface: + name: eth1 + enabled: false + state: down +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always, except for the platforms that use Netconf transport to manage the device. + type: list + sample: + - set interfaces ethernet eth0 description "test-interface" + - set interfaces ethernet eth0 speed 100 + - set interfaces ethernet eth0 mtu 256 + - set interfaces ethernet eth0 duplex full +""" +import re + +from copy import deepcopy +from time import sleep + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.connection import exec_command +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + conditional, + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + load_config, + get_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def search_obj_in_list(name, lst): + for o in lst: + if o["name"] == name: + return o + + return None + + +def map_obj_to_commands(updates): + commands = list() + want, have = updates + params = ("speed", "description", "duplex", "mtu") + for w in want: + name = w["name"] + disable = w["disable"] + state = w["state"] + + obj_in_have = search_obj_in_list(name, have) + set_interface = "set interfaces ethernet " + name + delete_interface = "delete interfaces ethernet " + name + + if state == "absent" and obj_in_have: + commands.append(delete_interface) + elif state in ("present", "up", "down"): + if obj_in_have: + for item in params: + value = w.get(item) + + if value and value != obj_in_have.get(item): + if item == "description": + value = "'" + str(value) + "'" + commands.append( + set_interface + " " + item + " " + str(value) + ) + + if disable and not obj_in_have.get("disable", False): + commands.append(set_interface + " disable") + elif not disable and obj_in_have.get("disable", False): + commands.append(delete_interface + " disable") + else: + commands.append(set_interface) + for item in params: + value = w.get(item) + if value: + if item == "description": + value = "'" + str(value) + "'" + commands.append( + set_interface + " " + item + " " + str(value) + ) + + if disable: + commands.append(set_interface + " disable") + return commands + + +def map_config_to_obj(module): + data = get_config(module, flags=["| grep interface"]) + obj = [] + for line in data.split("\n"): + if line.startswith("set interfaces ethernet"): + match = re.search(r"set interfaces ethernet (\S+)", line, re.M) + name = match.group(1) + if name: + interface = {} + for item in obj: + if item["name"] == name: + interface = item + break + + if not interface: + interface = {"name": name} + obj.append(interface) + + match = re.search(r"%s (\S+)" % name, line, re.M) + if match: + param = match.group(1) + if param == "description": + match = re.search(r"description (.+)", line, re.M) + description = match.group(1).strip("'") + interface["description"] = description + elif param == "speed": + match = re.search(r"speed (\S+)", line, re.M) + speed = match.group(1).strip("'") + interface["speed"] = speed + elif param == "mtu": + match = re.search(r"mtu (\S+)", line, re.M) + mtu = match.group(1).strip("'") + interface["mtu"] = int(mtu) + elif param == "duplex": + match = re.search(r"duplex (\S+)", line, re.M) + duplex = match.group(1).strip("'") + interface["duplex"] = duplex + elif param.strip("'") == "disable": + interface["disable"] = True + + return obj + + +def map_params_to_obj(module): + obj = [] + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + d = item.copy() + if d["enabled"]: + d["disable"] = False + else: + d["disable"] = True + + obj.append(d) + else: + params = { + "name": module.params["name"], + "description": module.params["description"], + "speed": module.params["speed"], + "mtu": module.params["mtu"], + "duplex": module.params["duplex"], + "delay": module.params["delay"], + "state": module.params["state"], + "neighbors": module.params["neighbors"], + } + + if module.params["enabled"]: + params.update({"disable": False}) + else: + params.update({"disable": True}) + + obj.append(params) + return obj + + +def get_interfaces_data(module, name): + command = "show interfaces ethernet %s" % name + rc, out, err = exec_command(module, command) + return [rc, out, err] + + +def get_lldp_neighbor(module): + command = "show lldp neighbors detail" + rc, out, err = exec_command(module, command) + return [rc, out, err] + + +def check_declarative_intent_params(module, want, result): + failed_conditions = [] + have_neighbors = None + for w in want: + want_state = w.get("state") + want_neighbors = w.get("neighbors") + + if want_state not in ("up", "down") and not want_neighbors: + continue + + if result["changed"]: + sleep(w["delay"]) + + command = "show interfaces ethernet %s" % w["name"] + rc, out, err = get_interfaces_data(w["name"], module) + if rc != 0: + module.fail_json( + msg=to_text(err, errors="surrogate_then_replace"), + command=command, + rc=rc, + ) + + if want_state in ("up", "down"): + match = re.search(r"%s (\w+)" % "state", out, re.M) + have_state = None + if match: + have_state = match.group(1) + if have_state is None or not conditional( + want_state, have_state.strip().lower() + ): + failed_conditions.append("state " + "eq(%s)" % want_state) + + if want_neighbors: + have_host = [] + have_port = [] + if have_neighbors is None: + rc, have_neighbors, err = get_lldp_neighbor(module) + if rc != 0: + module.fail_json( + msg=to_text(err, errors="surrogate_then_replace"), + command=command, + rc=rc, + ) + + if have_neighbors: + lines = have_neighbors.strip().split("Interface: ") + for line in lines: + field = line.split("\n") + if field[0].split(",")[0].strip() == w["name"]: + for item in field: + if item.strip().startswith("SysName:"): + have_host.append(item.split(":")[1].strip()) + if item.strip().startswith("PortDescr:"): + have_port.append(item.split(":")[1].strip()) + for item in want_neighbors: + host = item.get("host") + port = item.get("port") + if host and host not in have_host: + failed_conditions.append("host " + host) + if port and port not in have_port: + failed_conditions.append("port " + port) + + return failed_conditions + + +def main(): + """main entry point for module execution""" + neighbors_spec = dict(host=dict(), port=dict()) + + element_spec = dict( + name=dict(), + description=dict(), + speed=dict(), + mtu=dict(type="int"), + duplex=dict(choices=["full", "half", "auto"]), + enabled=dict(default=True, type="bool"), + neighbors=dict(type="list", elements="dict", options=neighbors_spec), + delay=dict(default=10, type="int"), + state=dict( + default="present", choices=["present", "absent", "up", "down"] + ), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["name"] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + required_one_of = [["name", "aggregate"]] + mutually_exclusive = [["name", "aggregate"]] + + required_together = [["speed", "duplex"]] + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, + required_together=required_together, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + + if warnings: + result["warnings"] = warnings + + want = map_params_to_obj(module) + have = map_config_to_obj(module) + + commands = map_obj_to_commands((want, have)) + result["commands"] = commands + + if commands: + commit = not module.check_mode + diff = load_config(module, commands, commit=commit) + if diff: + if module._diff: + result["diff"] = {"prepared": diff} + result["changed"] = True + + failed_conditions = check_declarative_intent_params(module, want, result) + + if failed_conditions: + msg = "One or more conditional statements have not been satisfied" + module.fail_json(msg=msg, failed_conditions=failed_conditions) + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_interfaces.py new file mode 100644 index 00000000..87738c69 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_interfaces.py @@ -0,0 +1,1134 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_interfaces +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_interfaces +short_description: Interfaces resource module +description: +- This module manages the interface attributes on VyOS network devices. +- This module supports managing base attributes of Ethernet, Bonding, VXLAN, Loopback + and Virtual Tunnel Interfaces. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Nilashish Chakraborty (@nilashishc) +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: The provided interfaces configuration. + type: list + elements: dict + suboptions: + name: + description: + - Full name of the interface, e.g. eth0, eth1, bond0, vti1, vxlan2. + type: str + required: true + description: + description: + - Interface description. + type: str + duplex: + description: + - Interface duplex mode. + - Applicable for Ethernet interfaces only. + choices: + - full + - half + - auto + type: str + enabled: + default: true + description: + - Administrative state of the interface. + - Set the value to C(true) to administratively enable the interface or C(false) + to disable it. + type: bool + mtu: + description: + - MTU for a specific interface. Refer to vendor documentation for valid values. + - Applicable for Ethernet, Bonding, VXLAN and Virtual Tunnel interfaces. + type: int + speed: + description: + - Interface link speed. + - Applicable for Ethernet interfaces only. + type: str + choices: + - auto + - '10' + - '100' + - '1000' + - '2500' + - '10000' + vifs: + description: + - Virtual sub-interfaces related configuration. + - 802.1Q VLAN interfaces are represented as virtual sub-interfaces in VyOS. + type: list + elements: dict + suboptions: + vlan_id: + description: + - Identifier for the virtual sub-interface. + type: int + description: + description: + - Virtual sub-interface description. + type: str + enabled: + description: + - Administrative state of the virtual sub-interface. + - Set the value to C(true) to administratively enable the interface or + C(false) to disable it. + type: bool + default: true + mtu: + description: + - MTU for the virtual sub-interface. + - Refer to vendor documentation for valid values. + type: int + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep interfaces). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - rendered + - gathered + - parsed + default: merged +""" +EXAMPLES = """ +# Using merged +# +# ------------- +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces loopback lo + +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_interfaces: + config: + - name: eth2 + description: Configured by Ansible + enabled: true + vifs: + - vlan_id: 200 + description: VIF 200 - ETH2 + + - name: eth3 + description: Configured by Ansible + mtu: 1500 + + - name: bond1 + description: Bond - 1 + mtu: 1200 + + - name: vti2 + description: VTI - 2 + enabled: false + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "enabled": true, +# "name": "eth3" +# }, +# { +# "enabled": true, +# "name": "eth2" +# }, +# { +# "enabled": true, +# "name": "eth1" +# }, +# { +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# "commands": [ +# "set interfaces ethernet eth2 description 'Configured by Ansible'", +# "set interfaces ethernet eth2 vif 200", +# "set interfaces ethernet eth2 vif 200 description 'VIF 200 - ETH2'", +# "set interfaces ethernet eth3 description 'Configured by Ansible'", +# "set interfaces ethernet eth3 mtu '1500'", +# "set interfaces bonding bond1", +# "set interfaces bonding bond1 description 'Bond - 1'", +# "set interfaces bonding bond1 mtu '1200'", +# "set interfaces vti vti2", +# "set interfaces vti vti2 description 'VTI - 2'", +# "set interfaces vti vti2 disable" +# ] +# +# "after": [ +# { +# "description": "Bond - 1", +# "enabled": true, +# "mtu": 1200, +# "name": "bond1" +# }, +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "description": "VTI - 2", +# "enabled": false, +# "name": "vti2" +# }, +# { +# "description": "Configured by Ansible", +# "enabled": true, +# "mtu": 1500, +# "name": "eth3" +# }, +# { +# "description": "Configured by Ansible", +# "enabled": true, +# "name": "eth2", +# "vifs": [ +# { +# "description": "VIF 200 - ETH2", +# "enabled": true, +# "vlan_id": "200" +# } +# ] +# }, +# { +# "enabled": true, +# "name": "eth1" +# }, +# { +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# +# ------------- +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces bonding bond1 description 'Bond - 1' +# set interfaces bonding bond1 mtu '1200' +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth2 description 'Configured by Ansible' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth2 vif 200 description 'VIF 200 - ETH2' +# set interfaces ethernet eth3 description 'Configured by Ansible' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 mtu '1500' +# set interfaces loopback lo +# set interfaces vti vti2 description 'VTI - 2' +# set interfaces vti vti2 disable +# + + +# Using replaced +# +# ------------- +# Before state: +# ------------- +# +# vyos:~$ show configuration commands | grep eth +# set interfaces bonding bond1 description 'Bond - 1' +# set interfaces bonding bond1 mtu '1400' +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 description 'Management Interface for the Appliance' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:f3:6c:b5' +# set interfaces ethernet eth0 smp_affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 description 'Configured by Ansible Eng Team' +# set interfaces ethernet eth1 duplex 'full' +# set interfaces ethernet eth1 hw-id '08:00:27:ad:ef:65' +# set interfaces ethernet eth1 smp_affinity 'auto' +# set interfaces ethernet eth1 speed '100' +# set interfaces ethernet eth2 description 'Configured by Ansible' +# set interfaces ethernet eth2 duplex 'full' +# set interfaces ethernet eth2 hw-id '08:00:27:ab:4e:79' +# set interfaces ethernet eth2 mtu '500' +# set interfaces ethernet eth2 smp_affinity 'auto' +# set interfaces ethernet eth2 speed '100' +# set interfaces ethernet eth2 vif 200 description 'Configured by Ansible' +# set interfaces ethernet eth3 description 'Configured by Ansible' +# set interfaces ethernet eth3 duplex 'full' +# set interfaces ethernet eth3 hw-id '08:00:27:17:3c:85' +# set interfaces ethernet eth3 mtu '1500' +# set interfaces ethernet eth3 smp_affinity 'auto' +# set interfaces ethernet eth3 speed '100' +# set interfaces loopback lo +# +# +- name: Replace device configurations of listed interfaces with provided configurations + vyos.vyos.vyos_interfaces: + config: + - name: eth2 + description: Replaced by Ansible + + - name: eth3 + description: Replaced by Ansible + + - name: eth1 + description: Replaced by Ansible + state: replaced +# +# +# ----------------------- +# Module Execution Result +# ----------------------- +# +# "before": [ +# { +# "description": "Bond - 1", +# "enabled": true, +# "mtu": 1400, +# "name": "bond1" +# }, +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "description": "Configured by Ansible", +# "duplex": "full", +# "enabled": true, +# "mtu": 1500, +# "name": "eth3", +# "speed": "100" +# }, +# { +# "description": "Configured by Ansible", +# "duplex": "full", +# "enabled": true, +# "mtu": 500, +# "name": "eth2", +# "speed": "100", +# "vifs": [ +# { +# "description": "VIF 200 - ETH2", +# "enabled": true, +# "vlan_id": "200" +# } +# ] +# }, +# { +# "description": "Configured by Ansible Eng Team", +# "duplex": "full", +# "enabled": true, +# "name": "eth1", +# "speed": "100" +# }, +# { +# "description": "Management Interface for the Appliance", +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# "commands": [ +# "delete interfaces ethernet eth2 speed", +# "delete interfaces ethernet eth2 duplex", +# "delete interfaces ethernet eth2 mtu", +# "delete interfaces ethernet eth2 vif 200 description", +# "set interfaces ethernet eth2 description 'Replaced by Ansible'", +# "delete interfaces ethernet eth3 speed", +# "delete interfaces ethernet eth3 duplex", +# "delete interfaces ethernet eth3 mtu", +# "set interfaces ethernet eth3 description 'Replaced by Ansible'", +# "delete interfaces ethernet eth1 speed", +# "delete interfaces ethernet eth1 duplex", +# "set interfaces ethernet eth1 description 'Replaced by Ansible'" +# ] +# +# "after": [ +# { +# "description": "Bond - 1", +# "enabled": true, +# "mtu": 1400, +# "name": "bond1" +# }, +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "description": "Replaced by Ansible", +# "enabled": true, +# "name": "eth3" +# }, +# { +# "description": "Replaced by Ansible", +# "enabled": true, +# "name": "eth2", +# "vifs": [ +# { +# "enabled": true, +# "vlan_id": "200" +# } +# ] +# }, +# { +# "description": "Replaced by Ansible", +# "enabled": true, +# "name": "eth1" +# }, +# { +# "description": "Management Interface for the Appliance", +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# +# ------------- +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces bonding bond1 description 'Bond - 1' +# set interfaces bonding bond1 mtu '1400' +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 description 'Management Interface for the Appliance' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 description 'Replaced by Ansible' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth2 description 'Replaced by Ansible' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth2 vif 200 +# set interfaces ethernet eth3 description 'Replaced by Ansible' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces loopback lo +# +# +# Using overridden +# +# +# -------------- +# Before state +# -------------- +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 description 'Ethernet Interface - 0' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 mtu '1200' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 description 'Configured by Ansible Eng Team' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 mtu '100' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth1 vif 100 description 'VIF 100 - ETH1' +# set interfaces ethernet eth1 vif 100 disable +# set interfaces ethernet eth2 description 'Configured by Ansible Team (Admin Down)' +# set interfaces ethernet eth2 disable +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 mtu '600' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth3 description 'Configured by Ansible Network' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces loopback lo +# set interfaces vti vti1 description 'Virtual Tunnel Interface - 1' +# set interfaces vti vti1 mtu '68' +# +# +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_interfaces: + config: + - name: eth0 + description: Outbound Interface For The Appliance + speed: auto + duplex: auto + + - name: eth2 + speed: auto + duplex: auto + + - name: eth3 + mtu: 1200 + state: overridden +# +# +# ------------------------ +# Module Execution Result +# ------------------------ +# +# "before": [ +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "description": "Virtual Tunnel Interface - 1", +# "enabled": true, +# "mtu": 68, +# "name": "vti1" +# }, +# { +# "description": "Configured by Ansible Network", +# "enabled": true, +# "name": "eth3" +# }, +# { +# "description": "Configured by Ansible Team (Admin Down)", +# "enabled": false, +# "mtu": 600, +# "name": "eth2" +# }, +# { +# "description": "Configured by Ansible Eng Team", +# "enabled": true, +# "mtu": 100, +# "name": "eth1", +# "vifs": [ +# { +# "description": "VIF 100 - ETH1", +# "enabled": false, +# "vlan_id": "100" +# } +# ] +# }, +# { +# "description": "Ethernet Interface - 0", +# "duplex": "auto", +# "enabled": true, +# "mtu": 1200, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# "commands": [ +# "delete interfaces vti vti1 description", +# "delete interfaces vti vti1 mtu", +# "delete interfaces ethernet eth1 description", +# "delete interfaces ethernet eth1 mtu", +# "delete interfaces ethernet eth1 vif 100 description", +# "delete interfaces ethernet eth1 vif 100 disable", +# "delete interfaces ethernet eth0 mtu", +# "set interfaces ethernet eth0 description 'Outbound Interface For The Appliance'", +# "delete interfaces ethernet eth2 description", +# "delete interfaces ethernet eth2 mtu", +# "set interfaces ethernet eth2 duplex 'auto'", +# "delete interfaces ethernet eth2 disable", +# "set interfaces ethernet eth2 speed 'auto'", +# "delete interfaces ethernet eth3 description", +# "set interfaces ethernet eth3 mtu '1200'" +# ], +# +# "after": [ +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "enabled": true, +# "name": "vti1" +# }, +# { +# "enabled": true, +# "mtu": 1200, +# "name": "eth3" +# }, +# { +# "duplex": "auto", +# "enabled": true, +# "name": "eth2", +# "speed": "auto" +# }, +# { +# "enabled": true, +# "name": "eth1", +# "vifs": [ +# { +# "enabled": true, +# "vlan_id": "100" +# } +# ] +# }, +# { +# "description": "Outbound Interface For The Appliance", +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# +# ------------ +# After state +# ------------ +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 description 'Outbound Interface For The Appliance' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth1 vif 100 +# set interfaces ethernet eth2 duplex 'auto' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth2 speed 'auto' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 mtu '1200' +# set interfaces loopback lo +# set interfaces vti vti1 +# +# +# Using deleted +# +# +# ------------- +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces bonding bond0 mtu '1300' +# set interfaces bonding bond1 description 'LAG - 1' +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 description 'Outbound Interface for this appliance' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 description 'Configured by Ansible Network' +# set interfaces ethernet eth1 duplex 'full' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth1 speed '100' +# set interfaces ethernet eth2 description 'Configured by Ansible' +# set interfaces ethernet eth2 disable +# set interfaces ethernet eth2 duplex 'full' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 mtu '600' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth2 speed '100' +# set interfaces ethernet eth3 description 'Configured by Ansible Network' +# set interfaces ethernet eth3 duplex 'full' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 speed '100' +# set interfaces loopback lo +# +# +- name: Delete attributes of given interfaces (Note - This won't delete the interfaces + themselves) + vyos.vyos.vyos_interfaces: + config: + - name: bond1 + + - name: eth1 + + - name: eth2 + + - name: eth3 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "enabled": true, +# "mtu": 1300, +# "name": "bond0" +# }, +# { +# "description": "LAG - 1", +# "enabled": true, +# "name": "bond1" +# }, +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "description": "Configured by Ansible Network", +# "duplex": "full", +# "enabled": true, +# "name": "eth3", +# "speed": "100" +# }, +# { +# "description": "Configured by Ansible", +# "duplex": "full", +# "enabled": false, +# "mtu": 600, +# "name": "eth2", +# "speed": "100" +# }, +# { +# "description": "Configured by Ansible Network", +# "duplex": "full", +# "enabled": true, +# "name": "eth1", +# "speed": "100" +# }, +# { +# "description": "Outbound Interface for this appliance", +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# "commands": [ +# "delete interfaces bonding bond1 description", +# "delete interfaces ethernet eth1 speed", +# "delete interfaces ethernet eth1 duplex", +# "delete interfaces ethernet eth1 description", +# "delete interfaces ethernet eth2 speed", +# "delete interfaces ethernet eth2 disable", +# "delete interfaces ethernet eth2 duplex", +# "delete interfaces ethernet eth2 disable", +# "delete interfaces ethernet eth2 description", +# "delete interfaces ethernet eth2 disable", +# "delete interfaces ethernet eth2 mtu", +# "delete interfaces ethernet eth2 disable", +# "delete interfaces ethernet eth3 speed", +# "delete interfaces ethernet eth3 duplex", +# "delete interfaces ethernet eth3 description" +# ] +# +# "after": [ +# { +# "enabled": true, +# "mtu": 1300, +# "name": "bond0" +# }, +# { +# "enabled": true, +# "name": "bond1" +# }, +# { +# "enabled": true, +# "name": "lo" +# }, +# { +# "enabled": true, +# "name": "eth3" +# }, +# { +# "enabled": true, +# "name": "eth2" +# }, +# { +# "enabled": true, +# "name": "eth1" +# }, +# { +# "description": "Outbound Interface for this appliance", +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# +# ------------ +# After state +# ------------ +# +# vyos@vyos:~$ show configuration commands | grep interfaces +# set interfaces bonding bond0 mtu '1300' +# set interfaces bonding bond1 +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 description 'Outbound Interface for this appliance' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:ea:0f:b9' +# set interfaces ethernet eth1 smp-affinity 'auto' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth2 smp-affinity 'auto' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces loopback lo +# +# + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep interfaces +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' +# set interfaces ethernet eth0 smp_affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 description 'Configured by Ansible' +# set interfaces ethernet eth1 duplex 'auto' +# set interfaces ethernet eth1 mtu '1500' +# set interfaces ethernet eth1 speed 'auto' +# set interfaces ethernet eth1 vif 200 description 'VIF - 200' +# set interfaces ethernet eth2 description 'Configured by Ansible' +# set interfaces ethernet eth2 duplex 'auto' +# set interfaces ethernet eth2 mtu '1500' +# set interfaces ethernet eth2 speed 'auto' +# set interfaces ethernet eth2 vif 200 description 'VIF - 200' +# +- name: Gather listed interfaces with provided configurations + vyos.vyos.vyos_interfaces: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "description": "Configured by Ansible", +# "duplex": "auto", +# "enabled": true, +# "mtu": 1500, +# "name": "eth2", +# "speed": "auto", +# "vifs": [ +# { +# "description": "VIF - 200", +# "enabled": true, +# "vlan_id": 200 +# } +# ] +# }, +# { +# "description": "Configured by Ansible", +# "duplex": "auto", +# "enabled": true, +# "mtu": 1500, +# "name": "eth1", +# "speed": "auto", +# "vifs": [ +# { +# "description": "VIF - 200", +# "enabled": true, +# "vlan_id": 200 +# } +# ] +# }, +# { +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] +# +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep interfaces +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' +# set interfaces ethernet eth0 smp_affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 description 'Configured by Ansible' +# set interfaces ethernet eth1 duplex 'auto' +# set interfaces ethernet eth1 mtu '1500' +# set interfaces ethernet eth1 speed 'auto' +# set interfaces ethernet eth1 vif 200 description 'VIF - 200' +# set interfaces ethernet eth2 description 'Configured by Ansible' +# set interfaces ethernet eth2 duplex 'auto' +# set interfaces ethernet eth2 mtu '1500' +# set interfaces ethernet eth2 speed 'auto' +# set interfaces ethernet eth2 vif 200 description 'VIF - 200' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_interfaces: + config: + - name: eth0 + enabled: true + duplex: auto + speed: auto + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + enabled: true + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 + enabled: true + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set interfaces ethernet eth0 duplex 'auto'", +# "set interfaces ethernet eth0 speed 'auto'", +# "delete interfaces ethernet eth0 disable", +# "set interfaces ethernet eth1 duplex 'auto'", +# "delete interfaces ethernet eth1 disable", +# "set interfaces ethernet eth1 speed 'auto'", +# "set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'", +# "set interfaces ethernet eth1 mtu '1500'", +# "set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'", +# "set interfaces ethernet eth1 vif 100 mtu '400'", +# "set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'", +# "set interfaces ethernet eth2 disable", +# "set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'", +# "set interfaces ethernet eth2 mtu '600'" +# ] + + +# Using parsed +# +# +- name: Parse the configuration. + vyos.vyos.vyos_interfaces: + running_config: + "set interfaces ethernet eth0 address 'dhcp' + set interfaces ethernet eth0 duplex 'auto' + set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' + set interfaces ethernet eth0 smp_affinity 'auto' + set interfaces ethernet eth0 speed 'auto' + set interfaces ethernet eth1 description 'Configured by Ansible' + set interfaces ethernet eth1 duplex 'auto' + set interfaces ethernet eth1 mtu '1500' + set interfaces ethernet eth1 speed 'auto' + set interfaces ethernet eth1 vif 200 description 'VIF - 200' + set interfaces ethernet eth2 description 'Configured by Ansible' + set interfaces ethernet eth2 duplex 'auto' + set interfaces ethernet eth2 mtu '1500' + set interfaces ethernet eth2 speed 'auto' + set interfaces ethernet eth2 vif 200 description 'VIF - 200'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "description": "Configured by Ansible", +# "duplex": "auto", +# "enabled": true, +# "mtu": 1500, +# "name": "eth2", +# "speed": "auto", +# "vifs": [ +# { +# "description": "VIF - 200", +# "enabled": true, +# "vlan_id": 200 +# } +# ] +# }, +# { +# "description": "Configured by Ansible", +# "duplex": "auto", +# "enabled": true, +# "mtu": 1500, +# "name": "eth1", +# "speed": "auto", +# "vifs": [ +# { +# "description": "VIF - 200", +# "enabled": true, +# "vlan_id": 200 +# } +# ] +# }, +# { +# "duplex": "auto", +# "enabled": true, +# "name": "eth0", +# "speed": "auto" +# } +# ] + + +""" +RETURN = """ +before: + description: The configuration as structured data prior to module invocation. + returned: always + sample: > + The configuration returned will always be in the same format + of the parameters above. + type: list +after: + description: The configuration as structured data after module completion. + returned: when changed + sample: > + The configuration returned will always be in the same format + of the parameters above. + type: list +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - 'set interfaces ethernet eth1 mtu 1200' + - 'set interfaces ethernet eth2 vif 100 description VIF 100' +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.interfaces.interfaces import ( + InterfacesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.interfaces.interfaces import ( + Interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + module = AnsibleModule( + argument_spec=InterfacesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_l3_interface.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_l3_interface.py new file mode 100644 index 00000000..88b5a911 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_l3_interface.py @@ -0,0 +1,357 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +module: vyos_l3_interface +author: Ricardo Carrillo Cruz (@rcarrillocruz) +short_description: (deprecated, removed after 2022-06-01) Manage L3 interfaces on + VyOS network devices +description: +- This module provides declarative management of L3 interfaces on VyOS network devices. +version_added: 1.0.0 +deprecated: + alternative: vyos_l3_interfaces + why: Updated modules released with more functionality. + removed_at_date: '2022-06-01' +notes: +- Tested against VYOS 1.1.7 +options: + name: + description: + - Name of the L3 interface. + type: str + ipv4: + description: + - IPv4 of the L3 interface. + type: str + ipv6: + description: + - IPv6 of the L3 interface. + type: str + aggregate: + description: List of L3 interfaces definitions + type: list + elements: dict + suboptions: + name: + description: + - Name of the L3 interface. + type: str + required: True + ipv4: + description: + - IPv4 of the L3 interface. + type: str + ipv6: + description: + - IPv6 of the L3 interface. + type: str + state: + description: + - State of the L3 interface configuration. + type: str + choices: + - present + - absent + state: + description: + - State of the L3 interface configuration. + default: present + type: str + choices: + - present + - absent +extends_documentation_fragment: +- vyos.vyos.vyos + + +""" + +EXAMPLES = """ +- name: Set eth0 IPv4 address + vyos.vyos.vyos_l3_interface: + name: eth0 + ipv4: 192.168.0.1/24 + +- name: Remove eth0 IPv4 address + vyos.vyos.vyos_l3_interface: + name: eth0 + state: absent + +- name: Set IP addresses on aggregate + vyos.vyos.vyos_l3_interface: + aggregate: + - {name: eth1, ipv4: 192.168.2.10/24} + - {name: eth2, ipv4: 192.168.3.10/24, ipv6: fd5d:12c9:2201:1::1/64} + +- name: Remove IP addresses on aggregate + vyos.vyos.vyos_l3_interface: + aggregate: + - {name: eth1, ipv4: 192.168.2.10/24} + - {name: eth2, ipv4: 192.168.3.10/24, ipv6: fd5d:12c9:2201:1::1/64} + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always, except for the platforms that use Netconf transport to manage the device. + type: list + sample: + - set interfaces ethernet eth0 address '192.168.0.1/24' +""" + +import socket +import re + +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + is_masklen, + validate_ip_address, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + load_config, + run_commands, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def is_ipv4(value): + if value: + address = value.split("/") + if is_masklen(address[1]) and validate_ip_address(address[0]): + return True + return False + + +def is_ipv6(value): + if value: + address = value.split("/") + if 0 <= int(address[1]) <= 128: + try: + socket.inet_pton(socket.AF_INET6, address[0]) + except socket.error: + return False + return True + return False + + +def search_obj_in_list(name, lst): + for o in lst: + if o["name"] == name: + return o + + return None + + +def map_obj_to_commands(updates, module): + commands = list() + want, have = updates + + for w in want: + name = w["name"] + ipv4 = w["ipv4"] + ipv6 = w["ipv6"] + state = w["state"] + + obj_in_have = search_obj_in_list(name, have) + + if state == "absent" and obj_in_have: + if ( + not ipv4 + and not ipv6 + and (obj_in_have["ipv4"] or obj_in_have["ipv6"]) + ): + if name == "lo": + commands.append("delete interfaces loopback lo address") + else: + commands.append( + "delete interfaces ethernet " + name + " address" + ) + else: + if ipv4 and ipv4 in obj_in_have["ipv4"]: + if name == "lo": + commands.append( + "delete interfaces loopback lo address " + ipv4 + ) + else: + commands.append( + "delete interfaces ethernet " + + name + + " address " + + ipv4 + ) + if ipv6 and ipv6 in obj_in_have["ipv6"]: + if name == "lo": + commands.append( + "delete interfaces loopback lo address " + ipv6 + ) + else: + commands.append( + "delete interfaces ethernet " + + name + + " address " + + ipv6 + ) + elif state == "present" and obj_in_have: + if ipv4 and ipv4 not in obj_in_have["ipv4"]: + if name == "lo": + commands.append( + "set interfaces loopback lo address " + ipv4 + ) + else: + commands.append( + "set interfaces ethernet " + name + " address " + ipv4 + ) + + if ipv6 and ipv6 not in obj_in_have["ipv6"]: + if name == "lo": + commands.append( + "set interfaces loopback lo address " + ipv6 + ) + else: + commands.append( + "set interfaces ethernet " + name + " address " + ipv6 + ) + + return commands + + +def map_config_to_obj(module): + obj = [] + output = run_commands(module, ["show interfaces"]) + lines = re.split(r"\n[e|l]", output[0])[1:] + + if len(lines) > 0: + for line in lines: + splitted_line = line.split() + + if len(splitted_line) > 0: + ipv4 = [] + ipv6 = [] + + if splitted_line[0].lower().startswith("th"): + name = "e" + splitted_line[0].lower() + elif splitted_line[0].lower().startswith("o"): + name = "l" + splitted_line[0].lower() + + for i in splitted_line[1:]: + if ("." in i or ":" in i) and "/" in i: + value = i.split(r"\n")[0] + if is_ipv4(value): + ipv4.append(value) + elif is_ipv6(value): + ipv6.append(value) + + obj.append({"name": name, "ipv4": ipv4, "ipv6": ipv6}) + + return obj + + +def map_params_to_obj(module): + obj = [] + + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + obj.append(item.copy()) + else: + obj.append( + { + "name": module.params["name"], + "ipv4": module.params["ipv4"], + "ipv6": module.params["ipv6"], + "state": module.params["state"], + } + ) + + return obj + + +def main(): + """main entry point for module execution""" + element_spec = dict( + name=dict(), + ipv4=dict(), + ipv6=dict(), + state=dict(default="present", choices=["present", "absent"]), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["name"] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + required_one_of = [["name", "aggregate"]] + mutually_exclusive = [["name", "aggregate"]] + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + + if warnings: + result["warnings"] = warnings + + want = map_params_to_obj(module) + have = map_config_to_obj(module) + + commands = map_obj_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_l3_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_l3_interfaces.py new file mode 100644 index 00000000..39dd23c1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_l3_interfaces.py @@ -0,0 +1,575 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_l3_interfaces +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_l3_interfaces +short_description: L3 interfaces resource module +description: This module manages the L3 interface attributes on VyOS network devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Nilashish Chakraborty (@NilashishC) +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: The provided L3 interfaces configuration. + type: list + elements: dict + suboptions: + name: + description: + - Full name of the interface, e.g. eth0, eth1. + type: str + required: true + ipv4: + description: + - List of IPv4 addresses of the interface. + type: list + elements: dict + suboptions: + address: + description: + - IPv4 address of the interface. + type: str + ipv6: + description: + - List of IPv6 addresses of the interface. + type: list + elements: dict + suboptions: + address: + description: + - IPv6 address of the interface. + type: str + vifs: + description: + - Virtual sub-interfaces L3 configurations. + elements: dict + type: list + suboptions: + vlan_id: + description: + - Identifier for the virtual sub-interface. + type: int + ipv4: + description: + - List of IPv4 addresses of the virtual interface. + type: list + elements: dict + suboptions: + address: + description: + - IPv4 address of the virtual interface. + type: str + ipv6: + description: + - List of IPv6 addresses of the virtual interface. + type: list + elements: dict + suboptions: + address: + description: + - IPv6 address of the virtual interface. + type: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep -e eth[2,3]). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - parsed + - gathered + - rendered + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos:~$ show configuration commands | grep -e eth[2,3] +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 vif 101 +# set interfaces ethernet eth3 vif 102 + +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth2 + ipv4: + - address: 192.0.2.10/28 + - address: 198.51.100.40/27 + ipv6: + - address: 2001:db8:100::2/32 + - address: 2001:db8:400::10/32 + + - name: eth3 + ipv4: + - address: 203.0.113.65/26 + vifs: + - vlan_id: 101 + ipv4: + - address: 192.0.2.71/28 + - address: 198.51.100.131/25 + - vlan_id: 102 + ipv6: + - address: 2001:db8:1000::5/38 + - address: 2001:db8:1400::3/38 + state: merged + +# After state: +# ------------- +# +# vyos:~$ show configuration commands | grep -e eth[2,3] +# set interfaces ethernet eth2 address '192.0.2.10/28' +# set interfaces ethernet eth2 address '198.51.100.40/27' +# set interfaces ethernet eth2 address '2001:db8:100::2/32' +# set interfaces ethernet eth2 address '2001:db8:400::10/32' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 address '203.0.113.65/26' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 vif 101 address '192.0.2.71/28' +# set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' +# set interfaces ethernet eth3 vif 102 address '2001:db8:1000::5/38' +# set interfaces ethernet eth3 vif 102 address '2001:db8:1400::3/38' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos:~$ show configuration commands | grep eth +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' +# set interfaces ethernet eth1 address '192.0.2.14/24' +# set interfaces ethernet eth2 address '192.0.2.10/24' +# set interfaces ethernet eth2 address '192.0.2.11/24' +# set interfaces ethernet eth2 address '2001:db8::10/32' +# set interfaces ethernet eth2 address '2001:db8::11/32' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 address '198.51.100.10/24' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 vif 101 address '198.51.100.130/25' +# set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::3/34' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' +# +- name: Replace device configurations of listed interfaces with provided configurations + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + + - name: eth3 + ipv6: + - address: 2001:db8::11/32 + state: replaced + +# After state: +# ------------- +# +# vyos:~$ show configuration commands | grep eth +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' +# set interfaces ethernet eth1 address '192.0.2.14/24' +# set interfaces ethernet eth2 address '192.0.2.10/24' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 address '2001:db8::11/32' +# set interfaces ethernet eth3 vif 101 +# set interfaces ethernet eth3 vif 102 + + +# Using overridden +# +# Before state +# -------------- +# +# vyos@vyos-appliance:~$ show configuration commands | grep eth +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' +# set interfaces ethernet eth1 address '192.0.2.14/24' +# set interfaces ethernet eth2 address '192.0.2.10/24' +# set interfaces ethernet eth2 address '192.0.2.11/24' +# set interfaces ethernet eth2 address '2001:db8::10/32' +# set interfaces ethernet eth2 address '2001:db8::11/32' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 address '198.51.100.10/24' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 vif 101 address '198.51.100.130/25' +# set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::3/34' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth0 + ipv4: + - address: dhcp + ipv6: + - address: dhcpv6 + state: overridden + +# After state +# ------------ +# +# vyos@vyos-appliance:~$ show configuration commands | grep eth +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 address 'dhcpv6' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 vif 101 +# set interfaces ethernet eth3 vif 102 + + +# Using deleted +# +# Before state +# ------------- +# vyos@vyos-appliance:~$ show configuration commands | grep eth +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:30:f0:22' +# set interfaces ethernet eth0 smp-affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:EA:0F:B9' +# set interfaces ethernet eth1 address '192.0.2.14/24' +# set interfaces ethernet eth2 address '192.0.2.10/24' +# set interfaces ethernet eth2 address '192.0.2.11/24' +# set interfaces ethernet eth2 address '2001:db8::10/32' +# set interfaces ethernet eth2 address '2001:db8::11/32' +# set interfaces ethernet eth2 hw-id '08:00:27:c2:98:23' +# set interfaces ethernet eth3 address '198.51.100.10/24' +# set interfaces ethernet eth3 hw-id '08:00:27:43:70:8c' +# set interfaces ethernet eth3 vif 101 address '198.51.100.130/25' +# set interfaces ethernet eth3 vif 101 address '198.51.100.131/25' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::3/34' +# set interfaces ethernet eth3 vif 102 address '2001:db8:4000::2/34' + +- name: Delete L3 attributes of given interfaces (Note - This won't delete the interface + itself) + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth1 + - name: eth2 + - name: eth3 + state: deleted + +# After state +# ------------ +# vyos@vyos-appliance:~$ show configuration commands | grep eth +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:f3:6c:b5' +# set interfaces ethernet eth0 smp_affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 hw-id '08:00:27:ad:ef:65' +# set interfaces ethernet eth1 smp_affinity 'auto' +# set interfaces ethernet eth2 hw-id '08:00:27:ab:4e:79' +# set interfaces ethernet eth2 smp_affinity 'auto' +# set interfaces ethernet eth3 hw-id '08:00:27:17:3c:85' +# set interfaces ethernet eth3 smp_affinity 'auto' + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos:~$ show configuration commands | grep -e eth[2,3,0] +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' +# set interfaces ethernet eth0 smp_affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 address '192.0.2.14/24' +# set interfaces ethernet eth2 address '192.0.2.11/24' +# set interfaces ethernet eth2 address '192.0.2.10/24' +# set interfaces ethernet eth2 address '2001:db8::10/32' +# set interfaces ethernet eth2 address '2001:db8::12/32' +# +- name: Gather listed l3 interfaces with provided configurations + vyos.vyos.vyos_l3_interfaces: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "ipv4": [ +# { +# "address": "192.0.2.11/24" +# }, +# { +# "address": "192.0.2.10/24" +# } +# ], +# "ipv6": [ +# { +# "address": "2001:db8::10/32" +# }, +# { +# "address": "2001:db8::12/32" +# } +# ], +# "name": "eth2" +# }, +# { +# "ipv4": [ +# { +# "address": "192.0.2.14/24" +# } +# ], +# "name": "eth1" +# }, +# { +# "ipv4": [ +# { +# "address": "dhcp" +# } +# ], +# "name": "eth0" +# } +# ] +# +# +# After state: +# ------------- +# +# vyos:~$ show configuration commands | grep -e eth[2,3] +# set interfaces ethernet eth0 address 'dhcp' +# set interfaces ethernet eth0 duplex 'auto' +# set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' +# set interfaces ethernet eth0 smp_affinity 'auto' +# set interfaces ethernet eth0 speed 'auto' +# set interfaces ethernet eth1 address '192.0.2.14/24' +# set interfaces ethernet eth2 address '192.0.2.11/24' +# set interfaces ethernet eth2 address '192.0.2.10/24' +# set interfaces ethernet eth2 address '2001:db8::10/32' +# set interfaces ethernet eth2 address '2001:db8::12/32' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: 2001:db8::10/32 + - address: 2001:db8::12/32 + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set interfaces ethernet eth1 address '192.0.2.14/24'", +# "set interfaces ethernet eth2 address '192.0.2.11/24'", +# "set interfaces ethernet eth2 address '192.0.2.10/24'", +# "set interfaces ethernet eth2 address '2001:db8::10/32'", +# "set interfaces ethernet eth2 address '2001:db8::12/32'" +# ] + + +# Using parsed +# +# +- name: parse the provided running configuration + vyos.vyos.vyos_l3_interfaces: + running_config: + "set interfaces ethernet eth0 address 'dhcp' + set interfaces ethernet eth1 address '192.0.2.14/24' + set interfaces ethernet eth2 address '192.0.2.10/24' + set interfaces ethernet eth2 address '192.0.2.11/24' + set interfaces ethernet eth2 address '2001:db8::10/32' + set interfaces ethernet eth2 address '2001:db8::12/32'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "ipv4": [ +# { +# "address": "192.0.2.10/24" +# }, +# { +# "address": "192.0.2.11/24" +# } +# ], +# "ipv6": [ +# { +# "address": "2001:db8::10/32" +# }, +# { +# "address": "2001:db8::12/32" +# } +# ], +# "name": "eth2" +# }, +# { +# "ipv4": [ +# { +# "address": "192.0.2.14/24" +# } +# ], +# "name": "eth1" +# }, +# { +# "ipv4": [ +# { +# "address": "dhcp" +# } +# ], +# "name": "eth0" +# } +# ] + + +""" +RETURN = """ +before: + description: The configuration as structured data prior to module invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The configuration as structured data after module completion. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['set interfaces ethernet eth1 192.0.2.14/2', 'set interfaces ethernet eth3 vif 101 address 198.51.100.130/25'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.l3_interfaces.l3_interfaces import ( + L3_interfacesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.l3_interfaces.l3_interfaces import ( + L3_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + + module = AnsibleModule( + argument_spec=L3_interfacesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = L3_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lag_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lag_interfaces.py new file mode 100644 index 00000000..08480859 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lag_interfaces.py @@ -0,0 +1,781 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_lag_interfaces +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_lag_interfaces +short_description: LAG interfaces resource module +description: This module manages attributes of link aggregation groups on VyOS network + devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: Rohit Thakur (@rohitthakur2590) +options: + config: + description: A list of link aggregation group configurations. + type: list + elements: dict + suboptions: + name: + description: + - Name of the link aggregation group (LAG) or bond. + type: str + required: true + mode: + description: + - LAG or bond mode. + type: str + choices: + - 802.3ad + - active-backup + - broadcast + - round-robin + - transmit-load-balance + - adaptive-load-balance + - xor-hash + members: + description: + - List of member interfaces for the LAG (bond). + type: list + elements: dict + suboptions: + member: + description: + - Name of the member interface. + type: str + primary: + description: + - Primary device interfaces for the LAG (bond). + type: str + hash_policy: + description: + - LAG or bonding transmit hash policy. + type: str + choices: + - layer2 + - layer2+3 + - layer3+4 + arp_monitor: + description: + - ARP Link monitoring parameters. + type: dict + suboptions: + interval: + description: + - ARP link monitoring frequency in milliseconds. + type: int + target: + description: + - IP address to use for ARP monitoring. + type: list + elements: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep bond). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - parsed + - gathered + - rendered + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 +# set interfaces bonding bond3 +# +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond2 + mode: active-backup + members: + - member: eth2 + - member: eth1 + hash_policy: layer2 + primary: eth2 + + - name: bond3 + mode: active-backup + hash_policy: layer2+3 + members: + - member: eth3 + primary: eth3 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "name": "bond2" +# }, +# { +# "name": "bond3" +# } +# ], +# +# "commands": [ +# "set interfaces bonding bond2 hash-policy 'layer2'", +# "set interfaces bonding bond2 mode 'active-backup'", +# "set interfaces ethernet eth2 bond-group bond2", +# "set interfaces ethernet eth1 bond-group bond2", +# "set interfaces bonding bond2 primary 'eth2'", +# "set interfaces bonding bond3 hash-policy 'layer2+3'", +# "set interfaces bonding bond3 mode 'active-backup'", +# "set interfaces ethernet eth3 bond-group bond3", +# "set interfaces bonding bond3 primary 'eth3'" +# ] +# +# "after": [ +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# }, +# { +# "member": "eth2" +# } +# ], +# "mode": "active-backup", +# "name": "bond2", +# "primary": "eth2" +# }, +# { +# "hash_policy": "layer2+3", +# "members": [ +# { +# "member": "eth3" +# } +# ], +# "mode": "active-backup", +# "name": "bond3", +# "primary": "eth3" +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 hash-policy 'layer2' +# set interfaces bonding bond2 mode 'active-backup' +# set interfaces bonding bond2 primary 'eth2' +# set interfaces bonding bond3 hash-policy 'layer2+3' +# set interfaces bonding bond3 mode 'active-backup' +# set interfaces bonding bond3 primary 'eth3' +# set interfaces ethernet eth1 bond-group 'bond2' +# set interfaces ethernet eth2 bond-group 'bond2' +# set interfaces ethernet eth3 bond-group 'bond3' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 hash-policy 'layer2' +# set interfaces bonding bond2 mode 'active-backup' +# set interfaces bonding bond2 primary 'eth2' +# set interfaces bonding bond3 hash-policy 'layer2+3' +# set interfaces bonding bond3 mode 'active-backup' +# set interfaces bonding bond3 primary 'eth3' +# set interfaces ethernet eth1 bond-group 'bond2' +# set interfaces ethernet eth2 bond-group 'bond2' +# set interfaces ethernet eth3 bond-group 'bond3' +# +- name: Replace device configurations of listed LAGs with provided configurations + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond3 + mode: 802.3ad + hash_policy: layer2 + members: + - member: eth3 + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# }, +# { +# "member": "eth2" +# } +# ], +# "mode": "active-backup", +# "name": "bond2", +# "primary": "eth2" +# }, +# { +# "hash_policy": "layer2+3", +# "members": [ +# { +# "member": "eth3" +# } +# ], +# "mode": "active-backup", +# "name": "bond3", +# "primary": "eth3" +# } +# ], +# +# "commands": [ +# "delete interfaces bonding bond3 primary", +# "set interfaces bonding bond3 hash-policy 'layer2'", +# "set interfaces bonding bond3 mode '802.3ad'" +# ], +# +# "after": [ +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# }, +# { +# "member": "eth2" +# } +# ], +# "mode": "active-backup", +# "name": "bond2", +# "primary": "eth2" +# }, +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth3" +# } +# ], +# "mode": "802.3ad", +# "name": "bond3" +# } +# ], +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 hash-policy 'layer2' +# set interfaces bonding bond2 mode 'active-backup' +# set interfaces bonding bond2 primary 'eth2' +# set interfaces bonding bond3 hash-policy 'layer2' +# set interfaces bonding bond3 mode '802.3ad' +# set interfaces ethernet eth1 bond-group 'bond2' +# set interfaces ethernet eth2 bond-group 'bond2' +# set interfaces ethernet eth3 bond-group 'bond3' + + +# Using overridden +# +# Before state +# -------------- +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 hash-policy 'layer2' +# set interfaces bonding bond2 mode 'active-backup' +# set interfaces bonding bond2 primary 'eth2' +# set interfaces bonding bond3 hash-policy 'layer2' +# set interfaces bonding bond3 mode '802.3ad' +# set interfaces ethernet eth1 bond-group 'bond2' +# set interfaces ethernet eth2 bond-group 'bond2' +# set interfaces ethernet eth3 bond-group 'bond3' +# +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond3 + mode: active-backup + members: + - member: eth1 + - member: eth2 + - member: eth3 + primary: eth3 + hash_policy: layer2 + state: overridden +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# }, +# { +# "member": "eth2" +# } +# ], +# "mode": "active-backup", +# "name": "bond2", +# "primary": "eth2" +# }, +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth3" +# } +# ], +# "mode": "802.3ad", +# "name": "bond3" +# } +# ], +# +# "commands": [ +# "delete interfaces bonding bond2 hash-policy", +# "delete interfaces ethernet eth1 bond-group bond2", +# "delete interfaces ethernet eth2 bond-group bond2", +# "delete interfaces bonding bond2 mode", +# "delete interfaces bonding bond2 primary", +# "set interfaces bonding bond3 mode 'active-backup'", +# "set interfaces ethernet eth1 bond-group bond3", +# "set interfaces ethernet eth2 bond-group bond3", +# "set interfaces bonding bond3 primary 'eth3'" +# ], +# +# "after": [ +# { +# "name": "bond2" +# }, +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# }, +# { +# "member": "eth2" +# }, +# { +# "member": "eth3" +# } +# ], +# "mode": "active-backup", +# "name": "bond3", +# "primary": "eth3" +# } +# ], +# +# +# After state +# ------------ +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 +# set interfaces bonding bond3 hash-policy 'layer2' +# set interfaces bonding bond3 mode 'active-backup' +# set interfaces bonding bond3 primary 'eth3' +# set interfaces ethernet eth1 bond-group 'bond3' +# set interfaces ethernet eth2 bond-group 'bond3' +# set interfaces ethernet eth3 bond-group 'bond3' + + +# Using deleted +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 hash-policy 'layer2' +# set interfaces bonding bond2 mode 'active-backup' +# set interfaces bonding bond2 primary 'eth2' +# set interfaces bonding bond3 hash-policy 'layer2+3' +# set interfaces bonding bond3 mode 'active-backup' +# set interfaces bonding bond3 primary 'eth3' +# set interfaces ethernet eth1 bond-group 'bond2' +# set interfaces ethernet eth2 bond-group 'bond2' +# set interfaces ethernet eth3 bond-group 'bond3' +# +- name: Delete LAG attributes of given interfaces (Note This won't delete the interface + itself) + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond2 + - name: bond3 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# }, +# { +# "member": "eth2" +# } +# ], +# "mode": "active-backup", +# "name": "bond2", +# "primary": "eth2" +# }, +# { +# "hash_policy": "layer2+3", +# "members": [ +# { +# "member": "eth3" +# } +# ], +# "mode": "active-backup", +# "name": "bond3", +# "primary": "eth3" +# } +# ], +# "commands": [ +# "delete interfaces bonding bond2 hash-policy", +# "delete interfaces ethernet eth1 bond-group bond2", +# "delete interfaces ethernet eth2 bond-group bond2", +# "delete interfaces bonding bond2 mode", +# "delete interfaces bonding bond2 primary", +# "delete interfaces bonding bond3 hash-policy", +# "delete interfaces ethernet eth3 bond-group bond3", +# "delete interfaces bonding bond3 mode", +# "delete interfaces bonding bond3 primary" +# ], +# +# "after": [ +# { +# "name": "bond2" +# }, +# { +# "name": "bond3" +# } +# ], +# +# After state +# ------------ +# vyos@vyos:~$ show configuration commands | grep bond +# set interfaces bonding bond2 +# set interfaces bonding bond3 + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep bond +# set interfaces bonding bond0 hash-policy 'layer2' +# set interfaces bonding bond0 mode 'active-backup' +# set interfaces bonding bond0 primary 'eth1' +# set interfaces bonding bond1 hash-policy 'layer2+3' +# set interfaces bonding bond1 mode 'active-backup' +# set interfaces bonding bond1 primary 'eth2' +# set interfaces ethernet eth1 bond-group 'bond0' +# set interfaces ethernet eth2 bond-group 'bond1' +# +- name: Gather listed lag interfaces with provided configurations + vyos.vyos.vyos_lag_interfaces: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "afi": "ipv6", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "This is ipv6 specific rule-set", +# "name": "UPLINK", +# "rules": [ +# { +# "action": "accept", +# "description": "Fwipv6-Rule 1 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 1 +# }, +# { +# "action": "accept", +# "description": "Fwipv6-Rule 2 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 2 +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv4", +# "rule_sets": [ +# { +# "default_action": "accept", +# "description": "IPv4 INBOUND rule set", +# "name": "INBOUND", +# "rules": [ +# { +# "action": "accept", +# "description": "Rule 101 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 101 +# }, +# { +# "action": "reject", +# "description": "Rule 102 is configured by Ansible", +# "ipsec": "match-ipsec", +# "number": 102 +# }, +# { +# "action": "accept", +# "description": "Rule 103 is configured by Ansible", +# "destination": { +# "group": { +# "address_group": "inbound" +# } +# }, +# "number": 103, +# "source": { +# "address": "192.0.2.0" +# }, +# "state": { +# "established": true, +# "invalid": false, +# "new": false, +# "related": true +# } +# } +# ] +# } +# ] +# } +# ] +# +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep bond +# set interfaces bonding bond0 hash-policy 'layer2' +# set interfaces bonding bond0 mode 'active-backup' +# set interfaces bonding bond0 primary 'eth1' +# set interfaces bonding bond1 hash-policy 'layer2+3' +# set interfaces bonding bond1 mode 'active-backup' +# set interfaces bonding bond1 primary 'eth2' +# set interfaces ethernet eth1 bond-group 'bond0' +# set interfaces ethernet eth2 bond-group 'bond1' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set interfaces bonding bond0 hash-policy 'layer2'", +# "set interfaces ethernet eth1 bond-group 'bond0'", +# "set interfaces bonding bond0 mode 'active-backup'", +# "set interfaces bonding bond0 primary 'eth1'", +# "set interfaces bonding bond1 hash-policy 'layer2+3'", +# "set interfaces ethernet eth2 bond-group 'bond1'", +# "set interfaces bonding bond1 mode 'active-backup'", +# "set interfaces bonding bond1 primary 'eth2'" +# ] + + +# Using parsed +# +# +- name: Parsed the commands for provided configuration + vyos.vyos.vyos_l3_interfaces: + running_config: + "set interfaces bonding bond0 hash-policy 'layer2' + set interfaces bonding bond0 mode 'active-backup' + set interfaces bonding bond0 primary 'eth1' + set interfaces bonding bond1 hash-policy 'layer2+3' + set interfaces bonding bond1 mode 'active-backup' + set interfaces bonding bond1 primary 'eth2' + set interfaces ethernet eth1 bond-group 'bond0' + set interfaces ethernet eth2 bond-group 'bond1'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "hash_policy": "layer2", +# "members": [ +# { +# "member": "eth1" +# } +# ], +# "mode": "active-backup", +# "name": "bond0", +# "primary": "eth1" +# }, +# { +# "hash_policy": "layer2+3", +# "members": [ +# { +# "member": "eth2" +# } +# ], +# "mode": "active-backup", +# "name": "bond1", +# "primary": "eth2" +# } +# ] + + +""" +RETURN = """ +before: + description: The configuration as structured data prior to module invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The configuration as structured data after module completion. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - 'set interfaces bonding bond2' + - 'set interfaces bonding bond2 hash-policy layer2' +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.lag_interfaces.lag_interfaces import ( + Lag_interfacesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.lag_interfaces.lag_interfaces import ( + Lag_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + + module = AnsibleModule( + argument_spec=Lag_interfacesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Lag_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_linkagg.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_linkagg.py new file mode 100644 index 00000000..4320dd3b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_linkagg.py @@ -0,0 +1,363 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +module: vyos_linkagg +author: Ricardo Carrillo Cruz (@rcarrillocruz) +short_description: (deprecated, removed after 2022-06-01) Manage link aggregation + groups on VyOS network devices +description: +- This module provides declarative management of link aggregation groups on VyOS network + devices. +version_added: 1.0.0 +deprecated: + alternative: vyos_lag_interfaces + why: Updated modules released with more functionality. + removed_at_date: '2022-06-01' +notes: +- Tested against VYOS 1.1.7 +options: + name: + description: + - Name of the link aggregation group. + type: str + mode: + description: + - Mode of the link aggregation group. + default: "802.3ad" + choices: + - 802.3ad + - active-backup + - broadcast + - round-robin + - transmit-load-balance + - adaptive-load-balance + - xor-hash + - "on" + type: str + members: + description: + - List of members of the link aggregation group. + type: list + elements: str + aggregate: + description: List of link aggregation definitions. + type: list + elements: dict + suboptions: + name: + description: + - Name of the link aggregation group. + required: true + type: str + mode: + description: + - Mode of the link aggregation group. + choices: + - 802.3ad + - active-backup + - broadcast + - round-robin + - transmit-load-balance + - adaptive-load-balance + - xor-hash + - "on" + type: str + members: + description: + - List of members of the link aggregation group. + type: list + elements: str + state: + description: + - State of the link aggregation group. + choices: + - present + - absent + - up + - down + type: str + state: + description: + - State of the link aggregation group. + default: present + choices: + - present + - absent + - up + - down + type: str +extends_documentation_fragment: +- vyos.vyos.vyos + + +""" + +EXAMPLES = """ +- name: configure link aggregation group + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth0 + - eth1 + +- name: remove configuration + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + +- name: Create aggregate of linkagg definitions + vyos.vyos.vyos_linkagg: + aggregate: + - {name: bond0, members: [eth1]} + - {name: bond1, members: [eth2]} + +- name: Remove aggregate of linkagg definitions + vyos.vyos.vyos_linkagg: + aggregate: + - name: bond0 + - name: bond1 + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always, except for the platforms that use Netconf transport to manage the device. + type: list + sample: + - set interfaces bonding bond0 + - set interfaces ethernet eth0 bond-group 'bond0' + - set interfaces ethernet eth1 bond-group 'bond0' +""" +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + load_config, + run_commands, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def search_obj_in_list(name, lst): + for o in lst: + if o["name"] == name: + return o + + return None + + +def map_obj_to_commands(updates, module): + commands = list() + want, have = updates + + for w in want: + name = w["name"] + members = w.get("members") or [] + mode = w["mode"] + + if mode == "on": + mode = "802.3ad" + + state = w["state"] + + obj_in_have = search_obj_in_list(name, have) + + if state == "absent": + if obj_in_have: + for m in obj_in_have["members"]: + commands.append( + "delete interfaces ethernet " + m + " bond-group" + ) + + commands.append("delete interfaces bonding " + name) + else: + if not obj_in_have: + commands.append( + "set interfaces bonding " + name + " mode " + mode + ) + + for m in members: + commands.append( + "set interfaces ethernet " + m + " bond-group " + name + ) + + if state == "down": + commands.append( + "set interfaces bonding " + name + " disable" + ) + else: + if mode != obj_in_have["mode"]: + commands.append( + "set interfaces bonding " + name + " mode " + mode + ) + + missing_members = list( + set(members) - set(obj_in_have["members"]) + ) + for m in missing_members: + commands.append( + "set interfaces ethernet " + m + " bond-group " + name + ) + + if state == "down" and obj_in_have["state"] == "up": + commands.append( + "set interfaces bonding " + name + " disable" + ) + elif state == "up" and obj_in_have["state"] == "down": + commands.append( + "delete interfaces bonding " + name + " disable" + ) + + return commands + + +def map_config_to_obj(module): + obj = [] + output = run_commands(module, ["show interfaces bonding slaves"]) + lines = output[0].splitlines() + + if len(lines) > 1: + for line in lines[1:]: + splitted_line = line.split() + + name = splitted_line[0] + mode = splitted_line[1] + state = splitted_line[2] + + if len(splitted_line) > 4: + members = splitted_line[4:] + else: + members = [] + + obj.append( + { + "name": name, + "mode": mode, + "members": members, + "state": state, + } + ) + + return obj + + +def map_params_to_obj(module): + obj = [] + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + obj.append(item.copy()) + else: + obj.append( + { + "name": module.params["name"], + "mode": module.params["mode"], + "members": module.params["members"], + "state": module.params["state"], + } + ) + + return obj + + +def main(): + """main entry point for module execution""" + element_spec = dict( + name=dict(), + mode=dict( + choices=[ + "802.3ad", + "active-backup", + "broadcast", + "round-robin", + "transmit-load-balance", + "adaptive-load-balance", + "xor-hash", + "on", + ], + default="802.3ad", + ), + members=dict(type="list", elements="str"), + state=dict( + default="present", choices=["present", "absent", "up", "down"] + ), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["name"] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + required_one_of = [["name", "aggregate"]] + mutually_exclusive = [["name", "aggregate"]] + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + + if warnings: + result["warnings"] = warnings + + want = map_params_to_obj(module) + have = map_config_to_obj(module) + + commands = map_obj_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp.py new file mode 100644 index 00000000..c1aaf5d4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_lldp +author: Ricardo Carrillo Cruz (@rcarrillocruz) +short_description: (deprecated, removed after 2022-06-01) Manage LLDP configuration + on VyOS network devices +description: +- This module provides declarative management of LLDP service on VyOS network devices. +version_added: 1.0.0 +deprecated: + alternative: vyos_lldp_global + why: Updated modules released with more functionality. + removed_at_date: '2022-06-01' +notes: +- Tested against VYOS 1.1.7 +options: + interfaces: + description: + - Name of the interfaces. + type: list + elements: str + state: + description: + - State of the link aggregation group. + default: present + choices: + - present + - absent + - enabled + - disabled + type: str +extends_documentation_fragment: +- vyos.vyos.vyos + + +""" + +EXAMPLES = """ +- name: Enable LLDP service + vyos.vyos.vyos_lldp: + state: present + +- name: Disable LLDP service + vyos.vyos.vyos_lldp: + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always, except for the platforms that use Netconf transport to manage the device. + type: list + sample: + - set service lldp +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def has_lldp(module): + config = get_config(module).splitlines() + + if "set service 'lldp'" in config or "set service lldp" in config: + return True + else: + return False + + +def main(): + """main entry point for module execution""" + argument_spec = dict( + interfaces=dict(type="list", elements="str"), + state=dict( + default="present", + choices=["present", "absent", "enabled", "disabled"], + ), + ) + + argument_spec.update(vyos_argument_spec) + + module = AnsibleModule( + argument_spec=argument_spec, supports_check_mode=True + ) + + warnings = list() + + result = {"changed": False} + + if warnings: + result["warnings"] = warnings + + HAS_LLDP = has_lldp(module) + + commands = [] + + if module.params["state"] == "absent" and HAS_LLDP: + commands.append("delete service lldp") + elif module.params["state"] == "present" and not HAS_LLDP: + commands.append("set service lldp") + + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_global.py new file mode 100644 index 00000000..e3adfcf7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_global.py @@ -0,0 +1,502 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_lldp_global +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_lldp_global +short_description: LLDP global resource module +description: This module manages link layer discovery protocol (LLDP) attributes on + VyOS devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: The provided link layer discovery protocol (LLDP) configuration. + type: dict + suboptions: + enable: + description: + - This argument is a boolean value to enable or disable LLDP. + type: bool + address: + description: + - This argument defines management-address. + type: str + snmp: + description: + - This argument enable the SNMP queries to LLDP database. + type: str + legacy_protocols: + description: + - List of the supported legacy protocols. + type: list + elements: str + choices: + - cdp + - edp + - fdp + - sonmp + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep lldp). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - replaced + - deleted + - gathered + - rendered + - parsed + default: merged + +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands|grep lldp +# +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_lldp_global: + config: + legacy_protocols: + - fdp + - cdp + snmp: enable + address: 192.0.2.11 + state: merged +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [] +# +# "commands": [ +# "set service lldp legacy-protocols fdp", +# "set service lldp legacy-protocols cdp", +# "set service lldp snmp enable", +# "set service lldp management-address '192.0.2.11'" +# ] +# +# "after": [ +# { +# "snmp": "enable" +# }, +# { +# "address": "192.0.2.11" +# }, +# { +# "legacy_protocols": [ +# "cdp", +# "fdp" +# ] +# } +# { +# "enable": true +# } +# ] +# +# After state: +# ------------- +# +# set service lldp legacy-protocols cdp +# set service lldp legacy-protocols fdp +# set service lldp management-address '192.0.2.11' +# set service lldp snmp enable + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep lldp +# set service lldp legacy-protocols cdp +# set service lldp legacy-protocols fdp +# set service lldp management-address '192.0.2.11' +# set service lldp snmp enable +# +- name: Replace device configurations with provided configurations + vyos.vyos.vyos_lldp_global: + config: + legacy_protocols: + - edp + - sonmp + - cdp + address: 192.0.2.14 + state: replaced +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# +# "before": [ +# { +# "snmp": "enable" +# }, +# { +# "address": "192.0.2.11" +# }, +# { +# "legacy_protocols": [ +# "cdp", +# "fdp" +# ] +# } +# { +# "enable": true +# } +# ] +# "commands": [ +# "delete service lldp snmp", +# "delete service lldp legacy-protocols fdp", +# "set service lldp management-address '192.0.2.14'", +# "set service lldp legacy-protocols edp", +# "set service lldp legacy-protocols sonmp" +# ] +# +# "after": [ +# { +# "address": "192.0.2.14" +# }, +# { +# "legacy_protocols": [ +# "cdp", +# "edp", +# "sonmp" +# ] +# } +# { +# "enable": true +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands|grep lldp +# set service lldp legacy-protocols cdp +# set service lldp legacy-protocols edp +# set service lldp legacy-protocols sonmp +# set service lldp management-address '192.0.2.14' + + +# Using deleted +# +# Before state +# ------------- +# vyos@vyos:~$ show configuration commands|grep lldp +# set service lldp legacy-protocols cdp +# set service lldp legacy-protocols edp +# set service lldp legacy-protocols sonmp +# set service lldp management-address '192.0.2.14' +# +- name: Delete attributes of given lldp service (This won't delete the LLDP service + itself) + vyos.vyos.vyos_lldp_global: + config: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "address": "192.0.2.14" +# }, +# { +# "legacy_protocols": [ +# "cdp", +# "edp", +# "sonmp" +# ] +# } +# { +# "enable": true +# } +# ] +# +# "commands": [ +# "delete service lldp management-address", +# "delete service lldp legacy-protocols" +# ] +# +# "after": [ +# { +# "enable": true +# } +# ] +# +# After state +# ------------ +# vyos@vyos:~$ show configuration commands | grep lldp +# set service lldp + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep lldp +# set service lldp legacy-protocols 'cdp' +# set service lldp management-address '192.0.2.17' +# +- name: Gather lldp global config with provided configurations + vyos.vyos.vyos_lldp_global: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "config_trap": true, +# "group": { +# "address_group": [ +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.3.1" +# }, +# { +# "address": "192.0.3.2" +# } +# ], +# "name": "ENG-HOSTS" +# }, +# { +# "description": "Sales office hosts address list", +# "members": [ +# { +# "address": "192.0.2.1" +# }, +# { +# "address": "192.0.2.2" +# }, +# { +# "address": "192.0.2.3" +# } +# ], +# "name": "SALES-HOSTS" +# } +# ], +# "network_group": [ +# { +# "description": "This group has the Management network addresses", +# "members": [ +# { +# "address": "192.0.1.0/24" +# } +# ], +# "name": "MGMT" +# } +# ] +# }, +# "log_martians": true, +# "ping": { +# "all": true, +# "broadcast": true +# }, +# "route_redirects": [ +# { +# "afi": "ipv4", +# "icmp_redirects": { +# "receive": false, +# "send": true +# }, +# "ip_src_route": true +# } +# ], +# "state_policy": [ +# { +# "action": "accept", +# "connection_type": "established", +# "log": true +# }, +# { +# "action": "reject", +# "connection_type": "invalid" +# } +# ], +# "syn_cookies": true, +# "twa_hazards_protection": true, +# "validation": "strict" +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep lldp +# set service lldp legacy-protocols 'cdp' +# set service lldp management-address '192.0.2.17' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_lldp_global: + config: + address: 192.0.2.17 + enable: true + legacy_protocols: + - cdp + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set service lldp legacy-protocols 'cdp'", +# "set service lldp", +# "set service lldp management-address '192.0.2.17'" +# ] +# + + +# Using parsed +# +# +- name: Parse the provided commands to provide structured configuration + vyos.vyos.vyos_lldp_global: + running_config: + "set service lldp legacy-protocols 'cdp' + set service lldp legacy-protocols 'fdp' + set service lldp management-address '192.0.2.11'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": { +# "address": "192.0.2.11", +# "enable": true, +# "legacy_protocols": [ +# "cdp", +# "fdp" +# ] +# } +# + + +""" +RETURN = """ +before: + description: The configuration as structured data prior to module invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The configuration as structured data after module completion. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - set service lldp legacy-protocols sonmp + - set service lldp management-address '192.0.2.14' +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.lldp_global.lldp_global import ( + Lldp_globalArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.lldp_global.lldp_global import ( + Lldp_global, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + module = AnsibleModule( + argument_spec=Lldp_globalArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + result = Lldp_global(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interface.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interface.py new file mode 100644 index 00000000..b8bf91cf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interface.py @@ -0,0 +1,280 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +module: vyos_lldp_interface +author: Ricardo Carrillo Cruz (@rcarrillocruz) +short_description: (deprecated, removed after 2022-06-01) Manage LLDP interfaces configuration + on VyOS network devices +description: +- This module provides declarative management of LLDP interfaces configuration on + VyOS network devices. +version_added: 1.0.0 +deprecated: + alternative: vyos_lldp_interfaces + why: Updated modules released with more functionality. + removed_at_date: '2022-06-01' +notes: +- Tested against VYOS 1.1.7 +options: + name: + description: + - Name of the interface LLDP should be configured on. + type: str + aggregate: + description: List of interfaces LLDP should be configured on. + type: list + elements: dict + suboptions: + name: + description: + - Name of the interface LLDP should be configured on. + required: True + type: str + state: + description: + - State of the LLDP configuration. + choices: + - present + - absent + - enabled + - disabled + type: str + state: + description: + - State of the LLDP configuration. + default: present + choices: + - present + - absent + - enabled + - disabled + type: str +extends_documentation_fragment: +- vyos.vyos.vyos + + +""" + +EXAMPLES = """ +- name: Enable LLDP on eth1 + net_lldp_interface: + state: present + +- name: Enable LLDP on specific interfaces + net_lldp_interface: + interfaces: + - eth1 + - eth2 + state: present + +- name: Disable LLDP globally + net_lldp_interface: + state: disabled + +- name: Create aggregate of LLDP interface configurations + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: present + +- name: Delete aggregate of LLDP interface configurations + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always, except for the platforms that use Netconf transport to manage the device. + type: list + sample: + - set service lldp eth1 + - set service lldp eth2 disable +""" + + +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def search_obj_in_list(name, lst): + for o in lst: + if o["name"] == name: + return o + + return None + + +def map_obj_to_commands(updates, module): + commands = list() + want, have = updates + + for w in want: + name = w["name"] + state = w["state"] + + obj_in_have = search_obj_in_list(name, have) + + if state == "absent" and obj_in_have: + commands.append("delete service lldp interface " + name) + elif state in ("present", "enabled"): + if not obj_in_have: + commands.append("set service lldp interface " + name) + elif ( + obj_in_have + and obj_in_have["state"] == "disabled" + and state == "enabled" + ): + commands.append( + "delete service lldp interface " + name + " disable" + ) + elif state == "disabled": + if not obj_in_have: + commands.append("set service lldp interface " + name) + commands.append( + "set service lldp interface " + name + " disable" + ) + elif obj_in_have and obj_in_have["state"] != "disabled": + commands.append( + "set service lldp interface " + name + " disable" + ) + + return commands + + +def map_config_to_obj(module): + obj = [] + config = get_config(module).splitlines() + + output = [c for c in config if c.startswith("set service lldp interface")] + + for i in output: + splitted_line = i.split() + + if len(splitted_line) > 5: + new_obj = {"name": splitted_line[4]} + + if splitted_line[5] == "'disable'": + new_obj["state"] = "disabled" + else: + new_obj = {"name": splitted_line[4][1:-1]} + new_obj["state"] = "present" + + obj.append(new_obj) + + return obj + + +def map_params_to_obj(module): + obj = [] + + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + obj.append(item.copy()) + else: + obj.append( + {"name": module.params["name"], "state": module.params["state"]} + ) + + return obj + + +def main(): + """main entry point for module execution""" + element_spec = dict( + name=dict(), + state=dict( + default="present", + choices=["present", "absent", "enabled", "disabled"], + ), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["name"] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + required_one_of = [["name", "aggregate"]] + mutually_exclusive = [["name", "aggregate"]] + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + + if warnings: + result["warnings"] = warnings + + want = map_params_to_obj(module) + have = map_config_to_obj(module) + + commands = map_obj_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py new file mode 100644 index 00000000..99ca61c2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py @@ -0,0 +1,673 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_lldp_interfaces +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_lldp_interfaces +short_description: LLDP interfaces resource module +description: This module manages attributes of lldp interfaces on VyOS network devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: A list of lldp interfaces configurations. + type: list + elements: dict + suboptions: + name: + description: + - Name of the lldp interface. + type: str + required: true + enable: + description: + - to disable lldp on the interface. + type: bool + default: true + location: + description: + - LLDP-MED location data. + type: dict + suboptions: + civic_based: + description: + - Civic-based location data. + type: dict + suboptions: + ca_info: + description: LLDP-MED address info + type: list + elements: dict + suboptions: + ca_type: + description: LLDP-MED Civic Address type. + type: int + ca_value: + description: LLDP-MED Civic Address value. + type: str + country_code: + description: Country Code + type: str + required: true + coordinate_based: + description: + - Coordinate-based location. + type: dict + suboptions: + altitude: + description: Altitude in meters. + type: int + datum: + description: Coordinate datum type. + type: str + choices: + - WGS84 + - NAD83 + - MLLW + latitude: + description: Latitude. + type: str + required: true + longitude: + description: Longitude. + type: str + required: true + elin: + description: Emergency Call Service ELIN number (between 10-25 numbers). + type: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep lldp). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - rendered + - parsed + - gathered + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep lldp +# +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": [] +# +# "commands": [ +# "set service lldp interface eth1 location civic-based country-code 'US'", +# "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'", +# "set service lldp interface eth1", +# "set service lldp interface eth2 location coordinate-based latitude '33.524449N'", +# "set service lldp interface eth2 location coordinate-based altitude '2200'", +# "set service lldp interface eth2 location coordinate-based datum 'WGS84'", +# "set service lldp interface eth2 location coordinate-based longitude '222.267255W'", +# "set service lldp interface eth2 location coordinate-based latitude '33.524449N'", +# "set service lldp interface eth2 location coordinate-based altitude '2200'", +# "set service lldp interface eth2 location coordinate-based datum 'WGS84'", +# "set service lldp interface eth2 location coordinate-based longitude '222.267255W'", +# "set service lldp interface eth2" +# +# "after": [ +# { +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth2" +# }, +# { +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } +# }, +# "name": "eth1" +# } +# ], +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep lldp +# set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' +# set service lldp interface eth1 location civic-based country-code 'US' +# set service lldp interface eth2 location coordinate-based altitude '2200' +# set service lldp interface eth2 location coordinate-based datum 'WGS84' +# set service lldp interface eth2 location coordinate-based latitude '33.524449N' +# set service lldp interface eth2 location coordinate-based longitude '222.267255W' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep lldp +# set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' +# set service lldp interface eth1 location civic-based country-code 'US' +# set service lldp interface eth2 location coordinate-based altitude '2200' +# set service lldp interface eth2 location coordinate-based datum 'WGS84' +# set service lldp interface eth2 location coordinate-based latitude '33.524449N' +# set service lldp interface eth2 location coordinate-based longitude '222.267255W' +# +- name: Replace device configurations of listed LLDP interfaces with provided configurations + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth2 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + + - name: eth1 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth2" +# }, +# { +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } +# }, +# "name": "eth1" +# } +# ] +# +# "commands": [ +# "delete service lldp interface eth2 location", +# "set service lldp interface eth2 'disable'", +# "set service lldp interface eth2 location civic-based country-code 'US'", +# "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'", +# "delete service lldp interface eth1 location", +# "set service lldp interface eth1 'disable'", +# "set service lldp interface eth1 location coordinate-based latitude '33.524449N'", +# "set service lldp interface eth1 location coordinate-based altitude '2200'", +# "set service lldp interface eth1 location coordinate-based datum 'WGS84'", +# "set service lldp interface eth1 location coordinate-based longitude '222.267255W'" +# ] +# +# "after": [ +# { +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } +# }, +# "name": "eth2" +# }, +# { +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth1" +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep lldp +# set service lldp interface eth1 'disable' +# set service lldp interface eth1 location coordinate-based altitude '2200' +# set service lldp interface eth1 location coordinate-based datum 'WGS84' +# set service lldp interface eth1 location coordinate-based latitude '33.524449N' +# set service lldp interface eth1 location coordinate-based longitude '222.267255W' +# set service lldp interface eth2 'disable' +# set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH' +# set service lldp interface eth2 location civic-based country-code 'US' + + +# Using overridden +# +# Before state +# -------------- +# +# vyos@vyos:~$ show configuration commands | grep lldp +# set service lldp interface eth1 'disable' +# set service lldp interface eth1 location coordinate-based altitude '2200' +# set service lldp interface eth1 location coordinate-based datum 'WGS84' +# set service lldp interface eth1 location coordinate-based latitude '33.524449N' +# set service lldp interface eth1 location coordinate-based longitude '222.267255W' +# set service lldp interface eth2 'disable' +# set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH' +# set service lldp interface eth2 location civic-based country-code 'US' +# +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth2 + location: + elin: 0000000911 + + state: overridden +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "enable": false, +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } +# }, +# "name": "eth2" +# }, +# { +# "enable": false, +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth1" +# } +# ] +# +# "commands": [ +# "delete service lldp interface eth2 location", +# "delete service lldp interface eth2 disable", +# "set service lldp interface eth2 location elin 0000000911" +# +# +# "after": [ +# { +# "location": { +# "elin": 0000000911 +# }, +# "name": "eth2" +# } +# ] +# +# +# After state +# ------------ +# +# vyos@vyos# run show configuration commands | grep lldp +# set service lldp interface eth2 location elin '0000000911' + + +# Using deleted +# +# Before state +# ------------- +# +# vyos@vyos# run show configuration commands | grep lldp +# set service lldp interface eth2 location elin '0000000911' +# +- name: Delete lldp interface attributes of given interfaces. + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth2 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# + before: [{location: {elin: 0000000911}, name: eth2}] +# "commands": [ +# "commands": [ +# "delete service lldp interface eth2" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep lldp +# set service 'lldp' + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep lldp +# set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' +# set service lldp interface eth1 location civic-based country-code 'US' +# set service lldp interface eth2 location coordinate-based altitude '2200' +# set service lldp interface eth2 location coordinate-based datum 'WGS84' +# set service lldp interface eth2 location coordinate-based latitude '33.524449N' +# set service lldp interface eth2 location coordinate-based longitude '222.267255W' +# +- name: Gather listed lldp interfaces from running configuration + vyos.vyos.vyos_lldp_interfaces: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth2" +# }, +# { +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } +# }, +# "name": "eth1" +# } +# ] +# +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep lldp +# set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' +# set service lldp interface eth1 location civic-based country-code 'US' +# set service lldp interface eth2 location coordinate-based altitude '2200' +# set service lldp interface eth2 location coordinate-based datum 'WGS84' +# set service lldp interface eth2 location coordinate-based latitude '33.524449N' +# set service lldp interface eth2 location coordinate-based longitude '222.267255W' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set service lldp interface eth1 location civic-based country-code 'US'", +# "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'", +# "set service lldp interface eth1", +# "set service lldp interface eth2 location coordinate-based latitude '33.524449N'", +# "set service lldp interface eth2 location coordinate-based altitude '2200'", +# "set service lldp interface eth2 location coordinate-based datum 'WGS84'", +# "set service lldp interface eth2 location coordinate-based longitude '222.267255W'", +# "set service lldp interface eth2" +# ] + + +# Using parsed +# +# +- name: Parsed the commands to provide structured configuration. + vyos.vyos.vyos_lldp_interfaces: + running_config: + "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + set service lldp interface eth1 location civic-based country-code 'US' + set service lldp interface eth2 location coordinate-based altitude '2200' + set service lldp interface eth2 location coordinate-based datum 'WGS84' + set service lldp interface eth2 location coordinate-based latitude '33.524449N' + set service lldp interface eth2 location coordinate-based longitude '222.267255W'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth2" +# }, +# { +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } +# }, +# "name": "eth1" +# } +# ] + + +""" +RETURN = """ +before: + description: The configuration as structured data prior to module invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The configuration as structured data after module completion. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - "set service lldp interface eth2 'disable'" + - "delete service lldp interface eth1 location" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.lldp_interfaces.lldp_interfaces import ( + Lldp_interfacesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.lldp_interfaces.lldp_interfaces import ( + Lldp_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + + module = AnsibleModule( + argument_spec=Lldp_interfacesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Lldp_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_logging.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_logging.py new file mode 100644 index 00000000..c7780d8e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_logging.py @@ -0,0 +1,337 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + + +DOCUMENTATION = """ +module: vyos_logging +author: Trishna Guha (@trishnaguha) +short_description: Manage logging on network devices +description: +- This module provides declarative management of logging on Vyatta Vyos devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + dest: + description: + - Destination of the logs. + type: str + choices: + - console + - file + - global + - host + - user + name: + description: + - If value of C(dest) is I(file) it indicates file-name, for I(user) it indicates + username and for I(host) indicates the host name to be notified. + type: str + facility: + description: + - Set logging facility. + type: str + level: + description: + - Set logging severity levels. + type: str + aggregate: + description: List of logging definitions. + type: list + elements: dict + suboptions: + dest: + description: + - Destination of the logs. + type: str + choices: + - console + - file + - global + - host + - user + name: + description: + - If value of C(dest) is I(file) it indicates file-name, for I(user) it indicates + username and for I(host) indicates the host name to be notified. + type: str + facility: + description: + - Set logging facility. + type: str + level: + description: + - Set logging severity levels. + type: str + state: + description: + - State of the logging configuration. + type: str + choices: + - present + - absent + state: + description: + - State of the logging configuration. + type: str + default: present + choices: + - present + - absent +extends_documentation_fragment: +- vyos.vyos.vyos +""" + +EXAMPLES = """ +- name: configure console logging + vyos.vyos.vyos_logging: + dest: console + facility: all + level: crit + +- name: remove console logging configuration + vyos.vyos.vyos_logging: + dest: console + state: absent + +- name: configure file logging + vyos.vyos.vyos_logging: + dest: file + name: test + facility: local3 + level: err + +- name: Add logging aggregate + vyos.vyos.vyos_logging: + aggregate: + - {dest: file, name: test1, facility: all, level: info} + - {dest: file, name: test2, facility: news, level: debug} + state: present + +- name: Remove logging aggregate + vyos.vyos.vyos_logging: + aggregate: + - {dest: console, facility: all, level: info} + - {dest: console, facility: daemon, level: warning} + - {dest: file, name: test2, facility: news, level: debug} + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always + type: list + sample: + - set system syslog global facility all level notice +""" + +import re + +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def spec_to_commands(updates, module): + commands = list() + want, have = updates + + for w in want: + dest = w["dest"] + name = w["name"] + facility = w["facility"] + level = w["level"] + state = w["state"] + del w["state"] + + if state == "absent" and w in have: + if w["name"]: + commands.append( + "delete system syslog {0} {1} facility {2} level {3}".format( + dest, name, facility, level + ) + ) + else: + commands.append( + "delete system syslog {0} facility {1} level {2}".format( + dest, facility, level + ) + ) + elif state == "present" and w not in have: + if w["name"]: + commands.append( + "set system syslog {0} {1} facility {2} level {3}".format( + dest, name, facility, level + ) + ) + else: + commands.append( + "set system syslog {0} facility {1} level {2}".format( + dest, facility, level + ) + ) + + return commands + + +def config_to_dict(module): + data = get_config(module) + obj = [] + + for line in data.split("\n"): + if line.startswith("set system syslog"): + match = re.search(r"set system syslog (\S+)", line, re.M) + dest = match.group(1) + if dest == "host": + match = re.search(r"host (\S+)", line, re.M) + name = match.group(1) + elif dest == "file": + match = re.search(r"file (\S+)", line, re.M) + name = match.group(1) + elif dest == "user": + match = re.search(r"user (\S+)", line, re.M) + name = match.group(1) + else: + name = None + + if "facility" in line: + match = re.search(r"facility (\S+)", line, re.M) + facility = match.group(1) + if "level" in line: + match = re.search(r"level (\S+)", line, re.M) + level = match.group(1).strip("'") + + obj.append( + { + "dest": dest, + "name": name, + "facility": facility, + "level": level, + } + ) + + return obj + + +def map_params_to_obj(module, required_if=None): + obj = [] + + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + module._check_required_if(required_if, item) + obj.append(item.copy()) + + else: + if module.params["dest"] not in ("host", "file", "user"): + module.params["name"] = None + + obj.append( + { + "dest": module.params["dest"], + "name": module.params["name"], + "facility": module.params["facility"], + "level": module.params["level"], + "state": module.params["state"], + } + ) + + return obj + + +def main(): + """main entry point for module execution""" + element_spec = dict( + dest=dict( + type="str", choices=["console", "file", "global", "host", "user"] + ), + name=dict(type="str"), + facility=dict(type="str"), + level=dict(type="str"), + state=dict(default="present", choices=["present", "absent"]), + ) + + aggregate_spec = deepcopy(element_spec) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) + + argument_spec.update(element_spec) + + argument_spec.update(vyos_argument_spec) + required_if = [ + ("dest", "host", ["name", "facility", "level"]), + ("dest", "file", ["name", "facility", "level"]), + ("dest", "user", ["name", "facility", "level"]), + ("dest", "console", ["facility", "level"]), + ("dest", "global", ["facility", "level"]), + ] + + module = AnsibleModule( + argument_spec=argument_spec, + required_if=required_if, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + if warnings: + result["warnings"] = warnings + want = map_params_to_obj(module, required_if=required_if) + have = config_to_dict(module) + + commands = spec_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospf_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospf_interfaces.py new file mode 100644 index 00000000..732a5e7f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospf_interfaces.py @@ -0,0 +1,917 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_ospf_interfaces +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +module: vyos_ospf_interfaces +version_added: 1.2.0 +short_description: OSPF Interfaces Resource Module. +description: +- This module manages OSPF configuration of interfaces on devices running VYOS. +author: Gomathi Selvi Srinivasan (@GomathiselviS) +options: + config: + description: A list of OSPF configuration for interfaces. + type: list + elements: dict + suboptions: + name: + description: + - Name/Identifier of the interface. + type: str + address_family: + description: + - OSPF settings on the interfaces in address-family context. + type: list + elements: dict + suboptions: + afi: + description: + - Address Family Identifier (AFI) for OSPF settings on the interfaces. + type: str + choices: ['ipv4', 'ipv6'] + required: True + authentication: + description: + - Authentication settings on the interface. + type: dict + suboptions: + plaintext_password: + description: + - Plain Text password. + type: str + md5_key: + description: + - md5 parameters. + type: dict + suboptions: + key_id: + description: + - key id. + type: int + key: + description: + - md5 key. + type: str + bandwidth: + description: + - Bandwidth of interface (kilobits/sec) + type: int + cost: + description: + - metric associated with interface. + type: int + dead_interval: + description: + - Time interval to detect a dead router. + type: int + hello_interval: + description: + - Timer interval between transmission of hello packets. + type: int + mtu_ignore: + description: + - if True, Disable MTU check for Database Description packets. + type: bool + network: + description: + - Interface type. + type: str + priority: + description: + - Interface priority. + type: int + retransmit_interval: + description: + - LSA retransmission interval. + type: int + transmit_delay: + description: + - LSA transmission delay. + type: int + ifmtu: + description: + - interface MTU. + type: int + instance: + description: + - Instance ID. + type: str + passive: + description: + - If True, disables forming adjacency. + type: bool + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the IOS device by + executing the command B(sh running-config | section ^interface). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state the configuration should be left in. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - gathered + - parsed + - rendered + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# + +# @vyos:~$ show configuration commands | match "ospf" + + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: True + state: merged + +# After State: +# -------------- + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + +# "after": [ +# " +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "before": [ +# { +# "name": "eth0" +# }, +# { +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "changed": true, +# "commands": [ +# "set interfaces ethernet eth1 ip ospf transmit-delay 50", +# "set interfaces ethernet eth1 ip ospf priority 26", +# "set interfaces ethernet eth1 ip ospf network point-to-point", +# "set interfaces ethernet eth1 ipv6 ospfv3 dead-interval 39", +# "set interfaces bonding bond2 ip ospf transmit-delay 45", +# "set interfaces bonding bond2 ip ospf bandwidth 70", +# "set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345", +# "set interfaces bonding bond2 ipv6 ospfv3 passive" +# ], + + + + +# Using replaced: + +# Before State: +# ------------ + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' + + - name: Replace provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: True + state: replaced + +# After State: +# ----------- + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf cost '100' +# set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' +# vyos@vyos:~$ + +# Module Execution +# ---------------- +# "after": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "cost": 100 +# }, +# { +# "afi": "ipv6", +# "ifmtu": 33 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "before": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "changed": true, +# "commands": [ +# "set interfaces ethernet eth1 ip ospf cost 100", +# "set interfaces ethernet eth1 ipv6 ospfv3 ifmtu 33", +# "delete interfaces ethernet eth1 ip ospf network point-to-point", +# "delete interfaces ethernet eth1 ip ospf priority 26", +# "delete interfaces ethernet eth1 ip ospf transmit-delay 50", +# "delete interfaces ethernet eth1 ipv6 ospfv3 dead-interval 39", +# "delete interfaces bonding bond2 ip ospf authentication", +# "delete interfaces bonding bond2 ip ospf bandwidth 70" +# ], +# + +# Using Overridden: +# ----------------- + +# Before State: +# ------------ + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf cost '100' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' +# set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' +# vyos@vyos:~$ + + - name: Override device configuration with provided configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + passive: True + state: overridden +# After State: +# ----------- + +# 200~vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces ethernet eth0 ip ospf cost '100' +# set interfaces ethernet eth0 ipv6 ospfv3 ifmtu '33' +# set interfaces ethernet eth0 ipv6 ospfv3 'passive' +# vyos@vyos:~$ +# +# +# "after": [ +# { +# "name": "bond2" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "cost": 100 +# }, +# { +# "afi": "ipv6", +# "ifmtu": 33, +# "passive": true +# } +# ], +# "name": "eth0" +# }, +# { +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "before": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "cost": 100, +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39, +# "ifmtu": 33 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "changed": true, +# "commands": [ +# "delete interfaces bonding bond2 ip ospf", +# "delete interfaces bonding bond2 ipv6 ospfv3", +# "delete interfaces ethernet eth1 ip ospf", +# "delete interfaces ethernet eth1 ipv6 ospfv3", +# "set interfaces ethernet eth0 ip ospf cost 100", +# "set interfaces ethernet eth0 ipv6 ospfv3 ifmtu 33", +# "set interfaces ethernet eth0 ipv6 ospfv3 passive" +# ], +# + +# Using deleted: +# ------------- + +# before state: +# ------------- + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth0 ip ospf cost '100' +# set interfaces ethernet eth0 ipv6 ospfv3 ifmtu '33' +# set interfaces ethernet eth0 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' +# vyos@vyos:~$ + + - name: Delete device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + state: deleted + +# After State: +# ----------- + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' +# vyos@vyos:~$ +# +# +# "after": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "before": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "cost": 100 +# }, +# { +# "afi": "ipv6", +# "ifmtu": 33, +# "passive": true +# } +# ], +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], +# "changed": true, +# "commands": [ +# "delete interfaces ethernet eth0 ip ospf", +# "delete interfaces ethernet eth0 ipv6 ospfv3" +# ], +# +# Using parsed: +# parsed.cfg: + +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth0 ip ospf cost '50' +# set interfaces ethernet eth0 ip ospf priority '26' +# set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33' +# set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' +# + + - name: parse configs + vyos.vyos.vyos_ospf_interfaces: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed + +# Module Execution: +# ---------------- + +# "parsed": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "cost": 50, +# "priority": 26 +# }, +# { +# "afi": "ipv6", +# "instance": "33", +# "mtu_ignore": true +# } +# ], +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39 +# } +# ], +# "name": "eth1" +# } +# ] + +# Using rendered: +# -------------- + + - name: Render + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: True + state: rendered + +# Module Execution: +# ---------------- + +# "rendered": [ +# "set interfaces ethernet eth1 ip ospf transmit-delay 50", +# "set interfaces ethernet eth1 ip ospf priority 26", +# "set interfaces ethernet eth1 ip ospf network point-to-point", +# "set interfaces ethernet eth1 ipv6 ospfv3 dead-interval 39", +# "set interfaces bonding bond2 ip ospf transmit-delay 45", +# "set interfaces bonding bond2 ip ospf bandwidth 70", +# "set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345", +# "set interfaces bonding bond2 ipv6 ospfv3 passive" +# ] +# + +# Using Gathered: +# -------------- + +# Native Config: + +# vyos@vyos:~$ show configuration commands | match "ospf" +# set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345' +# set interfaces bonding bond2 ip ospf bandwidth '70' +# set interfaces bonding bond2 ip ospf transmit-delay '45' +# set interfaces bonding bond2 ipv6 ospfv3 'passive' +# set interfaces ethernet eth1 ip ospf network 'point-to-point' +# set interfaces ethernet eth1 ip ospf priority '26' +# set interfaces ethernet eth1 ip ospf transmit-delay '50' +# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' +# vyos@vyos:~$ + + - name: gather configs + vyos.vyos.vyos_ospf_interfaces: + state: gathered + +# Module Execution: +# ----------------- + +# "gathered": [ +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "authentication": { +# "md5_key": { +# "key": "1111111111232345", +# "key_id": 10 +# } +# }, +# "bandwidth": 70, +# "transmit_delay": 45 +# }, +# { +# "afi": "ipv6", +# "passive": true +# } +# ], +# "name": "bond2" +# }, +# { +# "name": "eth0" +# }, +# { +# "address_family": [ +# { +# "afi": "ipv4", +# "network": "point-to-point", +# "priority": 26, +# "transmit_delay": 50 +# }, +# { +# "afi": "ipv6", +# "dead_interval": 39 +# } +# ], +# "name": "eth1" +# }, +# { +# "name": "eth2" +# }, +# { +# "name": "eth3" +# } +# ], + + + + + +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospf_interfaces.ospf_interfaces import ( + Ospf_interfacesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospf_interfaces.ospf_interfaces import ( + Ospf_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule( + argument_spec=Ospf_interfacesArgs.argument_spec, + mutually_exclusive=[], + required_if=[], + supports_check_mode=False, + ) + + result = Ospf_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospfv2.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospfv2.py new file mode 100644 index 00000000..280630fb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospfv2.py @@ -0,0 +1,1818 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_ospfv2 +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_ospfv2 +short_description: OSPFv2 resource module +description: This resource module configures and manages attributes of OSPFv2 routes + on VyOS network devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: A provided OSPFv2 route configuration. + type: dict + suboptions: + areas: + description: OSPFv2 area. + type: list + elements: dict + suboptions: + area_id: + description: OSPFv2 area identity. + type: str + area_type: + description: Area type. + type: dict + suboptions: + normal: + description: Normal OSPFv2 area. + type: bool + nssa: + description: NSSA OSPFv2 area. + type: dict + suboptions: + set: + description: Enabling NSSA. + type: bool + default_cost: + description: Summary-default cost of NSSA area. + type: int + no_summary: + description: Do not inject inter-area routes into stub. + type: bool + translate: + description: NSSA-ABR. + type: str + choices: [always, candidate, never] + stub: + description: Stub OSPFv2 area. + type: dict + suboptions: + set: + description: Enabling stub. + type: bool + default_cost: + description: Summary-default cost of stub area. + type: int + no_summary: + description: Do not inject inter-area routes into stub. + type: bool + authentication: + description: OSPFv2 area authentication type. + type: str + choices: [plaintext-password, md5] + network: + description: OSPFv2 network. + type: list + elements: dict + suboptions: + address: + required: true + description: OSPFv2 IPv4 network address. + type: str + range: + description: Summarize routes matching prefix (border routers only). + type: list + elements: dict + suboptions: + address: + description: border router IPv4 address. + type: str + cost: + description: Metric for this range. + type: int + not_advertise: + description: Don't advertise this range. + type: bool + substitute: + description: Announce area range (IPv4 address) as another prefix. + type: str + shortcut: + description: Area's shortcut mode. + type: str + choices: [default, disable, enable] + virtual_link: + description: Virtual link address. + type: list + elements: dict + suboptions: + address: + description: virtual link address. + type: str + authentication: + description: OSPFv2 area authentication type. + type: dict + suboptions: + md5: + description: MD5 key id based authentication. + type: list + elements: dict + suboptions: + key_id: + description: MD5 key id. + type: int + md5_key: + description: MD5 key. + type: str + plaintext_password: + description: Plain text password. + type: str + dead_interval: + description: Interval after which a neighbor is declared dead. + type: int + hello_interval: + description: Interval between hello packets. + type: int + retransmit_interval: + description: Interval between retransmitting lost link state advertisements. + type: int + transmit_delay: + description: Link state transmit delay. + type: int + log_adjacency_changes: + description: Log changes in adjacency state. + type: str + choices: [detail] + max_metric: + description: OSPFv2 maximum/infinite-distance metric. + type: dict + suboptions: + router_lsa: + description: Advertise own Router-LSA with infinite distance (stub router). + type: dict + suboptions: + administrative: + description: Administratively apply, for an indefinite period. + type: bool + on_shutdown: + description: Time to advertise self as stub-router. + type: int + on_startup: + description: Time to advertise self as stub-router + type: int + auto_cost: + description: Calculate OSPFv2 interface cost according to bandwidth. + type: dict + suboptions: + reference_bandwidth: + description: Reference bandwidth cost in Mbits/sec. + type: int + default_information: + description: Control distribution of default information. + type: dict + suboptions: + originate: + description: Distribute a default route. + type: dict + suboptions: + always: + description: Always advertise default route. + type: bool + metric: + description: OSPFv2 default metric. + type: int + metric_type: + description: OSPFv2 Metric types for default routes. + type: int + route_map: + description: Route map references. + type: str + default_metric: + description: Metric of redistributed routes + type: int + distance: + description: Administrative distance. + type: dict + suboptions: + global: + description: Global OSPFv2 administrative distance. + type: int + ospf: + description: OSPFv2 administrative distance. + type: dict + suboptions: + external: + description: Distance for external routes. + type: int + inter_area: + description: Distance for inter-area routes. + type: int + intra_area: + description: Distance for intra-area routes. + type: int + mpls_te: + description: MultiProtocol Label Switching-Traffic Engineering (MPLS-TE) parameters. + type: dict + suboptions: + enabled: + description: Enable MPLS-TE functionality. + type: bool + router_address: + description: Stable IP address of the advertising router. + type: str + + neighbor: + description: Neighbor IP address. + type: list + elements: dict + suboptions: + neighbor_id: + description: Identity (number/IP address) of neighbor. + type: str + poll_interval: + description: Seconds between dead neighbor polling interval. + type: int + priority: + description: Neighbor priority. + type: int + parameters: + description: OSPFv2 specific parameters. + type: dict + suboptions: + abr_type: + description: OSPFv2 ABR Type. + type: str + choices: [cisco, ibm, shortcut, standard] + opaque_lsa: + description: Enable the Opaque-LSA capability (rfc2370). + type: bool + rfc1583_compatibility: + description: Enable rfc1583 criteria for handling AS external routes. + type: bool + router_id: + description: Override the default router identifier. + type: str + passive_interface: + description: Suppress routing updates on an interface. + type: list + elements: str + passive_interface_exclude: + description: Interface to exclude when using passive-interface default. + type: list + elements: str + redistribute: + description: Redistribute information from another routing protocol. + type: list + elements: dict + suboptions: + route_type: + description: Route type to redistribute. + type: str + choices: [bgp, connected, kernel, rip, static] + metric: + description: Metric for redistribution routes. + type: int + metric_type: + description: OSPFv2 Metric types. + type: int + route_map: + description: Route map references. + type: str + route_map: + description: Filter routes installed in local route map. + type: list + elements: str + timers: + description: Adjust routing timers. + type: dict + suboptions: + refresh: + description: Adjust refresh parameters. + type: dict + suboptions: + timers: + description: refresh timer. + type: int + throttle: + description: Throttling adaptive timers. + type: dict + suboptions: + spf: + description: OSPFv2 SPF timers. + type: dict + suboptions: + delay: + description: Delay (msec) from first change received till SPF + calculation. + type: int + initial_holdtime: + description: Initial hold time(msec) between consecutive SPF calculations. + type: int + max_holdtime: + description: maximum hold time (sec). + type: int + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep ospf). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state the configuration should be left in. + type: str + choices: + - merged + - replaced + - deleted + - parsed + - gathered + - rendered + default: merged + +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos# run show configuration commands | grep ospf +# +# +- name: Merge the provided configuration with the existing running configuration + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: detail + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: ingress + mpls_te: + enabled: true + router_address: 192.0.11.11 + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 + redistribute: + - route_type: bgp + metric: 10 + metric_type: 2 + passive_interface: + - eth1 + - eth2 + parameters: + router_id: 192.0.1.1 + opaque_lsa: true + rfc1583_compatibility: true + abr_type: cisco + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": {} +# +# "commands": [ +# "set protocols ospf mpls-te enable", +# "set protocols ospf mpls-te router-address '192.0.11.11'", +# "set protocols ospf redistribute bgp", +# "set protocols ospf redistribute bgp metric-type 2", +# "set protocols ospf redistribute bgp metric 10", +# "set protocols ospf default-information originate metric-type 2", +# "set protocols ospf default-information originate always", +# "set protocols ospf default-information originate metric 10", +# "set protocols ospf default-information originate route-map ingress", +# "set protocols ospf auto-cost reference-bandwidth '2'", +# "set protocols ospf parameters router-id '192.0.1.1'", +# "set protocols ospf parameters opaque-lsa", +# "set protocols ospf parameters abr-type 'cisco'", +# "set protocols ospf parameters rfc1583-compatibility", +# "set protocols ospf passive-interface eth1", +# "set protocols ospf passive-interface eth2", +# "set protocols ospf max-metric router-lsa on-shutdown 10", +# "set protocols ospf max-metric router-lsa administrative", +# "set protocols ospf max-metric router-lsa on-startup 10", +# "set protocols ospf log-adjacency-changes 'detail'", +# "set protocols ospf neighbor 192.0.11.12 priority 2", +# "set protocols ospf neighbor 192.0.11.12 poll-interval 10", +# "set protocols ospf neighbor 192.0.11.12", +# "set protocols ospf area '2'", +# "set protocols ospf area 2 authentication plaintext-password", +# "set protocols ospf area 2 shortcut enable", +# "set protocols ospf area 2 area-type normal", +# "set protocols ospf area '3'", +# "set protocols ospf area 3 area-type nssa", +# "set protocols ospf area 4 range 192.0.3.0/24 cost 10", +# "set protocols ospf area 4 range 192.0.3.0/24", +# "set protocols ospf area 4 range 192.0.4.0/24 cost 12", +# "set protocols ospf area 4 range 192.0.4.0/24", +# "set protocols ospf area 4 area-type stub default-cost 20", +# "set protocols ospf area '4'", +# "set protocols ospf area 4 network 192.0.2.0/24" +# ] +# +# "after": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 3 area-type 'nssa' +# set protocols ospf area 4 area-type stub default-cost '20' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 range 192.0.3.0/24 cost '10' +# set protocols ospf area 4 range 192.0.4.0/24 cost '12' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.11.11' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf passive-interface 'eth2' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' + + +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos# run show configuration commands | grep ospf +# +# +- name: Merge the provided configuration to update existing running configuration + vyos.vyos.vyos_ospfv2: + config: + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: false + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# +# "commands": [ +# "delete protocols ospf area 4 area-type stub", +# "set protocols ospf area 4 network 192.0.22.0/24" +# "set protocols ospf area 4 network 192.0.32.0/24" +# ] +# +# "after": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# }, +# { +# "address": "192.0.22.0/24" +# }, +# { +# "address": "192.0.32.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 3 area-type 'nssa' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 network '192.0.22.0/24' +# set protocols ospf area 4 network '192.0.32.0/24' +# set protocols ospf area 4 range 192.0.3.0/24 cost '10' +# set protocols ospf area 4 range 192.0.4.0/24 cost '12' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.11.11' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf passive-interface 'eth2' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 3 area-type 'nssa' +# set protocols ospf area 4 area-type stub default-cost '20' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 range 192.0.3.0/24 cost '10' +# set protocols ospf area 4 range 192.0.4.0/24 cost '12' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.11.11' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf passive-interface 'eth2' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' +# +- name: Replace ospfv2 routes attributes configuration. + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: detail + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: ingress + mpls_te: + enabled: true + router_address: 192.0.22.22 + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 + redistribute: + - route_type: bgp + metric: 10 + metric_type: 2 + passive_interface: + - eth1 + parameters: + router_id: 192.0.1.1 + opaque_lsa: true + rfc1583_compatibility: true + abr_type: cisco + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.12.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 + range: + - address: 192.0.42.0/24 + cost: 10 + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# +# "commands": [ +# "delete protocols ospf passive-interface eth2", +# "delete protocols ospf area 3", +# "delete protocols ospf area 4 range 192.0.3.0/24 cost", +# "delete protocols ospf area 4 range 192.0.3.0/24", +# "delete protocols ospf area 4 range 192.0.4.0/24 cost", +# "delete protocols ospf area 4 range 192.0.4.0/24", +# "set protocols ospf mpls-te router-address '192.0.22.22'", +# "set protocols ospf area 4 range 192.0.42.0/24 cost 10", +# "set protocols ospf area 4 range 192.0.42.0/24", +# "set protocols ospf area 4 network 192.0.12.0/24", +# "set protocols ospf area 4 network 192.0.22.0/24", +# "set protocols ospf area 4 network 192.0.32.0/24" +# ] +# +# "after": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.12.0/24" +# }, +# { +# "address": "192.0.2.0/24" +# }, +# { +# "address": "192.0.22.0/24" +# }, +# { +# "address": "192.0.32.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.42.0/24", +# "cost": 10 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.22.22" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 4 area-type stub default-cost '20' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 network '192.0.12.0/24' +# set protocols ospf area 4 network '192.0.22.0/24' +# set protocols ospf area 4 network '192.0.32.0/24' +# set protocols ospf area 4 range 192.0.42.0/24 cost '10' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.22.22' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: detail + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: ingress + mpls_te: + enabled: true + router_address: 192.0.11.11 + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 + redistribute: + - route_type: bgp + metric: 10 + metric_type: 2 + passive_interface: + - eth1 + - eth2 + parameters: + router_id: 192.0.1.1 + opaque_lsa: true + rfc1583_compatibility: true + abr_type: cisco + areas: + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# [ +# "set protocols ospf mpls-te enable", +# "set protocols ospf mpls-te router-address '192.0.11.11'", +# "set protocols ospf redistribute bgp", +# "set protocols ospf redistribute bgp metric-type 2", +# "set protocols ospf redistribute bgp metric 10", +# "set protocols ospf default-information originate metric-type 2", +# "set protocols ospf default-information originate always", +# "set protocols ospf default-information originate metric 10", +# "set protocols ospf default-information originate route-map ingress", +# "set protocols ospf auto-cost reference-bandwidth '2'", +# "set protocols ospf parameters router-id '192.0.1.1'", +# "set protocols ospf parameters opaque-lsa", +# "set protocols ospf parameters abr-type 'cisco'", +# "set protocols ospf parameters rfc1583-compatibility", +# "set protocols ospf passive-interface eth1", +# "set protocols ospf passive-interface eth2", +# "set protocols ospf max-metric router-lsa on-shutdown 10", +# "set protocols ospf max-metric router-lsa administrative", +# "set protocols ospf max-metric router-lsa on-startup 10", +# "set protocols ospf log-adjacency-changes 'detail'", +# "set protocols ospf neighbor 192.0.11.12 priority 2", +# "set protocols ospf neighbor 192.0.11.12 poll-interval 10", +# "set protocols ospf neighbor 192.0.11.12", +# "set protocols ospf area '2'", +# "set protocols ospf area 2 authentication plaintext-password", +# "set protocols ospf area 2 shortcut enable", +# "set protocols ospf area 2 area-type normal", +# "set protocols ospf area '3'", +# "set protocols ospf area 3 area-type nssa", +# "set protocols ospf area 4 range 192.0.3.0/24 cost 10", +# "set protocols ospf area 4 range 192.0.3.0/24", +# "set protocols ospf area 4 range 192.0.4.0/24 cost 12", +# "set protocols ospf area 4 range 192.0.4.0/24", +# "set protocols ospf area 4 area-type stub default-cost 20", +# "set protocols ospf area '4'", +# "set protocols ospf area 4 network 192.0.2.0/24" +# ] + + +# Using parsed +# +# +- name: Parse the commands for provided structured configuration + vyos.vyos.vyos_ospfv2: + running_config: + "set protocols ospf area 2 area-type 'normal' + set protocols ospf area 2 authentication 'plaintext-password' + set protocols ospf area 2 shortcut 'enable' + set protocols ospf area 3 area-type 'nssa' + set protocols ospf area 4 area-type stub default-cost '20' + set protocols ospf area 4 network '192.0.2.0/24' + set protocols ospf area 4 range 192.0.3.0/24 cost '10' + set protocols ospf area 4 range 192.0.4.0/24 cost '12' + set protocols ospf auto-cost reference-bandwidth '2' + set protocols ospf default-information originate 'always' + set protocols ospf default-information originate metric '10' + set protocols ospf default-information originate metric-type '2' + set protocols ospf default-information originate route-map 'ingress' + set protocols ospf log-adjacency-changes 'detail' + set protocols ospf max-metric router-lsa 'administrative' + set protocols ospf max-metric router-lsa on-shutdown '10' + set protocols ospf max-metric router-lsa on-startup '10' + set protocols ospf mpls-te 'enable' + set protocols ospf mpls-te router-address '192.0.11.11' + set protocols ospf neighbor 192.0.11.12 poll-interval '10' + set protocols ospf neighbor 192.0.11.12 priority '2' + set protocols ospf parameters abr-type 'cisco' + set protocols ospf parameters 'opaque-lsa' + set protocols ospf parameters 'rfc1583-compatibility' + set protocols ospf parameters router-id '192.0.1.1' + set protocols ospf passive-interface 'eth1' + set protocols ospf passive-interface 'eth2' + set protocols ospf redistribute bgp metric '10' + set protocols ospf redistribute bgp metric-type '2'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# } + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 3 area-type 'nssa' +# set protocols ospf area 4 area-type stub default-cost '20' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 range 192.0.3.0/24 cost '10' +# set protocols ospf area 4 range 192.0.4.0/24 cost '12' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.11.11' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf passive-interface 'eth2' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' +# +- name: Gather ospfv2 routes config with provided configurations + vyos.vyos.vyos_ospfv2: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 3 area-type 'nssa' +# set protocols ospf area 4 area-type stub default-cost '20' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 range 192.0.3.0/24 cost '10' +# set protocols ospf area 4 range 192.0.4.0/24 cost '12' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.11.11' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf passive-interface 'eth2' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' + + +# Using deleted +# +# Before state +# ------------- +# +# vyos@192# run show configuration commands | grep ospf +# set protocols ospf area 2 area-type 'normal' +# set protocols ospf area 2 authentication 'plaintext-password' +# set protocols ospf area 2 shortcut 'enable' +# set protocols ospf area 3 area-type 'nssa' +# set protocols ospf area 4 area-type stub default-cost '20' +# set protocols ospf area 4 network '192.0.2.0/24' +# set protocols ospf area 4 range 192.0.3.0/24 cost '10' +# set protocols ospf area 4 range 192.0.4.0/24 cost '12' +# set protocols ospf auto-cost reference-bandwidth '2' +# set protocols ospf default-information originate 'always' +# set protocols ospf default-information originate metric '10' +# set protocols ospf default-information originate metric-type '2' +# set protocols ospf default-information originate route-map 'ingress' +# set protocols ospf log-adjacency-changes 'detail' +# set protocols ospf max-metric router-lsa 'administrative' +# set protocols ospf max-metric router-lsa on-shutdown '10' +# set protocols ospf max-metric router-lsa on-startup '10' +# set protocols ospf mpls-te 'enable' +# set protocols ospf mpls-te router-address '192.0.11.11' +# set protocols ospf neighbor 192.0.11.12 poll-interval '10' +# set protocols ospf neighbor 192.0.11.12 priority '2' +# set protocols ospf parameters abr-type 'cisco' +# set protocols ospf parameters 'opaque-lsa' +# set protocols ospf parameters 'rfc1583-compatibility' +# set protocols ospf parameters router-id '192.0.1.1' +# set protocols ospf passive-interface 'eth1' +# set protocols ospf passive-interface 'eth2' +# set protocols ospf redistribute bgp metric '10' +# set protocols ospf redistribute bgp metric-type '2' +# +- name: Delete attributes of ospfv2 routes. + vyos.vyos.vyos_ospfv2: + config: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": { +# "areas": [ +# { +# "area_id": "2", +# "area_type": { +# "normal": true +# }, +# "authentication": "plaintext-password", +# "shortcut": "enable" +# }, +# { +# "area_id": "3", +# "area_type": { +# "nssa": { +# "set": true +# } +# } +# }, +# { +# "area_id": "4", +# "area_type": { +# "stub": { +# "default_cost": 20, +# "set": true +# } +# }, +# "network": [ +# { +# "address": "192.0.2.0/24" +# } +# ], +# "range": [ +# { +# "address": "192.0.3.0/24", +# "cost": 10 +# }, +# { +# "address": "192.0.4.0/24", +# "cost": 12 +# } +# ] +# } +# ], +# "auto_cost": { +# "reference_bandwidth": 2 +# }, +# "default_information": { +# "originate": { +# "always": true, +# "metric": 10, +# "metric_type": 2, +# "route_map": "ingress" +# } +# }, +# "log_adjacency_changes": "detail", +# "max_metric": { +# "router_lsa": { +# "administrative": true, +# "on_shutdown": 10, +# "on_startup": 10 +# } +# }, +# "mpls_te": { +# "enabled": true, +# "router_address": "192.0.11.11" +# }, +# "neighbor": [ +# { +# "neighbor_id": "192.0.11.12", +# "poll_interval": 10, +# "priority": 2 +# } +# ], +# "parameters": { +# "abr_type": "cisco", +# "opaque_lsa": true, +# "rfc1583_compatibility": true, +# "router_id": "192.0.1.1" +# }, +# "passive_interface": [ +# "eth2", +# "eth1" +# ], +# "redistribute": [ +# { +# "metric": 10, +# "metric_type": 2, +# "route_type": "bgp" +# } +# ] +# } +# "commands": [ +# "delete protocols ospf" +# ] +# +# "after": {} +# After state +# ------------ +# vyos@192# run show configuration commands | grep ospf +# + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - "set protocols ospf parameters router-id 192.0.1.1" + - "set protocols ospf passive-interface 'eth1'" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospfv2.ospfv2 import ( + Ospfv2Args, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospfv2.ospfv2 import ( + Ospfv2, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + module = AnsibleModule( + argument_spec=Ospfv2Args.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Ospfv2(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospfv3.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospfv3.py new file mode 100644 index 00000000..ca5bc93c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ospfv3.py @@ -0,0 +1,667 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_ospfv3 +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_ospfv3 +short_description: OSPFV3 resource module +description: This resource module configures and manages attributes of OSPFv3 routes + on VyOS network devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: A provided OSPFv3 route configuration. + type: dict + suboptions: + areas: + description: OSPFv3 area. + type: list + elements: dict + suboptions: + area_id: + description: OSPFv3 Area name/identity. + type: str + export_list: + description: Name of export-list. + type: str + import_list: + description: Name of import-list. + type: str + range: + description: Summarize routes matching prefix (border routers only). + type: list + elements: dict + suboptions: + address: + description: border router IPv4 address. + type: str + advertise: + description: Advertise this range. + type: bool + not_advertise: + description: Don't advertise this range. + type: bool + parameters: + description: OSPFv3 specific parameters. + type: dict + suboptions: + router_id: + description: Override the default router identifier. + type: str + redistribute: + description: Redistribute information from another routing protocol. + type: list + elements: dict + suboptions: + route_type: + description: Route type to redistribute. + type: str + choices: [bgp, connected, kernel, ripng, static] + route_map: + description: Route map references. + type: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep ospfv3). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state the configuration should be left in. + type: str + choices: + - merged + - replaced + - deleted + - parsed + - gathered + - rendered + default: merged + +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos# run show configuration commands | grep ospfv3 +# +# +- name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: bgp + parameters: + router_id: 192.0.2.10 + areas: + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 + - area_id: '3' + range: + - address: 2001:db40::/32 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": {} +# +# "commands": [ +# "set protocols ospfv3 redistribute bgp", +# "set protocols ospfv3 parameters router-id '192.0.2.10'", +# "set protocols ospfv3 area 2 range 2001:db10::/32", +# "set protocols ospfv3 area 2 range 2001:db20::/32", +# "set protocols ospfv3 area 2 range 2001:db30::/32", +# "set protocols ospfv3 area '2'", +# "set protocols ospfv3 area 2 export-list export1", +# "set protocols ospfv3 area 2 import-list import1", +# "set protocols ospfv3 area '3'", +# "set protocols ospfv3 area 3 range 2001:db40::/32" +# ] +# +# "after": { +# "areas": [ +# { +# "area_id": "2", +# "export_list": "export1", +# "import_list": "import1", +# "range": [ +# { +# "address": "2001:db10::/32" +# }, +# { +# "address": "2001:db20::/32" +# }, +# { +# "address": "2001:db30::/32" +# } +# ] +# }, +# { +# "area_id": "3", +# "range": [ +# { +# "address": "2001:db40::/32" +# } +# ] +# } +# ], +# "parameters": { +# "router_id": "192.0.2.10" +# }, +# "redistribute": [ +# { +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospfv3 +# set protocols ospfv3 area 2 export-list 'export1' +# set protocols ospfv3 area 2 import-list 'import1' +# set protocols ospfv3 area 2 range '2001:db10::/32' +# set protocols ospfv3 area 2 range '2001:db20::/32' +# set protocols ospfv3 area 2 range '2001:db30::/32' +# set protocols ospfv3 area 3 range '2001:db40::/32' +# set protocols ospfv3 parameters router-id '192.0.2.10' +# set protocols ospfv3 redistribute 'bgp' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospfv3 +# set protocols ospfv3 area 2 export-list 'export1' +# set protocols ospfv3 area 2 import-list 'import1' +# set protocols ospfv3 area 2 range '2001:db10::/32' +# set protocols ospfv3 area 2 range '2001:db20::/32' +# set protocols ospfv3 area 2 range '2001:db30::/32' +# set protocols ospfv3 area 3 range '2001:db40::/32' +# set protocols ospfv3 parameters router-id '192.0.2.10' +# set protocols ospfv3 redistribute 'bgp' +# +- name: Replace ospfv3 routes attributes configuration. + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: bgp + parameters: + router_id: 192.0.2.10 + areas: + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: 2001:db10::/32 + - address: 2001:db30::/32 + - address: 2001:db50::/32 + - area_id: '4' + range: + - address: 2001:db60::/32 + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": { +# "areas": [ +# { +# "area_id": "2", +# "export_list": "export1", +# "import_list": "import1", +# "range": [ +# { +# "address": "2001:db10::/32" +# }, +# { +# "address": "2001:db20::/32" +# }, +# { +# "address": "2001:db30::/32" +# } +# ] +# }, +# { +# "area_id": "3", +# "range": [ +# { +# "address": "2001:db40::/32" +# } +# ] +# } +# ], +# "parameters": { +# "router_id": "192.0.2.10" +# }, +# "redistribute": [ +# { +# "route_type": "bgp" +# } +# ] +# } +# +# "commands": [ +# "delete protocols ospfv3 area 2 range 2001:db20::/32", +# "delete protocols ospfv3 area 3", +# "set protocols ospfv3 area 2 range 2001:db50::/32", +# "set protocols ospfv3 area '4'", +# "set protocols ospfv3 area 4 range 2001:db60::/32" +# ] +# +# "after": { +# "areas": [ +# { +# "area_id": "2", +# "export_list": "export1", +# "import_list": "import1", +# "range": [ +# { +# "address": "2001:db10::/32" +# }, +# { +# "address": "2001:db30::/32" +# }, +# { +# "address": "2001:db50::/32" +# } +# ] +# }, +# { +# "area_id": "4", +# "range": [ +# { +# "address": "2001:db60::/32" +# } +# ] +# } +# ], +# "parameters": { +# "router_id": "192.0.2.10" +# }, +# "redistribute": [ +# { +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospfv3 +# set protocols ospfv3 area 2 export-list 'export1' +# set protocols ospfv3 area 2 import-list 'import1' +# set protocols ospfv3 area 2 range '2001:db10::/32' +# set protocols ospfv3 area 2 range '2001:db30::/32' +# set protocols ospfv3 area 2 range '2001:db50::/32' +# set protocols ospfv3 area 4 range '2001:db60::/32' +# set protocols ospfv3 parameters router-id '192.0.2.10' +# set protocols ospfv3 redistribute 'bgp' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: bgp + parameters: + router_id: 192.0.2.10 + areas: + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 + - area_id: '3' + range: + - address: 2001:db40::/32 + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# [ +# "set protocols ospfv3 redistribute bgp", +# "set protocols ospfv3 parameters router-id '192.0.2.10'", +# "set protocols ospfv3 area 2 range 2001:db10::/32", +# "set protocols ospfv3 area 2 range 2001:db20::/32", +# "set protocols ospfv3 area 2 range 2001:db30::/32", +# "set protocols ospfv3 area '2'", +# "set protocols ospfv3 area 2 export-list export1", +# "set protocols ospfv3 area 2 import-list import1", +# "set protocols ospfv3 area '3'", +# "set protocols ospfv3 area 3 range 2001:db40::/32" +# ] + + +# Using parsed +# +# +- name: Parse the commands to provide structured configuration. + vyos.vyos.vyos_ospfv3: + running_config: + "set protocols ospfv3 area 2 export-list 'export1' + set protocols ospfv3 area 2 import-list 'import1' + set protocols ospfv3 area 2 range '2001:db10::/32' + set protocols ospfv3 area 2 range '2001:db20::/32' + set protocols ospfv3 area 2 range '2001:db30::/32' + set protocols ospfv3 area 3 range '2001:db40::/32' + set protocols ospfv3 parameters router-id '192.0.2.10' + set protocols ospfv3 redistribute 'bgp'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": { +# "areas": [ +# { +# "area_id": "2", +# "export_list": "export1", +# "import_list": "import1", +# "range": [ +# { +# "address": "2001:db10::/32" +# }, +# { +# "address": "2001:db20::/32" +# }, +# { +# "address": "2001:db30::/32" +# } +# ] +# }, +# { +# "area_id": "3", +# "range": [ +# { +# "address": "2001:db40::/32" +# } +# ] +# } +# ], +# "parameters": { +# "router_id": "192.0.2.10" +# }, +# "redistribute": [ +# { +# "route_type": "bgp" +# } +# ] +# } + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospfv3 +# set protocols ospfv3 area 2 export-list 'export1' +# set protocols ospfv3 area 2 import-list 'import1' +# set protocols ospfv3 area 2 range '2001:db10::/32' +# set protocols ospfv3 area 2 range '2001:db20::/32' +# set protocols ospfv3 area 2 range '2001:db30::/32' +# set protocols ospfv3 area 3 range '2001:db40::/32' +# set protocols ospfv3 parameters router-id '192.0.2.10' +# set protocols ospfv3 redistribute 'bgp' +# +- name: Gather ospfv3 routes config with provided configurations + vyos.vyos.vyos_ospfv3: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": { +# "areas": [ +# { +# "area_id": "2", +# "export_list": "export1", +# "import_list": "import1", +# "range": [ +# { +# "address": "2001:db10::/32" +# }, +# { +# "address": "2001:db20::/32" +# }, +# { +# "address": "2001:db30::/32" +# } +# ] +# }, +# { +# "area_id": "3", +# "range": [ +# { +# "address": "2001:db40::/32" +# } +# ] +# } +# ], +# "parameters": { +# "router_id": "192.0.2.10" +# }, +# "redistribute": [ +# { +# "route_type": "bgp" +# } +# ] +# } +# +# After state: +# ------------- +# +# vyos@192# run show configuration commands | grep ospfv3 +# set protocols ospfv3 area 2 export-list 'export1' +# set protocols ospfv3 area 2 import-list 'import1' +# set protocols ospfv3 area 2 range '2001:db10::/32' +# set protocols ospfv3 area 2 range '2001:db20::/32' +# set protocols ospfv3 area 2 range '2001:db30::/32' +# set protocols ospfv3 area 3 range '2001:db40::/32' +# set protocols ospfv3 parameters router-id '192.0.2.10' +# set protocols ospfv3 redistribute 'bgp' + + +# Using deleted +# +# Before state +# ------------- +# +# vyos@192# run show configuration commands | grep ospfv3 +# set protocols ospfv3 area 2 export-list 'export1' +# set protocols ospfv3 area 2 import-list 'import1' +# set protocols ospfv3 area 2 range '2001:db10::/32' +# set protocols ospfv3 area 2 range '2001:db20::/32' +# set protocols ospfv3 area 2 range '2001:db30::/32' +# set protocols ospfv3 area 3 range '2001:db40::/32' +# set protocols ospfv3 parameters router-id '192.0.2.10' +# set protocols ospfv3 redistribute 'bgp' +# +- name: Delete attributes of ospfv3 routes. + vyos.vyos.vyos_ospfv3: + config: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": { +# "areas": [ +# { +# "area_id": "2", +# "export_list": "export1", +# "import_list": "import1", +# "range": [ +# { +# "address": "2001:db10::/32" +# }, +# { +# "address": "2001:db20::/32" +# }, +# { +# "address": "2001:db30::/32" +# } +# ] +# }, +# { +# "area_id": "3", +# "range": [ +# { +# "address": "2001:db40::/32" +# } +# ] +# } +# ], +# "parameters": { +# "router_id": "192.0.2.10" +# }, +# "redistribute": [ +# { +# "route_type": "bgp" +# } +# ] +# } +# "commands": [ +# "delete protocols ospfv3" +# ] +# +# "after": {} +# After state +# ------------ +# vyos@192# run show configuration commands | grep ospfv3 + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - "set protocols ospf parameters router-id 192.0.1.1" + - "set protocols ospfv3 area 2 range '2001:db10::/32'" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospfv3.ospfv3 import ( + Ospfv3Args, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospfv3.ospfv3 import ( + Ospfv3, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + module = AnsibleModule( + argument_spec=Ospfv3Args.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + + result = Ospfv3(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ping.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ping.py new file mode 100644 index 00000000..64509fbc --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_ping.py @@ -0,0 +1,261 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_ping +short_description: Tests reachability using ping from VyOS network devices +description: +- Tests reachability using ping from a VyOS device to a remote destination. +- Tested against VyOS 1.1.8 (helium) +- For a general purpose network module, see the M(net_ping) module. +- For Windows targets, use the M(win_ping) module instead. +- For targets running Python, use the M(ping) module instead. +version_added: 1.0.0 +author: +- Nilashish Chakraborty (@NilashishC) +options: + dest: + description: + - The IP Address or hostname (resolvable by the device) of the remote node. + required: true + type: str + count: + description: + - Number of packets to send to check reachability. + type: int + default: 5 + source: + description: + - The source interface or IP Address to use while sending the ping packet(s). + type: str + ttl: + description: + - The time-to-live value for the ICMP packet(s). + type: int + size: + description: + - Determines the size (in bytes) of the ping packet(s). + type: int + interval: + description: + - Determines the interval (in seconds) between consecutive pings. + type: int + state: + description: + - Determines if the expected result is success or fail. + type: str + choices: + - absent + - present + default: present +notes: +- Tested against VyOS 1.1.8 (helium). +- For a general purpose network module, see the M(net_ping) module. +- For Windows targets, use the M(win_ping) module instead. +- For targets running Python, use the M(ping) module instead. +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +extends_documentation_fragment: +- vyos.vyos.vyos +""" + +EXAMPLES = """ +- name: Test reachability to 10.10.10.10 + vyos.vyos.vyos_ping: + dest: 10.10.10.10 + +- name: Test reachability to 10.20.20.20 using source and ttl set + vyos.vyos.vyos_ping: + dest: 10.20.20.20 + source: eth0 + ttl: 128 + +- name: Test unreachability to 10.30.30.30 using interval + vyos.vyos.vyos_ping: + dest: 10.30.30.30 + interval: 3 + state: absent + +- name: Test reachability to 10.40.40.40 setting count and source + vyos.vyos.vyos_ping: + dest: 10.40.40.40 + source: eth1 + count: 20 + size: 512 +""" + +RETURN = """ +commands: + description: List of commands sent. + returned: always + type: list + sample: ["ping 10.8.38.44 count 10 interface eth0 ttl 128"] +packet_loss: + description: Percentage of packets lost. + returned: always + type: str + sample: "0%" +packets_rx: + description: Packets successfully received. + returned: always + type: int + sample: 20 +packets_tx: + description: Packets successfully transmitted. + returned: always + type: int + sample: 20 +rtt: + description: The round trip time (RTT) stats. + returned: when ping succeeds + type: dict + sample: {"avg": 2, "max": 8, "min": 1, "mdev": 24} +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + run_commands, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) +import re + + +def main(): + """main entry point for module execution""" + argument_spec = dict( + count=dict(type="int", default=5), + dest=dict(type="str", required=True), + source=dict(type="str"), + ttl=dict(type="int"), + size=dict(type="int"), + interval=dict(type="int"), + state=dict( + type="str", choices=["absent", "present"], default="present" + ), + ) + + argument_spec.update(vyos_argument_spec) + + module = AnsibleModule(argument_spec=argument_spec) + + count = module.params["count"] + dest = module.params["dest"] + source = module.params["source"] + size = module.params["size"] + ttl = module.params["ttl"] + interval = module.params["interval"] + + warnings = list() + + results = {} + if warnings: + results["warnings"] = warnings + + results["commands"] = [ + build_ping(dest, count, size, interval, source, ttl) + ] + + ping_results = run_commands(module, commands=results["commands"]) + ping_results_list = ping_results[0].split("\n") + + rtt_info, rate_info = None, None + for line in ping_results_list: + if line.startswith("rtt"): + rtt_info = line + if line.startswith("%s packets transmitted" % count): + rate_info = line + + if rtt_info: + rtt = parse_rtt(rtt_info) + for k, v in rtt.items(): + if rtt[k] is not None: + rtt[k] = int(v) + results["rtt"] = rtt + + pkt_loss, rx, tx = parse_rate(rate_info) + results["packet_loss"] = str(pkt_loss) + "%" + results["packets_rx"] = int(rx) + results["packets_tx"] = int(tx) + + validate_results(module, pkt_loss, results) + + module.exit_json(**results) + + +def build_ping(dest, count, size=None, interval=None, source=None, ttl=None): + cmd = "ping {0} count {1}".format(dest, str(count)) + + if source: + cmd += " interface {0}".format(source) + + if ttl: + cmd += " ttl {0}".format(str(ttl)) + + if size: + cmd += " size {0}".format(str(size)) + + if interval: + cmd += " interval {0}".format(str(interval)) + + return cmd + + +def parse_rate(rate_info): + rate_re = re.compile( + r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)" + ) + rate_err_re = re.compile( + r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)" + ) + + if rate_re.match(rate_info): + rate = rate_re.match(rate_info) + elif rate_err_re.match(rate_info): + rate = rate_err_re.match(rate_info) + + return rate.group("pkt_loss"), rate.group("rx"), rate.group("tx") + + +def parse_rtt(rtt_info): + rtt_re = re.compile( + r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)" + ) + rtt = rtt_re.match(rtt_info) + + return rtt.groupdict() + + +def validate_results(module, loss, results): + state = module.params["state"] + if state == "present" and int(loss) == 100: + module.fail_json(msg="Ping failed unexpectedly", **results) + elif state == "absent" and int(loss) < 100: + module.fail_json(msg="Ping succeeded unexpectedly", **results) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_static_route.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_static_route.py new file mode 100644 index 00000000..3a969974 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_static_route.py @@ -0,0 +1,330 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ +module: vyos_static_route +author: Trishna Guha (@trishnaguha) +short_description: (deprecated, removed after 2022-06-01) Manage static IP routes + on Vyatta VyOS network devices +description: +- This module provides declarative management of static IP routes on Vyatta VyOS network + devices. +version_added: 1.0.0 +deprecated: + alternative: vyos_static_routes + why: Updated modules released with more functionality. + removed_at_date: '2022-06-01' +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + prefix: + description: + - Network prefix of the static route. C(mask) param should be ignored if C(prefix) + is provided with C(mask) value C(prefix/mask). + type: str + mask: + description: + - Network prefix mask of the static route. + type: str + next_hop: + description: + - Next hop IP of the static route. + type: str + admin_distance: + description: + - Admin distance of the static route. + type: int + aggregate: + description: List of static route definitions + type: list + elements: dict + suboptions: + prefix: + description: + - Network prefix of the static route. C(mask) param should be ignored if C(prefix) + is provided with C(mask) value C(prefix/mask). + required: True + type: str + mask: + description: + - Network prefix mask of the static route. + type: str + next_hop: + description: + - Next hop IP of the static route. + type: str + admin_distance: + description: + - Admin distance of the static route. + type: int + state: + description: + - State of the static route configuration. + choices: + - present + - absent + type: str + state: + description: + - State of the static route configuration. + default: present + choices: + - present + - absent + type: str +extends_documentation_fragment: +- vyos.vyos.vyos + + +""" + +EXAMPLES = """ +- name: configure static route + vyos.vyos.vyos_static_route: + prefix: 192.168.2.0 + mask: 24 + next_hop: 10.0.0.1 + +- name: configure static route prefix/mask + vyos.vyos.vyos_static_route: + prefix: 192.168.2.0/16 + next_hop: 10.0.0.1 + +- name: remove configuration + vyos.vyos.vyos_static_route: + prefix: 192.168.2.0 + mask: 16 + next_hop: 10.0.0.1 + state: absent + +- name: configure aggregates of static routes + vyos.vyos.vyos_static_route: + aggregate: + - {prefix: 192.168.2.0, mask: 24, next_hop: 10.0.0.1} + - {prefix: 192.168.3.0, mask: 16, next_hop: 10.0.2.1} + - {prefix: 192.168.3.0/16, next_hop: 10.0.2.1} + +- name: Remove static route collections + vyos.vyos.vyos_static_route: + aggregate: + - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64} + - {prefix: 172.24.3.0/24, next_hop: 192.168.42.64} + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always + type: list + sample: + - set protocols static route 192.168.2.0/16 next-hop 10.0.0.1 +""" +import re + +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def spec_to_commands(updates, module): + commands = list() + want, have = updates + for w in want: + prefix = w["prefix"] + mask = w["mask"] + next_hop = w["next_hop"] + admin_distance = w["admin_distance"] + state = w["state"] + del w["state"] + + if state == "absent" and w in have: + commands.append( + "delete protocols static route %s/%s" % (prefix, mask) + ) + elif state == "present" and w not in have: + cmd = "set protocols static route %s/%s next-hop %s" % ( + prefix, + mask, + next_hop, + ) + if admin_distance != "None": + cmd += " distance %s" % (admin_distance) + commands.append(cmd) + + return commands + + +def config_to_dict(module): + data = get_config(module) + obj = [] + + for line in data.split("\n"): + if line.startswith("set protocols static route"): + match = re.search(r"static route (\S+)", line, re.M) + prefix = match.group(1).split("/")[0] + mask = match.group(1).split("/")[1] + if "next-hop" in line: + match_hop = re.search(r"next-hop (\S+)", line, re.M) + next_hop = match_hop.group(1).strip("'") + + match_distance = re.search(r"distance (\S+)", line, re.M) + if match_distance is not None: + admin_distance = match_distance.group(1)[1:-1] + else: + admin_distance = None + + if admin_distance is not None: + obj.append( + { + "prefix": prefix, + "mask": mask, + "next_hop": next_hop, + "admin_distance": admin_distance, + } + ) + else: + obj.append( + { + "prefix": prefix, + "mask": mask, + "next_hop": next_hop, + "admin_distance": "None", + } + ) + + return obj + + +def map_params_to_obj(module, required_together=None): + obj = [] + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + module._check_required_together(required_together, item) + d = item.copy() + if "/" in d["prefix"]: + d["mask"] = d["prefix"].split("/")[1] + d["prefix"] = d["prefix"].split("/")[0] + + if "admin_distance" in d: + d["admin_distance"] = str(d["admin_distance"]) + + obj.append(d) + else: + prefix = module.params["prefix"].strip() + if "/" in prefix: + mask = prefix.split("/")[1] + prefix = prefix.split("/")[0] + else: + mask = module.params["mask"].strip() + next_hop = module.params["next_hop"].strip() + admin_distance = str(module.params["admin_distance"]) + state = module.params["state"] + + obj.append( + { + "prefix": prefix, + "mask": mask, + "next_hop": next_hop, + "admin_distance": admin_distance, + "state": state, + } + ) + + return obj + + +def main(): + """main entry point for module execution""" + element_spec = dict( + prefix=dict(type="str"), + mask=dict(type="str"), + next_hop=dict(type="str"), + admin_distance=dict(type="int"), + state=dict(default="present", choices=["present", "absent"]), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["prefix"] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + required_one_of = [["aggregate", "prefix"]] + required_together = [["prefix", "next_hop"]] + mutually_exclusive = [["aggregate", "prefix"]] + + module = AnsibleModule( + argument_spec=argument_spec, + required_one_of=required_one_of, + required_together=required_together, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + ) + + warnings = list() + + result = {"changed": False} + if warnings: + result["warnings"] = warnings + want = map_params_to_obj(module, required_together=required_together) + have = config_to_dict(module) + + commands = spec_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_static_routes.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_static_routes.py new file mode 100644 index 00000000..fa29b722 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_static_routes.py @@ -0,0 +1,937 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for vyos_static_routes +""" + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_static_routes +short_description: Static routes resource module +description: This module manages attributes of static routes on VyOS network devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +author: +- Rohit Thakur (@rohitthakur2590) +options: + config: + description: A provided static route configuration. + type: list + elements: dict + suboptions: + address_families: + description: A dictionary specifying the address family to which the static + route(s) belong. + type: list + elements: dict + suboptions: + afi: + description: + - Specifies the type of route. + type: str + choices: + - ipv4 + - ipv6 + required: true + routes: + description: A ditionary that specify the static route configurations. + type: list + elements: dict + suboptions: + dest: + description: + - An IPv4/v6 address in CIDR notation that specifies the destination + network for the static route. + type: str + required: true + blackhole_config: + description: + - Configured to silently discard packets. + type: dict + suboptions: + type: + description: + - This is to configure only blackhole. + type: str + distance: + description: + - Distance for the route. + type: int + next_hops: + description: + - Next hops to the specified destination. + type: list + elements: dict + suboptions: + forward_router_address: + description: + - The IP address of the next hop that can be used to reach the + destination network. + type: str + required: true + enabled: + description: + - Disable IPv4/v6 next-hop static route. + type: bool + admin_distance: + description: + - Distance value for the route. + type: int + interface: + description: + - Name of the outgoing interface. + type: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep static route). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - replaced + - overridden + - deleted + - gathered + - rendered + - parsed + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands | grep static +# +- name: Merge the provided configuration with the exisiting running configuration + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 + state: merged +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# before": [] +# +# "commands": [ +# "set protocols static route 192.0.2.32/28", +# "set protocols static route 192.0.2.32/28 blackhole", +# "set protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", +# "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", +# "set protocols static route6 2001:db8:1000::/36", +# "set protocols static route6 2001:db8:1000::/36 blackhole distance '2'", +# "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'", +# "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" +# ] +# +# "after": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.6" +# }, +# { +# "forward_router_address": "192.0.2.7" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 'blackhole' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + + +# Using replaced +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 'blackhole' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' +# set protocols static route 192.0.2.33/28 'blackhole' +# set protocols static route 192.0.2.33/28 next-hop '192.0.2.3' +# set protocols static route 192.0.2.33/28 next-hop '192.0.2.4' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' +# +- name: Replace device configurations of listed static routes with provided configurations + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 192.0.2.7 + enabled: false + - forward_router_address: 192.0.2.9 + state: replaced +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.6" +# }, +# { +# "forward_router_address": "192.0.2.7" +# } +# ] +# }, +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.33/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.3" +# }, +# { +# "forward_router_address": "192.0.2.4" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# +# "commands": [ +# "delete protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", +# "delete protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", +# "set protocols static route 192.0.2.32/28 next-hop 192.0.2.7 'disable'", +# "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", +# "set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'", +# "set protocols static route 192.0.2.32/28 blackhole distance '2'" +# ] +# +# "after": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "enabled": false, +# "forward_router_address": "192.0.2.7" +# }, +# { +# "forward_router_address": "192.0.2.9" +# } +# ] +# }, +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.33/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.3" +# }, +# { +# "forward_router_address": "192.0.2.4" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 blackhole distance '2' +# set protocols static route 192.0.2.32/28 next-hop 192.0.2.7 'disable' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' +# set protocols static route 192.0.2.33/28 'blackhole' +# set protocols static route 192.0.2.33/28 next-hop '192.0.2.3' +# set protocols static route 192.0.2.33/28 next-hop '192.0.2.4' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + + +# Using overridden +# +# Before state +# -------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 blackhole distance '2' +# set protocols static route 192.0.2.32/28 next-hop 192.0.2.7 'disable' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' +# +- name: Overrides all device configuration with provided configuration + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 198.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.18 + state: overridden +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "before": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "enabled": false, +# "forward_router_address": "192.0.2.7" +# }, +# { +# "forward_router_address": "192.0.2.9" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# +# "commands": [ +# "delete protocols static route 192.0.2.32/28", +# "delete protocols static route6 2001:db8:1000::/36", +# "set protocols static route 198.0.2.48/28", +# "set protocols static route 198.0.2.48/28 next-hop '192.0.2.18'" +# +# +# "after": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "dest": "198.0.2.48/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.18" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# +# +# After state +# ------------ +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 198.0.2.48/28 next-hop '192.0.2.18' + + +# Using deleted to delete static route based on afi +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 'blackhole' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' +# +- name: Delete static route based on afi. + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + - afi: ipv6 + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.6" +# }, +# { +# "forward_router_address": "192.0.2.7" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# "commands": [ +# "delete protocols static route", +# "delete protocols static route6" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep static +# set protocols 'static' + + +# Using deleted to delete all the static routes when passes config is empty +# +# Before state +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 'blackhole' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' +# +- name: Delete all the static routes. + vyos.vyos.vyos_static_routes: + config: + state: deleted +# +# +# ------------------------ +# Module Execution Results +# ------------------------ +# +# "before": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.6" +# }, +# { +# "forward_router_address": "192.0.2.7" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# "commands": [ +# "delete protocols static route", +# "delete protocols static route6" +# ] +# +# "after": [] +# After state +# ------------ +# vyos@vyos# run show configuration commands | grep static +# set protocols 'static' + + +# Using rendered +# +# +- name: Render the commands for provided configuration + vyos.vyos.vyos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 + state: rendered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "rendered": [ +# "set protocols static route 192.0.2.32/28", +# "set protocols static route 192.0.2.32/28 blackhole", +# "set protocols static route 192.0.2.32/28 next-hop '192.0.2.6'", +# "set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'", +# "set protocols static route6 2001:db8:1000::/36", +# "set protocols static route6 2001:db8:1000::/36 blackhole distance '2'", +# "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'", +# "set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" +# ] + + +# Using parsed +# +# +- name: Parse the provided running configuration + vyos.vyos.vyos_static_routes: + running_config: + "set protocols static route 192.0.2.32/28 'blackhole' + set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' + set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'" + state: parsed +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# +# "parsed": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] + + +# Using gathered +# +# Before state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 'blackhole' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' +# +- name: Gather listed static routes with provided configurations + vyos.vyos.vyos_static_routes: + config: + state: gathered +# +# +# ------------------------- +# Module Execution Result +# ------------------------- +# +# "gathered": [ +# { +# "address_families": [ +# { +# "afi": "ipv4", +# "routes": [ +# { +# "blackhole_config": { +# "type": "blackhole" +# }, +# "dest": "192.0.2.32/28", +# "next_hops": [ +# { +# "forward_router_address": "192.0.2.6" +# }, +# { +# "forward_router_address": "192.0.2.7" +# } +# ] +# } +# ] +# }, +# { +# "afi": "ipv6", +# "routes": [ +# { +# "blackhole_config": { +# "distance": 2 +# }, +# "dest": "2001:db8:1000::/36", +# "next_hops": [ +# { +# "forward_router_address": "2001:db8:2000:2::1" +# }, +# { +# "forward_router_address": "2001:db8:2000:2::2" +# } +# ] +# } +# ] +# } +# ] +# } +# ] +# +# +# After state: +# ------------- +# +# vyos@vyos:~$ show configuration commands| grep static +# set protocols static route 192.0.2.32/28 'blackhole' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.6' +# set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' +# set protocols static route6 2001:db8:1000::/36 blackhole distance '2' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - "set protocols static route 192.0.2.32/28 next-hop '192.0.2.6'" + - "set protocols static route 192.0.2.32/28 'blackhole'" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.static_routes.static_routes import ( + Static_routesArgs, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.static_routes.static_routes import ( + Static_routes, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + required_if = [ + ("state", "merged", ("config",)), + ("state", "replaced", ("config",)), + ("state", "rendered", ("config",)), + ("state", "overridden", ("config",)), + ("state", "parsed", ("running_config",)), + ] + mutually_exclusive = [("config", "running_config")] + + module = AnsibleModule( + argument_spec=Static_routesArgs.argument_spec, + required_if=required_if, + supports_check_mode=True, + mutually_exclusive=mutually_exclusive, + ) + result = Static_routes(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_system.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_system.py new file mode 100644 index 00000000..93c0909b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_system.py @@ -0,0 +1,227 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_system +author: Nathaniel Case (@Qalthos) +short_description: Run `set system` commands on VyOS devices +description: +- Runs one or more commands on remote devices running VyOS. This module can also be + introspected to validate key parameters before returning successfully. +version_added: 1.0.0 +extends_documentation_fragment: +- vyos.vyos.vyos +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + host_name: + description: + - Configure the device hostname parameter. This option takes an ASCII string value. + type: str + domain_name: + description: + - The new domain name to apply to the device. + type: str + name_server: + description: + - A list of name servers to use with the device. Mutually exclusive with I(domain_search) + type: list + elements: str + aliases: + - name_servers + domain_search: + description: + - A list of domain names to search. Mutually exclusive with I(name_server) + type: list + elements: str + state: + description: + - Whether to apply (C(present)) or remove (C(absent)) the settings. + default: present + type: str + choices: + - present + - absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always + type: list + sample: + - set system hostname vyos01 + - set system domain-name foo.example.com +""" + +EXAMPLES = """ +- name: configure hostname and domain-name + vyos.vyos.vyos_system: + host_name: vyos01 + domain_name: test.example.com + +- name: remove all configuration + vyos.vyos.vyos_system: + state: absent + +- name: configure name servers + vyos.vyos.vyos_system: name_servers - 8.8.8.8 - 8.8.4.4 +- name: configure domain search suffixes + vyos.vyos.vyos_system: + domain_search: + - sub1.example.com + - sub2.example.com +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def spec_key_to_device_key(key): + device_key = key.replace("_", "-") + + # domain-search is longer than just it's key + if device_key == "domain-search": + device_key += " domain" + + return device_key + + +def config_to_dict(module): + data = get_config(module) + + config = {"domain_search": [], "name_server": []} + + for line in data.split("\n"): + if line.startswith("set system host-name"): + config["host_name"] = line[22:-1] + elif line.startswith("set system domain-name"): + config["domain_name"] = line[24:-1] + elif line.startswith("set system domain-search domain"): + config["domain_search"].append(line[33:-1]) + elif line.startswith("set system name-server"): + config["name_server"].append(line[24:-1]) + + return config + + +def spec_to_commands(want, have): + commands = [] + + state = want.pop("state") + + # state='absent' by itself has special meaning + if state == "absent" and all(v is None for v in want.values()): + # Clear everything + for key in have: + commands.append("delete system %s" % spec_key_to_device_key(key)) + + for key in want: + if want[key] is None: + continue + + current = have.get(key) + proposed = want[key] + device_key = spec_key_to_device_key(key) + + # These keys are lists which may need to be reconciled with the device + if key in ["domain_search", "name_server"]: + if not proposed: + # Empty list was passed, delete all values + commands.append("delete system %s" % device_key) + for config in proposed: + if state == "absent" and config in current: + commands.append( + "delete system %s '%s'" % (device_key, config) + ) + elif state == "present" and config not in current: + commands.append( + "set system %s '%s'" % (device_key, config) + ) + else: + if state == "absent" and current and proposed: + commands.append("delete system %s" % device_key) + elif state == "present" and proposed and proposed != current: + commands.append("set system %s '%s'" % (device_key, proposed)) + + return commands + + +def map_param_to_obj(module): + return { + "host_name": module.params["host_name"], + "domain_name": module.params["domain_name"], + "domain_search": module.params["domain_search"], + "name_server": module.params["name_server"], + "state": module.params["state"], + } + + +def main(): + argument_spec = dict( + host_name=dict(type="str"), + domain_name=dict(type="str"), + domain_search=dict(type="list", elements="str"), + name_server=dict( + type="list", aliases=["name_servers"], elements="str" + ), + state=dict( + type="str", default="present", choices=["present", "absent"] + ), + ) + + argument_spec.update(vyos_argument_spec) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + mutually_exclusive=[("domain_name", "domain_search")], + ) + + warnings = list() + + result = {"changed": False, "warnings": warnings} + + want = map_param_to_obj(module) + have = config_to_dict(module) + + commands = spec_to_commands(want, have) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_user.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_user.py new file mode 100644 index 00000000..4f67529d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_user.py @@ -0,0 +1,404 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# (c) 2017, Ansible by Red Hat, inc +# +# This file is part of Ansible by Red Hat +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# + + +DOCUMENTATION = """ +module: vyos_user +author: Trishna Guha (@trishnaguha) +short_description: Manage the collection of local users on VyOS device +description: +- This module provides declarative management of the local usernames configured on + network devices. It allows playbooks to manage either individual usernames or the + collection of usernames in the current running config. It also supports purging + usernames from the configuration that are not explicitly defined. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + aggregate: + description: + - The set of username objects to be configured on the remote VyOS device. The + list entries can either be the username or a hash of username and properties. + This argument is mutually exclusive with the C(name) argument. + aliases: + - users + - collection + type: list + elements: dict + suboptions: + name: + description: + - The username to be configured on the VyOS device. This argument accepts a string + value and is mutually exclusive with the C(aggregate) argument. Please note + that this option is not same as C(provider username). + required: True + type: str + full_name: + description: + - The C(full_name) argument provides the full name of the user account to be created + on the remote device. This argument accepts any text string value. + type: str + configured_password: + description: + - The password to be configured on the VyOS device. The password needs to be provided + in clear and it will be encrypted on the device. Please note that this option + is not same as C(provider password). + type: str + update_password: + description: + - Since passwords are encrypted in the device running config, this argument will + instruct the module when to change the password. When set to C(always), the + password will always be updated in the device and when set to C(on_create) the + password will be updated only if the username is created. + type: str + choices: + - on_create + - always + level: + description: + - The C(level) argument configures the level of the user when logged into the + system. This argument accepts string values admin or operator. + type: str + aliases: + - role + state: + description: + - Configures the state of the username definition as it relates to the device + operational configuration. When set to I(present), the username(s) should be + configured in the device active configuration and when set to I(absent) the + username(s) should not be in the device active configuration + type: str + choices: + - present + - absent + name: + description: + - The username to be configured on the VyOS device. This argument accepts a string + value and is mutually exclusive with the C(aggregate) argument. Please note + that this option is not same as C(provider username). + type: str + full_name: + description: + - The C(full_name) argument provides the full name of the user account to be created + on the remote device. This argument accepts any text string value. + type: str + configured_password: + description: + - The password to be configured on the VyOS device. The password needs to be provided + in clear and it will be encrypted on the device. Please note that this option + is not same as C(provider password). + type: str + update_password: + description: + - Since passwords are encrypted in the device running config, this argument will + instruct the module when to change the password. When set to C(always), the + password will always be updated in the device and when set to C(on_create) the + password will be updated only if the username is created. + default: always + type: str + choices: + - on_create + - always + level: + description: + - The C(level) argument configures the level of the user when logged into the + system. This argument accepts string values admin or operator. + type: str + aliases: + - role + purge: + description: + - Instructs the module to consider the resource definition absolute. It will remove + any previously configured usernames on the device with the exception of the + `admin` user (the current defined set of users). + type: bool + default: false + state: + description: + - Configures the state of the username definition as it relates to the device + operational configuration. When set to I(present), the username(s) should be + configured in the device active configuration and when set to I(absent) the + username(s) should not be in the device active configuration + type: str + default: present + choices: + - present + - absent +extends_documentation_fragment: +- vyos.vyos.vyos +""" + +EXAMPLES = """ +- name: create a new user + vyos.vyos.vyos_user: + name: ansible + configured_password: password + state: present +- name: remove all users except admin + vyos.vyos.vyos_user: + purge: yes +- name: set multiple users to level operator + vyos.vyos.vyos_user: + aggregate: + - name: netop + - name: netend + level: operator + state: present +- name: Change Password for User netop + vyos.vyos.vyos_user: + name: netop + configured_password: '{{ new_password }}' + update_password: always + state: present +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always + type: list + sample: + - set system login user test level operator + - set system login user authentication plaintext-password password +""" + +import re + +from copy import deepcopy +from functools import partial + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + get_config, + load_config, +) +from ansible.module_utils.six import iteritems +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def validate_level(value, module): + if value not in ("admin", "operator"): + module.fail_json( + msg="level must be either admin or operator, got %s" % value + ) + + +def spec_to_commands(updates, module): + commands = list() + update_password = module.params["update_password"] + + def needs_update(want, have, x): + return want.get(x) and (want.get(x) != have.get(x)) + + def add(command, want, x): + command.append("set system login user %s %s" % (want["name"], x)) + + for update in updates: + want, have = update + + if want["state"] == "absent": + commands.append("delete system login user %s" % want["name"]) + continue + + if needs_update(want, have, "level"): + add(commands, want, "level %s" % want["level"]) + + if needs_update(want, have, "full_name"): + add(commands, want, "full-name %s" % want["full_name"]) + + if needs_update(want, have, "configured_password"): + if update_password == "always" or not have: + add( + commands, + want, + "authentication plaintext-password %s" + % want["configured_password"], + ) + + return commands + + +def parse_level(data): + match = re.search(r"level (\S+)", data, re.M) + if match: + level = match.group(1)[1:-1] + return level + + +def parse_full_name(data): + match = re.search(r"full-name (\S+)", data, re.M) + if match: + full_name = match.group(1)[1:-1] + return full_name + + +def config_to_dict(module): + data = get_config(module) + + match = re.findall(r"^set system login user (\S+)", data, re.M) + if not match: + return list() + + instances = list() + + for user in set(match): + regex = r" %s .+$" % user + cfg = re.findall(regex, data, re.M) + cfg = "\n".join(cfg) + obj = { + "name": user, + "state": "present", + "configured_password": None, + "level": parse_level(cfg), + "full_name": parse_full_name(cfg), + } + instances.append(obj) + + return instances + + +def get_param_value(key, item, module): + # if key doesn't exist in the item, get it from module.params + if not item.get(key): + value = module.params[key] + + # validate the param value (if validator func exists) + validator = globals().get("validate_%s" % key) + if all((value, validator)): + validator(value, module) + + return value + + +def map_params_to_obj(module): + aggregate = module.params["aggregate"] + if not aggregate: + if not module.params["name"] and module.params["purge"]: + return list() + else: + users = [{"name": module.params["name"]}] + else: + users = list() + for item in aggregate: + if not isinstance(item, dict): + users.append({"name": item}) + else: + users.append(item) + + objects = list() + + for item in users: + get_value = partial(get_param_value, item=item, module=module) + item["configured_password"] = get_value("configured_password") + item["full_name"] = get_value("full_name") + item["level"] = get_value("level") + item["state"] = get_value("state") + objects.append(item) + + return objects + + +def update_objects(want, have): + updates = list() + for entry in want: + item = next((i for i in have if i["name"] == entry["name"]), None) + if item is None: + updates.append((entry, {})) + elif item: + for key, value in iteritems(entry): + if value and value != item[key]: + updates.append((entry, item)) + return updates + + +def main(): + """main entry point for module execution""" + element_spec = dict( + name=dict(), + full_name=dict(), + level=dict(aliases=["role"]), + configured_password=dict(no_log=True), + update_password=dict( + default="always", choices=["on_create", "always"] + ), + state=dict(default="present", choices=["present", "absent"]), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["name"] = dict(required=True) + + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict( + type="list", + elements="dict", + options=aggregate_spec, + aliases=["users", "collection"], + ), + purge=dict(type="bool", default=False), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + mutually_exclusive = [("name", "aggregate")] + module = AnsibleModule( + argument_spec=argument_spec, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True, + ) + + warnings = list() + result = {"changed": False, "warnings": warnings} + + want = map_params_to_obj(module) + have = config_to_dict(module) + commands = spec_to_commands(update_objects(want, have), module) + + if module.params["purge"]: + want_users = [x["name"] for x in want] + have_users = [x["name"] for x in have] + for item in set(have_users).difference(want_users): + commands.append("delete system login user %s" % item) + + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_vlan.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_vlan.py new file mode 100644 index 00000000..c04ac93c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/modules/vyos_vlan.py @@ -0,0 +1,411 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2017, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ +module: vyos_vlan +author: Trishna Guha (@trishnaguha) +short_description: Manage VLANs on VyOS network devices +description: +- This module provides declarative management of VLANs on VyOS network devices. +version_added: 1.0.0 +notes: +- Tested against VyOS 1.1.8 (helium). +- This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +options: + name: + description: + - Name of the VLAN. + type: str + address: + description: + - Configure Virtual interface address. + type: str + vlan_id: + description: + - ID of the VLAN. Range 0-4094. + type: int + interfaces: + description: + - List of interfaces that should be associated to the VLAN. + type: list + elements: str + associated_interfaces: + description: + - This is a intent option and checks the operational state of the for given vlan + C(name) for associated interfaces. If the value in the C(associated_interfaces) + does not match with the operational state of vlan on device it will result in + failure. + type: list + elements: str + delay: + description: + - Delay the play should wait to check for declarative intent params values. + default: 10 + type: int + aggregate: + description: List of VLANs definitions. + type: list + elements: dict + suboptions: + name: + description: + - Name of the VLAN. + type: str + address: + description: + - Configure Virtual interface address. + type: str + vlan_id: + description: + - ID of the VLAN. Range 0-4094. + type: int + required: true + interfaces: + description: + - List of interfaces that should be associated to the VLAN. + type: list + elements: str + required: true + associated_interfaces: + description: + - This is a intent option and checks the operational state of the for given vlan + C(name) for associated interfaces. If the value in the C(associated_interfaces) + does not match with the operational state of vlan on device it will result in + failure. + type: list + elements: str + delay: + description: + - Delay the play should wait to check for declarative intent params values. + type: int + state: + description: + - State of the VLAN configuration. + type: str + choices: + - present + - absent + purge: + description: + - Purge VLANs not defined in the I(aggregate) parameter. + default: false + type: bool + state: + description: + - State of the VLAN configuration. + default: present + type: str + choices: + - present + - absent +extends_documentation_fragment: +- vyos.vyos.vyos +""" + +EXAMPLES = """ +- name: Create vlan + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + state: present + +- name: Add interfaces to VLAN + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: + - eth1 + - eth2 + +- name: Configure virtual interface address + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth1 + address: 172.26.100.37/24 + +- name: vlan interface config + intent + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth0 + associated_interfaces: + - eth0 + +- name: vlan intent check + vyos.vyos.vyos_vlan: + vlan_id: 100 + associated_interfaces: + - eth3 + - eth4 + +- name: Delete vlan + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth1 + state: absent +""" + +RETURN = """ +commands: + description: The list of configuration mode commands to send to the device + returned: always + type: list + sample: + - set interfaces ethernet eth1 vif 100 description VLAN 100 + - set interfaces ethernet eth1 vif 100 address 172.26.100.37/24 + - delete interfaces ethernet eth1 vif 100 +""" +import re +import time + +from copy import deepcopy + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + remove_default_spec, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + load_config, + run_commands, +) +from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import ( + vyos_argument_spec, +) + + +def search_obj_in_list(vlan_id, lst): + obj = list() + for o in lst: + if o["vlan_id"] == vlan_id: + obj.append(o) + return obj + + +def map_obj_to_commands(updates, module): + commands = list() + want, have = updates + purge = module.params["purge"] + + for w in want: + vlan_id = w["vlan_id"] + name = w["name"] + address = w["address"] + state = w["state"] + + obj_in_have = search_obj_in_list(vlan_id, have) + + if state == "absent": + if obj_in_have: + for obj in obj_in_have: + for i in obj["interfaces"]: + commands.append( + "delete interfaces ethernet {0} vif {1}".format( + i, vlan_id + ) + ) + + elif state == "present": + if not obj_in_have: + if w["interfaces"] and w["vlan_id"]: + for i in w["interfaces"]: + cmd = "set interfaces ethernet {0} vif {1}".format( + i, vlan_id + ) + if w["name"]: + commands.append( + cmd + " description {0}".format(name) + ) + elif w["address"]: + commands.append( + cmd + " address {0}".format(address) + ) + else: + commands.append(cmd) + + if purge: + for h in have: + obj_in_want = search_obj_in_list(h["vlan_id"], want) + if not obj_in_want: + for i in h["interfaces"]: + commands.append( + "delete interfaces ethernet {0} vif {1}".format( + i, h["vlan_id"] + ) + ) + + return commands + + +def map_params_to_obj(module): + obj = [] + aggregate = module.params.get("aggregate") + if aggregate: + for item in aggregate: + for key in item: + if item.get(key) is None: + item[key] = module.params[key] + + d = item.copy() + + if not d["vlan_id"]: + module.fail_json(msg="vlan_id is required") + + d["vlan_id"] = str(d["vlan_id"]) + module._check_required_one_of(module.required_one_of, item) + + obj.append(d) + else: + obj.append( + { + "vlan_id": str(module.params["vlan_id"]), + "name": module.params["name"], + "address": module.params["address"], + "state": module.params["state"], + "interfaces": module.params["interfaces"], + "associated_interfaces": module.params[ + "associated_interfaces" + ], + } + ) + + return obj + + +def map_config_to_obj(module): + objs = [] + + output = run_commands(module, "show interfaces") + lines = output[0].strip().splitlines()[3:] + + for line in lines: + splitted_line = re.split(r"\s{2,}", line.strip()) + obj = {} + + eth = splitted_line[0].strip("'") + if eth.startswith("eth"): + obj["interfaces"] = [] + if "." in eth: + interface = eth.split(".")[0] + obj["interfaces"].append(interface) + obj["vlan_id"] = eth.split(".")[-1] + else: + obj["interfaces"].append(eth) + obj["vlan_id"] = None + + if splitted_line[1].strip("'") != "-": + obj["address"] = splitted_line[1].strip("'") + + if len(splitted_line) > 3: + obj["name"] = splitted_line[3].strip("'") + obj["state"] = "present" + objs.append(obj) + + return objs + + +def check_declarative_intent_params(want, module, result): + + have = None + obj_interface = list() + is_delay = False + + for w in want: + if w.get("associated_interfaces") is None: + continue + + if result["changed"] and not is_delay: + time.sleep(module.params["delay"]) + is_delay = True + + if have is None: + have = map_config_to_obj(module) + + obj_in_have = search_obj_in_list(w["vlan_id"], have) + if obj_in_have: + for obj in obj_in_have: + obj_interface.extend(obj["interfaces"]) + + for w in want: + if w.get("associated_interfaces") is None: + continue + for i in w["associated_interfaces"]: + if (set(obj_interface) - set(w["associated_interfaces"])) != set( + [] + ): + module.fail_json( + msg="Interface {0} not configured on vlan {1}".format( + i, w["vlan_id"] + ) + ) + + +def main(): + """main entry point for module execution""" + element_spec = dict( + vlan_id=dict(type="int"), + name=dict(), + address=dict(), + interfaces=dict(type="list", elements="str"), + associated_interfaces=dict(type="list", elements="str"), + delay=dict(default=10, type="int"), + state=dict(default="present", choices=["present", "absent"]), + ) + + aggregate_spec = deepcopy(element_spec) + aggregate_spec["vlan_id"].update(required=True) + aggregate_spec["interfaces"].update(required=True) + # remove default in aggregate spec, to handle common arguments + remove_default_spec(aggregate_spec) + + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + purge=dict(default=False, type="bool"), + ) + + argument_spec.update(element_spec) + argument_spec.update(vyos_argument_spec) + + required_one_of = [ + ["vlan_id", "aggregate"], + ["aggregate", "interfaces", "associated_interfaces"], + ] + + mutually_exclusive = [["vlan_id", "aggregate"]] + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_one_of=required_one_of, + mutually_exclusive=mutually_exclusive, + ) + + warnings = list() + result = {"changed": False} + + if warnings: + result["warnings"] = warnings + + want = map_params_to_obj(module) + have = map_config_to_obj(module) + + commands = map_obj_to_commands((want, have), module) + result["commands"] = commands + + if commands: + commit = not module.check_mode + load_config(module, commands, commit=commit) + result["changed"] = True + + check_declarative_intent_params(want, module, result) + + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/terminal/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/terminal/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/terminal/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/plugins/terminal/vyos.py b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/terminal/vyos.py new file mode 100644 index 00000000..a6590022 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/plugins/terminal/vyos.py @@ -0,0 +1,73 @@ +# +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import os +import re + +from ansible.plugins.terminal import TerminalBase +from ansible.errors import AnsibleConnectionFailure + + +class TerminalModule(TerminalBase): + + terminal_stdout_re = [ + re.compile(br"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"), + re.compile(br"\@[\w\-\.]+:\S+?[>#\$] ?$"), + ] + + terminal_stderr_re = [ + re.compile(br"\n\s*Invalid command:"), + re.compile(br"\nCommit failed"), + re.compile(br"\n\s+Set failed"), + ] + + ansi_re = TerminalBase.ansi_re + [ + # Color codes + re.compile(br"\x1b\[(\d+(;\d+)*)?m"), + # Clear line (CSI K) + re.compile(br"\x1b\[K"), + # Xterm change cursor mode (CSI ? 1 [h|l]) + re.compile(br"\x1b\[\?1(h|l)"), + # Xterm change keypad (ESC [=|>]) + re.compile(br"\x1b(=|>)"), + # Xterm window title string (OSC <title string> BEL) + re.compile(br"\x1b]0;[^\x07]*\x07"), + ] + + try: + terminal_length = os.getenv("ANSIBLE_VYOS_TERMINAL_LENGTH", 10000) + terminal_length = int(terminal_length) + except ValueError: + raise AnsibleConnectionFailure( + "Invalid value set for vyos terminal length '%s', value should be a valid integer string" + % terminal_length + ) + + def on_open_shell(self): + try: + for cmd in (b"set terminal length 0", b"set terminal width 512"): + self._exec_cli_command(cmd) + self._exec_cli_command( + b"set terminal length %d" % self.terminal_length + ) + except AnsibleConnectionFailure: + raise AnsibleConnectionFailure("unable to set terminal parameters") diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/requirements.txt b/collections-debian-merged/ansible_collections/vyos/vyos/requirements.txt new file mode 100644 index 00000000..e98b9313 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/requirements.txt @@ -0,0 +1,2 @@ +ansible-pylibssh +paramiko diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/test-requirements.txt b/collections-debian-merged/ansible_collections/vyos/vyos/test-requirements.txt new file mode 100644 index 00000000..d897a57f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/test-requirements.txt @@ -0,0 +1,7 @@ +black ; python_version > '3.5' +flake8 +mock +pexpect +pytest-xdist +yamllint +coverage==4.5.4 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/.gitignore b/collections-debian-merged/ansible_collections/vyos/vyos/tests/.gitignore new file mode 100644 index 00000000..ea1472ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/network-integration.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/network-integration.cfg new file mode 100644 index 00000000..d12c1efe --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/network-integration.cfg @@ -0,0 +1,4 @@ +[persistent_connection] +command_timeout = 100 +connect_timeout = 100 +connect_retry_timeout = 100 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/target-prefixes.network b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/target-prefixes.network new file mode 100644 index 00000000..0c45ebaf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +vyos
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml new file mode 100644 index 00000000..afbc291e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- name: Ensure required interfaces are present in running-config + vars: + lines: "set interfaces ethernet eth0 address dhcp\nset interfaces ethernet eth0\ + \ speed auto\nset interfaces ethernet eth0 duplex auto\nset interfaces ethernet\ + \ eth1\nset interfaces ethernet eth2\ndelete interfaces loopback lo\n" + ignore_errors: true + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml new file mode 100644 index 00000000..1ade232f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml @@ -0,0 +1,34 @@ +--- +- debug: + msg: cli/basic-no-login.yaml on connection={{ ansible_connection }} + +- name: Setup + vyos.vyos.vyos_banner: + banner: pre-login + text: "Junk pre-login banner\nover multiple lines\n" + state: present + +- name: remove pre-login + register: result + vyos.vyos.vyos_banner: + banner: pre-login + state: absent + +- debug: + msg: '{{ result }}' + +- assert: + that: + - result.changed == true + - "'delete system login banner pre-login' in result.commands" + +- name: remove pre-login (idempotent) + register: result + vyos.vyos.vyos_banner: + banner: pre-login + state: absent + +- assert: + that: + - result.changed == false + - result.commands | length == 0 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml new file mode 100644 index 00000000..17cc07d3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml @@ -0,0 +1,36 @@ +--- +- debug: + msg: cli/basic-post-login.yaml on connection={{ ansible_connection }} + +- name: setup - remove post-login + vyos.vyos.vyos_banner: + banner: post-login + state: absent + +- name: Set post-login + register: result + vyos.vyos.vyos_banner: + banner: post-login + text: "this is my post-login banner\nthat has a multiline\nstring\n" + state: present + +- debug: + msg: '{{ result }}' + +- assert: + that: + - result.changed == true + - "'this is my post-login banner' in result.commands[0]" + - "'that has a multiline' in result.commands[0]" + +- name: Set post-login again (idempotent) + register: result + vyos.vyos.vyos_banner: + banner: post-login + text: "this is my post-login banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml new file mode 100644 index 00000000..526c657e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml @@ -0,0 +1,36 @@ +--- +- debug: + msg: cli/basic-pre-login.yaml on connection={{ ansible_connection }} + +- name: setup - remove pre-login + vyos.vyos.vyos_banner: + banner: pre-login + state: absent + +- name: Set pre-login + register: result + vyos.vyos.vyos_banner: + banner: pre-login + text: "this is my pre-login banner\nthat has a multiline\nstring\n" + state: present + +- debug: + msg: '{{ result }}' + +- assert: + that: + - result.changed == true + - "'this is my pre-login banner' in result.commands[0]" + - "'that has a multiline' in result.commands[0]" + +- name: Set pre-login again (idempotent) + register: result + vyos.vyos.vyos_banner: + banner: pre-login + text: "this is my pre-login banner\nthat has a multiline\nstring\n" + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/main.yaml new file mode 100644 index 00000000..676b8ec5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/main.yaml @@ -0,0 +1,7 @@ +--- +- include: cli.yaml + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml new file mode 100644 index 00000000..690937fa --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" + +- name: test bad operator + register: result + ignore_errors: true + vyos.vyos.vyos_command: + commands: + - show version + - show interfaces + wait_for: + - result[0] is 'VyOS' + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml new file mode 100644 index 00000000..61ed0548 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: START cli/cli_command.yaml on connection={{ ansible_connection }} + +- block: + + - name: get output for single command + register: result + ansible.netcommon.cli_command: + command: show version + + - assert: + that: + - result.changed == false + - result.stdout is defined + + - name: send invalid command + register: result + ignore_errors: true + ansible.netcommon.cli_command: + command: show foo + + - assert: + that: + - result.failed == true + - result.msg is defined + when: ansible_connection == 'ansible.netcommon.network_cli' + +- block: + + - name: test failure for local connection + register: result + ignore_errors: true + ansible.netcommon.cli_command: + command: show version + + - assert: + that: + - result.failed == true + - "'Connection type local is not valid for this module' in result.msg" + when: ansible_connection == 'local' + +- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/contains.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/contains.yaml new file mode 100644 index 00000000..efaf811f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/contains.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + register: result + vyos.vyos.vyos_command: + commands: + - show version + - show interface + wait_for: + - result[0] contains VyOS + - result[1] contains eth0 + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/invalid.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/invalid.yaml new file mode 100644 index 00000000..ac8af3fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/invalid.yaml @@ -0,0 +1,24 @@ +--- +- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" + +- name: run invalid command + register: result + ignore_errors: true + vyos.vyos.vyos_command: + commands: show foo + +- assert: + that: result.failed + +- name: run commands that include invalid command + register: result + ignore_errors: true + vyos.vyos.vyos_command: + commands: + - show version + - show foo + +- assert: + that: result.failed + +- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/output.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/output.yaml new file mode 100644 index 00000000..9ed19067 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/output.yaml @@ -0,0 +1,42 @@ +--- +- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" + +- name: get output for single command + register: result + vyos.vyos.vyos_command: + commands: show version + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: get output for multiple commands + register: result + vyos.vyos.vyos_command: + commands: + - show version + - show interfaces + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout | length == 2 + +- name: Get output for multiple commands that call less explicitly + register: result + vyos.vyos.vyos_command: + commands: + - show hardware cpu detail + - show hardware mem + - show license + +- assert: + that: + - result.changed == false + - result.stdout_lines is defined + - result.stdout_lines[2] | length >= 20 + +- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/timeout.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/timeout.yaml new file mode 100644 index 00000000..fceea5c5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/cli/timeout.yaml @@ -0,0 +1,18 @@ +--- +- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" + +- name: test bad condition + register: result + ignore_errors: true + vyos.vyos.vyos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..013d1762 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_command/tests/redirection/cli/shortname.yaml @@ -0,0 +1,41 @@ +--- +- debug: msg="START cli/shortname.yaml on connection={{ ansible_connection }}" + +- name: get output for single command + register: result + vyos.vyos.command: + commands: show version + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: get output for multiple commands + register: result + vyos.vyos.command: + commands: + - show version + - show interfaces + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout | length == 2 + +- name: Get output for multiple commands that call less explicitly + register: result + vyos.vyos.command: + commands: + - show hardware cpu detail + - show hardware mem + - show license +- assert: + that: + - result.changed == false + - result.stdout_lines is defined + - result.stdout_lines[2] | length >= 20 + +- debug: msg="END cli/shortname.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/cli_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/cli_config.yaml new file mode 100644 index 00000000..98bd1fce --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/cli_config.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli_config test cases + find: + paths: '{{ role_path }}/tests/cli_config' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/main.yaml new file mode 100644 index 00000000..60fb6bf0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/main.yaml @@ -0,0 +1,11 @@ +--- +- include: cli.yaml + +- include: cli_config.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/templates/config.j2 b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/templates/config.j2 new file mode 100644 index 00000000..fc4d42c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/templates/config.j2 @@ -0,0 +1,2 @@ +set interfaces ethernet eth0 description TEST-INTF +set system login user test_user diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/backup.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/backup.yaml new file mode 100644 index 00000000..ae59a0d5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/backup.yaml @@ -0,0 +1,113 @@ +--- +- debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- name: delete backup files + file: + path: '{{ item.path }}' + state: absent + with_items: '{{backup_files.files|default([])}}' + +- name: take configure backup + register: result + vyos.vyos.vyos_config: + backup: true + +- assert: + that: + - result.changed == true + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- assert: + that: + - backup_files.files is defined + +- name: delete configurable backup file path + file: + path: '{{ item }}' + state: absent + with_items: + - '{{ role_path }}/backup_test_dir/' + - '{{ role_path }}/backup/backup.cfg' + +- name: take configuration backup in custom filename and directory path + become: true + register: result + vyos.vyos.vyos_config: + backup: true + backup_options: + filename: backup.cfg + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-1 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom filename + become: true + register: result + vyos.vyos.vyos_config: + backup: true + backup_options: + filename: backup.cfg + +- assert: + that: + - result.changed == true + +- name: check if the backup file-2 exist + find: + paths: '{{ role_path }}/backup/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom path and default filename + become: true + register: result + vyos.vyos.vyos_config: + backup: true + backup_options: + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-3 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/check_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/check_config.yaml new file mode 100644 index 00000000..4300c10e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/check_config.yaml @@ -0,0 +1,57 @@ +--- +- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}" + +- name: setup- ensure interface is not present + vyos.vyos.vyos_config: + lines: delete interfaces loopback lo + +- name: setup- create interface + register: result + vyos.vyos.vyos_config: + lines: + - interfaces + - interfaces loopback lo + - interfaces loopback lo description test + +- name: Check that multiple duplicate lines collapse into a single commands + assert: + that: + - '{{ result.commands|length }} == 1' + +- name: Check that set is correctly prepended + assert: + that: + - result.commands[0] == 'set interfaces loopback lo description test' + +- name: configure config_check config command + register: result + vyos.vyos.vyos_config: + lines: delete interfaces loopback lo + +- assert: + that: + - result.changed == true + +- name: check config_check config command idempontent + register: result + vyos.vyos.vyos_config: + lines: delete interfaces loopback lo + +- assert: + that: + - result.changed == false + +- name: check multiple line config filter is working + register: result + vyos.vyos.vyos_config: + lines: + - set system login user esa level admin + - set system login user esa authentication encrypted-password '!abc!' + - set system login user vyos level admin + - set system login user vyos authentication encrypted-password 'abc' + +- assert: + that: + - '{{ result.filtered|length }} == 2' + +- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/comment.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/comment.yaml new file mode 100644 index 00000000..30325856 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/comment.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- name: configure using comment + register: result + vyos.vyos.vyos_config: + lines: set system host-name foo + comment: this is a test + +- assert: + that: + - result.changed == true + - "'set system host-name foo' in result.commands" + +- name: collect system commits + register: result + vyos.vyos.vyos_command: + commands: show system commit + +- assert: + that: + - "'this is a test' in result.stdout_lines[0][1]" + +- name: teardown + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/comment.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/config.cfg new file mode 100644 index 00000000..36c98f19 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/config.cfg @@ -0,0 +1,3 @@ + set service lldp + set protocols static + diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/save.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/save.yaml new file mode 100644 index 00000000..e8a9035b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/save.yaml @@ -0,0 +1,54 @@ +--- +- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- name: configure hostaname and save + register: result + vyos.vyos.vyos_config: + lines: set system host-name foo + save: true + +- assert: + that: + - result.changed == true + - "'set system host-name foo' in result.commands" + +- name: configure hostaname and don't save + register: result + vyos.vyos.vyos_config: + lines: set system host-name bar + +- assert: + that: + - result.changed == true + - "'set system host-name bar' in result.commands" + +- name: save config + register: result + vyos.vyos.vyos_config: + save: true + +- assert: + that: + - result.changed == true + +- name: save config again + register: result + vyos.vyos.vyos_config: + save: true + +- assert: + that: + - result.changed == false + +- name: teardown + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + save: true + +- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/simple.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/simple.yaml new file mode 100644 index 00000000..4e2db4e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli/simple.yaml @@ -0,0 +1,53 @@ +--- +- debug: msg="START cli/simple.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- name: configure simple config command + register: result + vyos.vyos.vyos_config: + lines: set system host-name foo + +- assert: + that: + - result.changed == true + - "'set system host-name foo' in result.commands" + +- name: check simple config command idempontent + register: result + vyos.vyos.vyos_config: + lines: set system host-name foo + +- assert: + that: + - result.changed == false + +- name: Delete services + vyos.vyos.vyos_config: &id001 + lines: + - delete service lldp + - delete protocols static + +- name: Configuring when commands starts with whitespaces + register: result + vyos.vyos.vyos_config: + src: '{{ role_path }}/tests/cli/config.cfg' + +- assert: + that: + - result.changed == true + - '"set service lldp" in result.commands' + - '"set protocols static" in result.commands' + +- name: Delete services + vyos.vyos.vyos_config: *id001 + +- name: teardown + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml new file mode 100644 index 00000000..3880a040 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml @@ -0,0 +1,114 @@ +--- +- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" + +- name: delete configurable backup file path + file: + path: '{{ item }}' + state: absent + with_items: + - '{{ role_path }}/backup_test_dir/' + - '{{ role_path }}/backup/backup.cfg' + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- name: delete backup files + file: + path: '{{ item.path }}' + state: absent + with_items: '{{backup_files.files|default([])}}' + +- name: take config backup + become: true + register: result + ansible.netcommon.cli_config: + backup: true + +- assert: + that: + - result.changed == true + +- name: collect any backup files + find: + paths: '{{ role_path }}/backup' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_files + connection: local + +- assert: + that: + - backup_files.files is defined + +- name: take configuration backup in custom filename and directory path + become: true + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + filename: backup.cfg + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-1 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom filename + become: true + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + filename: backup.cfg + +- assert: + that: + - result.changed == true + +- name: check if the backup file-2 exist + find: + paths: '{{ role_path }}/backup/backup.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom path and default filename + become: true + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-3 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + pattern: '{{ inventory_hostname_short }}_config*' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml new file mode 100644 index 00000000..6b711443 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml @@ -0,0 +1,30 @@ +--- +- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove interface description + ansible.netcommon.cli_config: &id002 + config: delete interfaces loopback lo description + +- name: configure device with config + register: result + ansible.netcommon.cli_config: &id001 + config: set interfaces loopback lo description 'this is a test' + +- assert: + that: + - result.changed == true + +- name: Idempotence + register: result + ansible.netcommon.cli_config: *id001 + +- assert: + that: + - result.changed == false + +- name: teardown + ansible.netcommon.cli_config: *id002 + +- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml new file mode 100644 index 00000000..030b75d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection + }}" + +- name: setup + ansible.netcommon.cli_config: &id001 + config: set system host-name {{ inventory_hostname_short }} + +- name: configure using comment + register: result + ansible.netcommon.cli_config: + config: set system host-name foo + commit_comment: this is a test + +- assert: + that: + - result.changed == true + +- name: collect system commits + register: result + vyos.vyos.vyos_command: + commands: show system commit + +- assert: + that: + - "'this is a test' in result.stdout_lines[0][1]" + +- name: teardown + ansible.netcommon.cli_config: *id001 + +- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..3f3e489e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml @@ -0,0 +1,99 @@ +--- +- debug: msg="START cli/shortname.yaml on connection={{ ansible_connection }}" + +- name: setup- ensure interface is not present + vyos.vyos.config: + lines: delete interfaces loopback lo + +- name: setup- create interface + register: result + vyos.vyos.config: + lines: + - interfaces + - interfaces loopback lo + - interfaces loopback lo description test + +- name: Check that multiple duplicate lines collapse into a single commands + assert: + that: + - '{{ result.commands|length }} == 1' + +- name: Check that set is correctly prepended + assert: + that: + - result.commands[0] == 'set interfaces loopback lo description test' + +- name: configure config_check config command + register: result + vyos.vyos.config: + lines: delete interfaces loopback lo + +- assert: + that: + - result.changed == true + +- name: check config_check config command idempontent + register: result + vyos.vyos.config: + lines: delete interfaces loopback lo + +- assert: + that: + - result.changed == false + +- name: check multiple line config filter is working + register: result + vyos.vyos.config: + lines: + - set system login user esa level admin + - set system login user esa authentication encrypted-password '!abc!' + - set system login user vyos level admin + - set system login user vyos authentication encrypted-password 'abc' + +- assert: + that: + - '{{ result.filtered|length }} == 2' + +- name: Remove interface description and delete temp user + vyos.vyos.config: &cleanup + lines: + - "delete interfaces ethernet eth0 description TEST-INTF" + - "delete system login user test_user" + +- name: Use src with module alias + register: result + vyos.vyos.config: + src: config.j2 + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth0 description TEST-INTF" in result.commands' + - '"set system login user test_user" in result.commands' + +- name: "Restore hostname to {{ inventory_hostname }} and delete temp user" + vyos.vyos.config: *cleanup + +- name: use module alias to take configuration backup + register: result + vyos.vyos.config: + backup: true + backup_options: + filename: backup_with_alias.cfg + dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' + +- assert: + that: + - result.changed == true + +- name: check if the backup file-4 exist + find: + paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup_with_alias.cfg' + register: backup_file + connection: local + +- assert: + that: + - backup_file.files is defined + +- debug: msg="END cli/shortname.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/main.yaml new file mode 100644 index 00000000..676b8ec5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/main.yaml @@ -0,0 +1,7 @@ +--- +- include: cli.yaml + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml new file mode 100644 index 00000000..5802f731 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml @@ -0,0 +1,42 @@ +--- +- name: get host name + register: vyos_host + vyos.vyos.vyos_command: + commands: + - show host name + +- name: get version info + register: vyos_version + vyos.vyos.vyos_command: + commands: + - show version + +- name: collect all facts from the device + register: result + vyos.vyos.vyos_facts: + gather_subset: all + +- name: check that hostname is present + assert: + that: + - result.ansible_facts.ansible_net_hostname == vyos_host.stdout[0] + +- name: check that subsets are present + assert: + that: + - "'neighbors' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'config' in result.ansible_facts.ansible_net_gather_subset" + +- name: check that version info is present + assert: + that: + - result.ansible_facts.ansible_net_version in vyos_version.stdout_lines[0][0] + - result.ansible_facts.ansible_net_model in vyos_version.stdout_lines[0][9] + - result.ansible_facts.ansible_net_serialnum in vyos_version.stdout_lines[0][10] + +- name: check that config info is present + assert: + that: + - result.ansible_facts.ansible_net_commits is defined + - result.ansible_facts.ansible_net_config is defined diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..05399f1d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_facts/tests/redirection/cli/shortname.yaml @@ -0,0 +1,42 @@ +--- +- name: get host name + register: vyos_host + vyos.vyos.command: + commands: + - show host name + +- name: get version info + register: vyos_version + vyos.vyos.command: + commands: + - show version + +- name: collect all facts from the device + register: result + vyos.vyos.facts: + gather_subset: all + +- name: check that hostname is present + assert: + that: + - result.ansible_facts.ansible_net_hostname == vyos_host.stdout[0] + +- name: check that subsets are present + assert: + that: + - "'neighbors' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'config' in result.ansible_facts.ansible_net_gather_subset" + +- name: check that version info is present + assert: + that: + - result.ansible_facts.ansible_net_version in vyos_version.stdout_lines[0][0] + - result.ansible_facts.ansible_net_model in vyos_version.stdout_lines[0][9] + - result.ansible_facts.ansible_net_serialnum in vyos_version.stdout_lines[0][10] + +- name: check that config info is present + assert: + that: + - result.ansible_facts.ansible_net_commits is defined + - result.ansible_facts.ansible_net_config is defined diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..45446bdb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_parsed_config.cfg @@ -0,0 +1,19 @@ +set firewall all-ping 'enable' +set firewall broadcast-ping 'enable' +set firewall config-trap 'enable' +set firewall group address-group MGMT-HOSTS address '192.0.1.1' +set firewall group address-group MGMT-HOSTS address '192.0.1.3' +set firewall group address-group MGMT-HOSTS address '192.0.1.5' +set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' +set firewall group network-group MGMT description 'This group has the Management network addresses' +set firewall group network-group MGMT network '192.0.1.0/24' +set firewall ip-src-route 'enable' +set firewall log-martians 'enable' +set firewall receive-redirects 'disable' +set firewall send-redirects 'enable' +set firewall source-validation 'strict' +set firewall state-policy established action 'accept' +set firewall state-policy established log 'enable' +set firewall state-policy invalid action 'reject' +set firewall syn-cookies 'enable' +set firewall twa-hazards-protection 'enable' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml new file mode 100644 index 00000000..f79bb9ac --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml @@ -0,0 +1,18 @@ +--- +- name: Setup + vars: + lines: "set firewall all-ping 'enable'\nset firewall broadcast-ping 'enable'\n\ + set firewall config-trap 'enable'\nset firewall group address-group MGMT-HOSTS\ + \ address '192.0.1.1'\nset firewall group address-group MGMT-HOSTS address\ + \ '192.0.1.3'\nset firewall group address-group MGMT-HOSTS address '192.0.1.5'\n\ + set firewall group address-group MGMT-HOSTS description 'This group has the\ + \ Management hosts address list'\nset firewall group network-group MGMT description\ + \ 'This group has the Management network addresses'\nset firewall group network-group\ + \ MGMT network '192.0.1.0/24'\nset firewall ip-src-route 'enable'\nset firewall\ + \ log-martians 'enable'\nset firewall receive-redirects 'disable'\nset firewall\ + \ send-redirects 'enable'\nset firewall source-validation 'strict'\nset firewall\ + \ state-policy established action 'accept'\nset firewall state-policy established\ + \ log 'enable'\nset firewall state-policy invalid action 'reject'\nset firewall\ + \ syn-cookies 'enable'\nset firewall twa-hazards-protection 'enable'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..5c869246 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Config + vars: + lines: "delete firewall\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml new file mode 100644 index 00000000..44df47ce --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml @@ -0,0 +1,48 @@ +--- +- debug: + msg: Start vyos_firewall_global deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of firewall. + register: result + vyos.vyos.vyos_firewall_global: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['after'] }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml new file mode 100644 index 00000000..3910952e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: START vyos_firewall_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_global: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_global: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_global: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_global: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml new file mode 100644 index 00000000..eda24fda --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml @@ -0,0 +1,33 @@ +--- +- debug: + msg: START vyos_firewall_global gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_global: &id001 + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate == result['gathered'] }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml new file mode 100644 index 00000000..4f226603 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml @@ -0,0 +1,89 @@ +--- +- debug: + msg: START vyos_firewall_global merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_global: &id001 + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + + - connection_type: established + action: accept + log: true + + - connection_type: invalid + action: reject + route_redirects: + + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + + - address: 192.0.1.1 + + - address: 192.0.1.3 + + - address: 192.0.1.5 + network_group: + + - name: MGMT + description: This group has the Management network addresses + members: + + - address: 192.0.1.0/24 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml new file mode 100644 index 00000000..b94d95ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml @@ -0,0 +1,41 @@ +--- +- debug: + msg: START vyos_firewall_global parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather firewall_global facts + register: firewall_global_facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - firewall_global + + - name: Provide the running configuration for parsing (config to be parsed) + register: result + vyos.vyos.vyos_firewall_global: &id001 + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + + - name: Assert that correct parsing done + assert: + that: "{{ ansible_facts['network_resources']['firewall_global'] == result['parsed']\ + \ }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml new file mode 100644 index 00000000..528563e2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml @@ -0,0 +1,84 @@ +--- +- debug: + msg: START vyos_firewall_global rendered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_firewall_global: &id001 + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + + - connection_type: established + action: accept + log: true + + - connection_type: invalid + action: reject + route_redirects: + + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + + - name: SALES-HOSTS + description: Sales office hosts address list + members: + + - address: 192.0.2.1 + + - address: 192.0.2.2 + + - address: 192.0.2.3 + + - name: ENG-HOSTS + description: Sales office hosts address list + members: + + - address: 192.0.3.1 + + - address: 192.0.3.2 + network_group: + + - name: MGMT + description: This group has the Management network addresses + members: + + - address: 192.0.1.0/24 + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml new file mode 100644 index 00000000..31a76448 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml @@ -0,0 +1,100 @@ +--- +- debug: + msg: START vyos_firewall_global replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed firewall with provided configurations + register: result + vyos.vyos.vyos_firewall_global: &id001 + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + + - connection_type: established + action: accept + log: true + + - connection_type: invalid + action: reject + route_redirects: + + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + + - name: SALES-HOSTS + description: Sales office hosts address list + members: + + - address: 192.0.2.1 + + - address: 192.0.2.2 + + - address: 192.0.2.3 + + - name: ENG-HOSTS + description: Sales office hosts address list + members: + + - address: 192.0.3.1 + + - address: 192.0.3.2 + network_group: + + - name: MGMT + description: This group has the Management network addresses + members: + + - address: 192.0.1.0/24 + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['after'] }}" + + - name: Replace device configurations of listed firewall with provided configurarions + (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_global: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml new file mode 100644 index 00000000..00c56358 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml @@ -0,0 +1,94 @@ +--- +- debug: + msg: START vyos_firewall_global round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + + - connection_type: established + action: accept + log: true + + - connection_type: invalid + action: reject + route_redirects: + + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + + - address: 192.0.1.1 + + - address: 192.0.1.3 + + - address: 192.0.1.5 + network_group: + + - name: MGMT + description: This group has the Management network addresses + members: + + - address: 192.0.1.0/24 + state: merged + + - name: Gather firewall_global facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - firewall_global + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_firewall_global: + config: + validation: strict + config_trap: false + log_martians: false + syn_cookies: false + twa_hazards_protection: false + ping: + all: false + broadcast: false + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] == result['after'] }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_firewall_global: + config: "{{ ansible_facts['network_resources']['firewall_global'] }}" + state: replaced + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] == revert['after']}}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..2a314139 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml @@ -0,0 +1,89 @@ +--- +- debug: + msg: START shortname integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.firewall_global: &id001 + config: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + + - connection_type: established + action: accept + log: true + + - connection_type: invalid + action: reject + route_redirects: + + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + + - address: 192.0.1.1 + + - address: 192.0.1.3 + + - address: 192.0.1.5 + network_group: + + - name: MGMT + description: This group has the Management network addresses + members: + + - address: 192.0.1.0/24 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.firewall_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/vars/main.yaml new file mode 100644 index 00000000..4a1e7a8b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_global/vars/main.yaml @@ -0,0 +1,217 @@ +--- +merged: + before: [] + commands: + - set firewall group address-group MGMT-HOSTS address 192.0.1.1 + - set firewall group address-group MGMT-HOSTS address 192.0.1.3 + - set firewall group address-group MGMT-HOSTS address 192.0.1.5 + - set firewall group address-group MGMT-HOSTS description 'This group has the + Management hosts address list' + - set firewall group address-group MGMT-HOSTS + - set firewall group network-group MGMT network 192.0.1.0/24 + - set firewall group network-group MGMT description 'This group has the Management + network addresses' + - set firewall group network-group MGMT + - set firewall ip-src-route 'enable' + - set firewall receive-redirects 'disable' + - set firewall send-redirects 'enable' + - set firewall config-trap 'enable' + - set firewall state-policy established action 'accept' + - set firewall state-policy established log 'enable' + - set firewall state-policy invalid action 'reject' + - set firewall broadcast-ping 'enable' + - set firewall all-ping 'enable' + - set firewall log-martians 'enable' + - set firewall twa-hazards-protection 'enable' + - set firewall syn-cookies 'enable' + - set firewall source-validation 'strict' + after: + config_trap: true + group: + address_group: + - members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 + description: This group has the Management hosts address list + name: MGMT-HOSTS + network_group: + - members: + - address: 192.0.1.0/24 + description: This group has the Management network addresses + name: MGMT + log_martians: true + ping: + all: true + broadcast: true + route_redirects: + - afi: ipv4 + icmp_redirects: + receive: false + send: true + ip_src_route: true + syn_cookies: true + state_policy: + - action: accept + connection_type: established + log: true + - action: reject + connection_type: invalid + twa_hazards_protection: true + validation: strict +populate: + validation: strict + config_trap: true + log_martians: true + syn_cookies: true + twa_hazards_protection: true + ping: + all: true + broadcast: true + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 +replaced: + commands: + - delete firewall group address-group MGMT-HOSTS + - set firewall group address-group SALES-HOSTS address 192.0.2.1 + - set firewall group address-group SALES-HOSTS address 192.0.2.2 + - set firewall group address-group SALES-HOSTS address 192.0.2.3 + - set firewall group address-group SALES-HOSTS description 'Sales office hosts + address list' + - set firewall group address-group SALES-HOSTS + - set firewall group address-group ENG-HOSTS address 192.0.3.1 + - set firewall group address-group ENG-HOSTS address 192.0.3.2 + - set firewall group address-group ENG-HOSTS description 'Sales office hosts address + list' + - set firewall group address-group ENG-HOSTS + after: + config_trap: true + group: + address_group: + - members: + - address: 192.0.3.1 + - address: 192.0.3.2 + description: Sales office hosts address list + name: ENG-HOSTS + - members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + description: Sales office hosts address list + name: SALES-HOSTS + network_group: + - members: + - address: 192.0.1.0/24 + description: This group has the Management network addresses + name: MGMT + log_martians: true + ping: + all: true + broadcast: true + route_redirects: + - afi: ipv4 + icmp_redirects: + receive: false + send: true + ip_src_route: true + state_policy: + - action: accept + connection_type: established + log: true + - action: reject + connection_type: invalid + syn_cookies: true + twa_hazards_protection: true + validation: strict +rendered: + commands: + - set firewall group address-group SALES-HOSTS address 192.0.2.1 + - set firewall group address-group SALES-HOSTS address 192.0.2.2 + - set firewall group address-group SALES-HOSTS address 192.0.2.3 + - set firewall group address-group SALES-HOSTS description 'Sales office hosts + address list' + - set firewall group address-group SALES-HOSTS + - set firewall group address-group ENG-HOSTS address 192.0.3.1 + - set firewall group address-group ENG-HOSTS address 192.0.3.2 + - set firewall group address-group ENG-HOSTS description 'Sales office hosts address + list' + - set firewall group address-group ENG-HOSTS + - set firewall group network-group MGMT network 192.0.1.0/24 + - set firewall group network-group MGMT description 'This group has the Management + network addresses' + - set firewall group network-group MGMT + - set firewall ip-src-route 'enable' + - set firewall receive-redirects 'disable' + - set firewall send-redirects 'enable' + - set firewall config-trap 'enable' + - set firewall state-policy established action 'accept' + - set firewall state-policy established log 'enable' + - set firewall state-policy invalid action 'reject' + - set firewall broadcast-ping 'enable' + - set firewall all-ping 'enable' + - set firewall log-martians 'enable' + - set firewall twa-hazards-protection 'enable' + - set firewall syn-cookies 'enable' + - set firewall source-validation 'strict' +deleted: + commands: + - 'delete firewall ' + after: [] +round_trip: + after: + validation: strict + config_trap: false + log_martians: false + syn_cookies: false + twa_hazards_protection: false + ping: + all: false + broadcast: false + state_policy: + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject + route_redirects: + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false + group: + address_group: + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 + network_group: + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/1 b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/1 new file mode 100644 index 00000000..70ae90f3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/1 @@ -0,0 +1,120 @@ +--- +merged: + before: [] + + + commands: + - "set interfaces ethernet eth1 firewall in name 'INBOUND'" + - "set interfaces ethernet eth1 firewall out name 'OUTBOUND'" + - "set interfaces ethernet eth1 firewall local name 'LOCAL'" + - "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'" + - "set interfaces ethernet eth3 firewall in name 'INBOUND'" + - "set interfaces ethernet eth3 firewall out name 'OUTBOUND'" + - "set interfaces ethernet eth3 firewall local name 'LOCAL'" + - "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'" + + after: + - name: 'eth1' + access_rules: + - afi: 'ipv4' + rules: + - name: 'INBOUND' + direction: 'in' + - name: 'OUBOUND' + direction: 'out' + - afi: 'ipv6' + rules: + - name: 'V6-LOCAL' + direction: 'local' + +populate: + - name: 'eth1' + access_rules: + - afi: 'ipv4' + rules: + - name: 'INBOUND' + direction: 'in' + - name: 'OUBOUND' + direction: 'out' + - afi: 'ipv6' + rules: + - name: 'LOCAL' + direction: 'local' + +replaced: + commands: + - "delete service lldp interface eth2 location" + - "set service lldp interface eth2 'disable'" + - "set service lldp interface eth2 location civic-based country-code 'US'" + - "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'" + - "delete service lldp interface eth1 location" + - "set service lldp interface eth1 'disable'" + - "set service lldp interface eth1 location coordinate-based latitude '33.524449N'" + - "set service lldp interface eth1 location coordinate-based altitude '2200'" + - "set service lldp interface eth1 location coordinate-based datum 'WGS84'" + - "set service lldp interface eth1 location coordinate-based longitude '222.267255W'" + + after: + - name: 'eth2' + enable: false + location: + civic_based: + country_code: 'US' + ca_info: + - ca_type: 0 + ca_value: 'ENGLISH' + + - name: 'eth1' + enable: false + location: + coordinate_based: + altitude: 2200 + datum: 'WGS84' + longitude: '222.267255W' + latitude: '33.524449N' + +populate_intf: + - name: 'eth2' + enable: false + location: + civic_based: + country_code: 'US' + ca_info: + - ca_type: 0 + ca_value: 'ENGLISH' + +overridden: + commands: + - "delete service lldp interface eth2 location" + - "delete service lldp interface eth2 'disable'" + - "set service lldp interface eth2 location elin '0000000911'" + + after: + - name: 'eth2' + location: + elin: 0000000911 + +deleted: + commands: + - "delete service lldp interface eth1" + - "delete service lldp interface eth2" + + after: [] + +round_trip: + after: + - name: 'eth1' + location: + civic_based: + country_code: 'US' + ca_info: + - ca_type: 0 + ca_value: 'ENGLISH' + + - name: 'eth2' + location: + coordinate_based: + altitude: 2200 + datum: 'WGS84' + longitude: '222.267255W' + latitude: '33.524449N' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..54696e8d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,10 @@ +set interfaces ethernet eth1 firewall in name 'INBOUND' +set interfaces ethernet eth1 firewall out name 'OUTBOUND' +set interfaces ethernet eth1 firewall local name 'LOCAL' +set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth2 firewall in name 'INBOUND' +set interfaces ethernet eth2 firewall out name 'OUTBOUND' +set interfaces ethernet eth2 firewall local name 'LOCAL' +set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth0 + diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml new file mode 100644 index 00000000..3e60c414 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,12 @@ +--- +- name: Setup + vars: + lines: "set interfaces ethernet eth1 firewall in name 'INBOUND' \nset interfaces\ + \ ethernet eth1 firewall out name 'OUTBOUND' \nset interfaces ethernet eth1\ + \ firewall local name 'LOCAL' \nset interfaces ethernet eth1 firewall local\ + \ ipv6-name 'V6-LOCAL'\nset interfaces ethernet eth2 firewall in name 'INBOUND'\n\ + set interfaces ethernet eth2 firewall out name 'OUTBOUND'\nset interfaces\ + \ ethernet eth2 firewall local name 'LOCAL' \nset interfaces ethernet eth2\ + \ firewall local ipv6-name 'V6-LOCAL'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml new file mode 100644 index 00000000..40a7f4ab --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml @@ -0,0 +1,7 @@ +--- +- name: Setup + vars: + lines: "set firewall name 'INBOUND'\nset firewall name 'OUTBOUND'\nset firewall\ + \ name 'LOCAL'\nset firewall ipv6-name 'V6-LOCAL'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..38a18003 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,7 @@ +--- +- name: Remove Config + vars: + lines: "delete interfaces ethernet eth1 firewall\ndelete interfaces ethernet\ + \ eth2 firewall\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml new file mode 100644 index 00000000..08447497 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml @@ -0,0 +1,7 @@ +--- +- name: Remove Config + vars: + lines: "delete firewall name INBOUND\ndelete firewall name OUTBOUND\ndelete\ + \ firewall name LOCAL\ndelete firewall ipv6-name V6-LOCAL\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..078dd89c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,58 @@ +--- +- debug: + msg: Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of given firewall rules. + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + + - name: eth2 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml new file mode 100644 index 00000000..f7db06b3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml @@ -0,0 +1,68 @@ +--- +- debug: + msg: Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Delete firewall interfaces based on IP address type provided. + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + + - afi: ipv6 + + - name: eth2 + access_rules: + + - afi: ipv4 + + - afi: ipv6 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_afi['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_afi['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_afi['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml new file mode 100644 index 00000000..d85654ce --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml @@ -0,0 +1,54 @@ +--- +- debug: + msg: Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Delete all the firewall interfaces. + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml new file mode 100644 index 00000000..f7e91f87 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: Start vyos_firewall_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Delete firewall interface. + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + rules: + + - direction: in + name: INBOUND + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_single['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_single['after'] | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_single['after'] | symmetric_difference(result['before'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..66c49bf2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_firewall_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..fd8dd744 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,40 @@ +--- +- debug: + msg: START vyos_firewall_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_firewall_config.yaml + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..0c28eabf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml @@ -0,0 +1,96 @@ +--- +- debug: + msg: START vyos_firewall_interfaces merged integration tests on connection={{ + ansible_connection }} + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + rules: + + - direction: in + name: INBOUND + + - direction: local + name: LOCAL + + - direction: out + name: OUTBOUND + + - afi: ipv6 + rules: + + - direction: local + name: V6-LOCAL + + - name: eth2 + access_rules: + + - afi: ipv4 + rules: + + - direction: in + name: INBOUND + + - direction: local + name: LOCAL + + - direction: out + name: OUTBOUND + + - afi: ipv6 + rules: + + - direction: local + name: V6-LOCAL + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml new file mode 100644 index 00000000..873f4c49 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml @@ -0,0 +1,70 @@ +--- +- debug: + msg: START vyos_firewall_interfaces merged integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_firewall_config.yaml + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + rules: + + - direction: in + name: OUTBOUND + + - direction: out + name: INBOUND + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ populate | symmetric_difference(result['before']) |length == 0\ + \ }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged_edit['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged_edit['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged_edit['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..01d30b67 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,66 @@ +--- +- debug: + msg: START vyos_firewall_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_firewall_config.yaml + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth2 + access_rules: + + - afi: ipv4 + rules: + + - name: INBOUND + direction: out + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..c7032e10 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: START vyos_firewall_interfaces parsed integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_firewall_config.yaml + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather firewall_interfaces facts + register: firewall_interfaces_facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - firewall_interfaces + + - name: Provide the running configuration for parsing (config to be parsed) + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + + - name: Assert that correct parsing done + assert: + that: "{{ ansible_facts['network_resources']['firewall_interfaces'] | symmetric_difference(result['parsed'])\ + \ |length == 0 }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..022dd502 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,72 @@ +--- +- debug: + msg: START vyos_firewall_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + rules: + + - name: INBOUND + direction: in + + - name: OUTBOUND + direction: out + + - name: LOCAL + direction: local + + - afi: ipv6 + rules: + + - name: V6-LOCAL + direction: local + + - name: eth2 + access_rules: + + - afi: ipv4 + rules: + + - name: INBOUND + direction: in + + - name: OUTBOUND + direction: out + + - name: LOCAL + direction: local + + - afi: ipv6 + rules: + + - name: V6-LOCAL + direction: local + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..b2b00675 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,83 @@ +--- +- debug: + msg: START vyos_firewall_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_firewall_config.yaml + +- include_tasks: _populate_rule_sets.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed firewall rules with provided + configurations + register: result + vyos.vyos.vyos_firewall_interfaces: &id001 + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + rules: + + - name: OUTBOUND + direction: out + + - afi: ipv6 + rules: + + - name: V6-LOCAL + direction: local + + - name: eth2 + access_rules: + + - afi: ipv4 + rules: + + - name: INBOUND + direction: in + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed firewall rules with provided + configurarions (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_interfaces: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml new file mode 100644 index 00000000..9155b7c1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml @@ -0,0 +1,94 @@ +--- +- debug: + msg: START vyos_firewall_interfaces round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_firewall_config.yaml + +- include_tasks: _populate_rule_sets.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_firewall_interfaces: + config: + + - name: eth1 + access_rules: + + - afi: ipv4 + rules: + + - name: INBOUND + direction: in + + - name: OUTBOUND + direction: out + + - name: LOCAL + direction: local + + - afi: ipv6 + rules: + + - name: V6-LOCAL + direction: local + state: merged + + - name: Gather firewall_interfaces facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - firewall_interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_firewall_interfaces: + config: + + - name: eth2 + access_rules: + + - afi: ipv4 + rules: + + - name: INBOUND + direction: in + + - name: OUTBOUND + direction: out + + - name: LOCAL + direction: local + + - afi: ipv6 + rules: + + - name: V6-LOCAL + direction: local + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_firewall_interfaces: + config: "{{ ansible_facts['network_resources']['firewall_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml + + - include_tasks: _remove_firewall_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml new file mode 100644 index 00000000..45be6dbb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_interfaces/vars/main.yaml @@ -0,0 +1,279 @@ +--- +merged: + before: + - name: eth0 + - name: eth1 + - name: eth2 + commands: + - set interfaces ethernet eth1 firewall in name 'INBOUND' + - set interfaces ethernet eth1 firewall out name 'OUTBOUND' + - set interfaces ethernet eth1 firewall local name 'LOCAL' + - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + - set interfaces ethernet eth2 firewall in name 'INBOUND' + - set interfaces ethernet eth2 firewall out name 'OUTBOUND' + - set interfaces ethernet eth2 firewall local name 'LOCAL' + - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth2 +populate: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth2 +merged_edit: + commands: + - set interfaces ethernet eth1 firewall in name 'OUTBOUND' + - set interfaces ethernet eth1 firewall out name 'INBOUND' + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: OUTBOUND + - direction: local + name: LOCAL + - direction: out + name: INBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth2 +replaced: + commands: + - delete interfaces ethernet eth2 firewall out name + - delete interfaces ethernet eth2 firewall local name + - delete interfaces ethernet eth2 firewall local ipv6-name + - delete interfaces ethernet eth1 firewall local name + - delete interfaces ethernet eth1 firewall in name + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + name: eth2 +overridden: + before: + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: LOCAL + direction: local + - name: OUTBOUND + direction: out + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth2 + commands: + - delete interfaces ethernet eth1 firewall + - delete interfaces ethernet eth2 firewall in name + - delete interfaces ethernet eth2 firewall local name + - delete interfaces ethernet eth2 firewall local ipv6-name + - set interfaces ethernet eth2 firewall out name 'INBOUND' + after: + - name: eth0 + - name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: out + name: eth2 +deleted: + commands: + - delete interfaces ethernet eth1 firewall + - delete interfaces ethernet eth2 firewall + after: + - name: eth0 + - name: eth1 + - name: eth2 +deleted_afi: + commands: + - delete interfaces ethernet eth1 firewall in name + - delete interfaces ethernet eth1 firewall local name + - delete interfaces ethernet eth1 firewall out name + - delete interfaces ethernet eth1 firewall local ipv6-name + - delete interfaces ethernet eth2 firewall in name + - delete interfaces ethernet eth2 firewall local name + - delete interfaces ethernet eth2 firewall out name + - delete interfaces ethernet eth2 firewall local ipv6-name + after: + - name: eth0 + - access_rules: + - afi: ipv4 + - afi: ipv6 + name: eth1 + - access_rules: + - afi: ipv4 + - afi: ipv6 + name: eth2 +deleted_single: + commands: + - delete interfaces ethernet eth1 firewall in name 'INBOUND' + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth2 +rendered: + commands: + - set interfaces ethernet eth1 firewall in name 'INBOUND' + - set interfaces ethernet eth1 firewall out name 'OUTBOUND' + - set interfaces ethernet eth1 firewall local name 'LOCAL' + - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + - set interfaces ethernet eth2 firewall in name 'INBOUND' + - set interfaces ethernet eth2 firewall out name 'OUTBOUND' + - set interfaces ethernet eth2 firewall local name 'LOCAL' + - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +round_trip: + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..b54c1094 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_parsed_config.cfg @@ -0,0 +1,25 @@ +set firewall group address-group 'inbound' +set firewall ipv6-name UPLINK default-action 'accept' +set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' +set firewall ipv6-name UPLINK rule 1 action 'accept' +set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' +set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' +set firewall ipv6-name UPLINK rule 2 action 'accept' +set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' +set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' +set firewall name INBOUND default-action 'accept' +set firewall name INBOUND description 'IPv4 INBOUND rule set' +set firewall name INBOUND rule 101 action 'accept' +set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' +set firewall name INBOUND rule 101 ipsec 'match-ipsec' +set firewall name INBOUND rule 102 action 'reject' +set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' +set firewall name INBOUND rule 102 ipsec 'match-ipsec' +set firewall name INBOUND rule 103 action 'accept' +set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' +set firewall name INBOUND rule 103 destination group address-group 'inbound' +set firewall name INBOUND rule 103 source address '192.0.2.0' +set firewall name INBOUND rule 103 state established 'enable' +set firewall name INBOUND rule 103 state invalid 'disable' +set firewall name INBOUND rule 103 state new 'disable' +set firewall name INBOUND rule 103 state related 'enable' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml new file mode 100644 index 00000000..551736e4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml @@ -0,0 +1,27 @@ +--- +- name: Setup + vars: + lines: "set firewall group address-group 'inbound'\nset firewall ipv6-name UPLINK\ + \ default-action 'accept'\nset firewall ipv6-name UPLINK description 'This\ + \ is ipv6 specific rule-set'\nset firewall ipv6-name UPLINK rule 1 action\ + \ 'accept'\nset firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule\ + \ 1 is configured by Ansible'\nset firewall ipv6-name UPLINK rule 1 ipsec\ + \ 'match-ipsec'\nset firewall ipv6-name UPLINK rule 2 action 'accept'\nset\ + \ firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured\ + \ by Ansible'\nset firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec'\n\ + set firewall name INBOUND default-action 'accept'\nset firewall name INBOUND\ + \ description 'IPv4 INBOUND rule set'\nset firewall name INBOUND rule 101\ + \ action 'accept'\nset firewall name INBOUND rule 101 description 'Rule 101\ + \ is configured by Ansible'\nset firewall name INBOUND rule 101 ipsec 'match-ipsec'\n\ + set firewall name INBOUND rule 102 action 'reject'\nset firewall name INBOUND\ + \ rule 102 description 'Rule 102 is configured by Ansible'\nset firewall name\ + \ INBOUND rule 102 ipsec 'match-ipsec'\nset firewall name INBOUND rule 103\ + \ action 'accept'\nset firewall name INBOUND rule 103 description 'Rule 103\ + \ is configured by Ansible'\nset firewall name INBOUND rule 103 destination\ + \ group address-group 'inbound'\nset firewall name INBOUND rule 103 source\ + \ address '192.0.2.0'\nset firewall name INBOUND rule 103 state established\ + \ 'enable'\nset firewall name INBOUND rule 103 state invalid 'disable'\nset\ + \ firewall name INBOUND rule 103 state new 'disable'\nset firewall name INBOUND\ + \ rule 103 state related 'enable'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..acb08034 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Config + vars: + lines: "delete firewall ipv6-name\ndelete firewall name\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml new file mode 100644 index 00000000..67bfd3c1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml @@ -0,0 +1,56 @@ +--- +- debug: + msg: Start vyos_firewall_rules deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete firewall rule set. + register: result + vyos.vyos.vyos_firewall_rules: &id001 + config: + - afi: ipv6 + rule_sets: + - name: UPLINK + - afi: ipv4 + rule_sets: + - name: INBOUND + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_rs['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_rs['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_rules: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_rs['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml new file mode 100644 index 00000000..e20670de --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml @@ -0,0 +1,54 @@ +--- +- debug: + msg: Start vyos_firewall_rules deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete firewall rule. + register: result + vyos.vyos.vyos_firewall_rules: &id001 + config: + + - afi: ipv6 + + - afi: ipv4 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_rules: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml new file mode 100644 index 00000000..16e563c2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml @@ -0,0 +1,50 @@ +--- +- debug: + msg: Start vyos_firewall_rules deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete all the firewall rules. + register: result + vyos.vyos.vyos_firewall_rules: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_rules: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml new file mode 100644 index 00000000..c30cf03e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_firewall_rules empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_rules: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_rules: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_rules: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_rules: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_firewall_rules: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml new file mode 100644 index 00000000..59c81aad --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml @@ -0,0 +1,26 @@ +--- +- debug: + msg: START vyos_firewall_rules gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_rules: + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml new file mode 100644 index 00000000..adf7e471 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml @@ -0,0 +1,102 @@ +--- +- debug: + msg: START vyos_firewall_rules merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_firewall_rules: &id001 + config: + + - afi: ipv6 + rule_sets: + + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + + - afi: ipv4 + rule_sets: + + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_rules: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml new file mode 100644 index 00000000..6acc9518 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml @@ -0,0 +1,69 @@ +--- +- debug: + msg: START vyos_firewall_rules overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_firewall_rules: &id001 + config: + + - afi: ipv4 + rule_sets: + + - name: Downlink + description: IPv4 INBOUND rule set + default_action: accept + rules: + + - number: 501 + action: accept + description: Rule 501 is configured by Ansible + ipsec: match-ipsec + + - number: 502 + action: reject + description: Rule 502 is configured by Ansible + ipsec: match-ipsec + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_rules: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml new file mode 100644 index 00000000..bc955249 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_firewall_rules parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided Firewall rules config to agnostic model + register: result + vyos.vyos.vyos_firewall_rules: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml new file mode 100644 index 00000000..6670fd7b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml @@ -0,0 +1,62 @@ +--- +- debug: + msg: START vyos_firewall_rules rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_firewall_rules: + config: + + - afi: ipv6 + rule_sets: + + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + + - afi: ipv4 + rule_sets: + + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + +- debug: + msg: END vyos_firewall_rules rendered integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml new file mode 100644 index 00000000..eba16892 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml @@ -0,0 +1,78 @@ +--- +- debug: + msg: START vyos_firewall_rules replaced integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed firewall rules with provided + configurations + register: result + vyos.vyos.vyos_firewall_rules: &id001 + config: + + - afi: ipv6 + rule_sets: + + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + + - afi: ipv4 + rule_sets: + + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed firewall rules with provided + configurarions (IDEMPOTENT) + register: result + vyos.vyos.vyos_firewall_rules: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml new file mode 100644 index 00000000..762086f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml @@ -0,0 +1,101 @@ +--- +- debug: + msg: START vyos_firewall_rules round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_firewall_rules: + config: + + - afi: ipv6 + rule_sets: + + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + + - afi: ipv4 + rule_sets: + + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + state: merged + + - name: Gather firewall_rules facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - firewall_rules + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_firewall_rules: + config: + + - afi: ipv4 + rule_sets: + + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_firewall_rules: + config: "{{ ansible_facts['network_resources']['firewall_rules'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/vars/main.yaml new file mode 100644 index 00000000..88323bae --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_firewall_rules/vars/main.yaml @@ -0,0 +1,314 @@ +--- +merged: + before: [] + commands: + - set firewall ipv6-name UPLINK default-action 'accept' + - set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + - set firewall ipv6-name UPLINK rule 1 action 'accept' + - set firewall ipv6-name UPLINK rule 1 + - set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured + by Ansible' + - set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + - set firewall ipv6-name UPLINK rule 2 action 'accept' + - set firewall ipv6-name UPLINK rule 2 + - set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured + by Ansible' + - set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + - set firewall name INBOUND default-action 'accept' + - set firewall name INBOUND description 'IPv4 INBOUND rule set' + - set firewall name INBOUND rule 101 action 'accept' + - set firewall name INBOUND rule 101 + - set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + - set firewall name INBOUND rule 101 ipsec 'match-ipsec' + - set firewall name INBOUND rule 102 action 'reject' + - set firewall name INBOUND rule 102 + - set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + - set firewall name INBOUND rule 102 ipsec 'match-ipsec' + - set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + - set firewall name INBOUND rule 103 destination group address-group inbound + - set firewall name INBOUND rule 103 + - set firewall name INBOUND rule 103 source address 192.0.2.0 + - set firewall name INBOUND rule 103 state established enable + - set firewall name INBOUND rule 103 state related enable + - set firewall name INBOUND rule 103 state invalid disable + - set firewall name INBOUND rule 103 state new disable + - set firewall name INBOUND rule 103 action 'accept' + after: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true +populate: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true +replaced: + commands: + - delete firewall ipv6-name UPLINK rule 1 + - delete firewall ipv6-name UPLINK rule 2 + - delete firewall name INBOUND rule 102 + - delete firewall name INBOUND rule 103 + - set firewall name INBOUND rule 104 action 'reject' + - set firewall name INBOUND rule 104 description 'Rule 104 is configured by Ansible' + - set firewall name INBOUND rule 104 + - set firewall name INBOUND rule 104 ipsec 'match-none' + after: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none +overridden: + before: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none + commands: + - delete firewall ipv6-name UPLINK + - delete firewall name INBOUND + - set firewall name Downlink default-action 'accept' + - set firewall name Downlink description 'IPv4 INBOUND rule set' + - set firewall name Downlink rule 501 action 'accept' + - set firewall name Downlink rule 501 + - set firewall name Downlink rule 501 description 'Rule 501 is configured by Ansible' + - set firewall name Downlink rule 501 ipsec 'match-ipsec' + - set firewall name Downlink rule 502 action 'reject' + - set firewall name Downlink rule 502 + - set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' + - set firewall name Downlink rule 502 ipsec 'match-ipsec' + after: + - afi: ipv4 + rule_sets: + - name: Downlink + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 501 + action: accept + description: Rule 501 is configured by Ansible + ipsec: match-ipsec + - number: 502 + action: reject + description: Rule 502 is configured by Ansible + ipsec: match-ipsec +parsed: + after: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true +rendered: + commands: + - set firewall ipv6-name UPLINK default-action 'accept' + - set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + - set firewall name INBOUND default-action 'accept' + - set firewall name INBOUND description 'IPv4 INBOUND rule set' + - set firewall name INBOUND rule 101 action 'accept' + - set firewall name INBOUND rule 101 + - set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + - set firewall name INBOUND rule 101 ipsec 'match-ipsec' + - set firewall name INBOUND rule 102 action 'reject' + - set firewall name INBOUND rule 102 + - set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + - set firewall name INBOUND rule 102 ipsec 'match-ipsec' + - set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + - set firewall name INBOUND rule 103 destination group address-group inbound + - set firewall name INBOUND rule 103 + - set firewall name INBOUND rule 103 source address 192.0.2.0 + - set firewall name INBOUND rule 103 state established enable + - set firewall name INBOUND rule 103 state related enable + - set firewall name INBOUND rule 103 state invalid disable + - set firewall name INBOUND rule 103 state new disable + - set firewall name INBOUND rule 103 action 'accept' +deleted_rs: + commands: + - delete firewall ipv6-name UPLINK + - delete firewall name INBOUND + after: [] +deleted_afi_all: + commands: + - delete firewall ipv6-name + - delete firewall name + after: [] +round_trip: + after: + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..b50d7daf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tests/cli/basic.yaml @@ -0,0 +1,248 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Run vyos lsmod command + register: lsmod_out + vyos.vyos.vyos_command: + commands: + - lsmod + +- name: Set up - delete interface + vyos.vyos.vyos_interface: + name: eth1 + state: absent + +- name: Set up - Create interface + register: result + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1" in result.commands' + - "\"set interfaces ethernet eth1 description 'test-interface'\" in result.commands" + +- name: Configure interface params + when: "'virtio_net' not in lsmod_out.stdout[0]" + register: result + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface-1 + speed: 100 + duplex: half + mtu: 256 + +- assert: + that: + - result.changed == true + - "\"set interfaces ethernet eth1 description 'test-interface-1'\" in result.commands" + - '"set interfaces ethernet eth1 speed 100" in result.commands' + - '"set interfaces ethernet eth1 duplex half" in result.commands' + - '"set interfaces ethernet eth1 mtu 256" in result.commands' + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- name: Configure interface params (idempotent) + register: result + when: "'virtio_net' not in lsmod_out.stdout[0]" + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface-1 + speed: 100 + duplex: half + mtu: 256 + +- assert: + that: + - result.changed == false + when: "'virtio' not in lsmod_out.stdout[0]" + +- name: Change interface params + register: result + when: "'virtio_net' not in lsmod_out.stdout[0]" + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface-2 + speed: 1000 + duplex: full + mtu: 512 + +- assert: + that: + - result.changed == true + - "\"set interfaces ethernet eth1 description 'test-interface-2'\" in result.commands" + - '"set interfaces ethernet eth1 speed 1000" in result.commands' + - '"set interfaces ethernet eth1 duplex full" in result.commands' + - '"set interfaces ethernet eth1 mtu 512" in result.commands' + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- name: Disable interface + register: result + vyos.vyos.vyos_interface: + name: eth1 + enabled: false + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1 disable" in result.commands' + +- name: Enable interface + register: result + vyos.vyos.vyos_interface: + name: eth1 + enabled: true + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 disable" in result.commands' + +- name: Delete interface + register: result + vyos.vyos.vyos_interface: + name: eth1 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1" in result.commands' + +- name: Delete interface (idempotent) + register: result + vyos.vyos.vyos_interface: + name: eth1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Aggregate setup- delete interface + register: result + vyos.vyos.vyos_interface: + name: eth2 + state: absent + +- name: Set interface on aggregate + register: result + when: "'virtio_net' not in lsmod_out.stdout[0]" + vyos.vyos.vyos_interface: + aggregate: + + - name: eth1 + description: test-interface-1 + speed: 100 + duplex: half + mtu: 512 + + - name: eth2 + description: test-interface-2 + speed: 1000 + duplex: full + mtu: 256 + +- assert: + that: + - result.changed == true + - "\"set interfaces ethernet eth1 description 'test-interface-1'\" in result.commands" + - '"set interfaces ethernet eth1 speed 100" in result.commands' + - '"set interfaces ethernet eth1 duplex half" in result.commands' + - '"set interfaces ethernet eth1 mtu 512" in result.commands' + - "\"set interfaces ethernet eth2 description 'test-interface-2'\" in result.commands" + - '"set interfaces ethernet eth2 speed 1000" in result.commands' + - '"set interfaces ethernet eth2 duplex full" in result.commands' + - '"set interfaces ethernet eth2 mtu 256" in result.commands' + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- name: Set interface on aggregate (idempotent) + register: result + when: "'virtio_net' not in lsmod_out.stdout[0]" + vyos.vyos.vyos_interface: + aggregate: + + - name: eth1 + description: test-interface-1 + speed: 100 + duplex: half + mtu: 512 + + - name: eth2 + description: test-interface-2 + speed: 1000 + duplex: full + mtu: 256 + +- assert: + that: + - result.changed == false + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- name: Disable interface on aggregate + register: result + vyos.vyos.vyos_interface: + aggregate: + + - name: eth1 + + - name: eth2 + description: test-interface + enabled: false + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1 disable" in result.commands' + - '"set interfaces ethernet eth2 disable" in result.commands' + +- name: Enable interface on aggregate + register: result + vyos.vyos.vyos_interface: + aggregate: + + - name: eth1 + + - name: eth2 + enabled: true + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 disable" in result.commands' + - '"delete interfaces ethernet eth2 disable" in result.commands' + +- name: Delete interface aggregate + register: result + vyos.vyos.vyos_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1" in result.commands' + - '"delete interfaces ethernet eth2" in result.commands' + +- name: Delete interface aggregate (idempotent) + register: result + vyos.vyos.vyos_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: absent + +- assert: + that: + - result.changed == false diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml new file mode 100644 index 00000000..045daa25 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml @@ -0,0 +1,55 @@ +--- +- debug: msg="START vyos cli/net_interface.yaml on connection={{ ansible_connection + }}" + +- name: Run vyos lsmod command + register: lsmod_out + vyos.vyos.vyos_command: + commands: + - lsmod + +- name: Set up - delete interface + ansible.netcommon.net_interface: + name: eth1 + state: absent + +- name: Create interface using platform agnostic module + register: result + ansible.netcommon.net_interface: + name: eth1 + state: present + description: test-interface + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1" in result.commands' + - "\"set interfaces ethernet eth1 description 'test-interface'\" in result.commands" + +- name: Configure interface params using platform agnostic module + when: "'virtio_net' not in lsmod_out.stdout[0]" + register: result + ansible.netcommon.net_interface: + name: eth1 + state: present + description: test-interface-1 + speed: 100 + duplex: half + mtu: 256 + +- assert: + that: + - result.changed == true + - "\"set interfaces ethernet eth1 description 'test-interface-1'\" in result.commands" + - '"set interfaces ethernet eth1 speed 100" in result.commands' + - '"set interfaces ethernet eth1 duplex half" in result.commands' + - '"set interfaces ethernet eth1 mtu 256" in result.commands' + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- name: teardown - delete interface + ansible.netcommon.net_interface: + name: eth1 + state: absent + +- debug: msg="END vyos cli/net_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..e5c3fc78 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,12 @@ +set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1' +set interfaces ethernet eth1 duplex 'auto' +set interfaces ethernet eth1 hw-id '08:00:27:da:67:43' +set interfaces ethernet eth1 mtu '1500' +set interfaces ethernet eth1 speed 'auto' +set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' +set interfaces ethernet eth1 vif 100 mtu '400' +set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' +set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)' +set interfaces ethernet eth2 'disable' +set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0' +set interfaces ethernet eth2 mtu '600' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml new file mode 100644 index 00000000..686236f2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,15 @@ +--- +- name: Setup + vars: + lines: "set interfaces ethernet \"{{ intf }}\" description 'Configured by Ansible'\n\ + set interfaces ethernet \"{{ intf }}\" speed 'auto'\nset interfaces ethernet\ + \ \"{{ intf }}\" duplex 'auto'\nset interfaces ethernet \"{{ intf }}\" mtu\ + \ '1500'\nset interfaces ethernet \"{{ intf }}\" vif 200\nset interfaces ethernet\ + \ \"{{ intf }}\" vif 200 description 'VIF - 200'\n" + loop: + - eth1 + - eth2 + loop_control: + loop_var: intf + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..298cf5d7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- name: Remove Config + vars: + lines: "delete interfaces ethernet \"{{ intf }}\" description\ndelete interfaces\ + \ ethernet \"{{ intf }}\" speed\ndelete interfaces ethernet \"{{ intf }}\"\ + \ duplex\ndelete interfaces ethernet \"{{ intf }}\" mtu\ndelete interfaces\ + \ ethernet \"{{ intf }}\" disable\ndelete interfaces ethernet \"{{ intf }}\"\ + \ vif\n" + loop: + - eth1 + - eth2 + loop_control: + loop_var: intf + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..56e747a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of given interfaces + register: result + vyos.vyos.vyos_interfaces: &id001 + config: + + - name: eth1 + + - name: eth2 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..652f1589 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..ac9892cb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,26 @@ +--- +- debug: + msg: START vyos_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_interfaces: + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..e0fa0b97 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml @@ -0,0 +1,69 @@ +--- +- debug: + msg: START vyos_interfaces merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_interfaces: &id001 + config: + + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + vifs: + + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + + - vlan_id: 101 + description: Eth1 - VIF 101 + + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..9921e5dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,59 @@ +--- +- debug: + msg: START vyos_interfaces overridden integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_interfaces: &id001 + config: + + - name: eth0 + speed: auto + duplex: auto + + - name: eth2 + description: Overridden by Ansible + mtu: 1200 + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..a44fc2f3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided interfaces config to agnostic model + register: result + vyos.vyos.vyos_interfaces: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..5030d718 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: START vyos_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_interfaces: + config: + - name: eth0 + enabled: true + duplex: auto + speed: auto + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + enabled: true + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 + enabled: true + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..8b68c5a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: START vyos_interfaces replaced integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed interfaces with provided configurations + register: result + vyos.vyos.vyos_interfaces: &id001 + config: + + - name: eth1 + description: Replaced by Ansible + vifs: + + - vlan_id: 100 + description: VIF 100 - Replaced by Ansible + + - name: eth2 + mtu: 1400 + description: Replaced by Ansible + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed interfaces with provided configurarions + (IDEMPOTENT) + register: result + vyos.vyos.vyos_interfaces: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml new file mode 100644 index 00000000..f003c0bb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml @@ -0,0 +1,86 @@ +--- +- debug: + msg: START vyos_interfaces round trip integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_interfaces: + config: + + - name: eth0 + enabled: true + duplex: auto + speed: auto + + - name: eth1 + description: Interface - 1 + mtu: 1500 + vifs: + + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 200 + + - vlan_id: 101 + enabled: false + + - name: eth2 + description: Interface - 2 + enabled: true + mtu: 900 + state: merged + + - name: Gather interfaces facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_interfaces: + config: + + - name: eth1 + description: Interface 1 - Description (WILL BE REVERTED) + mtu: 1200 + vifs: + + - vlan_id: 100 + description: Eth1 - VIF 100 (WILL BE REVERTED) + mtu: 400 + + - vlan_id: 101 + description: Eth1 - VIF 101 (WILL BE REMOVED) + enabled: true + + - name: eth2 + description: Interface 2 (ADMIN DOWN) (WILL BE REVERTED) + mtu: 600 + enabled: false + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_interfaces: + config: "{{ ansible_facts['network_resources']['interfaces'] }}" + state: replaced + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..d2e501a3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START shortname integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.interfaces: &id001 + config: + + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + vifs: + + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + + - vlan_id: 101 + description: Eth1 - VIF 101 + + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/vars/main.yaml new file mode 100644 index 00000000..83d0e590 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_interfaces/vars/main.yaml @@ -0,0 +1,218 @@ +--- +merged: + before: + - name: eth0 + enabled: true + speed: auto + duplex: auto + - name: eth1 + enabled: true + - name: eth2 + enabled: true + commands: + - set interfaces ethernet eth1 description 'Configured by Ansible - Interface + 1' + - set interfaces ethernet eth1 mtu '1500' + - set interfaces ethernet eth1 duplex 'auto' + - set interfaces ethernet eth1 speed 'auto' + - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' + - set interfaces ethernet eth1 vif 100 mtu '400' + - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' + - set interfaces ethernet eth2 description 'Configured by Ansible - Interface + 2 (ADMIN DOWN)' + - set interfaces ethernet eth2 mtu '600' + - set interfaces ethernet eth2 disable + after: + - name: eth0 + enabled: true + duplex: auto + speed: auto + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + enabled: true + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 + enabled: true + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false +populate: + - name: eth1 + enabled: true + speed: auto + duplex: auto + description: Configured by Ansible + mtu: 1500 + vifs: + - vlan_id: 200 + enabled: true + description: VIF - 200 + - name: eth2 + enabled: true + speed: auto + duplex: auto + description: Configured by Ansible + mtu: 1500 + vifs: + - vlan_id: 200 + enabled: true + description: VIF - 200 + - name: eth0 + enabled: true + duplex: auto + speed: auto +replaced: + commands: + - delete interfaces ethernet eth1 mtu + - delete interfaces ethernet eth1 speed + - delete interfaces ethernet eth1 duplex + - delete interfaces ethernet eth1 vif 200 description + - set interfaces ethernet eth1 description 'Replaced by Ansible' + - set interfaces ethernet eth1 vif 100 description 'VIF 100 - Replaced by Ansible' + - delete interfaces ethernet eth2 speed + - delete interfaces ethernet eth2 duplex + - delete interfaces ethernet eth2 vif 200 description + - set interfaces ethernet eth2 description 'Replaced by Ansible' + - set interfaces ethernet eth2 mtu '1400' + after: + - name: eth1 + description: Replaced by Ansible + enabled: true + vifs: + - vlan_id: 100 + enabled: true + description: VIF 100 - Replaced by Ansible + - vlan_id: 200 + enabled: true + - name: eth2 + mtu: 1400 + description: Replaced by Ansible + enabled: true + vifs: + - vlan_id: 200 + enabled: true + - name: eth0 + enabled: true + duplex: auto + speed: auto +parsed: + after: + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + enabled: true + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 + enabled: true + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false +overridden: + commands: + - delete interfaces ethernet eth1 description + - delete interfaces ethernet eth1 speed + - delete interfaces ethernet eth1 duplex + - delete interfaces ethernet eth1 mtu + - delete interfaces ethernet eth1 vif 200 description + - delete interfaces ethernet eth2 speed + - delete interfaces ethernet eth2 duplex + - delete interfaces ethernet eth2 vif 200 description + - set interfaces ethernet eth2 description 'Overridden by Ansible' + - set interfaces ethernet eth2 mtu '1200' + after: + - name: eth0 + enabled: true + speed: auto + duplex: auto + - name: eth1 + enabled: true + vifs: + - vlan_id: 200 + enabled: true + - name: eth2 + enabled: true + description: Overridden by Ansible + mtu: 1200 + vifs: + - vlan_id: 200 + enabled: true +rendered: + commands: + - set interfaces ethernet eth0 duplex 'auto' + - set interfaces ethernet eth0 speed 'auto' + - set interfaces ethernet eth1 duplex 'auto' + - set interfaces ethernet eth1 speed 'auto' + - set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1' + - set interfaces ethernet eth1 mtu '1500' + - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' + - set interfaces ethernet eth1 vif 100 mtu '400' + - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' + - set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)' + - set interfaces ethernet eth2 mtu '600' + +deleted: + commands: + - delete interfaces ethernet eth1 description + - delete interfaces ethernet eth1 speed + - delete interfaces ethernet eth1 duplex + - delete interfaces ethernet eth1 mtu + - delete interfaces ethernet eth1 vif 200 description + - delete interfaces ethernet eth2 description + - delete interfaces ethernet eth2 speed + - delete interfaces ethernet eth2 duplex + - delete interfaces ethernet eth2 mtu + - delete interfaces ethernet eth2 vif 200 description + after: + - name: eth0 + enabled: true + speed: auto + duplex: auto + - name: eth1 + enabled: true + vifs: + - vlan_id: 200 + enabled: true + - name: eth2 + enabled: true + vifs: + - vlan_id: 200 + enabled: true +round_trip: + after: + - name: eth0 + enabled: true + speed: auto + duplex: auto + - name: eth1 + description: Interface 1 - Description (WILL BE REVERTED) + enabled: true + mtu: 1200 + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 (WILL BE REVERTED) + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 (WILL BE REMOVED) + enabled: true + - name: eth2 + description: Interface 2 (ADMIN DOWN) (WILL BE REVERTED) + mtu: 600 + enabled: false diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..2ffb1abd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml @@ -0,0 +1,231 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Remove IP address + vyos.vyos.vyos_l3_interface: + name: eth1 + state: absent + +- name: Remove IP address + vyos.vyos.vyos_l3_interface: + name: eth2 + state: absent + +- name: Set IPv4 address + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + +- name: Set IPv4 address (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + +- assert: + that: + - result.changed == false + +- name: Set IPv6 address + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' + +- name: Set IPv6 address (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + +- assert: + that: + - result.changed == false + +- name: Remove all IP addresses + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 address" in result.commands' + +- name: Remove all IP addresses again (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Set IPv4 and IPv6 address + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' + +- name: Set IPv4 and IPv6 address again (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + +- assert: + that: + - result.changed == false + +- name: Remove IPv4 address + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + +- name: Remove IPv4 address again (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + state: absent + +- assert: + that: + - result.changed == false + +- name: Remove IPv6 address + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' + +- name: Remove IPv6 address again (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + state: absent + +- assert: + that: + - result.changed == false + +- name: Set IP addresses on aggregate + register: result + vyos.vyos.vyos_l3_interface: + aggregate: + + - name: eth1 + ipv4: 192.168.2.10/24 + + - name: eth2 + ipv4: 192.168.3.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + + - name: eth2 + ipv4: 192.168.4.10/24 + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + - '"set interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' + - '"set interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' + - '"set interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' + +- name: Set IP addresses on aggregate (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + aggregate: + + - name: eth1 + ipv4: 192.168.2.10/24 + + - name: eth2 + ipv4: 192.168.3.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + + - name: eth2 + ipv4: 192.168.4.10/24 + +- assert: + that: + - result.changed == false + +- name: Remove IP addresses on aggregate + register: result + vyos.vyos.vyos_l3_interface: + aggregate: + + - name: eth1 + ipv4: 192.168.2.10/24 + + - name: eth2 + ipv4: 192.168.3.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + + - name: eth2 + ipv4: 192.168.4.10/24 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + - '"delete interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' + - '"delete interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' + - '"delete interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' + +- name: Remove IP addresses on aggregate (idempotent) + register: result + vyos.vyos.vyos_l3_interface: + aggregate: + + - name: eth1 + ipv4: 192.168.2.10/24 + + - name: eth2 + ipv4: 192.168.3.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + + - name: eth2 + ipv4: 192.168.4.10/24 + state: absent + +- assert: + that: + - result.changed == false diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/meta/main.yml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/meta/main.yml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..f622cf94 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + delegate_to: localhost + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..ef070a72 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,9 @@ +set interfaces ethernet eth1 address '192.0.2.10/24' +set interfaces ethernet eth1 address '2001:db8::10/32' +set interfaces ethernet eth1 hw-id '08:00:27:da:67:43' +set interfaces ethernet eth2 address '198.51.100.10/24' +set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0' +set interfaces ethernet eth2 vif 101 address '198.51.100.130/25' +set interfaces ethernet eth2 vif 101 address '2001:db8::20/32' + + diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml new file mode 100644 index 00000000..563b1d7b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,9 @@ +--- +- name: Setup + vars: + lines: "set interfaces ethernet eth1 address '192.0.2.14/24'\nset interfaces\ + \ ethernet eth2 address '192.0.2.10/24'\nset interfaces ethernet eth2 address\ + \ '192.0.2.11/24'\nset interfaces ethernet eth2 address '2001:db8::10/32'\n\ + set interfaces ethernet eth2 address '2001:db8::12/32'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..1fb0dd3e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,12 @@ +--- +- name: Remove Config + vars: + lines: "delete interfaces ethernet \"{{ intf }}\" address\ndelete interfaces\ + \ ethernet \"{{ intf }}\" vif\n" + loop: + - eth1 + - eth2 + loop_control: + loop_var: intf + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..ff4aabfd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - include_tasks: _populate.yaml + + - name: Delete attributes of given interfaces + register: result + vyos.vyos.vyos_l3_interfaces: &id001 + config: + + - name: eth1 + + - name: eth2 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_l3_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..9929dd7f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_l3_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_l3_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_l3_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_l3_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_l3_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_l3_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..625047bb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,34 @@ +--- +- debug: + msg: START vyos_l3_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_l3_interfaces: &id001 + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_l3_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..99fb5524 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml @@ -0,0 +1,72 @@ +--- +- debug: + msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_l3_interfaces: &id001 + config: + + - name: eth1 + ipv4: + + - address: 192.0.2.10/24 + ipv6: + + - address: 2001:db8::10/32 + + - name: eth2 + ipv4: + + - address: 198.51.100.10/24 + vifs: + + - vlan_id: 101 + ipv4: + + - address: 198.51.100.130/25 + ipv6: + + - address: 2001:db8::20/32 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_l3_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..644fe080 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - include_tasks: _populate.yaml + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_l3_interfaces: &id001 + config: + + - name: eth0 + ipv4: + + - address: dhcp + + - name: eth1 + ipv4: + + - address: 192.0.2.15/24 + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_l3_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..d5ff2056 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_l3_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided interfaces config to agnostic model + register: result + vyos.vyos.vyos_l3_interfaces: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..02a28655 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,44 @@ +--- +- debug: + msg: START vyos_l3_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_l3_interfaces: &id001 + config: + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: 2001:db8::10/32 + - address: 2001:db8::12/32 + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + vyos.vyos.vyos_l3_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..2c664bbd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,62 @@ +--- +- debug: + msg: START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - include_tasks: _populate.yaml + + - name: Replace device configurations of listed interfaces with provided configurations + register: result + vyos.vyos.vyos_l3_interfaces: &id001 + config: + + - name: eth1 + ipv4: + + - address: 192.0.2.19/24 + + - name: eth2 + ipv6: + + - address: 2001:db8::11/32 + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed interfaces with provided configurarions + (IDEMPOTENT) + register: result + vyos.vyos.vyos_l3_interfaces: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..33082d5f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml @@ -0,0 +1,43 @@ +--- +- debug: + msg: START l3_interfaces rendered on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.l3_interfaces: &id001 + config: + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: 2001:db8::10/32 + - address: 2001:db8::12/32 + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + vyos.vyos.l3_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml new file mode 100644 index 00000000..e9781e6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml @@ -0,0 +1,118 @@ +--- +merged: + before: + - name: eth0 + ipv4: + - address: dhcp + - name: eth1 + - name: eth2 + commands: + - set interfaces ethernet eth1 address '192.0.2.10/24' + - set interfaces ethernet eth1 address '2001:db8::10/32' + - set interfaces ethernet eth2 address '198.51.100.10/24' + - set interfaces ethernet eth2 vif 101 address '198.51.100.130/25' + - set interfaces ethernet eth2 vif 101 address '2001:db8::20/32' + after: + - name: eth0 + ipv4: + - address: dhcp + - name: eth1 + ipv4: + - address: 192.0.2.10/24 + ipv6: + - address: 2001:db8::10/32 + - name: eth2 + ipv4: + - address: 198.51.100.10/24 + vifs: + - vlan_id: 101 + ipv4: + - address: 198.51.100.130/25 + ipv6: + - address: 2001:db8::20/32 +populate: + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: 2001:db8::10/32 + - address: 2001:db8::12/32 + - name: eth0 + ipv4: + - address: dhcp +replaced: + commands: + - delete interfaces ethernet eth2 address '192.0.2.10/24' + - delete interfaces ethernet eth2 address '192.0.2.11/24' + - delete interfaces ethernet eth2 address '2001:db8::10/32' + - delete interfaces ethernet eth2 address '2001:db8::12/32' + - set interfaces ethernet eth2 address '2001:db8::11/32' + - delete interfaces ethernet eth1 address '192.0.2.14/24' + - set interfaces ethernet eth1 address '192.0.2.19/24' + after: + - name: eth2 + ipv6: + - address: 2001:db8::11/32 + - name: eth1 + ipv4: + - address: 192.0.2.19/24 + - name: eth0 + ipv4: + - address: dhcp +overridden: + commands: + - delete interfaces ethernet eth1 address '192.0.2.14/24' + - set interfaces ethernet eth1 address '192.0.2.15/24' + - delete interfaces ethernet eth2 address '192.0.2.10/24' + - delete interfaces ethernet eth2 address '192.0.2.11/24' + - delete interfaces ethernet eth2 address '2001:db8::10/32' + - delete interfaces ethernet eth2 address '2001:db8::12/32' + after: + - name: eth0 + ipv4: + - address: dhcp + - name: eth1 + ipv4: + - address: 192.0.2.15/24 + - name: eth2 +parsed: + after: + - name: eth1 + ipv4: + - address: 192.0.2.10/24 + ipv6: + - address: 2001:db8::10/32 + - name: eth2 + ipv4: + - address: 198.51.100.10/24 + vifs: + - vlan_id: 101 + ipv4: + - address: 198.51.100.130/25 + ipv6: + - address: 2001:db8::20/32 +rendered: + commands: + - set interfaces ethernet eth1 address '192.0.2.14/24' + - set interfaces ethernet eth2 address '192.0.2.11/24' + - set interfaces ethernet eth2 address '192.0.2.10/24' + - set interfaces ethernet eth2 address '2001:db8::10/32' + - set interfaces ethernet eth2 address '2001:db8::12/32' + +deleted: + commands: + - delete interfaces ethernet eth1 address '192.0.2.14/24' + - delete interfaces ethernet eth2 address '192.0.2.10/24' + - delete interfaces ethernet eth2 address '192.0.2.11/24' + - delete interfaces ethernet eth2 address '2001:db8::10/32' + - delete interfaces ethernet eth2 address '2001:db8::12/32' + after: + - name: eth0 + ipv4: + - address: dhcp + - name: eth1 + - name: eth2 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml new file mode 100644 index 00000000..927a6cec --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml @@ -0,0 +1,6 @@ +--- +- name: Add Bond + vars: + lines: "set interfaces bonding bond0\nset interfaces bonding bond1\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..ea3bfce6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,8 @@ +set interfaces bonding bond0 hash-policy 'layer2' +set interfaces bonding bond0 mode 'active-backup' +set interfaces bonding bond0 primary 'eth1' +set interfaces bonding bond1 hash-policy 'layer2+3' +set interfaces bonding bond1 mode 'active-backup' +set interfaces bonding bond1 primary 'eth2' +set interfaces ethernet eth1 bond-group 'bond0' +set interfaces ethernet eth2 bond-group 'bond1'
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml new file mode 100644 index 00000000..f6467425 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,11 @@ +--- +- name: Setup + vars: + lines: "set interfaces bonding bond0\nset interfaces bonding bond0 hash-policy\ + \ 'layer2'\nset interfaces bonding bond0 mode 'active-backup'\nset interfaces\ + \ ethernet eth1 bond-group bond0\nset interfaces bonding bond1\nset interfaces\ + \ bonding bond0 primary 'eth1'\nset interfaces bonding bond1 hash-policy 'layer2+3'\n\ + set interfaces bonding bond1 mode 'active-backup'\nset interfaces ethernet\ + \ eth2 bond-group bond1\nset interfaces bonding bond1 primary 'eth2'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml new file mode 100644 index 00000000..6679d6a0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Bond + vars: + lines: "delete interfaces bonding bond0\ndelete interfaces bonding bond1\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..5469bf58 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,10 @@ +--- +- name: Remove Config + vars: + lines: "delete interfaces bonding bond0 hash-policy\ndelete interfaces ethernet\ + \ eth1 bond-group bond0\ndelete interfaces bonding bond0 mode\ndelete interfaces\ + \ bonding bond0 primary\ndelete interfaces bonding bond1 hash-policy\ndelete\ + \ interfaces ethernet eth2 bond-group bond1\ndelete interfaces bonding bond1\ + \ mode\ndelete interfaces bonding bond1 primary\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..ac8204f9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: Start vyos_lag_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of given LAG interfaces. + register: result + vyos.vyos.vyos_lag_interfaces: &id001 + config: + + - name: bond0 + + - name: bond1 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..6e89eaed --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_lag_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lag_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lag_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lag_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lag_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lag_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..aca168dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,26 @@ +--- +- debug: + msg: START vyos_lag_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_lag_interfaces: &id001 + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..35f1e358 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml @@ -0,0 +1,70 @@ +--- +- debug: + msg: START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_bond.yaml + +- include_tasks: _add_bond.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_lag_interfaces: &id001 + config: + + - name: bond0 + hash_policy: layer2 + mode: active-backup + members: + + - member: eth1 + primary: eth1 + + - name: bond1 + hash_policy: layer2+3 + mode: active-backup + members: + + - member: eth2 + primary: eth2 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..aa6e2473 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START vyos_lag_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_bond.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_lag_interfaces: &id001 + config: + + - name: bond1 + mode: active-backup + members: + + - member: eth2 + primary: eth2 + hash_policy: layer2 + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..ed7bc612 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,33 @@ +--- +- debug: + msg: START vyos_lag_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather lag_interfaces facts + register: lag_interfaces_facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - lag_interfaces + + - name: Provide the running configuration for parsing (config to be parsed) + register: result + vyos.vyos.vyos_lag_interfaces: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + + - name: Assert that correct parsing done + assert: + that: "{{ ansible_facts['network_resources']['lag_interfaces'] | symmetric_difference(result['parsed'])\ + \ |length == 0 }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..e6d7928c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START vyos_lag_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_lag_interfaces: + config: + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..c080056d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed LAG interfaces with provided + configurations + register: result + vyos.vyos.vyos_lag_interfaces: &id001 + config: + + - name: bond1 + mode: 802.3ad + hash_policy: layer2 + members: + + - member: eth2 + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed LAG interfaces with provided + configurarions (IDEMPOTENT) + register: result + vyos.vyos.vyos_lag_interfaces: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml new file mode 100644 index 00000000..55e2bbf5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml @@ -0,0 +1,78 @@ +--- +- debug: + msg: START vyos_lag_interfaces round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_bond.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_lag_interfaces: + config: + + - name: bond0 + hash_policy: layer2 + mode: active-backup + members: + + - member: eth1 + primary: eth1 + + - name: bond1 + hash_policy: layer2+3 + mode: active-backup + members: + + - member: eth2 + primary: eth2 + state: merged + + - name: Gather lag_interfaces facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - lag_interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_lag_interfaces: + config: + + - name: bond0 + hash_policy: layer2+3 + mode: 802.3ad + members: + + - member: eth1 + + - name: bond1 + hash_policy: layer2 + mode: xor-hash + members: + + - member: eth2 + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_lag_interfaces: + config: "{{ ansible_facts['network_resources']['lag_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..be1cdc4c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml @@ -0,0 +1,69 @@ +--- +- debug: + msg: START lag_interfaces merged on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _remove_bond.yaml + +- include_tasks: _add_bond.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.lag_interfaces: &id001 + config: + + - name: bond0 + hash_policy: layer2 + mode: active-backup + members: + + - member: eth1 + primary: eth1 + + - name: bond1 + hash_policy: layer2+3 + mode: active-backup + members: + + - member: eth2 + primary: eth2 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml new file mode 100644 index 00000000..9784fb97 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml @@ -0,0 +1,109 @@ +--- +merged: + before: + - name: bond0 + - name: bond1 + commands: + - set interfaces bonding bond0 hash-policy 'layer2' + - set interfaces bonding bond0 mode 'active-backup' + - set interfaces ethernet eth1 bond-group 'bond0' + - set interfaces bonding bond0 primary 'eth1' + - set interfaces bonding bond1 hash-policy 'layer2+3' + - set interfaces bonding bond1 mode 'active-backup' + - set interfaces ethernet eth2 bond-group 'bond1' + - set interfaces bonding bond1 primary 'eth2' + after: + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 +populate: + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 +replaced: + commands: + - delete interfaces bonding bond1 primary + - set interfaces bonding bond1 hash-policy 'layer2' + - set interfaces bonding bond1 mode '802.3ad' + after: + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2 + members: + - member: eth2 + mode: 802.3ad +overridden: + commands: + - delete interfaces bonding bond0 hash-policy + - delete interfaces ethernet eth1 bond-group 'bond0' + - delete interfaces bonding bond0 mode + - delete interfaces bonding bond0 primary + - set interfaces bonding bond1 hash-policy 'layer2' + after: + - name: bond0 + - name: bond1 + hash_policy: layer2 + members: + - member: eth2 + mode: active-backup + primary: eth2 +deleted: + commands: + - delete interfaces bonding bond0 hash-policy + - delete interfaces ethernet eth1 bond-group 'bond0' + - delete interfaces bonding bond0 mode + - delete interfaces bonding bond0 primary + - delete interfaces bonding bond1 hash-policy + - delete interfaces ethernet eth2 bond-group 'bond1' + - delete interfaces bonding bond1 mode + - delete interfaces bonding bond1 primary + after: + - name: bond0 + - name: bond1 +rendered: + commands: + - set interfaces bonding bond0 hash-policy 'layer2' + - set interfaces ethernet eth1 bond-group 'bond0' + - set interfaces bonding bond0 mode 'active-backup' + - set interfaces bonding bond0 primary 'eth1' + - set interfaces bonding bond1 hash-policy 'layer2+3' + - set interfaces ethernet eth2 bond-group 'bond1' + - set interfaces bonding bond1 mode 'active-backup' + - set interfaces bonding bond1 primary 'eth2' +round_trip: + after: + - name: bond0 + hash_policy: layer2+3 + members: + - member: eth1 + mode: 802.3ad + primary: eth1 + - name: bond1 + hash_policy: layer2 + members: + - member: eth2 + mode: xor-hash + primary: eth2 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml new file mode 100644 index 00000000..ffe0c42e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml @@ -0,0 +1,200 @@ +--- +- debug: msg="cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Remove linkagg + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + +- name: Remove linkagg + vyos.vyos.vyos_linkagg: + name: bond1 + state: absent + +- name: Create linkagg + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth1 + state: present + +- assert: + that: + - result.changed == true + - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' + +- name: Create linkagg again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth1 + state: present + +- assert: + that: + - result.changed == false + +- name: Add linkagg member + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth2 + state: present + +- assert: + that: + - result.changed == true + - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' + +- name: Add linkagg member again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth2 + state: present + +- assert: + that: + - result.changed == false + +- name: Disable linkagg + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + state: down + +- assert: + that: + - result.changed == true + - '"set interfaces bonding bond0 disable" in result.commands' + +- name: Disable linkagg again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + state: down + +- assert: + that: + - result.changed == false + +- name: Enable linkagg + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + state: up + +- assert: + that: + - result.changed == true + - '"delete interfaces bonding bond0 disable" in result.commands[0]' + +- name: Enable linkagg again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + state: up + +- assert: + that: + - result.changed == false + +- name: Remove linkagg + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 bond-group" in result.commands' + - '"delete interfaces ethernet eth2 bond-group" in result.commands' + - '"delete interfaces bonding bond0" in result.commands' + +- name: Remove linkagg again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + +- assert: + that: + - result.changed == false + +- name: Create collection of linkagg definitions + register: result + vyos.vyos.vyos_linkagg: + aggregate: + + - name: bond0 + members: + - eth1 + + - name: bond1 + members: + - eth2 + state: present + +- assert: + that: + - result.changed == true + - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' + - '"set interfaces bonding bond1 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth2 bond-group bond1" in result.commands' + +- name: Create collection of linkagg definitions again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + aggregate: + + - name: bond0 + members: + - eth1 + + - name: bond1 + members: + - eth2 + state: present + +- assert: + that: + - result.changed == false + +- name: Remove collection of linkagg definitions + register: result + vyos.vyos.vyos_linkagg: + aggregate: + + - name: bond0 + + - name: bond1 + state: absent + +- assert: + that: + - result.changed == true + - '"delete interfaces ethernet eth1 bond-group" in result.commands' + - '"delete interfaces bonding bond0" in result.commands' + - '"delete interfaces ethernet eth2 bond-group" in result.commands' + - '"delete interfaces bonding bond1" in result.commands' + +- name: Remove collection of linkagg definitions again (idempotent) + register: result + vyos.vyos.vyos_linkagg: + aggregate: + + - name: bond0 + + - name: bond1 + state: absent + +- assert: + that: + - result.changed == false diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml new file mode 100644 index 00000000..8178f921 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml @@ -0,0 +1,30 @@ +--- +- debug: msg="START vyos cli/net_linkagg.yaml on connection={{ ansible_connection + }}" + +- name: Remove linkagg - set + ansible.netcommon.net_linkagg: + name: bond0 + state: absent + +- name: Create linkagg using platform agnostic module + register: result + ansible.netcommon.net_linkagg: + name: bond0 + members: + - eth1 + state: present + +- assert: + that: + - result.changed == true + - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' + - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' + +- name: Remove linkagg - teardown + ansible.netcommon.net_linkagg: + name: bond0 + state: absent + +- debug: msg="END vyos cli/net_linkagg.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml new file mode 100644 index 00000000..b108bbfc --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Make sure LLDP is not running before tests + vyos.vyos.vyos_config: + lines: delete service lldp + +- name: Enable LLDP service + register: result + vyos.vyos.vyos_lldp: + state: present + +- assert: + that: + - result.changed == true + - '"set service lldp" in result.commands' + +- name: Enable LLDP service again (idempotent) + register: result + vyos.vyos.vyos_lldp: + state: present + +- assert: + that: + - result.changed == false + +- name: Disable LLDP service + register: result + vyos.vyos.vyos_lldp: + state: absent + +- assert: + that: + - result.changed == true + - '"delete service lldp" in result.commands' + +- name: + register: result + vyos.vyos.vyos_lldp: + state: absent + +- assert: + that: + - result.changed == false diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml new file mode 100644 index 00000000..d19b126c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml @@ -0,0 +1,22 @@ +--- +- debug: msg="START vyos cli/net_lldp.yaml on connection={{ ansible_connection }}" + +- name: Make sure LLDP is not running - setup + vyos.vyos.vyos_config: + lines: delete service lldp + +- name: Enable LLDP service using platform agnostic module + register: result + ansible.netcommon.net_lldp: + state: present + +- assert: + that: + - result.changed == true + - '"set service lldp" in result.commands' + +- name: Make sure LLDP is not running - teardown + vyos.vyos.vyos_config: + lines: delete service lldp + +- debug: msg="END vyos cli/net_lldp.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..9c9f66c5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_parsed_config.cfg @@ -0,0 +1,3 @@ +set service lldp legacy-protocols 'fdp' +set service lldp legacy-protocols 'cdp' +set service lldp management-address '192.0.2.17' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml new file mode 100644 index 00000000..e4392426 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml @@ -0,0 +1,7 @@ +--- +- name: Setup + vars: + lines: "set service lldp\nset service lldp legacy-protocols 'cdp'\nset service\ + \ lldp management-address '192.0.2.17'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..b8234491 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml @@ -0,0 +1,7 @@ +--- +- name: Remove Config + vars: + lines: "delete service lldp legacy-protocols\ndelete service lldp management-address\n\ + delete service lldp\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml new file mode 100644 index 00000000..f4c6cbc5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: Start vyos_lldp_global deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of LLDP service. + register: result + vyos.vyos.vyos_lldp_global: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate == result['before']}}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['after']}}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml new file mode 100644 index 00000000..0333fa41 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: START vyos_lldp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_global: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_global: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_global: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_global: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml new file mode 100644 index 00000000..95e01de6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml @@ -0,0 +1,25 @@ +--- +- debug: + msg: START vyos_lldp_global gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_lldp_global: + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate == result['gathered'] }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml new file mode 100644 index 00000000..aeabc9f6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: START vyos_lldp_global merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_lldp_global: &id001 + config: + legacy_protocols: + - fdp + - cdp + address: 192.0.2.11 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_global: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml new file mode 100644 index 00000000..b9c3abf0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml @@ -0,0 +1,15 @@ +--- +- debug: + msg: START vyos_lldp_global parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided LLDP global config to agnostic model + register: result + vyos.vyos.vyos_lldp_global: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] == result['parsed'] }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml new file mode 100644 index 00000000..5e9f4c5a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml @@ -0,0 +1,28 @@ +--- +- debug: + msg: START vyos_lldp_global rendered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_lldp_global: + config: + address: 192.0.2.17 + enable: true + legacy_protocols: + - cdp + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml new file mode 100644 index 00000000..9a833f5e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml @@ -0,0 +1,55 @@ +--- +- debug: + msg: START vyos_lldp_global replaced integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of LLDP service with provided configurations + register: result + vyos.vyos.vyos_lldp_global: &id001 + config: + legacy_protocols: + - edp + - sonmp + - cdp + address: 192.0.2.14 + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['after'] }}" + + - name: Replace device configurations of LLDP service with provided configurarions + (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_global: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml new file mode 100644 index 00000000..2e8284f1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: START vyos_lldp_global round trip integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_lldp_global: + config: + legacy_protocols: + - fdp + - cdp + address: 192.0.2.11 + state: merged + + - name: Gather vyos_lldp_global facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - lldp_global + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_lldp_global: + config: + legacy_protocols: + - edp + - sonmp + - cdp + address: 192.0.2.14 + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] == result['after'] }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_lldp_global: + config: "{{ ansible_facts['network_resources']['lldp_global'] }}" + state: replaced + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] == revert['after'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/vars/main.yaml new file mode 100644 index 00000000..622b8e4d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_global/vars/main.yaml @@ -0,0 +1,60 @@ +--- +merged: + before: + address: 192.0.2.17 + enable: true + legacy_protocols: + - cdp + commands: + - set service lldp management-address '192.0.2.11' + - set service lldp legacy-protocols 'fdp' + after: + address: 192.0.2.11 + enable: true + legacy_protocols: + - cdp + - fdp +populate: + address: 192.0.2.17 + enable: true + legacy_protocols: + - cdp +replaced: + commands: + - set service lldp legacy-protocols 'edp' + - set service lldp legacy-protocols 'sonmp' + - set service lldp management-address '192.0.2.14' + after: + address: 192.0.2.14 + enable: true + legacy_protocols: + - cdp + - edp + - sonmp +parsed: + after: + address: 192.0.2.17 + enable: true + legacy_protocols: + - fdp + - cdp +rendered: + commands: + - set service lldp legacy-protocols 'cdp' + - set service lldp + - set service lldp management-address '192.0.2.17' +deleted: + commands: + - delete service lldp management-address + - delete service lldp legacy-protocols + after: + enable: true +round_trip: + after: + address: 192.0.2.14 + enable: true + legacy_protocols: + - cdp + - edp + - fdp + - sonmp diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..2697f484 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml @@ -0,0 +1,181 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Make sure LLDP is not running before tests + vyos.vyos.vyos_config: + lines: delete service lldp + +- name: Create LLDP configuration + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: present + +- assert: + that: + - result.changed == true + - '"set service lldp interface eth1" in result.commands' + +- name: Create LLDP configuration again (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: present + +- assert: + that: + - result.changed == false + +- name: Disable LLDP configuration + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: disabled + +- assert: + that: + - result.changed == true + - '"set service lldp interface eth1 disable" in result.commands' + +- name: Disable LLDP configuration again (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: disabled + +- assert: + that: + - result.changed == false + +- name: Enable LLDP configuration + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: enabled + +- assert: + that: + - result.changed == true + - '"delete service lldp interface eth1 disable" in result.commands' + +- name: Enable LLDP configuration again (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: enabled + +- assert: + that: + - result.changed == false + +- name: Delete LLDP configuration + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: absent + +- assert: + that: + - result.changed == true + - '"delete service lldp interface eth1" in result.commands' + +- name: Delete LLDP configuration again (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Create aggregate of LLDP interface configurations + register: result + vyos.vyos.vyos_lldp_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: present + +- assert: + that: + - result.changed == true + - '"set service lldp interface eth1" in result.commands' + - '"set service lldp interface eth2" in result.commands' + +- name: Create aggregate of LLDP interface configurations again (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: present + +- assert: + that: + - result.changed == false + +- name: Override LLDP interface configuration on aggregate + register: result + vyos.vyos.vyos_lldp_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: disabled + state: present + +- assert: + that: + - result.changed == true + - '"set service lldp interface eth2 disable" in result.commands' + +- name: Override LLDP interface configuration on aggregate again (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: disabled + state: present + +- assert: + that: + - result.changed == false + +- name: Delete aggregate of LLDP interface configurations + register: result + vyos.vyos.vyos_lldp_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: absent + +- assert: + that: + - result.changed == true + - '"delete service lldp interface eth1" in result.commands' + - '"delete service lldp interface eth2" in result.commands' + +- name: Delete aggregate of LLDP interface configurations (idempotent) + register: result + vyos.vyos.vyos_lldp_interface: + aggregate: + + - name: eth1 + + - name: eth2 + state: absent + +- assert: + that: + - result.changed == false diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml new file mode 100644 index 00000000..98fc93a4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml @@ -0,0 +1,25 @@ +--- +- debug: msg="START vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection + }}" + +- name: Make sure LLDP is not running - setup + vyos.vyos.vyos_config: + lines: delete service lldp + +- name: Create LLDP configuration using platform agnostic module + register: result + ansible.netcommon.net_lldp_interface: + name: eth1 + state: present + +- assert: + that: + - result.changed == true + - '"set service lldp interface eth1" in result.commands' + +- name: Make sure LLDP is not running - teardown + vyos.vyos.vyos_config: + lines: delete service lldp + +- debug: msg="END vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..40c96c40 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,6 @@ +set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' +set service lldp interface eth1 location civic-based country-code 'US' +set service lldp interface eth2 location coordinate-based altitude '2200' +set service lldp interface eth2 location coordinate-based datum 'WGS84' +set service lldp interface eth2 location coordinate-based latitude '33.524449N' +set service lldp interface eth2 location coordinate-based longitude '222.267255W'
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml new file mode 100644 index 00000000..4353cec4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,12 @@ +--- +- name: Setup + vars: + lines: "set service lldp interface eth1\nset service lldp interface eth1 location\ + \ civic-based country-code US\nset service lldp interface eth1 location civic-based\ + \ ca-type 0 ca-value ENGLISH\nset service lldp interface eth2\nset service\ + \ lldp interface eth2 location coordinate-based latitude 33.524449N\nset service\ + \ lldp interface eth2 location coordinate-based altitude 2200\nset service\ + \ lldp interface eth2 location coordinate-based datum WGS84\nset service lldp\ + \ interface eth2 location coordinate-based longitude 222.267255W\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml new file mode 100644 index 00000000..11e2940d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml @@ -0,0 +1,8 @@ +--- +- name: Setup + vars: + lines: "set service lldp interface eth2\nset service lldp interface eth2 location\ + \ civic-based country-code US\nset service lldp interface eth2 location civic-based\ + \ ca-type 0 ca-value ENGLISH\nset service lldp interface eth2 disable\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..a885f01a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Config + vars: + lines: "delete service lldp interface\ndelete service lldp\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..21bf96d0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,54 @@ +--- +- debug: + msg: Start vyos_lldp_interfaces deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of given LLDP interfaces. + register: result + vyos.vyos.vyos_lldp_interfaces: &id001 + config: + + - name: eth1 + + - name: eth2 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..4ef40c9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_lldp_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_lldp_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..180b62f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,25 @@ +--- +- debug: + msg: START vyos_lldp_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_lldp_interfaces: + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..657961ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml @@ -0,0 +1,67 @@ +--- +- debug: + msg: START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_lldp_interfaces: &id001 + config: + + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + + - ca_type: 0 + ca_value: ENGLISH + + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..3e6ce408 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,56 @@ +--- +- debug: + msg: START vyos_lldp_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate_intf.yaml + +- block: + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_lldp_interfaces: &id001 + config: + + - name: eth2 + location: + elin: 0000000911 + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate_intf | symmetric_difference(result['before']) |length ==\ + \ 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..0ca52bed --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_lldp_nterfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided interfaces config to agnostic model + register: result + vyos.vyos.vyos_lldp_interfaces: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..342e64b9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,37 @@ +--- +- debug: + msg: START vyos_lldp_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_lldp_interfaces: + config: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..3218e800 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,72 @@ +--- +- debug: + msg: START vyos_lldp_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed LLDP interfaces with provided + configurations + register: result + vyos.vyos.vyos_lldp_interfaces: &id001 + config: + + - name: eth2 + enable: false + location: + civic_based: + country_code: US + ca_info: + + - ca_type: 0 + ca_value: ENGLISH + + - name: eth1 + enable: false + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed LLDP interfaces with provided + configurarions (IDEMPOTENT) + register: result + vyos.vyos.vyos_lldp_interfaces: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml new file mode 100644 index 00000000..e6189a3d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml @@ -0,0 +1,63 @@ +--- +- debug: + msg: START vyos_lldp_interfaces round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_lldp_interfaces: + config: + + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + + - ca_type: 0 + ca_value: ENGLISH + state: merged + + - name: Gather lldp_interfaces facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - lldp_interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_lldp_interfaces: + config: + + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_lldp_interfaces: + config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..f43a8e81 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml @@ -0,0 +1,54 @@ +--- +- debug: + msg: START shortaname integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate_intf.yaml + +- block: + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.lldp_interfaces: &id001 + config: + + - name: eth2 + location: + elin: 0000000911 + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate_intf | symmetric_difference(result['before']) |length ==\ + \ 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml new file mode 100644 index 00000000..092f653c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml @@ -0,0 +1,136 @@ +--- +merged: + before: [] + commands: + - set service lldp interface eth1 location civic-based country-code 'US' + - set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + - set service lldp interface eth1 + - set service lldp interface eth2 location coordinate-based latitude '33.524449N' + - set service lldp interface eth2 location coordinate-based altitude '2200' + - set service lldp interface eth2 location coordinate-based datum 'WGS84' + - set service lldp interface eth2 location coordinate-based longitude '222.267255W' + - set service lldp interface eth2 + after: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N +populate: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N +rendered: + commands: + - set service lldp interface eth1 location civic-based country-code 'US' + - set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH' + - set service lldp interface eth1 + - set service lldp interface eth2 location coordinate-based latitude '33.524449N' + - set service lldp interface eth2 location coordinate-based altitude '2200' + - set service lldp interface eth2 location coordinate-based datum 'WGS84' + - set service lldp interface eth2 location coordinate-based longitude '222.267255W' + - set service lldp interface eth2 +replaced: + commands: + - delete service lldp interface eth2 location + - set service lldp interface eth2 'disable' + - set service lldp interface eth2 location civic-based country-code 'US' + - set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH' + - delete service lldp interface eth1 location + - set service lldp interface eth1 'disable' + - set service lldp interface eth1 location coordinate-based latitude '33.524449N' + - set service lldp interface eth1 location coordinate-based altitude '2200' + - set service lldp interface eth1 location coordinate-based datum 'WGS84' + - set service lldp interface eth1 location coordinate-based longitude '222.267255W' + after: + - name: eth2 + enable: false + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth1 + enable: false + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N +populate_intf: + - name: eth2 + enable: false + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH +overridden: + commands: + - delete service lldp interface eth2 location + - delete service lldp interface eth2 'disable' + - set service lldp interface eth2 location elin '0000000911' + after: + - name: eth2 + location: + elin: 0000000911 +parsed: + after: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N +deleted: + commands: + - delete service lldp interface eth1 + - delete service lldp interface eth2 + after: [] +round_trip: + after: + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tests/cli/basic.yaml new file mode 100644 index 00000000..a025047b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tests/cli/basic.yaml @@ -0,0 +1,155 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: set-up logging + register: result + vyos.vyos.vyos_logging: + dest: console + facility: all + level: info + state: present + +- assert: + that: + - result.changed == true + - '"set system syslog console facility all level info" in result.commands' + +- name: set-up logging again (idempotent) + register: result + vyos.vyos.vyos_logging: + dest: console + facility: all + level: info + state: present + +- assert: + that: + - result.changed == false + +- name: file logging + register: result + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: present + +- assert: + that: + - result.changed == true + - '"set system syslog file test facility all level notice" in result.commands' + +- name: file logging again (idempotent) + register: result + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: present + +- assert: + that: + - result.changed == false + +- name: delete logging + register: result + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: absent + +- assert: + that: + - result.changed == true + - '"delete system syslog file test facility all level notice" in result.commands' + +- name: delete logging again (idempotent) + register: result + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: absent + +- assert: + that: + - result.changed == false + +- name: Add logging collections + register: result + vyos.vyos.vyos_logging: + aggregate: + + - dest: file + name: test1 + facility: all + level: info + + - dest: file + name: test2 + facility: news + level: debug + state: present + +- assert: + that: + - result.changed == true + - '"set system syslog file test1 facility all level info" in result.commands' + - '"set system syslog file test2 facility news level debug" in result.commands' + +- name: Add and remove logging collections with overrides + register: result + vyos.vyos.vyos_logging: + aggregate: + + - dest: console + facility: all + level: info + + - dest: file + name: test1 + facility: all + level: info + state: absent + + - dest: console + facility: daemon + level: warning + state: present + +- assert: + that: + - result.changed == true + - '"delete system syslog file test1 facility all level info" in result.commands' + - '"set system syslog console facility daemon level warning" in result.commands' + +- name: Remove logging collections + register: result + vyos.vyos.vyos_logging: + aggregate: + + - dest: console + facility: all + level: info + + - dest: console + facility: daemon + level: warning + + - dest: file + name: test2 + facility: news + level: debug + state: absent + +- assert: + that: + - result.changed == true + - '"delete system syslog console facility all level info" in result.commands' + - '"delete system syslog console facility daemon level warning" in result.commands' + - '"delete system syslog file test2 facility news level debug" in result.commands' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml new file mode 100644 index 00000000..f8bda74c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START vyos cli/net_logging.yaml on connection={{ ansible_connection + }}" + +- name: delete logging - setup + register: result + ansible.netcommon.net_logging: + dest: file + name: test + facility: all + level: notice + state: absent + +- name: file logging using platform agnostic module + register: result + ansible.netcommon.net_logging: + dest: file + name: test + facility: all + level: notice + state: present + +- assert: + that: + - result.changed == true + - '"set system syslog file test facility all level notice" in result.commands' + +- name: delete logging - teardown + register: result + ansible.netcommon.net_logging: + dest: file + name: test + facility: all + level: notice + state: absent + +- debug: msg="END vyos cli/net_logging.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml new file mode 100644 index 00000000..b957d2f4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include: cli.yaml + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg new file mode 100644 index 00000000..aa576770 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed.cfg @@ -0,0 +1,6 @@ +set interfaces ethernet eth0 ip ospf cost '50' +set interfaces ethernet eth0 ip ospf priority '26' +set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore' +set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33' +set interfaces bonding bond2 ip ospf transmit-delay '45' +set interfaces bonding bond2 ipv6 ospfv3 'passive' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..54696e8d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,10 @@ +set interfaces ethernet eth1 firewall in name 'INBOUND' +set interfaces ethernet eth1 firewall out name 'OUTBOUND' +set interfaces ethernet eth1 firewall local name 'LOCAL' +set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth2 firewall in name 'INBOUND' +set interfaces ethernet eth2 firewall out name 'OUTBOUND' +set interfaces ethernet eth2 firewall local name 'LOCAL' +set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth0 + diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml new file mode 100644 index 00000000..c4749d3b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_populate.yaml @@ -0,0 +1,13 @@ +--- +- name: setup + vyos.vyos.vyos_config: + lines: + - set interfaces ethernet eth0 ip ospf cost 50 + - set interfaces ethernet eth0 ip ospf priority 26 + - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - set interfaces bonding bond2 ip ospf transmit-delay 45 + - set interfaces bonding bond2 ipv6 ospfv3 passive + ignore_errors: true + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..9a2e699b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- name: Remove pre-existing OSPF processes + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 ip ospf + - delete interfaces ethernet eth0 ipv6 ospfv3 + - delete interfaces ethernet eth1 ip ospf + - delete interfaces ethernet eth1 ipv6 ospfv3 + - delete interfaces bonding bond1 ip ospf + - delete interfaces bonding bond1 ipv6 ospfv3 + - delete interfaces bonding bond2 ip ospf + - delete interfaces bonding bond2 ipv6 ospfv3 + ignore_errors: true + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml new file mode 100644 index 00000000..573e6117 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: START vyos_ospf_interfaces deleted integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Delete the provided configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "bond2" + state: deleted + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 2 + - result.changed == true + - result.commands|symmetric_difference(deleted.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Delete the existing configuration with the provided running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml new file mode 100644 index 00000000..aff0f66f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_ospf_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospf_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..ec320c3f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START vyos_ospf_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather config from the device in structured format. + register: result + vyos.vyos.vyos_ospf_interfaces: + state: gathered + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.changed == false + - result.gathered|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml new file mode 100644 index 00000000..294b6f1d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml @@ -0,0 +1,53 @@ +--- +- debug: + msg: START vyos_ospf_interfaces merged integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + mtu_ignore: true + instance: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: merged + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 6 + - result.changed == true + - result.commands|symmetric_difference(merged.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml new file mode 100644 index 00000000..67bbca14 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: START vyos_ospf_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Override the existing configuration with the provided running configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + state: overridden + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 8 + - result.changed == true + - result.commands|symmetric_difference(overridden.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Override the existing configuration with the provided running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..a065a000 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,16 @@ +--- +- debug: + msg: START vyos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- name: Provide the running configuration for parsing (config to be parsed) + become: true + register: result + vyos.vyos.vyos_ospf_interfaces: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + +- assert: + that: + - result.changed == false + - result.parsed|symmetric_difference(merged.after) == [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..328406b6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,33 @@ +--- +- debug: + msg: START vyos_ospf_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + mtu_ignore: true + instance: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: rendered + + - assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(merged.commands) == [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml new file mode 100644 index 00000000..ff32012a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_ospf_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace the existing configuration with the provided running configuration + register: result + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: true + state: replaced + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - result.commands|length == 8 + - result.changed == true + - result.commands|symmetric_difference(replaced.commands) == [] + - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Replace the existing configuration with the provided running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospf_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml new file mode 100644 index 00000000..46eb79d8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml @@ -0,0 +1,70 @@ +--- +- debug: + msg: START vyos_ospf_interfaces rtt integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: baseconfig + vyos.vyos.vyos_ospf_interfaces: &id001 + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + mtu_ignore: true + instance: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: merged + + - become: true + vyos.vyos.vyos_facts: + gather_network_resources: ospf_interfaces + + - assert: + that: + - baseconfig.commands|length == 6 + - baseconfig.changed == true + - baseconfig.commands|symmetric_difference(merged.commands) == [] + - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] + + - name: Apply the provided configuration (config to be reverted) + become: true + register: result + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + + + - name: Revert back to base config using facts round trip + become: true + register: revert + vyos.vyos.vyos_ospf_interfaces: + config: "{{ ansible_facts['network_resources']['ospf_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: baseconfig.after == revert.after + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml new file mode 100644 index 00000000..a98d3516 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml @@ -0,0 +1,133 @@ +--- +merged: + commands: + - set interfaces ethernet eth0 ip ospf cost 50 + - set interfaces ethernet eth0 ip ospf priority 26 + - set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + - set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - set interfaces bonding bond2 ip ospf transmit-delay 45 + - set interfaces bonding bond2 ipv6 ospfv3 passive + after: + - address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + name: "bond2" + - address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + instance: "33" + mtu_ignore: true + name: "eth0" + +replaced: + commands: + - set interfaces ethernet eth0 ip ospf transmit-delay 50 + - set interfaces ethernet eth0 ip ospf network point-to-point + - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39 + - delete interfaces ethernet eth0 ip ospf cost 50 + - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + - set interfaces bonding bond2 ip ospf bandwidth 70 + - set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key 1111111111232345 + + after: + - address_family: + - afi: "ipv4" + authentication: + md5_key: + key: "1111111111232345" + key_id: 10 + bandwidth: 70 + transmit_delay: 45 + - afi: "ipv6" + passive: true + name: "bond2" + - address_family: + - afi: "ipv4" + network: "point-to-point" + priority: 26 + transmit_delay: 50 + - afi: "ipv6" + dead_interval: 39 + name: "eth0" + +overridden: + commands: + - delete interfaces bonding bond2 ip ospf + - delete interfaces bonding bond2 ipv6 ospfv3 + - set interfaces ethernet eth0 ip ospf transmit-delay 50 + - set interfaces ethernet eth0 ip ospf network point-to-point + - set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39 + - delete interfaces ethernet eth0 ip ospf cost 50 + - delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33 + - delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore + + after: + - address_family: + - afi: "ipv4" + network: "point-to-point" + priority: 26 + transmit_delay: 50 + - afi: "ipv6" + dead_interval: 39 + name: "eth0" + +deleted: + commands: + - delete interfaces bonding bond2 ip ospf + - delete interfaces bonding bond2 ipv6 ospfv3 + after: + - address_family: + - afi: "ipv4" + cost: 50 + priority: 26 + - afi: "ipv6" + instance: "33" + mtu_ignore: true + name: "eth0" + +rendered: + commands: + - set interfaces ethernet eth1 firewall in name 'INBOUND' + - set interfaces ethernet eth1 firewall out name 'OUTBOUND' + - set interfaces ethernet eth1 firewall local name 'LOCAL' + - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + - set interfaces ethernet eth2 firewall in name 'INBOUND' + - set interfaces ethernet eth2 firewall out name 'OUTBOUND' + - set interfaces ethernet eth2 firewall local name 'LOCAL' + - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +round_trip: + after: + - name: eth0 + - access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL + name: eth1 + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INBOUND + - direction: local + name: LOCAL + - direction: out + name: OUTBOUND + - afi: ipv6 + rules: + - direction: local + name: V6-LOCAL diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..9cc720b4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_parsed_config.cfg @@ -0,0 +1,29 @@ +set protocols ospf area 2 area-type 'normal' +set protocols ospf area 2 authentication 'plaintext-password' +set protocols ospf area 2 shortcut 'enable' +set protocols ospf area 3 area-type 'nssa' +set protocols ospf area 4 area-type stub default-cost '20' +set protocols ospf area 4 network '192.0.2.0/24' +set protocols ospf area 4 range 192.0.3.0/24 cost '10' +set protocols ospf area 4 range 192.0.4.0/24 cost '12' +set protocols ospf auto-cost reference-bandwidth '2' +set protocols ospf default-information originate 'always' +set protocols ospf default-information originate metric '10' +set protocols ospf default-information originate metric-type '2' +set protocols ospf default-information originate route-map 'ingress' +set protocols ospf log-adjacency-changes 'detail' +set protocols ospf max-metric router-lsa 'administrative' +set protocols ospf max-metric router-lsa on-shutdown '10' +set protocols ospf max-metric router-lsa on-startup '10' +set protocols ospf mpls-te 'enable' +set protocols ospf mpls-te router-address '192.0.11.11' +set protocols ospf neighbor 192.0.11.12 poll-interval '10' +set protocols ospf neighbor 192.0.11.12 priority '2' +set protocols ospf parameters abr-type 'cisco' +set protocols ospf parameters 'opaque-lsa' +set protocols ospf parameters 'rfc1583-compatibility' +set protocols ospf parameters router-id '192.0.1.1' +set protocols ospf passive-interface 'eth1' +set protocols ospf passive-interface 'eth2' +set protocols ospf redistribute bgp metric '10' +set protocols ospf redistribute bgp metric-type '2' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml new file mode 100644 index 00000000..9f358d5e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml @@ -0,0 +1,35 @@ +--- +- name: Setup + vars: + lines: "set protocols ospf mpls-te 'enable' \n + set protocols ospf mpls-te router-address '192.0.11.11' \n + set protocols ospf redistribute bgp metric-type '2' \n + set protocols ospf redistribute bgp metric '10'\n + set protocols ospf default-information originate metric-type '2' \n + set protocols ospf default-information originate 'always' \n + set protocols ospf default-information originate metric '10' \n + set protocols ospf default-information originate route-map 'ingress' \n + set protocols ospf auto-cost reference-bandwidth '2' \n + set protocols ospf parameters router-id '192.0.1.1' \n + set protocols ospf parameters 'opaque-lsa' \n + set protocols ospf parameters abr-type 'cisco' \n + set protocols ospf parameters 'rfc1583-compatibility' \n + set protocols ospf passive-interface 'eth1' \n + set protocols ospf passive-interface 'eth2' \n + set protocols ospf max-metric router-lsa on-shutdown '10' \n + set protocols ospf max-metric router-lsa 'administrative' \n + set protocols ospf max-metric router-lsa on-startup '10' \n + set protocols ospf log-adjacency-changes 'detail' \n + set protocols ospf neighbor 192.0.11.12 priority '2' \n + set protocols ospf neighbor 192.0.11.12 poll-interval '10' \n + set protocols ospf area 2 authentication 'plaintext-password' \n + set protocols ospf area 2 shortcut 'enable' \n + set protocols ospf area 2 area-type 'normal' \n + set protocols ospf area 3 area-type 'nssa' \n + set protocols ospf area 4 range 192.0.3.0/24 cost '10' \n + set protocols ospf area 4 range 192.0.4.0/24 cost '12' \n + set protocols ospf area 4 area-type stub default-cost '20' \n + set protocols ospf area 4 network '192.0.2.0/24'" + + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..73608705 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Config + vars: + lines: "delete protocols ospf\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml new file mode 100644 index 00000000..a61f5a7c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml @@ -0,0 +1,48 @@ +--- +- debug: + msg: Start vyos_ospfv2 deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete attributes of ospfv2. + register: result + vyos.vyos.vyos_ospfv2: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['after'] }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv2: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml new file mode 100644 index 00000000..4566bf47 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: START vyos_ospfv2 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv2: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv2: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv2: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv2: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml new file mode 100644 index 00000000..bc5e1e27 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml @@ -0,0 +1,24 @@ +--- +- debug: + msg: START vyos_ospfv2 gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospfv2: + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate == result['gathered'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml new file mode 100644 index 00000000..6a58bb57 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml @@ -0,0 +1,101 @@ +--- +- debug: + msg: START vyos_ospfv2 merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospfv2: &id001 + config: + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + mpls_te: + enabled: true + router_address: '192.0.11.11' + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + redistribute: + - route_type: 'bgp' + metric: 10 + metric_type: 2 + passive_interface: + - 'eth1' + - 'eth2' + parameters: + router_id: '192.0.1.1' + opaque_lsa: true + rfc1583_compatibility: true + abr_type: 'cisco' + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv2: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml new file mode 100644 index 00000000..9b6823c9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml @@ -0,0 +1,70 @@ +--- +- debug: + msg: START vyos_ospfv2 merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospfv2: &id001 + config: + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + passive_interface: + - 'eth1' + areas: + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + set: false + network: + - address: '192.0.2.0/24' + - address: '192.0.22.0/24' + - address: '192.0.32.0/24' + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged_update['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged_update['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged_update['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv2: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged_update['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml new file mode 100644 index 00000000..cfa29f99 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml @@ -0,0 +1,15 @@ +--- +- debug: + msg: START vyos_ospfv2 parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided ospfv2 config to agnostic model + register: result + vyos.vyos.vyos_ospfv2: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] == result['parsed'] }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml new file mode 100644 index 00000000..8a805a6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml @@ -0,0 +1,76 @@ +--- +- debug: + msg: START vyos_ospfv2 rendered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + mpls_te: + enabled: true + router_address: '192.0.11.11' + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + redistribute: + - route_type: 'bgp' + metric: 10 + metric_type: 2 + passive_interface: + - 'eth1' + - 'eth2' + parameters: + router_id: '192.0.1.1' + opaque_lsa: true + rfc1583_compatibility: true + abr_type: 'cisco' + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" +- debug: + msg: END vyos_ospfv2 rendered integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml new file mode 100644 index 00000000..07606f94 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml @@ -0,0 +1,100 @@ +--- +- debug: + msg: START vyos_ospfv2 replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed ospfv2 routes with provided configurations + register: result + vyos.vyos.vyos_ospfv2: &id001 + config: + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + mpls_te: + enabled: true + router_address: '192.0.22.22' + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + redistribute: + - route_type: 'bgp' + metric: 10 + metric_type: 2 + passive_interface: + - 'eth1' + parameters: + router_id: '192.0.1.1' + opaque_lsa: true + rfc1583_compatibility: true + abr_type: 'cisco' + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: '192.0.2.0/24' + - address: '192.0.12.0/24' + - address: '192.0.22.0/24' + - address: '192.0.32.0/24' + range: + - address: '1.1.2.0/24' + cost: 10 + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['after'] }}" + + - name: Replace device configurations of listed ospfv2 routes with provided configurarions + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv2: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml new file mode 100644 index 00000000..7efc2a7b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml @@ -0,0 +1,149 @@ +--- +- debug: + msg: START vyos_ospfv2 round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_ospfv2: + config: + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + mpls_te: + enabled: true + router_address: '192.0.11.11' + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + redistribute: + - route_type: 'bgp' + metric: 10 + metric_type: 2 + passive_interface: + - 'eth1' + - 'eth2' + parameters: + router_id: '192.0.1.1' + opaque_lsa: true + rfc1583_compatibility: true + abr_type: 'cisco' + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + state: merged + + - name: Gather ospfv2 facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - ospfv2 + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_ospfv2: + config: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.12.0/24' + - address: '192.0.2.0/24' + - address: '192.0.22.0/24' + - address: '192.0.32.0/24' + range: + - address: '1.1.2.0/24' + cost: 10 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.22.22' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' + state: replaced + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] == result['after'] }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_ospfv2: + config: "{{ ansible_facts['network_resources']['ospfv2'] }}" + state: replaced + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] == revert['after']}}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..ecaf4bde --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml @@ -0,0 +1,99 @@ +--- +- debug: + msg: START shortname integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.ospfv2: &id001 + config: + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + mpls_te: + enabled: true + router_address: '192.0.11.11' + auto_cost: + reference_bandwidth: 2 + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + redistribute: + - route_type: 'bgp' + metric: 10 + metric_type: 2 + passive_interface: + - 'eth1' + - 'eth2' + parameters: + router_id: '192.0.1.1' + opaque_lsa: true + rfc1583_compatibility: true + abr_type: 'cisco' + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.ospfv2: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/vars/main.yaml new file mode 100644 index 00000000..e55da20f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv2/vars/main.yaml @@ -0,0 +1,485 @@ +--- +merged: + before: {} + commands: + - set protocols ospf mpls-te enable + - set protocols ospf mpls-te router-address '192.0.11.11' + - set protocols ospf redistribute bgp + - set protocols ospf redistribute bgp metric-type 2 + - set protocols ospf redistribute bgp metric 10 + - set protocols ospf default-information originate metric-type 2 + - set protocols ospf default-information originate always + - set protocols ospf default-information originate metric 10 + - set protocols ospf default-information originate route-map ingress + - set protocols ospf auto-cost reference-bandwidth '2' + - set protocols ospf parameters router-id '192.0.1.1' + - set protocols ospf parameters opaque-lsa + - set protocols ospf parameters abr-type 'cisco' + - set protocols ospf parameters rfc1583-compatibility + - set protocols ospf passive-interface eth1 + - set protocols ospf passive-interface eth2 + - set protocols ospf max-metric router-lsa on-shutdown 10 + - set protocols ospf max-metric router-lsa administrative + - set protocols ospf max-metric router-lsa on-startup 10 + - set protocols ospf log-adjacency-changes 'detail' + - set protocols ospf neighbor 192.0.11.12 priority 2 + - set protocols ospf neighbor 192.0.11.12 poll-interval 10 + - set protocols ospf neighbor 192.0.11.12 + - set protocols ospf area '2' + - set protocols ospf area 2 authentication plaintext-password + - set protocols ospf area 2 shortcut enable + - set protocols ospf area 2 area-type normal + - set protocols ospf area '3' + - set protocols ospf area 3 area-type nssa + - set protocols ospf area 4 range 192.0.3.0/24 cost 10 + - set protocols ospf area 4 range 192.0.3.0/24 + - set protocols ospf area 4 range 192.0.4.0/24 cost 12 + - set protocols ospf area 4 range 192.0.4.0/24 + - set protocols ospf area 4 area-type stub default-cost 20 + - set protocols ospf area '4' + - set protocols ospf area 4 network 192.0.2.0/24 + after: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.11.11' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + - 'eth2' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' +merged_update: + before: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.11.11' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + - 'eth2' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' + after: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + network: + - address: '192.0.2.0/24' + - address: '192.0.22.0/24' + - address: '192.0.32.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.11.11' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + - 'eth2' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' + commands: + - delete protocols ospf area 4 area-type stub + - set protocols ospf area 4 network 192.0.22.0/24 + - set protocols ospf area 4 network 192.0.32.0/24 +populate: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.11.11' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + - 'eth2' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' +replaced: + commands: + - delete protocols ospf passive-interface eth2 + - delete protocols ospf area 3 + - delete protocols ospf area 4 range 192.0.3.0/24 cost + - delete protocols ospf area 4 range 192.0.3.0/24 + - delete protocols ospf area 4 range 192.0.4.0/24 cost + - delete protocols ospf area 4 range 192.0.4.0/24 + - set protocols ospf mpls-te router-address '192.0.22.22' + - set protocols ospf area 4 range 1.1.2.0/24 cost 10 + - set protocols ospf area 4 range 1.1.2.0/24 + - set protocols ospf area 4 network 192.0.12.0/24 + - set protocols ospf area 4 network 192.0.22.0/24 + - set protocols ospf area 4 network 192.0.32.0/24 + after: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.12.0/24' + - address: '192.0.2.0/24' + - address: '192.0.22.0/24' + - address: '192.0.32.0/24' + range: + - address: '1.1.2.0/24' + cost: 10 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.22.22' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' +rendered: + commands: + - set protocols ospf mpls-te enable + - set protocols ospf mpls-te router-address '192.0.11.11' + - set protocols ospf redistribute bgp + - set protocols ospf redistribute bgp metric-type 2 + - set protocols ospf redistribute bgp metric 10 + - set protocols ospf default-information originate metric-type 2 + - set protocols ospf default-information originate always + - set protocols ospf default-information originate metric 10 + - set protocols ospf default-information originate route-map ingress + - set protocols ospf auto-cost reference-bandwidth '2' + - set protocols ospf parameters router-id '192.0.1.1' + - set protocols ospf parameters opaque-lsa + - set protocols ospf parameters abr-type 'cisco' + - set protocols ospf parameters rfc1583-compatibility + - set protocols ospf passive-interface eth1 + - set protocols ospf passive-interface eth2 + - set protocols ospf max-metric router-lsa on-shutdown 10 + - set protocols ospf max-metric router-lsa administrative + - set protocols ospf max-metric router-lsa on-startup 10 + - set protocols ospf log-adjacency-changes 'detail' + - set protocols ospf neighbor 192.0.11.12 priority 2 + - set protocols ospf neighbor 192.0.11.12 poll-interval 10 + - set protocols ospf neighbor 192.0.11.12 + - set protocols ospf area '2' + - set protocols ospf area 2 authentication plaintext-password + - set protocols ospf area 2 shortcut enable + - set protocols ospf area 2 area-type normal + - set protocols ospf area '3' + - set protocols ospf area 3 area-type nssa + - set protocols ospf area 4 range 192.0.3.0/24 cost 10 + - set protocols ospf area 4 range 192.0.3.0/24 + - set protocols ospf area 4 range 192.0.4.0/24 cost 12 + - set protocols ospf area 4 range 192.0.4.0/24 + - set protocols ospf area 4 area-type stub default-cost 20 + - set protocols ospf area '4' + - set protocols ospf area 4 network 192.0.2.0/24 +parsed: + after: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.2.0/24' + range: + - address: '192.0.3.0/24' + cost: 10 + - address: '192.0.4.0/24' + cost: 12 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.11.11' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + - 'eth2' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' +deleted: + commands: + - 'delete protocols ospf' + after: {} +round_trip: + after: + areas: + - area_id: '2' + area_type: + normal: true + authentication: "plaintext-password" + shortcut: 'enable' + - area_id: '4' + area_type: + stub: + default_cost: 20 + set: true + network: + - address: '192.0.12.0/24' + - address: '192.0.2.0/24' + - address: '192.0.22.0/24' + - address: '192.0.32.0/24' + range: + - address: '1.1.2.0/24' + cost: 10 + auto_cost: + reference_bandwidth: 2 + default_information: + originate: + always: true + metric: 10 + metric_type: 2 + route_map: 'ingress' + log_adjacency_changes: 'detail' + max_metric: + router_lsa: + administrative: true + on_shutdown: 10 + on_startup: 10 + mpls_te: + enabled: true + router_address: '192.0.22.22' + neighbor: + - neighbor_id: '192.0.11.12' + poll_interval: 10 + priority: 2 + parameters: + abr_type: 'cisco' + opaque_lsa: true + rfc1583_compatibility: true + router_id: '192.0.1.1' + passive_interface: + - 'eth1' + redistribute: + - metric: 10 + metric_type: 2 + route_type: 'bgp' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/meta/main.yaml new file mode 100644 index 00000000..7413320e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_vyos_tests diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..5e012d5a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_parsed_config.cfg @@ -0,0 +1,8 @@ +set protocols ospfv3 area 2 export-list 'export1' +set protocols ospfv3 area 2 import-list 'import1' +set protocols ospfv3 area 2 range '2001:db10::/32' +set protocols ospfv3 area 2 range '2001:db20::/32' +set protocols ospfv3 area 2 range '2001:db30::/32' +set protocols ospfv3 area 3 range '2001:db40::/32' +set protocols ospfv3 parameters router-id '192.0.2.10' +set protocols ospfv3 redistribute 'bgp' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml new file mode 100644 index 00000000..fb66d0a5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml @@ -0,0 +1,13 @@ +--- +- name: Setup + vars: + lines: "set protocols ospfv3 area 2 export-list 'export1' \n + set protocols ospfv3 area 2 import-list 'import1' \n + set protocols ospfv3 area 2 range '2001:db10::/32' \n + set protocols ospfv3 area 2 range '2001:db20::/32' \n + set protocols ospfv3 area 2 range '2001:db30::/32' \n + set protocols ospfv3 area 3 range '2001:db40::/32' \n + set protocols ospfv3 parameters router-id '192.0.2.10' \n + set protocols ospfv3 redistribute 'bgp'" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..2a475050 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Config + vars: + lines: "delete protocols ospfv3\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml new file mode 100644 index 00000000..55bec184 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml @@ -0,0 +1,48 @@ +--- +- debug: + msg: Start vyos_ospfv3 deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete ospfv3 routes + register: result + vyos.vyos.vyos_ospfv3: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['after'] }}" + + - name: Delete ospfv3 routes (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv3: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml new file mode 100644 index 00000000..fec61abf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: START vyos_ospfv3 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv3: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv3: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv3: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_ospfv3: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml new file mode 100644 index 00000000..6645b99f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml @@ -0,0 +1,25 @@ +--- +- debug: + msg: START vyos_ospfv3 gathered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospfv3: + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate == result['gathered'] }}" + + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml new file mode 100644 index 00000000..93095009 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml @@ -0,0 +1,62 @@ +--- +- debug: + msg: START vyos_ospfv3 merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospfv3: &id001 + config: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv3: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml new file mode 100644 index 00000000..0d506b37 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START vyos_ospfv3 merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_ospfv3: &id001 + config: + areas: + - area_id: '2' + range: + - address: '2001:db10::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + - address: '2001:db70::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ populate == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged_update['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged_update['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv3: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged_update['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml new file mode 100644 index 00000000..62870831 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml @@ -0,0 +1,15 @@ +--- +- debug: + msg: START vyos_ospfv3 parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided ospfv3 config to agnostic model + register: result + vyos.vyos.vyos_ospfv3: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] == result['parsed'] }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml new file mode 100644 index 00000000..3f714ced --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml @@ -0,0 +1,38 @@ +--- +- debug: + msg: START vyos_ospfv3 rendered integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: 'bgp' + parameters: + router_id: '192.0.2.10' + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + +- debug: + msg: END vyos_ospfv3 rendered integration tests on connection={{ ansible_connection }} diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml new file mode 100644 index 00000000..74d25dbf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml @@ -0,0 +1,66 @@ +--- +- debug: + msg: START vyos_ospfv3 replaced integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed ospfv3 routes with provided configurations + register: result + vyos.vyos.vyos_ospfv3: &id001 + config: + redistribute: + - route_type: 'bgp' + parameters: + router_id: '192.0.2.10' + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + + range: + - address: '2001:db10::/32' + - address: '2001:db30::/32' + - address: '2001:db50::/32' + - area_id: '4' + range: + - address: '2001:db60::/32' + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate == result['before'] }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['after'] }}" + + - name: Replace device configurations of listed ospfv3 routes with provided configurarions + (IDEMPOTENT) + register: result + vyos.vyos.vyos_ospfv3: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] == result['before'] }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml new file mode 100644 index 00000000..d8175540 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml @@ -0,0 +1,75 @@ +--- +- debug: + msg: START vyos_ospfv3 round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_ospfv3: + config: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' + state: merged + + - name: Gather ospfv3 facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - ospfv3 + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_ospfv3: + config: + redistribute: + - route_type: 'bgp' + parameters: + router_id: '192.0.2.10' + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + + range: + - address: '2001:db10::/32' + - address: '2001:db30::/32' + - address: '2001:db50::/32' + - area_id: '4' + range: + - address: '2001:db60::/32' + state: replaced + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] == result['after'] }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_ospfv3: + config: "{{ ansible_facts['network_resources']['ospfv3'] }}" + state: replaced + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] == revert['after']}}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..fdeeb895 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START shortname integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.ospfv3: &id001 + config: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.ospfv3: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] == result['before'] }}" + when: ansible_version.full is version('2.10.0', '>=') + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/vars/main.yaml new file mode 100644 index 00000000..6ded89a8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_ospfv3/vars/main.yaml @@ -0,0 +1,142 @@ +--- +merged: + before: {} + commands: + - set protocols ospfv3 redistribute bgp + - set protocols ospfv3 parameters router-id '192.0.2.10' + - set protocols ospfv3 area 2 range 2001:db10::/32 + - set protocols ospfv3 area 2 range 2001:db20::/32 + - set protocols ospfv3 area 2 range 2001:db30::/32 + - set protocols ospfv3 area '2' + - set protocols ospfv3 area 2 export-list export1 + - set protocols ospfv3 area 2 import-list import1 + - set protocols ospfv3 area '3' + - set protocols ospfv3 area 3 range 2001:db40::/32 + after: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' + + +merged_update: + commands: + - set protocols ospfv3 area 3 range 2001:db70::/32 + after: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + - address: '2001:db70::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' + +populate: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' +replaced: + commands: + - delete protocols ospfv3 area 2 range 2001:db20::/32 + - delete protocols ospfv3 area 3 + - set protocols ospfv3 area 2 range 2001:db50::/32 + - set protocols ospfv3 area '4' + - set protocols ospfv3 area 4 range 2001:db60::/32 + after: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db30::/32' + - address: '2001:db50::/32' + - area_id: '4' + range: + - address: '2001:db60::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' +rendered: + commands: + - set protocols ospfv3 redistribute bgp + - set protocols ospfv3 parameters router-id '192.0.2.10' + - set protocols ospfv3 area 2 range 2001:db10::/32 + - set protocols ospfv3 area 2 range 2001:db20::/32 + - set protocols ospfv3 area 2 range 2001:db30::/32 + - set protocols ospfv3 area '2' + - set protocols ospfv3 area 2 export-list export1 + - set protocols ospfv3 area 2 import-list import1 + - set protocols ospfv3 area '3' + - set protocols ospfv3 area 3 range 2001:db40::/32 +parsed: + after: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' +deleted: + commands: + - 'delete protocols ospfv3' + after: {} +round_trip: + after: + areas: + - area_id: '2' + export_list: 'export1' + import_list: 'import1' + range: + - address: '2001:db10::/32' + - address: '2001:db30::/32' + - address: '2001:db50::/32' + - area_id: '4' + range: + - address: '2001:db60::/32' + parameters: + router_id: '192.0.2.10' + redistribute: + - route_type: 'bgp' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml new file mode 100644 index 00000000..be93e89e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml @@ -0,0 +1,137 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: create static route + register: result + vyos.vyos.vyos_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + state: present + +- assert: + that: + - result.changed == true + - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands' + +- name: create static route again (idempotent) + register: result + vyos.vyos.vyos_static_route: + prefix: 172.24.0.0 + mask: 24 + next_hop: 192.168.42.64 + state: present + +- assert: + that: + - result.changed == false + +- name: modify admin distance of static route + register: result + vyos.vyos.vyos_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + admin_distance: 1 + state: present + +- assert: + that: + - result.changed == true + - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64 distance + 1" in result.commands' + +- name: modify admin distance of static route again (idempotent) + register: result + vyos.vyos.vyos_static_route: + prefix: 172.24.0.0 + mask: 24 + next_hop: 192.168.42.64 + admin_distance: 1 + state: present + +- assert: + that: + - result.changed == false + +- name: delete static route + register: result + vyos.vyos.vyos_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + admin_distance: 1 + state: absent + +- assert: + that: + - result.changed == true + - '"delete protocols static route 172.24.0.0/24" in result.commands' + +- name: delete static route again (idempotent) + register: result + vyos.vyos.vyos_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + admin_distance: 1 + state: absent + +- assert: + that: + - result.changed == false + +- name: Add static route collections + register: result + vyos.vyos.vyos_static_route: + aggregate: + + - prefix: 172.24.1.0/24 + next_hop: 192.168.42.64 + + - prefix: 172.24.2.0 + mask: 24 + next_hop: 192.168.42.64 + state: present + +- assert: + that: + - result.changed == true + - '"set protocols static route 172.24.1.0/24 next-hop 192.168.42.64" in result.commands' + - '"set protocols static route 172.24.2.0/24 next-hop 192.168.42.64" in result.commands' + +- name: Add and remove static route collections with overrides + register: result + vyos.vyos.vyos_static_route: + aggregate: + + - prefix: 172.24.1.0/24 + next_hop: 192.168.42.64 + + - prefix: 172.24.2.0/24 + next_hop: 192.168.42.64 + state: absent + + - prefix: 172.24.3.0/24 + next_hop: 192.168.42.64 + state: present + +- assert: + that: + - result.changed == true + - '"delete protocols static route 172.24.2.0/24" in result.commands' + - '"set protocols static route 172.24.3.0/24 next-hop 192.168.42.64" in result.commands' + +- name: Remove static route collections + register: result + vyos.vyos.vyos_static_route: + aggregate: + + - prefix: 172.24.1.0/24 + next_hop: 192.168.42.64 + + - prefix: 172.24.3.0/24 + next_hop: 192.168.42.64 + state: absent + +- assert: + that: + - result.changed == true + - '"delete protocols static route 172.24.1.0/24" in result.commands' + - '"delete protocols static route 172.24.3.0/24" in result.commands' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml new file mode 100644 index 00000000..c53c838c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml @@ -0,0 +1,32 @@ +--- +- debug: msg="START vyos cli/net_static_route.yaml on connection={{ ansible_connection + }}" + +- name: delete static route - setup + register: result + ansible.netcommon.net_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + state: absent + +- name: create static route using platform agnostic module + register: result + ansible.netcommon.net_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + state: present + +- assert: + that: + - result.changed == true + - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands' + +- name: delete static route - teardown + register: result + ansible.netcommon.net_static_route: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + state: absent + +- debug: msg="END vyos cli/net_static_route.yaml on connection={{ ansible_connection + }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/defaults/main.yaml new file mode 100644 index 00000000..852a6bee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '[^_].*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/meta/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/meta/main.yaml new file mode 100644 index 00000000..91da2a75 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/meta/main.yaml @@ -0,0 +1,2 @@ +--- +... diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/cli.yaml new file mode 100644 index 00000000..93eb2fe4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/main.yaml new file mode 100644 index 00000000..6b7d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/main.yaml @@ -0,0 +1,9 @@ +--- +- include: cli.yaml + tags: + - network_cli + +- include: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') + tags: + - network_cli diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/redirection.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/redirection.yaml new file mode 100644 index 00000000..5564a3ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tasks/redirection.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all redirection cli test cases + find: + paths: '{{ role_path }}/tests/redirection/cli' + patterns: '{{ testcase }}.yaml' + register: shortname_test_cases + delegate_to: localhost + +- name: set test_items for redirection + set_fact: test_items="{{ shortname_test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..b2ecd4e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg @@ -0,0 +1,6 @@ +set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' +set protocols static route 192.0.2.32/28 next-hop '192.0.2.10' +set protocols static route 192.0.2.32/28 blackhole +set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' +set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' +set protocols static route6 2001:db8:1000::/36 blackhole distance '2' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml new file mode 100644 index 00000000..f292e5de --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml @@ -0,0 +1,12 @@ +--- +- name: Setup + vars: + lines: "set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'\nset\ + \ protocols static route 192.0.2.32/28 next-hop '192.0.2.9'\nset protocols\ + \ static route 192.0.2.32/28 blackhole\nset protocols static route 192.0.2.32/28\n\ + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'\n\ + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'\n\ + set protocols static route6 2001:db8:1000::/36 blackhole distance '2'\nset\ + \ protocols static route6 2001:db8:1000::/36\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml new file mode 100644 index 00000000..5a5cccb8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove Config + vars: + lines: "delete protocols static route\ndelete protocols static route6\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml new file mode 100644 index 00000000..221f1b51 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml @@ -0,0 +1,56 @@ +--- +- debug: + msg: Start vyos_static_routes deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete static route based on afi. + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + + - afi: ipv6 + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml new file mode 100644 index 00000000..e10f1bc6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml @@ -0,0 +1,50 @@ +--- +- debug: + msg: Start vyos_static_routes deleted integration tests ansible_connection={{ + ansible_connection }} + +- include_tasks: _populate.yaml + +- block: + + - name: Delete all the static routes. + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + state: deleted + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated + assert: + that: + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that the after dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: Delete attributes of given interfaces (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result.changed == false + - result.commands|length == 0 + + - name: Assert that the before dicts were correctly generated + assert: + that: + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ + \ |length == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml new file mode 100644 index 00000000..f58ef398 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- debug: + msg: START vyos_static_routes empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_static_routes: + config: + state: merged + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_static_routes: + config: + state: replaced + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_static_routes: + config: + state: overridden + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_static_routes: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_static_routes: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml new file mode 100644 index 00000000..d3b84d1f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml @@ -0,0 +1,34 @@ +--- +- debug: + msg: START vyos_static_routes gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + state: gathered + + - name: Assert that gathered dicts was correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ + \ }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml new file mode 100644 index 00000000..999ae867 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml @@ -0,0 +1,78 @@ +--- +- debug: + msg: START vyos_static_routes merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + + - forward_router_address: 192.0.2.10 + + - forward_router_address: 192.0.2.9 + + - address_families: + + - afi: ipv6 + routes: + + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 2001:db8:2000:2::1 + + - forward_router_address: 2001:db8:2000:2::2 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml new file mode 100644 index 00000000..a9112a51 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml @@ -0,0 +1,61 @@ +--- +- debug: + msg: START vyos_static_routes overridden integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Overrides all device configuration with provided configuration + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 198.0.2.48/28 + next_hops: + + - forward_router_address: 192.0.2.18 + state: overridden + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that correct commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that after dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Overrides all device configuration with provided configurations (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml new file mode 100644 index 00000000..4b6e434a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml @@ -0,0 +1,41 @@ +--- +- debug: + msg: START vyos_static_routes parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Gather static_routes facts + register: static_routes_facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - static_routes + + - name: Provide the running configuration for parsing (config to be parsed) + register: result + vyos.vyos.vyos_static_routes: &id001 + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed + + - name: Assert that correct parsing done + assert: + that: "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed'])\ + \ |length == 0 }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml new file mode 100644 index 00000000..ff185232 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml @@ -0,0 +1,62 @@ +--- +- debug: + msg: START vyos_static_routes rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + + - forward_router_address: 192.0.2.10 + + - forward_router_address: 192.0.2.9 + + - address_families: + + - afi: ipv6 + routes: + + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 2001:db8:2000:2::1 + + - forward_router_address: 2001:db8:2000:2::2 + state: rendered + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ + \ |length == 0 }}" + + - name: Structure provided configuration into device specific commands (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml new file mode 100644 index 00000000..80ed8010 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml @@ -0,0 +1,69 @@ +--- +- debug: + msg: START vyos_static_routes replaced integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Replace device configurations of listed static routes with provided + configurations + register: result + vyos.vyos.vyos_static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 192.0.2.7 + + - forward_router_address: 192.0.2.8 + + - forward_router_address: 192.0.2.9 + state: replaced + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace device configurations of listed static routes with provided + configurarions (IDEMPOTENT) + register: result + vyos.vyos.vyos_static_routes: *id001 + + - name: Assert that task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml new file mode 100644 index 00000000..340fde9e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml @@ -0,0 +1,90 @@ +--- +- debug: + msg: START vyos_static_routes round trip integration tests on connection={{ + ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + + - name: Apply the provided configuration (base config) + register: base_config + vyos.vyos.vyos_static_routes: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + + - forward_router_address: 192.0.2.10 + + - forward_router_address: 192.0.2.9 + + - address_families: + + - afi: ipv6 + routes: + + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 2001:db8:2000:2::1 + + - forward_router_address: 2001:db8:2000:2::2 + state: merged + + - name: Gather static_routes facts + vyos.vyos.vyos_facts: + gather_subset: + - default + gather_network_resources: + - static_routes + + - name: Apply the provided configuration (config to be reverted) + register: result + vyos.vyos.vyos_static_routes: + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 192.0.2.7 + + - forward_router_address: 192.0.2.8 + + - forward_router_address: 192.0.2.9 + state: merged + + - name: Assert that changes were applied + assert: + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Revert back to base config using facts round trip + register: revert + vyos.vyos.vyos_static_routes: + config: "{{ ansible_facts['network_resources']['static_routes'] }}" + state: overridden + + - name: Assert that config was reverted + assert: + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ + \ == 0 }}" + always: + + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml new file mode 100644 index 00000000..08c22b97 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml @@ -0,0 +1,76 @@ +--- +- debug: + msg: START shortname merged integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.static_routes: &id001 + config: + + - address_families: + + - afi: ipv4 + routes: + + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + + - forward_router_address: 192.0.2.10 + + - forward_router_address: 192.0.2.9 + + - address_families: + + - afi: ipv6 + routes: + + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + + - forward_router_address: 2001:db8:2000:2::1 + + - forward_router_address: 2001:db8:2000:2::2 + state: merged + + - name: Assert that before dicts were correctly generated + assert: + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" + + - name: Assert that after dicts was correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + vyos.vyos.static_routes: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + + - name: Assert that before dicts were correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" + always: + - include_tasks: _remove_config.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/vars/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/vars/main.yaml new file mode 100644 index 00000000..6ce4cea6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_static_routes/vars/main.yaml @@ -0,0 +1,123 @@ +--- +merged: + before: [] + commands: + - set protocols static route 192.0.2.32/28 next-hop '192.0.2.10' + - set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' + - set protocols static route 192.0.2.32/28 blackhole + - set protocols static route 192.0.2.32/28 + - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + - set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + - set protocols static route6 2001:db8:1000::/36 + after: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.9 + - forward_router_address: 192.0.2.10 + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 +populate: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.9 + - forward_router_address: 192.0.2.10 + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 +replaced: + commands: + - delete protocols static route 192.0.2.32/28 next-hop '192.0.2.10' + - set protocols static route 192.0.2.32/28 next-hop '192.0.2.7' + - set protocols static route 192.0.2.32/28 next-hop '192.0.2.8' + - set protocols static route 192.0.2.32/28 blackhole distance '2' + after: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 192.0.2.7 + - forward_router_address: 192.0.2.8 + - forward_router_address: 192.0.2.9 + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 +overridden: + commands: + - delete protocols static route 192.0.2.32/28 + - delete protocols static route6 2001:db8:1000::/36 + - set protocols static route 198.0.2.48/28 next-hop '192.0.2.18' + - set protocols static route 198.0.2.48/28 + after: + - address_families: + - afi: ipv4 + routes: + - dest: 198.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.18 +rendered: + commands: + - set protocols static route 192.0.2.32/28 next-hop '192.0.2.10' + - set protocols static route 192.0.2.32/28 next-hop '192.0.2.9' + - set protocols static route 192.0.2.32/28 blackhole + - set protocols static route 192.0.2.32/28 + - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' + - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' + - set protocols static route6 2001:db8:1000::/36 blackhole distance '2' + - set protocols static route6 2001:db8:1000::/36 + +deleted_afi_all: + commands: + - delete protocols static route + - delete protocols static route6 + after: [] +round_trip: + after: + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 192.0.2.7 + - forward_router_address: 192.0.2.8 + - forward_router_address: 192.0.2.9 + - forward_router_address: 192.0.2.10 + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/aliases b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/aliases new file mode 100644 index 00000000..8071e1f7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/aliases @@ -0,0 +1 @@ +shippable/vyos/group1 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tests/cli/basic.yaml new file mode 100644 index 00000000..9c3c09ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tests/cli/basic.yaml @@ -0,0 +1,61 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: + - delete system name-server 192.0.2.1 + - delete system name-server 192.0.2.2 + - delete system name-server 192.0.2.3 + match: none + +- name: configure name servers + register: result + vyos.vyos.vyos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - result.commands[0] is search("set system name-server '192.0.2.1'") + - result.commands[1] is search("set system name-server '192.0.2.2'") + - result.commands[2] is search("set system name-server '192.0.2.3'") + +- name: verify name_servers + register: result + vyos.vyos.vyos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + +- assert: + that: + - result.changed == false + +- name: remove one + register: result + vyos.vyos.vyos_system: + name_servers: + - 192.0.2.3 + state: absent + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - result.commands[0] is search("delete system name-server '192.0.2.3'") + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete system name-server name-server 192.0.2.1 + - delete system name-server name-server 192.0.2.2 + - delete system name-server name-server 192.0.2.3 + match: none + +- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tests/cli/net_system.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tests/cli/net_system.yaml new file mode 100644 index 00000000..3e68d204 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_system/tests/cli/net_system.yaml @@ -0,0 +1,28 @@ +--- +- debug: msg="START vyos cli/net_system.yaml on connection={{ ansible_connection + }}" + +- name: setup + vyos.vyos.vyos_config: + lines: + - delete system name-server 192.0.2.1 + match: none + +- name: configure name servers using platform agnostic module + register: result + ansible.netcommon.net_system: + name_servers: + - 192.0.2.1 + +- assert: + that: + - result.changed == true + - result.commands[0] is search("set system name-server '192.0.2.1'") + +- name: setup + vyos.vyos.vyos_config: + lines: + - delete system name-server 192.0.2.1 + match: none + +- debug: msg="END vyos cli/net_system.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tests/cli/auth.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tests/cli/auth.yaml new file mode 100644 index 00000000..bc4e7880 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tests/cli/auth.yaml @@ -0,0 +1,39 @@ +--- +- block: + + - name: Create user with password + vyos.vyos.vyos_user: + name: auth_user + role: admin + state: present + configured_password: pass123 + + - name: test login via ssh with new user + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) + }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper + show version' + responses: + (?i)password: pass123 + + - name: test login via ssh with invalid password (should fail) + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) + }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper + show version' + responses: + (?i)password: badpass + ignore_errors: true + register: results + + - name: check that attempt failed + assert: + that: + - results.failed + always: + + - name: delete user + register: result + vyos.vyos.vyos_user: + name: auth_user + state: absent diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tests/cli/basic.yaml new file mode 100644 index 00000000..00a7a264 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_user/tests/cli/basic.yaml @@ -0,0 +1,86 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Setup + vyos.vyos.vyos_config: + lines: + - delete system login user ansibletest1 + - delete system login user ansibletest2 + - delete system login user ansibletest3 + +- name: Create user + register: result + vyos.vyos.vyos_user: + name: ansibletest1 + configured_password: test + state: present + +- assert: + that: + - result.changed == true + - '"set system login user" in result.commands[0]' + - '"authentication plaintext-password" in result.commands[0]' + +- name: Collection of users (SetUp) + register: result + vyos.vyos.vyos_user: + aggregate: + + - name: ansibletest2 + + - name: ansibletest3 + level: operator + state: present + +- assert: + that: + - result.changed == true + - result.commands == ["set system login user ansibletest2 level operator", + "set system login user ansibletest3 level operator"] + +- name: Add user again (Idempotent) + register: result + vyos.vyos.vyos_user: + name: ansibletest1 + configured_password: test + state: present + update_password: on_create + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + +- name: Add collection of users (Idempotent) + register: result + vyos.vyos.vyos_user: + aggregate: + + - name: ansibletest2 + + - name: ansibletest3 + level: operator + state: present + +- assert: + that: + - result.changed == false + - result.commands | length == 0 + +- name: tearDown + register: result + vyos.vyos.vyos_user: + users: + + - name: ansibletest1 + + - name: ansibletest2 + + - name: ansibletest3 + state: absent + +- assert: + that: + - result.changed == true + - result.commands == ["delete system login user ansibletest1", "delete system + login user ansibletest2", "delete system login user ansibletest3"] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/defaults/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/defaults/main.yaml new file mode 100644 index 00000000..a845c24b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: '*' +test_items: [] diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tasks/cli.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tasks/cli.yaml new file mode 100644 index 00000000..b23cb605 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tasks/cli.yaml @@ -0,0 +1,26 @@ +--- +- name: collect all cli test cases + find: + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - network_cli + +- name: run test case (connection=local) + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' + loop_control: + loop_var: test_case_to_run + tags: + - local diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tasks/main.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tasks/main.yaml new file mode 100644 index 00000000..07b0f2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- include: cli.yaml diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml new file mode 100644 index 00000000..eade5a42 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml @@ -0,0 +1,107 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth0 vif 101 + - delete interfaces ethernet eth1 vif 201 + +- name: set vlan with name + register: result + vyos.vyos.vyos_vlan: &id001 + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + +- assert: + that: + - result.changed == true + - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" + +- name: set vlan with name(idempotence) + register: result + vyos.vyos.vyos_vlan: *id001 + +- assert: + that: + - result.changed == false + +- name: set vlan with address + register: result + vyos.vyos.vyos_vlan: &id002 + vlan_id: 5 + address: 192.168.5.12/24 + interfaces: eth0 + +- assert: + that: + - result.changed == true + - "'set interfaces ethernet eth0 vif 5 address 192.168.5.12/24' in result.commands" + +- name: set vlan with address(idempotence) + register: result + vyos.vyos.vyos_vlan: *id002 + +- assert: + that: + - result.changed == false + +- name: delete + register: result + vyos.vyos.vyos_vlan: &id003 + vlan_id: 100 + interfaces: eth1 + state: absent + +- assert: + that: + - result.changed == true + - "'delete interfaces ethernet eth1 vif 100' in result.commands" + +- name: delete(idempotence) + register: result + vyos.vyos.vyos_vlan: *id003 + +- assert: + that: + - result.changed == false + +- name: Create VLANs using aggregate + register: result + vyos.vyos.vyos_vlan: &id004 + aggregate: + + - vlan_id: 101 + name: voice + interfaces: eth0 + + - vlan_id: 201 + name: mgm + interfaces: eth1 + state: present + +- assert: + that: + - result.changed == true + - "'set interfaces ethernet eth0 vif 101 description voice' in result.commands" + - "'set interfaces ethernet eth1 vif 201 description mgm' in result.commands" + +- name: Create VLANs using aggregate (idempotent) + register: result + vyos.vyos.vyos_vlan: *id004 + +- assert: + that: + - result.changed == false + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 101 + - delete interfaces ethernet eth1 vif 201 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml new file mode 100644 index 00000000..f180d177 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml @@ -0,0 +1,59 @@ +--- +- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 100 + +- name: set vlan with name + register: result + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + +- assert: + that: + - result.changed == true + - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" + +- name: check vlan interface intent + register: result + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + associated_interfaces: eth1 + +- assert: + that: + - result.failed == false + +- name: vlan interface config + intent + register: result + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth0 + associated_interfaces: + - eth0 + - eth1 + +- assert: + that: + - result.failed == false + +- name: vlan intent fail + register: result + ignore_errors: true + vyos.vyos.vyos_vlan: + vlan_id: 100 + associated_interfaces: + - eth3 + - eth4 + +- assert: + that: + - result.failed == True + +- debug: msg="End cli/intent.yaml on connection={{ ansible_connection }}" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml new file mode 100644 index 00000000..2059a438 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml @@ -0,0 +1,60 @@ +--- +- debug: msg="START cli/multiple.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth1 vif 100 + +- name: Add multiple interfaces to vlan + register: result + vyos.vyos.vyos_vlan: &id001 + vlan_id: 100 + interfaces: + - eth0 + - eth1 + +- assert: + that: + - result.changed == true + - "'set interfaces ethernet eth0 vif 100' in result.commands" + - "'set interfaces ethernet eth1 vif 100' in result.commands" + +- name: Add multiple interfaces to vlan(idempotence) + register: result + vyos.vyos.vyos_vlan: *id001 + +- assert: + that: + - result.changed == false + +- name: delete vlan with multiple interfaces + register: result + vyos.vyos.vyos_vlan: &id002 + vlan_id: 100 + interfaces: + - eth0 + - eth1 + state: absent + +- assert: + that: + - result.changed == true + - "'delete interfaces ethernet eth0 vif 100' in result.commands" + - "'delete interfaces ethernet eth1 vif 100' in result.commands" + +- name: delete vlan with multiple interfaces(idempotence) + register: result + vyos.vyos.vyos_vlan: *id002 + +- assert: + that: + - result.changed == false + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth1 vif 100 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..c835eef8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/ignore-2.10.txt @@ -0,0 +1 @@ +plugins/action/vyos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/ignore-2.9.txt new file mode 100644 index 00000000..8f3fd9cf --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/ignore-2.9.txt @@ -0,0 +1,13 @@ +plugins/modules/vyos_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/vyos_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/vyos_l3_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/vyos_l3_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/vyos_linkagg.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/vyos_linkagg.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/vyos_static_route.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/vyos_static_route.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/vyos_lldp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/vyos_lldp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/modules/vyos_lldp_interface.py validate-modules:deprecation-mismatch # 2.9 expects METADATA +plugins/modules/vyos_lldp_interface.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict +plugins/action/vyos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/requirements.txt b/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/requirements.txt new file mode 100644 index 00000000..3e3a9669 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/sanity/requirements.txt @@ -0,0 +1,4 @@ +packaging # needed for update-bundled and changelog +sphinx ; python_version >= '3.5' # docs build requires python 3+ +sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ +straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/builtins.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/builtins.py new file mode 100644 index 00000000..bfc8adfb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/builtins.py @@ -0,0 +1,34 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# +# Compat for python2.7 +# + +# One unittest needs to import builtins via __import__() so we need to have +# the string that represents it +try: + import __builtin__ +except ImportError: + BUILTINS = "builtins" +else: + BUILTINS = "__builtin__" diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/mock.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/mock.py new file mode 100644 index 00000000..b7df24ff --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/mock.py @@ -0,0 +1,127 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +""" +Compat module for Python3.x's unittest.mock module +""" +import sys +import _io + +# Python 2.7 + +# Note: Could use the pypi mock library on python3.x as well as python2.x. It +# is the same as the python3 stdlib mock library + +try: + # Allow wildcard import because we really do want to import all of mock's + # symbols into this compat shim + # pylint: disable=wildcard-import,unused-wildcard-import + from unittest.mock import * +except ImportError: + # Python 2 + # pylint: disable=wildcard-import,unused-wildcard-import + try: + from mock import * + except ImportError: + print("You need the mock library installed on python2.x to run tests") + + +# Prior to 3.4.4, mock_open cannot handle binary read_data +if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + sep = b"\n" if isinstance(read_data, bytes) else "\n" + data_as_list = [l + sep for l in read_data.split(sep)] + + if data_as_list[-1] == sep: + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + def mock_open(mock=None, read_data=""): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return type(read_data)().join(_data) + + def _readline_side_effect(): + if handle.readline.return_value is not None: + while True: + yield handle.readline.return_value + for line in _data: + yield line + + global file_spec + if file_spec is None: + + file_spec = list( + set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))) + ) + + if mock is None: + mock = MagicMock(name="open", spec=open) + + handle = MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/unittest.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/unittest.py new file mode 100644 index 00000000..df3379b8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/compat/unittest.py @@ -0,0 +1,39 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +""" +Compat module for Python2.7's unittest module +""" + +import sys + +# Allow wildcard import because we really do want to import all of +# unittests's symbols into this compat shim +# pylint: disable=wildcard-import,unused-wildcard-import +if sys.version_info < (2, 7): + try: + # Need unittest2 on python2.6 + from unittest2 import * + except ImportError: + print("You need unittest2 installed on python2.6.x to run tests") +else: + from unittest import * diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/loader.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/loader.py new file mode 100644 index 00000000..c21188ee --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/loader.py @@ -0,0 +1,116 @@ +# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import os + +from ansible.errors import AnsibleParserError +from ansible.parsing.dataloader import DataLoader +from ansible.module_utils._text import to_bytes, to_text + + +class DictDataLoader(DataLoader): + def __init__(self, file_mapping=None): + file_mapping = {} if file_mapping is None else file_mapping + assert type(file_mapping) == dict + + super(DictDataLoader, self).__init__() + + self._file_mapping = file_mapping + self._build_known_directories() + self._vault_secrets = None + + def load_from_file(self, path, cache=True, unsafe=False): + path = to_text(path) + if path in self._file_mapping: + return self.load(self._file_mapping[path], path) + return None + + # TODO: the real _get_file_contents returns a bytestring, so we actually convert the + # unicode/text it's created with to utf-8 + def _get_file_contents(self, path): + path = to_text(path) + if path in self._file_mapping: + return (to_bytes(self._file_mapping[path]), False) + else: + raise AnsibleParserError("file not found: %s" % path) + + def path_exists(self, path): + path = to_text(path) + return path in self._file_mapping or path in self._known_directories + + def is_file(self, path): + path = to_text(path) + return path in self._file_mapping + + def is_directory(self, path): + path = to_text(path) + return path in self._known_directories + + def list_directory(self, path): + ret = [] + path = to_text(path) + for x in list(self._file_mapping.keys()) + self._known_directories: + if x.startswith(path): + if os.path.dirname(x) == path: + ret.append(os.path.basename(x)) + return ret + + def is_executable(self, path): + # FIXME: figure out a way to make paths return true for this + return False + + def _add_known_directory(self, directory): + if directory not in self._known_directories: + self._known_directories.append(directory) + + def _build_known_directories(self): + self._known_directories = [] + for path in self._file_mapping: + dirname = os.path.dirname(path) + while dirname not in ("/", ""): + self._add_known_directory(dirname) + dirname = os.path.dirname(dirname) + + def push(self, path, content): + rebuild_dirs = False + if path not in self._file_mapping: + rebuild_dirs = True + + self._file_mapping[path] = content + + if rebuild_dirs: + self._build_known_directories() + + def pop(self, path): + if path in self._file_mapping: + del self._file_mapping[path] + self._build_known_directories() + + def clear(self): + self._file_mapping = dict() + self._known_directories = [] + + def get_basedir(self): + return os.getcwd() + + def set_vault_secrets(self, vault_secrets): + self._vault_secrets = vault_secrets diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/path.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/path.py new file mode 100644 index 00000000..74b02be8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/path.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock +from ansible.utils.path import unfrackpath + + +mock_unfrackpath_noop = MagicMock( + spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x +) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/procenv.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/procenv.py new file mode 100644 index 00000000..1587949e --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/procenv.py @@ -0,0 +1,94 @@ +# (c) 2016, Matt Davis <mdavis@ansible.com> +# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import sys +import json + +from contextlib import contextmanager +from io import BytesIO, StringIO +from ansible_collections.vyos.vyos.tests.unit.compat import unittest +from ansible.module_utils.six import PY3 +from ansible.module_utils._text import to_bytes + + +@contextmanager +def swap_stdin_and_argv(stdin_data="", argv_data=tuple()): + """ + context manager that temporarily masks the test runner's values for stdin and argv + """ + real_stdin = sys.stdin + real_argv = sys.argv + + if PY3: + fake_stream = StringIO(stdin_data) + fake_stream.buffer = BytesIO(to_bytes(stdin_data)) + else: + fake_stream = BytesIO(to_bytes(stdin_data)) + + try: + sys.stdin = fake_stream + sys.argv = argv_data + + yield + finally: + sys.stdin = real_stdin + sys.argv = real_argv + + +@contextmanager +def swap_stdout(): + """ + context manager that temporarily replaces stdout for tests that need to verify output + """ + old_stdout = sys.stdout + + if PY3: + fake_stream = StringIO() + else: + fake_stream = BytesIO() + + try: + sys.stdout = fake_stream + + yield fake_stream + finally: + sys.stdout = old_stdout + + +class ModuleTestCase(unittest.TestCase): + def setUp(self, module_args=None): + if module_args is None: + module_args = { + "_ansible_remote_tmp": "/tmp", + "_ansible_keep_remote_files": False, + } + + args = json.dumps(dict(ANSIBLE_MODULE_ARGS=module_args)) + + # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually + self.stdin_swap = swap_stdin_and_argv(stdin_data=args) + self.stdin_swap.__enter__() + + def tearDown(self): + # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually + self.stdin_swap.__exit__(None, None, None) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/vault_helper.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/vault_helper.py new file mode 100644 index 00000000..b34ae134 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/vault_helper.py @@ -0,0 +1,42 @@ +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible.module_utils._text import to_bytes + +from ansible.parsing.vault import VaultSecret + + +class TextVaultSecret(VaultSecret): + """A secret piece of text. ie, a password. Tracks text encoding. + + The text encoding of the text may not be the default text encoding so + we keep track of the encoding so we encode it to the same bytes.""" + + def __init__(self, text, encoding=None, errors=None, _bytes=None): + super(TextVaultSecret, self).__init__() + self.text = text + self.encoding = encoding or "utf-8" + self._bytes = _bytes + self.errors = errors or "strict" + + @property + def bytes(self): + """The text encoded with encoding, unless we specifically set _bytes.""" + return self._bytes or to_bytes( + self.text, encoding=self.encoding, errors=self.errors + ) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/yaml_helper.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/yaml_helper.py new file mode 100644 index 00000000..5df30aae --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/mock/yaml_helper.py @@ -0,0 +1,167 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import io +import yaml + +from ansible.module_utils.six import PY3 +from ansible.parsing.yaml.loader import AnsibleLoader +from ansible.parsing.yaml.dumper import AnsibleDumper + + +class YamlTestUtils(object): + """Mixin class to combine with a unittest.TestCase subclass.""" + + def _loader(self, stream): + """Vault related tests will want to override this. + + Vault cases should setup a AnsibleLoader that has the vault password.""" + return AnsibleLoader(stream) + + def _dump_stream(self, obj, stream, dumper=None): + """Dump to a py2-unicode or py3-string stream.""" + if PY3: + return yaml.dump(obj, stream, Dumper=dumper) + else: + return yaml.dump(obj, stream, Dumper=dumper, encoding=None) + + def _dump_string(self, obj, dumper=None): + """Dump to a py2-unicode or py3-string""" + if PY3: + return yaml.dump(obj, Dumper=dumper) + else: + return yaml.dump(obj, Dumper=dumper, encoding=None) + + def _dump_load_cycle(self, obj): + # Each pass though a dump or load revs the 'generation' + # obj to yaml string + string_from_object_dump = self._dump_string(obj, dumper=AnsibleDumper) + + # wrap a stream/file like StringIO around that yaml + stream_from_object_dump = io.StringIO(string_from_object_dump) + loader = self._loader(stream_from_object_dump) + # load the yaml stream to create a new instance of the object (gen 2) + obj_2 = loader.get_data() + + # dump the gen 2 objects directory to strings + string_from_object_dump_2 = self._dump_string( + obj_2, dumper=AnsibleDumper + ) + + # The gen 1 and gen 2 yaml strings + self.assertEqual(string_from_object_dump, string_from_object_dump_2) + # the gen 1 (orig) and gen 2 py object + self.assertEqual(obj, obj_2) + + # again! gen 3... load strings into py objects + stream_3 = io.StringIO(string_from_object_dump_2) + loader_3 = self._loader(stream_3) + obj_3 = loader_3.get_data() + + string_from_object_dump_3 = self._dump_string( + obj_3, dumper=AnsibleDumper + ) + + self.assertEqual(obj, obj_3) + # should be transitive, but... + self.assertEqual(obj_2, obj_3) + self.assertEqual(string_from_object_dump, string_from_object_dump_3) + + def _old_dump_load_cycle(self, obj): + """Dump the passed in object to yaml, load it back up, dump again, compare.""" + stream = io.StringIO() + + yaml_string = self._dump_string(obj, dumper=AnsibleDumper) + self._dump_stream(obj, stream, dumper=AnsibleDumper) + + yaml_string_from_stream = stream.getvalue() + + # reset stream + stream.seek(0) + + loader = self._loader(stream) + # loader = AnsibleLoader(stream, vault_password=self.vault_password) + obj_from_stream = loader.get_data() + + stream_from_string = io.StringIO(yaml_string) + loader2 = self._loader(stream_from_string) + # loader2 = AnsibleLoader(stream_from_string, vault_password=self.vault_password) + obj_from_string = loader2.get_data() + + stream_obj_from_stream = io.StringIO() + stream_obj_from_string = io.StringIO() + + if PY3: + yaml.dump( + obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper + ) + yaml.dump( + obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper + ) + else: + yaml.dump( + obj_from_stream, + stream_obj_from_stream, + Dumper=AnsibleDumper, + encoding=None, + ) + yaml.dump( + obj_from_stream, + stream_obj_from_string, + Dumper=AnsibleDumper, + encoding=None, + ) + + yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue() + yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue() + + stream_obj_from_stream.seek(0) + stream_obj_from_string.seek(0) + + if PY3: + yaml_string_obj_from_stream = yaml.dump( + obj_from_stream, Dumper=AnsibleDumper + ) + yaml_string_obj_from_string = yaml.dump( + obj_from_string, Dumper=AnsibleDumper + ) + else: + yaml_string_obj_from_stream = yaml.dump( + obj_from_stream, Dumper=AnsibleDumper, encoding=None + ) + yaml_string_obj_from_string = yaml.dump( + obj_from_string, Dumper=AnsibleDumper, encoding=None + ) + + assert yaml_string == yaml_string_obj_from_stream + assert ( + yaml_string + == yaml_string_obj_from_stream + == yaml_string_obj_from_string + ) + assert ( + yaml_string + == yaml_string_obj_from_stream + == yaml_string_obj_from_string + == yaml_string_stream_obj_from_stream + == yaml_string_stream_obj_from_string + ) + assert obj == obj_from_stream + assert obj == obj_from_string + assert obj == yaml_string_obj_from_stream + assert obj == yaml_string_obj_from_string + assert ( + obj + == obj_from_stream + == obj_from_string + == yaml_string_obj_from_stream + == yaml_string_obj_from_string + ) + return { + "obj": obj, + "yaml_string": yaml_string, + "yaml_string_from_stream": yaml_string_from_stream, + "obj_from_stream": obj_from_stream, + "obj_from_string": obj_from_string, + "yaml_string_obj_from_string": yaml_string_obj_from_string, + } diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/conftest.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/conftest.py new file mode 100644 index 00000000..e19a1e04 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/conftest.py @@ -0,0 +1,40 @@ +# Copyright (c) 2017 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import json + +import pytest + +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_bytes +from ansible.module_utils.common._collections_compat import MutableMapping + + +@pytest.fixture +def patch_ansible_module(request, mocker): + if isinstance(request.param, string_types): + args = request.param + elif isinstance(request.param, MutableMapping): + if "ANSIBLE_MODULE_ARGS" not in request.param: + request.param = {"ANSIBLE_MODULE_ARGS": request.param} + if "_ansible_remote_tmp" not in request.param["ANSIBLE_MODULE_ARGS"]: + request.param["ANSIBLE_MODULE_ARGS"][ + "_ansible_remote_tmp" + ] = "/tmp" + if ( + "_ansible_keep_remote_files" + not in request.param["ANSIBLE_MODULE_ARGS"] + ): + request.param["ANSIBLE_MODULE_ARGS"][ + "_ansible_keep_remote_files" + ] = False + args = json.dumps(request.param) + else: + raise Exception( + "Malformed data to the patch_ansible_module pytest fixture" + ) + + mocker.patch("ansible.module_utils.basic._ANSIBLE_ARGS", to_bytes(args)) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/__init__.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/__init__.py diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/show_host_name b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/show_host_name new file mode 100644 index 00000000..e89bc064 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/show_host_name @@ -0,0 +1 @@ +vyos01 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/show_version b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/show_version new file mode 100644 index 00000000..a015d554 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/show_version @@ -0,0 +1,14 @@ +Version: VyOS 1.1.7 +Description: VyOS 1.1.7 (helium) +Copyright: 2016 VyOS maintainers and contributors +Built by: maintainers@vyos.net +Built on: Wed Feb 17 09:57:31 UTC 2016 +Build ID: 1602170957-4459750 +System type: x86 64-bit +Boot via: image +Hypervisor: VMware +HW model: VMware Virtual Platform +HW S/N: VMware-42 3c 26 25 44 c5 0a 91-cf 2c 97 2b fe 9b 25 be +HW UUID: 423C2625-44C5-0A91-CF2C-972BFE9B25BE +Uptime: 01:08:20 up 52 days, 2:13, 1 user, load average: 0.00, 0.01, 0.05 + diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_config.cfg new file mode 100644 index 00000000..fcef8ebd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_config.cfg @@ -0,0 +1,10 @@ +set system host-name 'router' +set system domain-name 'example.com' +set system domain-search domain 'example.com' +set system name-server '8.8.8.8' +set system name-server '8.8.4.4' +set interfaces ethernet eth0 address '1.2.3.4/24' +set interfaces ethernet eth0 description 'test string' +set interfaces ethernet eth1 address '6.7.8.9/24' +set interfaces ethernet eth1 description 'test string' +set interfaces ethernet eth1 disable diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_src.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_src.cfg new file mode 100644 index 00000000..410f6115 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_src.cfg @@ -0,0 +1,6 @@ +set system host-name foo + +delete interfaces ethernet eth0 address +set interfaces ethernet eth1 address '6.7.8.9/24' + set interfaces ethernet eth1 description 'test string' +set interfaces ethernet eth1 disable diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg new file mode 100644 index 00000000..81c06b25 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_config_src_brackets.cfg @@ -0,0 +1,22 @@ +interfaces { + ethernet eth0 { + address 10.10.10.10/24 + } + ethernet eth1 { + address 6.7.8.9/24 + description test string + disable + } +} +policy { + route testroute { + rule 1 { + set { + table 10 + } + } + } +} +system { + host-name foo +} diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg new file mode 100644 index 00000000..2a2a8e8b --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_global_config.cfg @@ -0,0 +1,6 @@ +set firewall group address-group RND-HOSTS address 192.0.2.1 +set firewall group address-group RND-HOSTS address 192.0.2.3 +set firewall group address-group RND-HOSTS address 192.0.2.5 +set firewall group address-group RND-HOSTS description 'This group has the Management hosts address lists' +set firewall group network-group RND network 192.0.2.0/24 +set firewall group network-group RND description 'This group has the Management network addresses' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg new file mode 100644 index 00000000..24704d2d --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_interfaces_config.cfg @@ -0,0 +1,8 @@ +set interfaces ethernet eth0 firewall in name 'INBOUND' +set interfaces ethernet eth0 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth0 firewall local name 'LOCAL' +set interfaces ethernet eth0 firewall out name 'OUTBOUND' +set interfaces ethernet eth2 firewall in name 'INBOUND' +set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' +set interfaces ethernet eth2 firewall local name 'LOCAL' +set interfaces ethernet eth2 firewall out name 'OUTBOUND' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg new file mode 100644 index 00000000..f65b3869 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_firewall_rules_config.cfg @@ -0,0 +1,13 @@ +set firewall name V4-INGRESS default-action 'accept' +set firewall ipv6-name V6-INGRESS default-action 'accept' +set firewall name V4-INGRESS description 'This is IPv4 V4-INGRESS rule set' +set firewall name V4-INGRESS enable-default-log +set firewall name V4-INGRESS rule 101 protocol 'icmp' +set firewall name V4-INGRESS rule 101 description 'Rule 101 is configured by Ansible' +set firewall name V4-INGRESS rule 101 fragment 'match-frag' +set firewall name V4-INGRESS rule 101 +set firewall name V4-INGRESS rule 101 disabled +set firewall name V4-INGRESS rule 101 action 'accept' +set firewall name V4-INGRESS rule 101 ipsec 'match-ipsec' +set firewall name V4-EGRESS default-action 'reject' +set firewall ipv6-name V6-EGRESS default-action 'reject' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_interface_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_interface_config.cfg new file mode 100644 index 00000000..08769164 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_interface_config.cfg @@ -0,0 +1,6 @@ +set interfaces ethernet eth0 address 'dhcp' +set interfaces ethernet eth0 hw-id '08:00:27:7c:85:05' +set interfaces ethernet eth1 description 'test-interface' +set interfaces ethernet eth2 hw-id '08:00:27:04:85:99' +set interfaces ethernet eth3 hw-id '08:00:27:1c:82:d1' +set interfaces loopback 'lo' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg new file mode 100644 index 00000000..90f120cb --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_interfaces_config.cfg @@ -0,0 +1,7 @@ +set interfaces ethernet eth0 address 'dhcp' +set interfaces ethernet eth0 hw-id '08:00:27:7c:85:05' +set interfaces ethernet eth1 description 'test-interface' +set interfaces ethernet eth2 hw-id '08:00:27:04:85:99' +set interfaces ethernet eth3 hw-id '08:00:27:1c:82:d1' +set interfaces ethernet eth3 description 'Ethernet 3' +set interfaces loopback 'lo' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_lldp_neighbor_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_lldp_neighbor_config.cfg new file mode 100644 index 00000000..267958c9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_lldp_neighbor_config.cfg @@ -0,0 +1,68 @@ +------------------------------------------------------------------------------- +LLDP neighbors: +------------------------------------------------------------------------------- +Interface: eth1, via: LLDP, RID: 1, Time: 0 day, 00:30:34 + Chassis: + ChassisID: mac 08:00:27:7c:85:05 + SysName: vyos + SysDescr: Vyatta Router running on VyOS 1.1.8 (helium) + MgmtIP: 192.168.56.101 + Capability: Bridge, off + Capability: Router, on + Capability: Wlan, off + Port: + PortID: mac 08:00:27:04:85:99 + PortDescr: eth0 + PMD autoneg: supported: yes, enabled: yes + Adv: 10Base-T, HD: yes, FD: yes + Adv: 100Base-T, HD: yes, FD: yes + Adv: 1000Base-T, HD: no, FD: yes + MAU oper type: 1000BaseTFD - Four-pair Category 5 UTP, full duplex mode + LLDP-MED: + Device Type: Network Connectivity Device + Capability: Capabilities + Capability: Policy + Capability: Location + Capability: MDI/PSE + Capability: MDI/PD + Capability: Inventory + Inventory: + Hardware Revision: 1.2 + Software Revision: 3.13.11-1-586-vyos + Firmware Revision: VirtualBox + Serial Number: 0 + Manufacturer: innotek GmbH + Model: VirtualBox +------------------------------------------------------------------------------- +Interface: eth0, via: LLDP, RID: 1, Time: 0 day, 00:32:50 + Chassis: + ChassisID: mac 08:00:27:7c:85:05 + SysName: vyos + SysDescr: Vyatta Router running on VyOS 1.1.8 (helium) + MgmtIP: 192.168.56.101 + Capability: Bridge, off + Capability: Router, on + Capability: Wlan, off + Port: + PortID: mac 08:00:27:18:e6:f2 + PortDescr: eth1 + PMD autoneg: supported: yes, enabled: yes + Adv: 10Base-T, HD: yes, FD: yes + Adv: 100Base-T, HD: yes, FD: yes + Adv: 1000Base-T, HD: no, FD: yes + MAU oper type: 1000BaseTFD - Four-pair Category 5 UTP, full duplex mode + LLDP-MED: + Device Type: Network Connectivity Device + Capability: Capabilities + Capability: Policy + Capability: Location + Capability: MDI/PSE + Capability: MDI/PD + Capability: Inventory + Inventory: + Hardware Revision: 1.2 + Software Revision: 3.13.11-1-586-vyos + Firmware Revision: VirtualBox + Serial Number: 0 + Manufacturer: innotek GmbH + Model: VirtualBox diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospf_interfaces_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospf_interfaces_config.cfg new file mode 100644 index 00000000..1fab55e3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospf_interfaces_config.cfg @@ -0,0 +1,4 @@ +set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33' +set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore' +set interfaces ethernet eth1 ip ospf cost '100' +set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospfv2_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospfv2_config.cfg new file mode 100644 index 00000000..297671b2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospfv2_config.cfg @@ -0,0 +1,9 @@ +set protocols ospf area 12 area-type normal +set protocols ospf area 12 authentication plaintext-password +set protocols ospf area 12 shortcut enable +set protocols ospf area 14 range 192.0.13.0/24 cost 10 +set protocols ospf area 14 range 192.0.13.0/24 +set protocols ospf area 14 range 192.0.14.0/24 cost 12 +set protocols ospf area 14 range 192.0.14.0/24 +set protocols ospf area 14 area-type stub default-cost 20 +set protocols ospf area 14 network 192.0.12.0/24 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospfv3_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospfv3_config.cfg new file mode 100644 index 00000000..060b9b33 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ospfv3_config.cfg @@ -0,0 +1,6 @@ +set protocols ospfv3 area 12 export-list 'export1' +set protocols ospfv3 area 12 import-list 'import1' +set protocols ospfv3 area 12 range '2001:db11::/32' +set protocols ospfv3 area 12 range '2001:db22::/32' +set protocols ospfv3 area 12 range '2001:db33::/32' +set protocols ospfv3 area 13 range '2001:db44::/32'
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2 b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2 new file mode 100644 index 00000000..c28fba15 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.10_count_2 @@ -0,0 +1,7 @@ +PING 10.10.10.10 (10.10.10.10) 56(84) bytes of data. +64 bytes from 10.10.10.10: icmp_req=1 ttl=255 time=1.27 ms +64 bytes from 10.10.10.10: icmp_req=2 ttl=255 time=2.28 ms + +--- 10.8.38.66 ping statistics --- +2 packets transmitted, 2 received, 0% packet loss, time 1001ms +rtt min/avg/max/mdev = 12.1222/17.124/22.225/10.143 ms diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512 b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512 new file mode 100644 index 00000000..54e026c2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.11_count_10_ttl_128_size_512 @@ -0,0 +1,15 @@ +PING 10.10.10.11 (10.8.38.65) 512(540) bytes of data. +520 bytes from 10.10.10.11: icmp_req=1 ttl=255 time=1.17 ms +520 bytes from 10.10.10.11: icmp_req=2 ttl=255 time=1.32 ms +520 bytes from 10.10.10.11: icmp_req=3 ttl=255 time=1.21 ms +520 bytes from 10.10.10.11: icmp_req=4 ttl=255 time=1.46 ms +520 bytes from 10.10.10.11: icmp_req=5 ttl=255 time=1.32 ms +520 bytes from 10.10.10.11: icmp_req=6 ttl=255 time=1.28 ms +520 bytes from 10.10.10.11: icmp_req=7 ttl=255 time=1.25 ms +520 bytes from 10.10.10.11: icmp_req=8 ttl=255 time=1.23 ms +520 bytes from 10.10.10.11: icmp_req=9 ttl=255 time=1.34 ms +520 bytes from 10.10.10.11: icmp_req=10 ttl=255 time=21.0 ms + +--- 10.10.10.11 ping statistics --- +10 packets transmitted, 10 received, 0% packet loss, time 9012ms +rtt min/avg/max/mdev = 1.170/3.262/21.002/5.913 ms diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4 b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4 new file mode 100644 index 00000000..08e61817 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_ping_ping_10.10.10.20_count_4 @@ -0,0 +1,9 @@ +PING 10.10.10.20 (10.10.10.20) 56(84) bytes of data. +From 10.10.10.20 icmp_seq=1 Destination Host Unreachable +From 10.10.10.20 icmp_seq=2 Destination Host Unreachable +From 10.10.10.20 icmp_seq=3 Destination Host Unreachable +From 10.10.10.20 icmp_seq=4 Destination Host Unreachable + +--- 10.10.10.20 ping statistics --- +4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3053ms +pipe 3 diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_static_routes_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_static_routes_config.cfg new file mode 100644 index 00000000..0411dc9a --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_static_routes_config.cfg @@ -0,0 +1,2 @@ +'set protocols static route 192.0.2.32/28 next-hop 192.0.2.9' +'set protocols static route 192.0.2.32/28 next-hop 192.0.2.10' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_user_config.cfg b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_user_config.cfg new file mode 100644 index 00000000..81cd1a48 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/fixtures/vyos_user_config.cfg @@ -0,0 +1,2 @@ +set system login user admin level operator authentication encrypted-password '$6$V5oWW3JM9NFAwOG$P2L4raFvIrZjjs3g0qmH4Ns5ti7flRpSs6aEqy4TrGZYXGeBiYzwi2A6jy' +set system login user ansible level operator authentication encrypted-password '$6$ZfvSv6A50W6yNPYX$4HP5eg2sywcXYxTqhApQ7zvUvx0HsQHrI9xuJoFLy2gM/' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_banner.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_banner.py new file mode 100644 index 00000000..c575409c --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_banner.py @@ -0,0 +1,63 @@ +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_banner +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule + + +class TestVyosBannerModule(TestVyosModule): + + module = vyos_banner + + def setUp(self): + super(TestVyosBannerModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestVyosBannerModule, self).tearDown() + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None): + self.load_config.return_value = dict(diff=None, session="session") + + def test_vyos_banner_create(self): + set_module_args(dict(banner="pre-login", text="test\nbanner\nstring")) + commands = [ + "set system login banner pre-login 'test\\nbanner\\nstring'" + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_banner_remove(self): + set_module_args(dict(banner="pre-login", state="absent")) + self.execute_module(changed=False, commands=[]) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_command.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_command.py new file mode 100644 index 00000000..820c6c44 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_command.py @@ -0,0 +1,122 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_command +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosCommandModule(TestVyosModule): + + module = vyos_command + + def setUp(self): + super(TestVyosCommandModule, self).setUp() + self.mock_run_commands = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_command.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + def tearDown(self): + super(TestVyosCommandModule, self).tearDown() + self.mock_run_commands.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + module, commands = args + output = list() + + for item in commands: + try: + command = item["command"] + except ValueError: + command = item + filename = str(command).replace(" ", "_") + output.append(load_fixture(filename)) + return output + + self.run_commands.side_effect = load_from_file + + def test_vyos_command_simple(self): + set_module_args(dict(commands=["show version"])) + result = self.execute_module() + self.assertEqual(len(result["stdout"]), 1) + self.assertTrue(result["stdout"][0].startswith("Version: VyOS")) + + def test_vyos_command_multiple(self): + set_module_args(dict(commands=["show version", "show version"])) + result = self.execute_module() + self.assertEqual(len(result["stdout"]), 2) + self.assertTrue(result["stdout"][0].startswith("Version: VyOS")) + + def test_vyos_command_wait_for(self): + wait_for = 'result[0] contains "VyOS maintainers"' + set_module_args(dict(commands=["show version"], wait_for=wait_for)) + self.execute_module() + + def test_vyos_command_wait_for_fails(self): + wait_for = 'result[0] contains "test string"' + set_module_args(dict(commands=["show version"], wait_for=wait_for)) + self.execute_module(failed=True) + self.assertEqual(self.run_commands.call_count, 10) + + def test_vyos_command_retries(self): + wait_for = 'result[0] contains "test string"' + set_module_args( + dict(commands=["show version"], wait_for=wait_for, retries=2) + ) + self.execute_module(failed=True) + self.assertEqual(self.run_commands.call_count, 2) + + def test_vyos_command_match_any(self): + wait_for = [ + 'result[0] contains "VyOS maintainers"', + 'result[0] contains "test string"', + ] + set_module_args( + dict(commands=["show version"], wait_for=wait_for, match="any") + ) + self.execute_module() + + def test_vyos_command_match_all(self): + wait_for = [ + 'result[0] contains "VyOS maintainers"', + 'result[0] contains "maintainers@vyos.net"', + ] + set_module_args( + dict(commands=["show version"], wait_for=wait_for, match="all") + ) + self.execute_module() + + def test_vyos_command_match_all_failure(self): + wait_for = [ + 'result[0] contains "VyOS maintainers"', + 'result[0] contains "test string"', + ] + commands = ["show version", "show version"] + set_module_args( + dict(commands=commands, wait_for=wait_for, match="all") + ) + self.execute_module(failed=True) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_config.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_config.py new file mode 100644 index 00000000..3c49d3aa --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_config.py @@ -0,0 +1,155 @@ +# +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import ( + patch, + MagicMock, +) +from ansible_collections.vyos.vyos.plugins.modules import vyos_config +from ansible_collections.vyos.vyos.plugins.cliconf.vyos import Cliconf +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosConfigModule(TestVyosModule): + + module = vyos_config + + def setUp(self): + super(TestVyosConfigModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_run_commands = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + self.mock_get_connection = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_connection" + ) + self.get_connection = self.mock_get_connection.start() + + self.cliconf_obj = Cliconf(MagicMock()) + self.running_config = load_fixture("vyos_config_config.cfg") + + self.conn = self.get_connection() + self.conn.edit_config = MagicMock() + self.running_config = load_fixture("vyos_config_config.cfg") + + def tearDown(self): + super(TestVyosConfigModule, self).tearDown() + + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_run_commands.stop() + self.mock_get_connection.stop() + + def load_fixtures(self, commands=None): + config_file = "vyos_config_config.cfg" + self.get_config.return_value = load_fixture(config_file) + self.load_config.return_value = None + + def test_vyos_config_unchanged(self): + src = load_fixture("vyos_config_config.cfg") + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff(src, src) + ) + set_module_args(dict(src=src)) + self.execute_module() + + def test_vyos_config_src(self): + src = load_fixture("vyos_config_src.cfg") + set_module_args(dict(src=src)) + candidate = "\n".join(self.module.format_commands(src.splitlines())) + commands = [ + "set system host-name foo", + "delete interfaces ethernet eth0 address", + ] + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + candidate, self.running_config + ) + ) + self.execute_module(changed=True, commands=commands) + + def test_vyos_config_src_brackets(self): + src = load_fixture("vyos_config_src_brackets.cfg") + set_module_args(dict(src=src)) + commands = [ + "set interfaces ethernet eth0 address 10.10.10.10/24", + "set policy route testroute rule 1 set table 10", + "set system host-name foo", + ] + self.conn.get_diff = MagicMock(side_effect=self.cliconf_obj.get_diff) + self.execute_module(changed=True, commands=commands) + + def test_vyos_config_backup(self): + set_module_args(dict(backup=True)) + result = self.execute_module() + self.assertIn("__backup__", result) + + def test_vyos_config_lines(self): + commands = ["set system host-name foo"] + set_module_args(dict(lines=commands)) + candidate = "\n".join(commands) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + candidate, self.running_config + ) + ) + self.execute_module(changed=True, commands=commands) + + def test_vyos_config_config(self): + config = "set system host-name localhost" + new_config = ["set system host-name router"] + set_module_args(dict(lines=new_config, config=config)) + candidate = "\n".join(new_config) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff(candidate, config) + ) + self.execute_module(changed=True, commands=new_config) + + def test_vyos_config_match_none(self): + lines = [ + "set system interfaces ethernet eth0 address 1.2.3.4/24", + "set system interfaces ethernet eth0 description test string", + ] + set_module_args(dict(lines=lines, match="none")) + candidate = "\n".join(lines) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff( + candidate, None, diff_match="none" + ) + ) + self.execute_module(changed=True, commands=lines, sort=False) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_facts.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_facts.py new file mode 100644 index 00000000..b22a5232 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_facts.py @@ -0,0 +1,109 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import json +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_facts +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosFactsModule(TestVyosModule): + module = vyos_facts + + def setUp(self): + super(TestVyosFactsModule, self).setUp() + self.mock_run_commands = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + self.mock_get_resource_connection = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection = ( + self.mock_get_resource_connection.start() + ) + + self.mock_get_capabilities = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.get_capabilities" + ) + self.get_capabilities = self.mock_get_capabilities.start() + self.get_capabilities.return_value = { + "device_info": { + "network_os": "vyos", + "network_os_hostname": "vyos01", + "network_os_model": "VMware", + "network_os_version": "VyOS 1.1.7", + }, + "network_api": "cliconf", + } + + def tearDown(self): + super(TestVyosFactsModule, self).tearDown() + self.mock_run_commands.stop() + self.mock_get_capabilities.stop() + self.mock_get_resource_connection.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + module, commands = args + output = list() + for item in commands: + try: + obj = json.loads(item) + command = obj["command"] + except ValueError: + command = item + filename = str(command).replace(" ", "_") + output.append(load_fixture(filename)) + return output + + self.run_commands.side_effect = load_from_file + + def test_vyos_facts_default(self): + set_module_args(dict(gather_subset="default")) + result = self.execute_module() + facts = result.get("ansible_facts") + self.assertEqual(len(facts), 10) + self.assertEqual(facts["ansible_net_hostname"].strip(), "vyos01") + self.assertEqual(facts["ansible_net_version"], "VyOS 1.1.7") + + def test_vyos_facts_not_all(self): + set_module_args(dict(gather_subset="!all")) + result = self.execute_module() + facts = result.get("ansible_facts") + self.assertEqual(len(facts), 10) + self.assertEqual(facts["ansible_net_hostname"].strip(), "vyos01") + self.assertEqual(facts["ansible_net_version"], "VyOS 1.1.7") + + def test_vyos_facts_exclude_most(self): + set_module_args(dict(gather_subset=["!neighbors", "!config"])) + result = self.execute_module() + facts = result.get("ansible_facts") + self.assertEqual(len(facts), 10) + self.assertEqual(facts["ansible_net_hostname"].strip(), "vyos01") + self.assertEqual(facts["ansible_net_version"], "VyOS 1.1.7") + + def test_vyos_facts_invalid_subset(self): + set_module_args(dict(gather_subset="cereal")) + self.execute_module(failed=True) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_global.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_global.py new file mode 100644 index 00000000..0697f6e1 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_global.py @@ -0,0 +1,254 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_firewall_global +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosFirewallRulesModule(TestVyosModule): + + module = vyos_firewall_global + + def setUp(self): + super(TestVyosFirewallRulesModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data" + ) + + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosFirewallRulesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + return load_fixture("vyos_firewall_global_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_firewall_global_set_01_merged(self): + set_module_args( + dict( + config=dict( + validation="strict", + config_trap=True, + log_martians=True, + syn_cookies=True, + twa_hazards_protection=True, + ping=dict(all=True, broadcast=True), + state_policy=[ + dict( + connection_type="established", + action="accept", + log=True, + ), + dict(connection_type="invalid", action="reject"), + ], + route_redirects=[ + dict( + afi="ipv4", + ip_src_route=True, + icmp_redirects=dict(send=True, receive=False), + ) + ], + group=dict( + address_group=[ + dict( + name="MGMT-HOSTS", + description="This group has the Management hosts address lists", + members=[ + dict(address="192.0.1.1"), + dict(address="192.0.1.3"), + dict(address="192.0.1.5"), + ], + ) + ], + network_group=[ + dict( + name="MGMT", + description="This group has the Management network addresses", + members=[dict(address="192.0.1.0/24")], + ) + ], + ), + ), + state="merged", + ) + ) + commands = [ + "set firewall group address-group MGMT-HOSTS address 192.0.1.1", + "set firewall group address-group MGMT-HOSTS address 192.0.1.3", + "set firewall group address-group MGMT-HOSTS address 192.0.1.5", + "set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address lists'", + "set firewall group address-group MGMT-HOSTS", + "set firewall group network-group MGMT network 192.0.1.0/24", + "set firewall group network-group MGMT description 'This group has the Management network addresses'", + "set firewall group network-group MGMT", + "set firewall ip-src-route 'enable'", + "set firewall receive-redirects 'disable'", + "set firewall send-redirects 'enable'", + "set firewall config-trap 'enable'", + "set firewall state-policy established action 'accept'", + "set firewall state-policy established log 'enable'", + "set firewall state-policy invalid action 'reject'", + "set firewall broadcast-ping 'enable'", + "set firewall all-ping 'enable'", + "set firewall log-martians 'enable'", + "set firewall twa-hazards-protection 'enable'", + "set firewall syn-cookies 'enable'", + "set firewall source-validation 'strict'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_global_set_01_merged_idem(self): + set_module_args( + dict( + config=dict( + group=dict( + address_group=[ + dict( + name="RND-HOSTS", + description="This group has the Management hosts address lists", + members=[ + dict(address="192.0.2.1"), + dict(address="192.0.2.3"), + dict(address="192.0.2.5"), + ], + ) + ], + network_group=[ + dict( + name="RND", + description="This group has the Management network addresses", + members=[dict(address="192.0.2.0/24")], + ) + ], + ) + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_global_set_01_replaced(self): + set_module_args( + dict( + config=dict( + group=dict( + address_group=[ + dict( + name="RND-HOSTS", + description="This group has the Management hosts address lists", + members=[ + dict(address="192.0.2.1"), + dict(address="192.0.2.7"), + dict(address="192.0.2.9"), + ], + ) + ], + network_group=[ + dict( + name="RND", + description="This group has the Management network addresses", + members=[dict(address="192.0.2.0/24")], + ) + ], + ) + ), + state="replaced", + ) + ) + commands = [ + "delete firewall group address-group RND-HOSTS address 192.0.2.3", + "delete firewall group address-group RND-HOSTS address 192.0.2.5", + "set firewall group address-group RND-HOSTS address 192.0.2.7", + "set firewall group address-group RND-HOSTS address 192.0.2.9", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_global_set_01_replaced_idem(self): + set_module_args( + dict( + config=dict( + group=dict( + address_group=[ + dict( + name="RND-HOSTS", + description="This group has the Management hosts address lists", + members=[ + dict(address="192.0.2.1"), + dict(address="192.0.2.3"), + dict(address="192.0.2.5"), + ], + ) + ], + network_group=[ + dict( + name="RND", + description="This group has the Management network addresses", + members=[dict(address="192.0.2.0/24")], + ) + ], + ) + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_global_set_01_deleted(self): + set_module_args(dict(config=dict(), state="deleted")) + commands = ["delete firewall "] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py new file mode 100644 index 00000000..2a9a81c6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py @@ -0,0 +1,430 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import ( + vyos_firewall_interfaces, +) +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosFirewallInterfacesModule(TestVyosModule): + + module = vyos_firewall_interfaces + + def setUp(self): + super(TestVyosFirewallInterfacesModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos." + "facts.firewall_interfaces.firewall_interfaces.Firewall_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosFirewallInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + return load_fixture("vyos_firewall_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_firewall_rule_set_01_merged(self): + set_module_args( + dict( + config=[ + dict( + name="eth1", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + dict( + name="eth3", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + ], + state="merged", + ) + ) + commands = [ + "set interfaces ethernet eth1 firewall in name 'INBOUND'", + "set interfaces ethernet eth1 firewall out name 'OUTBOUND'", + "set interfaces ethernet eth1 firewall local name 'LOCAL'", + "set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'", + "set interfaces ethernet eth3 firewall in name 'INBOUND'", + "set interfaces ethernet eth3 firewall out name 'OUTBOUND'", + "set interfaces ethernet eth3 firewall local name 'LOCAL'", + "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_02_merged_idem(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + dict( + name="eth2", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_rule_set_01_deleted_per_afi(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + access_rules=[dict(afi="ipv4"), dict(afi="ipv6")], + ) + ], + state="deleted", + ) + ) + commands = [ + "delete interfaces ethernet eth0 firewall in name", + "delete interfaces ethernet eth0 firewall local name", + "delete interfaces ethernet eth0 firewall out name", + "delete interfaces ethernet eth0 firewall local ipv6-name", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_03_deleted_per_interface(self): + set_module_args( + dict( + config=[dict(name="eth0"), dict(name="eth2")], state="deleted" + ) + ) + commands = [ + "delete interfaces ethernet eth0 firewall", + "delete interfaces ethernet eth2 firewall", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_03_deleted_all(self): + set_module_args(dict(config=[], state="deleted")) + commands = [ + "delete interfaces ethernet eth0 firewall", + "delete interfaces ethernet eth2 firewall", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_03_deleted(self): + set_module_args( + dict( + config=[dict(name="eth0"), dict(name="eth2")], state="deleted" + ) + ) + commands = [ + "delete interfaces ethernet eth0 firewall", + "delete interfaces ethernet eth2 firewall", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_04_deleted_interface_idem(self): + set_module_args( + dict( + config=[dict(name="eth1"), dict(name="eth3")], state="deleted" + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_rule_set_02_replaced_idem(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + dict( + name="eth2", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_rule_set_01_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="INBOUND", direction="in")], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + dict( + name="eth2", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="LOCAL", direction="local")], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + dict( + name="eth3", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="LOCAL", direction="local")], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + ], + state="replaced", + ) + ) + commands = [ + "delete interfaces ethernet eth0 firewall out name", + "delete interfaces ethernet eth0 firewall local name", + "delete interfaces ethernet eth2 firewall in name", + "delete interfaces ethernet eth2 firewall out name", + "set interfaces ethernet eth3 firewall local name 'LOCAL'", + "set interfaces ethernet eth3 firewall local ipv6-name 'V6-LOCAL'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_01_overridden(self): + set_module_args( + dict( + config=[ + dict( + name="eth1", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="INBOUND", direction="in")], + ) + ], + ) + ], + state="overridden", + ) + ) + commands = [ + "delete interfaces ethernet eth0 firewall", + "delete interfaces ethernet eth2 firewall", + "set interfaces ethernet eth1 firewall in name 'INBOUND'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_02_overridden_idem(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + dict( + name="eth2", + access_rules=[ + dict( + afi="ipv4", + rules=[ + dict(name="INBOUND", direction="in"), + dict(name="OUTBOUND", direction="out"), + dict(name="LOCAL", direction="local"), + ], + ), + dict( + afi="ipv6", + rules=[ + dict(name="V6-LOCAL", direction="local") + ], + ), + ], + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py new file mode 100644 index 00000000..72194435 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py @@ -0,0 +1,1070 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_firewall_rules +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosFirewallRulesModule(TestVyosModule): + + module = vyos_firewall_rules + + def setUp(self): + super(TestVyosFirewallRulesModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data" + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_rules.firewall_rules.Firewall_rulesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosFirewallRulesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + return load_fixture("vyos_firewall_rules_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_firewall_rule_set_01_merged(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INBOUND", + description="This is IPv6 INBOUND rule set", + default_action="reject", + enable_default_log=True, + rules=[], + ), + dict( + name="V6-OUTBOUND", + description="This is IPv6 OUTBOUND rule set", + default_action="accept", + enable_default_log=False, + rules=[], + ), + ], + ), + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INBOUND", + description="This is IPv4 INBOUND rule set", + default_action="reject", + enable_default_log=True, + rules=[], + ), + dict( + name="V4-OUTBOUND", + description="This is IPv4 OUTBOUND rule set", + default_action="accept", + enable_default_log=False, + rules=[], + ), + ], + ), + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name V6-INBOUND default-action 'reject'", + "set firewall ipv6-name V6-INBOUND description 'This is IPv6 INBOUND rule set'", + "set firewall ipv6-name V6-INBOUND enable-default-log", + "set firewall ipv6-name V6-OUTBOUND default-action 'accept'", + "set firewall ipv6-name V6-OUTBOUND description 'This is IPv6 OUTBOUND rule set'", + "set firewall name V4-INBOUND default-action 'reject'", + "set firewall name V4-INBOUND description 'This is IPv4 INBOUND rule set'", + "set firewall name V4-INBOUND enable-default-log", + "set firewall name V4-OUTBOUND default-action 'accept'", + "set firewall name V4-OUTBOUND description 'This is IPv4 OUTBOUND rule set'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_rule_set_02_merged(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INBOUND", + description="This is IPv6 INBOUND rule set", + default_action="reject", + enable_default_log=True, + rules=[], + ), + dict( + name="V6-OUTBOUND", + description="This is IPv6 OUTBOUND rule set", + default_action="accept", + enable_default_log=False, + rules=[], + ), + ], + ), + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INBOUND", + description="This is IPv4 INBOUND rule set", + default_action="reject", + enable_default_log=True, + rules=[], + ), + dict( + name="V4-OUTBOUND", + description="This is IPv4 OUTBOUND rule set", + default_action="accept", + enable_default_log=False, + rules=[], + ), + ], + ), + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name V6-INBOUND default-action 'reject'", + "set firewall ipv6-name V6-INBOUND description 'This is IPv6 INBOUND rule set'", + "set firewall ipv6-name V6-INBOUND enable-default-log", + "set firewall ipv6-name V6-OUTBOUND default-action 'accept'", + "set firewall ipv6-name V6-OUTBOUND description 'This is IPv6 OUTBOUND rule set'", + "set firewall name V4-INBOUND default-action 'reject'", + "set firewall name V4-INBOUND description 'This is IPv4 INBOUND rule set'", + "set firewall name V4-INBOUND enable-default-log", + "set firewall name V4-OUTBOUND default-action 'accept'", + "set firewall name V4-OUTBOUND description 'This is IPv4 OUTBOUND rule set'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_rule_merged_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="INBOUND", + description="This is IPv4 INBOUND rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="101", + action="accept", + description="Rule 101 is configured by Ansible", + ipsec="match-ipsec", + protocol="icmp", + fragment="match-frag", + disabled=True, + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall name INBOUND default-action 'accept'", + "set firewall name INBOUND description 'This is IPv4 INBOUND rule set'", + "set firewall name INBOUND enable-default-log", + "set firewall name INBOUND rule 101 protocol 'icmp'", + "set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", + "set firewall name INBOUND rule 101 fragment 'match-frag'", + "set firewall name INBOUND rule 101", + "set firewall name INBOUND rule 101 disabled", + "set firewall name INBOUND rule 101 action 'accept'", + "set firewall name INBOUND rule 101 ipsec 'match-ipsec'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_rule_merged_02(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + protocol="tcp", + source=dict( + address="192.0.2.0", + mac_address="38:00:25:19:76:0c", + port=2127, + ), + destination=dict( + address="192.0.1.0", port=2124 + ), + limit=dict( + burst=10, + rate=dict( + number=20, unit="second" + ), + ), + recent=dict(count=10, time=20), + state=dict( + established=True, + related=True, + invalid=True, + new=True, + ), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall name INBOUND rule 101 protocol 'tcp'", + "set firewall name INBOUND rule 101 destination address 192.0.1.0", + "set firewall name INBOUND rule 101 destination port 2124", + "set firewall name INBOUND rule 101", + "set firewall name INBOUND rule 101 source address 192.0.2.0", + "set firewall name INBOUND rule 101 source mac-address 38:00:25:19:76:0c", + "set firewall name INBOUND rule 101 source port 2127", + "set firewall name INBOUND rule 101 state new enable", + "set firewall name INBOUND rule 101 state invalid enable", + "set firewall name INBOUND rule 101 state related enable", + "set firewall name INBOUND rule 101 state established enable", + "set firewall name INBOUND rule 101 limit burst 10", + "set firewall name INBOUND rule 101 limit rate 20/second", + "set firewall name INBOUND rule 101 recent count 10", + "set firewall name INBOUND rule 101 recent time 20", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_rule_merged_03(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + destination=dict( + group=dict( + address_group="OUT-ADDR-GROUP", + network_group="OUT-NET-GROUP", + port_group="OUT-PORT-GROUP", + ) + ), + source=dict( + group=dict( + address_group="IN-ADDR-GROUP", + network_group="IN-NET-GROUP", + port_group="IN-PORT-GROUP", + ) + ), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall name INBOUND rule 101 source group address-group IN-ADDR-GROUP", + "set firewall name INBOUND rule 101 source group network-group IN-NET-GROUP", + "set firewall name INBOUND rule 101 source group port-group IN-PORT-GROUP", + "set firewall name INBOUND rule 101 destination group address-group OUT-ADDR-GROUP", + "set firewall name INBOUND rule 101 destination group network-group OUT-NET-GROUP", + "set firewall name INBOUND rule 101 destination group port-group OUT-PORT-GROUP", + "set firewall name INBOUND rule 101", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_rule_merged_04(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + time=dict( + monthdays="2", + startdate="2020-01-24", + starttime="13:20:00", + stopdate="2020-01-28", + stoptime="13:30:00", + weekdays="!Sat,Sun", + utc=True, + ), + tcp=dict(flags="ALL"), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall name INBOUND rule 101", + "set firewall name INBOUND rule 101 tcp flags ALL", + "set firewall name INBOUND rule 101 time utc", + "set firewall name INBOUND rule 101 time monthdays 2", + "set firewall name INBOUND rule 101 time startdate 2020-01-24", + "set firewall name INBOUND rule 101 time stopdate 2020-01-28", + "set firewall name INBOUND rule 101 time weekdays !Sat,Sun", + "set firewall name INBOUND rule 101 time stoptime 13:30:00", + "set firewall name INBOUND rule 101 time starttime 13:20:00", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v6_rule_sets_rule_merged_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="INBOUND", + description="This is IPv6 INBOUND rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="101", + action="accept", + description="Rule 101 is configured by Ansible", + ipsec="match-ipsec", + protocol="icmp", + disabled=True, + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name INBOUND default-action 'accept'", + "set firewall ipv6-name INBOUND description 'This is IPv6 INBOUND rule set'", + "set firewall ipv6-name INBOUND enable-default-log", + "set firewall ipv6-name INBOUND rule 101 protocol 'icmp'", + "set firewall ipv6-name INBOUND rule 101 description 'Rule 101 is configured by Ansible'", + "set firewall ipv6-name INBOUND rule 101", + "set firewall ipv6-name INBOUND rule 101 disabled", + "set firewall ipv6-name INBOUND rule 101 action 'accept'", + "set firewall ipv6-name INBOUND rule 101 ipsec 'match-ipsec'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v6_rule_sets_rule_merged_02(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + protocol="tcp", + source=dict( + address="2001:db8::12", + mac_address="38:00:25:19:76:0c", + port=2127, + ), + destination=dict( + address="2001:db8::11", port=2124 + ), + limit=dict( + burst=10, + rate=dict( + number=20, unit="second" + ), + ), + recent=dict(count=10, time=20), + state=dict( + established=True, + related=True, + invalid=True, + new=True, + ), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name INBOUND rule 101 protocol 'tcp'", + "set firewall ipv6-name INBOUND rule 101 destination address 2001:db8::11", + "set firewall ipv6-name INBOUND rule 101 destination port 2124", + "set firewall ipv6-name INBOUND rule 101", + "set firewall ipv6-name INBOUND rule 101 source address 2001:db8::12", + "set firewall ipv6-name INBOUND rule 101 source mac-address 38:00:25:19:76:0c", + "set firewall ipv6-name INBOUND rule 101 source port 2127", + "set firewall ipv6-name INBOUND rule 101 state new enable", + "set firewall ipv6-name INBOUND rule 101 state invalid enable", + "set firewall ipv6-name INBOUND rule 101 state related enable", + "set firewall ipv6-name INBOUND rule 101 state established enable", + "set firewall ipv6-name INBOUND rule 101 limit burst 10", + "set firewall ipv6-name INBOUND rule 101 recent count 10", + "set firewall ipv6-name INBOUND rule 101 recent time 20", + "set firewall ipv6-name INBOUND rule 101 limit rate 20/second", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v6_rule_sets_rule_merged_03(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + destination=dict( + group=dict( + address_group="OUT-ADDR-GROUP", + network_group="OUT-NET-GROUP", + port_group="OUT-PORT-GROUP", + ) + ), + source=dict( + group=dict( + address_group="IN-ADDR-GROUP", + network_group="IN-NET-GROUP", + port_group="IN-PORT-GROUP", + ) + ), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name INBOUND rule 101 source group address-group IN-ADDR-GROUP", + "set firewall ipv6-name INBOUND rule 101 source group network-group IN-NET-GROUP", + "set firewall ipv6-name INBOUND rule 101 source group port-group IN-PORT-GROUP", + "set firewall ipv6-name INBOUND rule 101 destination group address-group OUT-ADDR-GROUP", + "set firewall ipv6-name INBOUND rule 101 destination group network-group OUT-NET-GROUP", + "set firewall ipv6-name INBOUND rule 101 destination group port-group OUT-PORT-GROUP", + "set firewall ipv6-name INBOUND rule 101", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v6_rule_sets_rule_merged_04(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + time=dict( + monthdays="2", + startdate="2020-01-24", + starttime="13:20:00", + stopdate="2020-01-28", + stoptime="13:30:00", + weekdays="!Sat,Sun", + utc=True, + ), + tcp=dict(flags="ALL"), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name INBOUND rule 101", + "set firewall ipv6-name INBOUND rule 101 tcp flags ALL", + "set firewall ipv6-name INBOUND rule 101 time utc", + "set firewall ipv6-name INBOUND rule 101 time monthdays 2", + "set firewall ipv6-name INBOUND rule 101 time startdate 2020-01-24", + "set firewall ipv6-name INBOUND rule 101 time stopdate 2020-01-28", + "set firewall ipv6-name INBOUND rule 101 time weekdays !Sat,Sun", + "set firewall ipv6-name INBOUND rule 101 time stoptime 13:30:00", + "set firewall ipv6-name INBOUND rule 101 time starttime 13:20:00", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v6_rule_sets_rule_merged_icmp_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv6", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + protocol="icmp", + icmp=dict( + type_name="port-unreachable" + ), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall ipv6-name INBOUND rule 101 icmpv6 type port-unreachable", + "set firewall ipv6-name INBOUND rule 101 protocol 'icmp'", + "set firewall ipv6-name INBOUND rule 101", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_rule_merged_icmp_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + protocol="icmp", + icmp=dict(type=1, code=1), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall name INBOUND rule 101 icmp type 1", + "set firewall name INBOUND rule 101 icmp code 1", + "set firewall name INBOUND rule 101 protocol 'icmp'", + "set firewall name INBOUND rule 101", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_rule_merged_icmp_02(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="INBOUND", + rules=[ + dict( + number="101", + protocol="icmp", + icmp=dict(type_name="echo-request"), + ) + ], + ), + ], + ) + ], + state="merged", + ) + ) + commands = [ + "set firewall name INBOUND rule 101 icmp type-name echo-request", + "set firewall name INBOUND rule 101 protocol 'icmp'", + "set firewall name INBOUND rule 101", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4_rule_sets_del_01(self): + set_module_args( + dict( + config=[dict(afi="ipv4", rule_sets=[dict(name="V4-INGRESS")])], + state="deleted", + ) + ) + commands = ["delete firewall name V4-INGRESS"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4v6_rule_sets_del_02(self): + set_module_args( + dict( + config=[ + dict(afi="ipv4", rule_sets=[dict(name="V4-INGRESS")]), + dict(afi="ipv6", rule_sets=[dict(name="V6-INGRESS")]), + ], + state="deleted", + ) + ) + commands = [ + "delete firewall name V4-INGRESS", + "delete firewall ipv6-name V6-INGRESS", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4v6_rule_sets_del_03(self): + set_module_args(dict(config=[], state="deleted")) + commands = ["delete firewall name", "delete firewall ipv6-name"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4v6_rule_sets_del_04(self): + set_module_args( + dict( + config=[ + dict(afi="ipv4", rule_sets=[dict(name="V4-ING")]), + dict(afi="ipv6", rule_sets=[dict(name="V6-ING")]), + ], + state="deleted", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_v4v6_rule_sets_rule_rep_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INGRESS", + description="This is IPv4 INGRESS rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="101", + action="reject", + description="Rule 101 is configured by Ansible RM", + ipsec="match-ipsec", + protocol="tcp", + fragment="match-frag", + disabled=False, + ), + dict( + number="102", + action="accept", + description="Rule 102 is configured by Ansible RM", + protocol="icmp", + disabled=True, + ), + ], + ), + ], + ), + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INGRESS", + default_action="accept", + description="This rule-set is configured by Ansible RM", + ), + dict( + name="V6-EGRESS", + default_action="reject", + description="This rule-set is configured by Ansible RM", + ), + ], + ), + ], + state="replaced", + ) + ) + commands = [ + "delete firewall name V4-INGRESS rule 101 disabled", + "delete firewall name V4-EGRESS default-action", + "set firewall name V4-INGRESS description 'This is IPv4 INGRESS rule set'", + "set firewall name V4-INGRESS rule 101 protocol 'tcp'", + "set firewall name V4-INGRESS rule 101 description 'Rule 101 is configured by Ansible RM'", + "set firewall name V4-INGRESS rule 101 action 'reject'", + "set firewall name V4-INGRESS rule 102 disabled", + "set firewall name V4-INGRESS rule 102 action 'accept'", + "set firewall name V4-INGRESS rule 102 protocol 'icmp'", + "set firewall name V4-INGRESS rule 102 description 'Rule 102 is configured by Ansible RM'", + "set firewall name V4-INGRESS rule 102", + "set firewall ipv6-name V6-INGRESS description 'This rule-set is configured by Ansible RM'", + "set firewall ipv6-name V6-EGRESS description 'This rule-set is configured by Ansible RM'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4v6_rule_sets_rule_rep_02(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INGRESS", + description="This is IPv4 V4-INGRESS rule set", + default_action="accept", + enable_default_log=False, + rules=[ + dict( + number="101", + action="accept", + description="Rule 101 is configured by Ansible", + ipsec="match-ipsec", + protocol="icmp", + fragment="match-frag", + disabled=True, + ), + ], + ), + ], + ), + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INGRESS", + default_action="accept", + ), + dict( + name="V6-EGRESS", + default_action="reject", + ), + ], + ), + ], + state="replaced", + ) + ) + commands = [ + "delete firewall name V4-INGRESS enable-default-log", + "delete firewall name V4-EGRESS default-action", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4v6_rule_sets_rule_rep_idem_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INGRESS", + description="This is IPv4 V4-INGRESS rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="101", + action="accept", + description="Rule 101 is configured by Ansible", + ipsec="match-ipsec", + protocol="icmp", + fragment="match-frag", + disabled=True, + ) + ], + ), + dict( + name="V4-EGRESS", + default_action="reject", + ), + ], + ), + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INGRESS", + default_action="accept", + ), + dict( + name="V6-EGRESS", + default_action="reject", + ), + ], + ), + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_v4v6_rule_sets_rule_mer_idem_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INGRESS", + description="This is IPv4 V4-INGRESS rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="101", + action="accept", + description="Rule 101 is configured by Ansible", + ipsec="match-ipsec", + protocol="icmp", + fragment="match-frag", + disabled=True, + ) + ], + ), + dict( + name="V4-EGRESS", + default_action="reject", + ), + ], + ), + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INGRESS", + default_action="accept", + ), + dict( + name="V6-EGRESS", + default_action="reject", + ), + ], + ), + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_v4v6_rule_sets_rule_ovr_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-IN", + description="This is IPv4 INGRESS rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="1", + action="reject", + description="Rule 1 is configured by Ansible RM", + ipsec="match-ipsec", + protocol="tcp", + fragment="match-frag", + disabled=False, + ), + dict( + number="2", + action="accept", + description="Rule 102 is configured by Ansible RM", + protocol="icmp", + disabled=True, + ), + ], + ), + ], + ), + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-IN", + default_action="accept", + description="This rule-set is configured by Ansible RM", + ), + dict( + name="V6-EG", + default_action="reject", + description="This rule-set is configured by Ansible RM", + ), + ], + ), + ], + state="overridden", + ) + ) + commands = [ + "delete firewall ipv6-name V6-INGRESS", + "delete firewall ipv6-name V6-EGRESS", + "delete firewall name V4-INGRESS", + "delete firewall name V4-EGRESS", + "set firewall name V4-IN default-action 'accept'", + "set firewall name V4-IN description 'This is IPv4 INGRESS rule set'", + "set firewall name V4-IN enable-default-log", + "set firewall name V4-IN rule 1 protocol 'tcp'", + "set firewall name V4-IN rule 1 description 'Rule 1 is configured by Ansible RM'", + "set firewall name V4-IN rule 1 fragment 'match-frag'", + "set firewall name V4-IN rule 1", + "set firewall name V4-IN rule 1 action 'reject'", + "set firewall name V4-IN rule 1 ipsec 'match-ipsec'", + "set firewall name V4-IN rule 2 disabled", + "set firewall name V4-IN rule 2 action 'accept'", + "set firewall name V4-IN rule 2 protocol 'icmp'", + "set firewall name V4-IN rule 2 description 'Rule 102 is configured by Ansible RM'", + "set firewall name V4-IN rule 2", + "set firewall ipv6-name V6-IN default-action 'accept'", + "set firewall ipv6-name V6-IN description 'This rule-set is configured by Ansible RM'", + "set firewall ipv6-name V6-EG default-action 'reject'", + "set firewall ipv6-name V6-EG description 'This rule-set is configured by Ansible RM'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_firewall_v4v6_rule_sets_rule_ovr_idem_01(self): + set_module_args( + dict( + config=[ + dict( + afi="ipv4", + rule_sets=[ + dict( + name="V4-INGRESS", + description="This is IPv4 V4-INGRESS rule set", + default_action="accept", + enable_default_log=True, + rules=[ + dict( + number="101", + action="accept", + description="Rule 101 is configured by Ansible", + ipsec="match-ipsec", + protocol="icmp", + fragment="match-frag", + disabled=True, + ) + ], + ), + dict( + name="V4-EGRESS", + default_action="reject", + ), + ], + ), + dict( + afi="ipv6", + rule_sets=[ + dict( + name="V6-INGRESS", + default_action="accept", + ), + dict( + name="V6-EGRESS", + default_action="reject", + ), + ], + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_interface.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_interface.py new file mode 100644 index 00000000..1194e3bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_interface.py @@ -0,0 +1,288 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_interface +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosInterfaceModule(TestVyosModule): + + module = vyos_interface + + def setUp(self): + super(TestVyosInterfaceModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_interface.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_interface.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_execute_interfaces_command = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_interface.get_interfaces_data" + ) + self.execute_interfaces_command = ( + self.mock_execute_interfaces_command.start() + ) + self.mock_execute_lldp_command = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_interface.get_lldp_neighbor" + ) + self.execute_lldp_command = self.mock_execute_lldp_command.start() + + # self.mock_get_config = patch( + # "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + # ) + # self.get_config = self.mock_get_config.start() + + # self.mock_load_config = patch( + # "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + # ) + # self.load_config = self.mock_load_config.start() + + # self.mock_get_resource_connection_config = patch( + # "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + # ) + # self.get_resource_connection_config = ( + # self.mock_get_resource_connection_config.start() + # ) + + # self.mock_get_resource_connection_facts = patch( + # "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + # ) + # self.get_resource_connection_facts = ( + # self.mock_get_resource_connection_facts.start() + # ) + + def tearDown(self): + super(TestVyosInterfaceModule, self).tearDown() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_lldp_command.stop() + self.mock_execute_interfaces_command.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = load_fixture( + "vyos_interface_config.cfg" + ) + self.execute_interfaces_command.return_value = [ + 0, + load_fixture("vyos_interface_config.cfg"), + None, + ] + self.execute_lldp_command.return_value = [ + 0, + load_fixture("vyos_lldp_neighbor_config.cfg"), + None, + ] + self.load_config.return_value = dict(diff=None, session="session") + + def test_vyos_setup_int(self): + set_module_args( + dict( + name="eth1", + enabled=True, + state="present", + speed="100", + duplex="half", + ) + ) + commands = [ + "set interfaces ethernet eth1 speed 100", + "set interfaces ethernet eth1 duplex half", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_setup_required_params(self): + set_module_args( + dict( + name="eth1", + enabled=True, + state="present", + speed="100", + ) + ) + result = self.execute_module(failed=True) + self.assertIn( + "parameters are required together: speed, duplex", result["msg"] + ) + + def test_vyos_setup_int_idempotent(self): + set_module_args( + dict( + name="eth1", + enabled=True, + state="present", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_disable_int(self): + set_module_args( + dict( + name="eth1", + state="absent", + ) + ) + commands = ["delete interfaces ethernet eth1"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_setup_int_aggregate(self): + set_module_args( + dict( + aggregate=[ + dict( + name="eth1", + enabled=True, + state="present", + mtu="512", + duplex="half", + speed="100", + ), + dict( + name="eth2", + enabled=True, + state="present", + speed="1000", + duplex="full", + mtu="256", + ), + ] + ) + ) + commands = [ + "set interfaces ethernet eth1 speed 100", + "set interfaces ethernet eth1 duplex half", + "set interfaces ethernet eth1 mtu 512", + "set interfaces ethernet eth2 speed 1000", + "set interfaces ethernet eth2 duplex full", + "set interfaces ethernet eth2 mtu 256", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_delete_int_aggregate(self): + set_module_args( + dict( + aggregate=[ + dict( + name="eth1", + state="absent", + ), + dict( + name="eth2", + state="absent", + ), + ] + ) + ) + commands = [ + "delete interfaces ethernet eth1", + "delete interfaces ethernet eth2", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_disable_int_aggregate(self): + set_module_args( + dict( + aggregate=[ + dict( + name="eth1", + enabled=False, + ), + dict( + name="eth2", + enabled=False, + ), + ] + ) + ) + commands = [ + "set interfaces ethernet eth1 disable", + "set interfaces ethernet eth2 disable", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_intent_wrongport(self): + set_module_args( + dict( + name="eth0", + neighbors=[dict(port="dummy_port", host="dummy_host")], + ) + ) + result = self.execute_module(failed=True) + self.assertIn( + "One or more conditional statements have not been satisfied", + result["msg"], + ) + + def test_vyos_intent_neighbor_fail(self): + set_module_args( + dict( + name="eth0", + neighbors=[ + dict( + port="eth0", + ) + ], + ) + ) + result = self.execute_module(failed=True) + self.assertIn( + "One or more conditional statements have not been satisfied", + result["msg"], + ) + + def test_vyos_intent_neighbor(self): + set_module_args( + dict( + name="eth1", + neighbors=[ + dict( + port="eth0", + ) + ], + ) + ) + self.execute_module(failed=False) + + def test_vyos_intent_neighbor_aggregate(self): + set_module_args( + dict( + aggregate=[ + dict( + name="eth1", + neighbors=[ + dict( + port="eth0", + ) + ], + ) + ] + ) + ) + self.execute_module(failed=False) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_interfaces.py new file mode 100644 index 00000000..40770df4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_interfaces.py @@ -0,0 +1,174 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import ( + vyos_interfaces, +) +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosFirewallInterfacesModule(TestVyosModule): + + module = vyos_interfaces + + def setUp(self): + super(TestVyosFirewallInterfacesModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos." + "facts.interfaces.interfaces.InterfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosFirewallInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + return load_fixture("vyos_interfaces_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_interfaces_merged(self): + set_module_args( + dict( + config=[ + dict(name="bond1", description="Bond - 1", enabled=True), + dict(name="vtun1", description="vtun - 1", enabled=True), + ], + state="merged", + ) + ) + + commands = [ + "set interfaces bonding bond1 description 'Bond - 1'", + "set interfaces openvpn vtun1 description 'vtun - 1'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_interfaces_merged_newinterface(self): + set_module_args( + dict( + config=[ + dict( + name="eth4", + description="Ethernet 4", + enabled=True, + speed="auto", + duplex="auto", + ), + dict(name="eth1", description="Configured by Ansible"), + ], + state="merged", + ) + ) + + commands = [ + "set interfaces ethernet eth1 description 'Configured by Ansible'", + "set interfaces ethernet eth4 description 'Ethernet 4'", + "set interfaces ethernet eth4 duplex 'auto'", + "set interfaces ethernet eth4 speed 'auto'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_interfaces_replaced_newinterface(self): + set_module_args( + dict( + config=[ + dict( + name="eth4", + description="Ethernet 4", + enabled=True, + speed="auto", + duplex="auto", + ), + dict(name="eth1", description="Configured by Ansible"), + ], + state="replaced", + ) + ) + + commands = [ + "set interfaces ethernet eth1 description 'Configured by Ansible'", + "set interfaces ethernet eth4 description 'Ethernet 4'", + "set interfaces ethernet eth4 duplex 'auto'", + "set interfaces ethernet eth4 speed 'auto'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_interfaces_overridden_newinterface(self): + set_module_args( + dict( + config=[ + dict( + name="eth4", + description="Ethernet 4", + enabled=True, + speed="auto", + duplex="auto", + ), + dict(name="eth1", description="Configured by Ansible"), + ], + state="overridden", + ) + ) + + commands = [ + "set interfaces ethernet eth1 description 'Configured by Ansible'", + "set interfaces ethernet eth4 description 'Ethernet 4'", + "set interfaces ethernet eth4 duplex 'auto'", + "set interfaces ethernet eth4 speed 'auto'", + "delete interfaces ethernet eth3 description", + ] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py new file mode 100644 index 00000000..3250d116 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py @@ -0,0 +1,461 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_ospf_interfaces +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosOspfInterfacesModule(TestVyosModule): + + module = vyos_ospf_interfaces + + def setUp(self): + super(TestVyosOspfInterfacesModule, self).setUp() + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.resource_module.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosOspfInterfacesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "vyos_ospf_interfaces_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def sort_address_family(self, entry_list): + for entry in entry_list: + if entry.get("address_family"): + entry["address_family"].sort(key=lambda i: i.get("afi")) + + def test_vyos_ospf_interfaces_merged_new_config(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict( + afi="ipv4", + cost=100, + authentication=dict( + plaintext_password="abcdefg!" + ), + priority=55, + ), + dict(afi="ipv6", mtu_ignore=True, instance=20), + ], + ), + dict( + name="bond2", + address_family=[ + dict( + afi="ipv4", + transmit_delay=9, + ), + dict(afi="ipv6", passive=True), + ], + ), + ], + state="merged", + ) + ) + commands = [ + "set interfaces bonding bond2 ip ospf transmit-delay 9", + "set interfaces bonding bond2 ipv6 ospfv3 passive", + "set interfaces ethernet eth0 ip ospf cost 100", + "set interfaces ethernet eth0 ip ospf priority 55", + "set interfaces ethernet eth0 ip ospf authentication plaintext-password abcdefg!", + "set interfaces ethernet eth0 ipv6 ospfv3 instance-id 20", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospf_interfaces_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict(afi="ipv6", mtu_ignore=True, instance=33), + ], + ), + dict( + name="eth1", + address_family=[ + dict( + afi="ipv4", + cost=100, + ), + dict(afi="ipv6", ifmtu=33), + ], + ), + ], + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospf_interfaces_existing_config_merged(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict(afi="ipv6", cost=500), + ], + ), + dict( + name="eth1", + address_family=[ + dict( + afi="ipv4", + priority=100, + ), + dict(afi="ipv6", ifmtu=25), + ], + ), + ], + ) + ) + commands = [ + "set interfaces ethernet eth0 ipv6 ospfv3 cost 500", + "set interfaces ethernet eth1 ip ospf priority 100", + "set interfaces ethernet eth1 ipv6 ospfv3 ifmtu 25", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospf_interfaces_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict( + afi="ipv4", + cost=100, + authentication=dict( + plaintext_password="abcdefg!" + ), + priority=55, + ), + ], + ), + dict( + name="bond2", + address_family=[ + dict( + afi="ipv4", + transmit_delay=9, + ), + dict(afi="ipv6", passive=True), + ], + ), + ], + state="replaced", + ) + ) + commands = [ + "set interfaces bonding bond2 ip ospf transmit-delay 9", + "set interfaces bonding bond2 ipv6 ospfv3 passive", + "set interfaces ethernet eth0 ip ospf cost 100", + "set interfaces ethernet eth0 ip ospf priority 55", + "set interfaces ethernet eth0 ip ospf authentication plaintext-password abcdefg!", + "delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33", + "delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospf_interfaces_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict(afi="ipv6", mtu_ignore=True, instance=33), + ], + ), + dict( + name="eth1", + address_family=[ + dict( + afi="ipv4", + cost=100, + ), + dict(afi="ipv6", ifmtu=33), + ], + ), + ], + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospf_interfaces_overridden(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict( + afi="ipv4", + cost=100, + authentication=dict( + plaintext_password="abcdefg!" + ), + priority=55, + ), + ], + ), + dict( + name="bond2", + address_family=[ + dict( + afi="ipv4", + transmit_delay=9, + ), + dict(afi="ipv6", passive=True), + ], + ), + ], + state="overridden", + ) + ) + commands = [ + "set interfaces bonding bond2 ip ospf transmit-delay 9", + "set interfaces bonding bond2 ipv6 ospfv3 passive", + "set interfaces ethernet eth0 ip ospf cost 100", + "set interfaces ethernet eth0 ip ospf priority 55", + "set interfaces ethernet eth0 ip ospf authentication plaintext-password abcdefg!", + "delete interfaces ethernet eth1 ip ospf", + "delete interfaces ethernet eth1 ipv6 ospfv3", + "delete interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore", + "delete interfaces ethernet eth0 ipv6 ospfv3 instance-id 33", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospf_interfaces_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict(afi="ipv6", mtu_ignore=True, instance=33), + ], + ), + dict( + name="eth1", + address_family=[ + dict( + afi="ipv4", + cost=100, + ), + dict(afi="ipv6", ifmtu=33), + ], + ), + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospf_interfaces_deleted(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + ), + ], + state="deleted", + ) + ) + commands = ["delete interfaces ethernet eth0 ipv6 ospfv3"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospf_interfaces_notpresent_deleted(self): + set_module_args( + dict( + config=[ + dict( + name="eth3", + ), + ], + state="deleted", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospf_interfaces_rendered(self): + set_module_args( + dict( + config=[ + dict( + name="eth0", + address_family=[ + dict( + afi="ipv4", + cost=100, + authentication=dict( + plaintext_password="abcdefg!" + ), + priority=55, + ), + dict(afi="ipv6", mtu_ignore=True, instance=20), + ], + ), + dict( + name="bond2", + address_family=[ + dict( + afi="ipv4", + transmit_delay=9, + ), + dict(afi="ipv6", passive=True), + ], + ), + ], + state="rendered", + ) + ) + commands = [ + "set interfaces ethernet eth0 ip ospf cost 100", + "set interfaces ethernet eth0 ip ospf authentication plaintext-password abcdefg!", + "set interfaces ethernet eth0 ip ospf priority 55", + "set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore", + "set interfaces ethernet eth0 ipv6 ospfv3 instance-id 20", + "set interfaces bonding bond2 ip ospf transmit-delay 9", + "set interfaces bonding bond2 ipv6 ospfv3 passive", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) + + def test_vyos_ospf_interfaces_parsed(self): + commands = [ + "set interfaces bonding bond2 ip ospf authentication md5 key-id 10 md5-key '1111111111232345'", + "set interfaces bonding bond2 ip ospf bandwidth '70'", + "set interfaces bonding bond2 ip ospf transmit-delay '45'", + "set interfaces bonding bond2 ipv6 ospfv3 'passive'", + "set interfaces ethernet eth0 ip ospf cost '50'", + "set interfaces ethernet eth0 ip ospf priority '26'", + "set interfaces ethernet eth0 ipv6 ospfv3 instance-id '33'", + "set interfaces ethernet eth0 ipv6 ospfv3 'mtu-ignore'", + "set interfaces ethernet eth1 ip ospf network 'point-to-point'", + "set interfaces ethernet eth1 ip ospf priority '26'", + "set interfaces ethernet eth1 ip ospf transmit-delay '50'", + "set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'", + ] + + parsed_str = "\n".join(commands) + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = [ + { + "address_family": [ + { + "afi": "ipv4", + "authentication": { + "md5_key": { + "key": "1111111111232345", + "key_id": 10, + } + }, + "bandwidth": 70, + "transmit_delay": 45, + }, + {"afi": "ipv6", "passive": True}, + ], + "name": "bond2", + }, + { + "address_family": [ + {"afi": "ipv4", "cost": 50, "priority": 26}, + {"afi": "ipv6", "instance": "33", "mtu_ignore": True}, + ], + "name": "eth0", + }, + { + "address_family": [ + { + "afi": "ipv4", + "network": "point-to-point", + "priority": 26, + "transmit_delay": 50, + }, + {"afi": "ipv6", "dead_interval": 39}, + ], + "name": "eth1", + }, + ] + result_list = self.sort_address_family(result["parsed"]) + given_list = self.sort_address_family(parsed_list) + self.assertEqual(result_list, given_list) + + def test_vyos_ospf_interfaces_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="vyos_ospf_interfaces_config.cfg" + ) + gathered_list = [ + { + "address_family": [ + {"afi": "ipv6", "instance": "33", "mtu_ignore": True} + ], + "name": "eth0", + }, + { + "address_family": [ + {"afi": "ipv4", "cost": 100}, + {"afi": "ipv6", "ifmtu": 33}, + ], + "name": "eth1", + }, + ] + + result_list = self.sort_address_family(result["gathered"]) + given_list = self.sort_address_family(gathered_list) + self.assertEqual(result_list, given_list) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospfv2.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospfv2.py new file mode 100644 index 00000000..9df41a55 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospfv2.py @@ -0,0 +1,435 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_ospfv2 +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosOspfv2Module(TestVyosModule): + + module = vyos_ospfv2 + + def setUp(self): + super(TestVyosOspfv2Module, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data" + ) + + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosOspfv2Module, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "vyos_ospfv2_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_ospfv2_merged_new_config(self): + set_module_args( + dict( + config=dict( + log_adjacency_changes="detail", + mpls_te=dict(enabled=True, router_address="192.0.11.11"), + auto_cost=dict(reference_bandwidth=2), + areas=[ + dict( + area_id="2", + area_type=dict(normal=True), + authentication="plaintext-password", + shortcut="enable", + ), + dict( + area_id="4", + area_type=dict(stub=dict(default_cost=10)), + network=[dict(address="192.0.2.0/24")], + range=[ + dict(address="192.0.3.0/24", cost=10), + dict(address="192.0.4.0/24", cost=12), + ], + ), + ], + ), + state="merged", + ) + ) + commands = [ + "set protocols ospf mpls-te enable", + "set protocols ospf mpls-te router-address '192.0.11.11'", + "set protocols ospf auto-cost reference-bandwidth '2'", + "set protocols ospf log-adjacency-changes 'detail'", + "set protocols ospf area '2'", + "set protocols ospf area 2 authentication plaintext-password", + "set protocols ospf area 2 shortcut enable", + "set protocols ospf area 2 area-type normal", + "set protocols ospf area 4 range 192.0.3.0/24 cost 10", + "set protocols ospf area 4 range 192.0.3.0/24", + "set protocols ospf area 4 range 192.0.4.0/24 cost 12", + "set protocols ospf area 4 range 192.0.4.0/24", + "set protocols ospf area 4 area-type stub default-cost 10", + "set protocols ospf area '4'", + "set protocols ospf area 4 network 192.0.2.0/24", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv2_merged_idem(self): + set_module_args( + dict( + config=dict( + areas=[ + dict( + area_id="12", + area_type=dict(normal=True), + authentication="plaintext-password", + shortcut="enable", + ), + dict( + area_id="14", + area_type=dict(stub=dict(default_cost=20)), + network=[dict(address="192.0.12.0/24")], + range=[ + dict(address="192.0.13.0/24", cost=10), + dict(address="192.0.14.0/24", cost=12), + ], + ), + ], + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospfv2_merged_update_existing(self): + set_module_args( + dict( + config=dict( + areas=[ + dict( + area_id="12", + area_type=dict(normal=True), + authentication="plaintext-password", + shortcut="enable", + ), + dict( + area_id="14", + area_type=dict(stub=dict(set=False)), + network=[ + dict(address="192.0.12.0/24"), + dict(address="192.0.22.0/24"), + ], + range=[ + dict(address="192.0.13.0/24", cost=10), + dict(address="192.0.14.0/24", cost=12), + ], + ), + ], + ), + state="merged", + ) + ) + commands = [ + "delete protocols ospf area 14 area-type stub", + "set protocols ospf area 14 network 192.0.22.0/24", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv2_replaced(self): + set_module_args( + dict( + config=dict( + log_adjacency_changes="detail", + mpls_te=dict(enabled=True, router_address="192.0.11.11"), + auto_cost=dict(reference_bandwidth=2), + areas=[ + dict( + area_id="12", + area_type=dict(normal=True), + authentication="plaintext-password", + shortcut="enable", + ), + dict( + area_id="15", + area_type=dict(stub=dict(default_cost=10)), + network=[dict(address="192.0.12.0/24")], + range=[ + dict(address="192.0.13.0/24", cost=10), + dict(address="192.0.14.0/24", cost=12), + dict(address="192.0.15.0/24", cost=14), + ], + ), + ], + ), + state="replaced", + ) + ) + commands = [ + "set protocols ospf mpls-te enable", + "set protocols ospf mpls-te router-address '192.0.11.11'", + "set protocols ospf auto-cost reference-bandwidth '2'", + "set protocols ospf log-adjacency-changes 'detail'", + "delete protocols ospf area 14", + "set protocols ospf area 15 range 192.0.13.0/24 cost 10", + "set protocols ospf area 15 range 192.0.13.0/24", + "set protocols ospf area 15 range 192.0.14.0/24 cost 12", + "set protocols ospf area 15 range 192.0.14.0/24", + "set protocols ospf area 15 range 192.0.15.0/24 cost 14", + "set protocols ospf area 15 range 192.0.15.0/24", + "set protocols ospf area 15 area-type stub default-cost 10", + "set protocols ospf area '15'", + "set protocols ospf area 15 network 192.0.12.0/24", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv2_replaced_idem(self): + set_module_args( + dict( + config=dict( + areas=[ + dict( + area_id="12", + area_type=dict(normal=True), + authentication="plaintext-password", + shortcut="enable", + ), + dict( + area_id="14", + area_type=dict(stub=dict(default_cost=20)), + network=[dict(address="192.0.12.0/24")], + range=[ + dict(address="192.0.13.0/24", cost=10), + dict(address="192.0.14.0/24", cost=12), + ], + ), + ], + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospfv2_deleted_no_config(self): + set_module_args(dict(config=None, state="deleted")) + commands = ["delete protocols ospf"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv2_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="vyos_ospfv2_config.cfg" + ) + gather_dict = { + "areas": [ + { + "area_id": "2", + "area_type": {"normal": True}, + "authentication": "plaintext-password", + "shortcut": "enable", + }, + { + "area_id": "14", + "area_type": {"stub": {"default_cost": 20, "set": True}}, + "network": [{"address": "192.0.12.0/24"}], + "range": [ + {"address": "192.0.13.0/24", "cost": 10}, + {"address": "192.0.14.0/24", "cost": 12}, + ], + }, + ], + } + self.assertEqual(sorted(gather_dict), sorted(result["gathered"])) + + def test_vyos_ospfv2_parsed(self): + parsed_str = """set protocols ospf area 2 area-type 'normal' + set protocols ospf area 2 authentication 'plaintext-password' + set protocols ospf area 2 shortcut 'enable' + set protocols ospf area 3 area-type 'nssa' + set protocols ospf area 4 area-type stub default-cost '20' + set protocols ospf area 4 network '192.0.2.0/24' + set protocols ospf area 4 range 192.0.3.0/24 cost '10' + set protocols ospf area 4 range 192.0.4.0/24 cost '12' + set protocols ospf default-information originate 'always' + set protocols ospf default-information originate metric '10' + set protocols ospf default-information originate metric-type '2' +set protocols ospf auto-cost reference-bandwidth '2' +set protocols ospf default-information originate route-map 'ingress' +set protocols ospf log-adjacency-changes 'detail' +set protocols ospf max-metric router-lsa 'administrative' +set protocols ospf max-metric router-lsa on-shutdown '10' +set protocols ospf max-metric router-lsa on-startup '10' +set protocols ospf mpls-te 'enable' +set protocols ospf mpls-te router-address '192.0.11.11' +set protocols ospf neighbor 192.0.11.12 poll-interval '10' +set protocols ospf neighbor 192.0.11.12 priority '2' +set protocols ospf parameters abr-type 'cisco' +set protocols ospf parameters 'opaque-lsa' +set protocols ospf parameters 'rfc1583-compatibility' +set protocols ospf parameters router-id '192.0.1.1' +set protocols ospf passive-interface 'eth1' +set protocols ospf passive-interface 'eth2' +set protocols ospf redistribute bgp metric '10' +set protocols ospf redistribute bgp metric-type '2'""" + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_list = { + "areas": [ + { + "area_id": "2", + "area_type": {"normal": True}, + "authentication": "plaintext-password", + "shortcut": "enable", + }, + {"area_id": "3", "area_type": {"nssa": {"set": True}}}, + { + "area_id": "4", + "area_type": {"stub": {"default_cost": 20, "set": True}}, + "network": [{"address": "192.0.2.0/24"}], + "range": [ + {"address": "192.0.3.0/24", "cost": 10}, + {"address": "192.0.4.0/24", "cost": 12}, + ], + }, + ], + "auto_cost": {"reference_bandwidth": 2}, + "default_information": { + "originate": { + "always": True, + "metric": 10, + "metric_type": 2, + "route_map": "ingress", + } + }, + "log_adjacency_changes": "detail", + "max_metric": { + "router_lsa": { + "administrative": True, + "on_shutdown": 10, + "on_startup": 10, + } + }, + "mpls_te": {"enabled": True, "router_address": "192.0.11.11"}, + "neighbor": [ + { + "neighbor_id": "192.0.11.12", + "poll_interval": 10, + "priority": 2, + } + ], + "parameters": { + "abr_type": "cisco", + "opaque_lsa": True, + "rfc1583_compatibility": True, + "router_id": "192.0.1.1", + }, + "passive_interface": ["eth2", "eth1"], + "redistribute": [ + {"metric": 10, "metric_type": 2, "route_type": "bgp"} + ], + } + self.assertEqual(sorted(parsed_list), sorted(result["parsed"])) + + def test_vyos_ospfv2_rendered(self): + set_module_args( + dict( + config=dict( + log_adjacency_changes="detail", + mpls_te=dict(enabled=True, router_address="192.0.11.11"), + auto_cost=dict(reference_bandwidth=2), + areas=[ + dict( + area_id="2", + area_type=dict(normal=True), + authentication="plaintext-password", + shortcut="enable", + ), + dict( + area_id="4", + area_type=dict(stub=dict(default_cost=10)), + network=[dict(address="192.0.2.0/24")], + range=[ + dict(address="192.0.3.0/24", cost=10), + dict(address="192.0.4.0/24", cost=12), + ], + ), + ], + ), + state="rendered", + ) + ) + commands = [ + "set protocols ospf mpls-te enable", + "set protocols ospf mpls-te router-address '192.0.11.11'", + "set protocols ospf auto-cost reference-bandwidth '2'", + "set protocols ospf log-adjacency-changes 'detail'", + "set protocols ospf area '2'", + "set protocols ospf area 2 authentication plaintext-password", + "set protocols ospf area 2 shortcut enable", + "set protocols ospf area 2 area-type normal", + "set protocols ospf area 4 range 192.0.3.0/24 cost 10", + "set protocols ospf area 4 range 192.0.3.0/24", + "set protocols ospf area 4 range 192.0.4.0/24 cost 12", + "set protocols ospf area 4 range 192.0.4.0/24", + "set protocols ospf area 4 area-type stub default-cost 10", + "set protocols ospf area '4'", + "set protocols ospf area 4 network 192.0.2.0/24", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospfv3.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospfv3.py new file mode 100644 index 00000000..ab38bf76 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ospfv3.py @@ -0,0 +1,348 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_ospfv3 +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosOspfv3Module(TestVyosModule): + + module = vyos_ospfv3 + + def setUp(self): + super(TestVyosOspfv3Module, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3.Ospfv3Facts.get_device_data" + ) + + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosOspfv3Module, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None, transport="cli", filename=None): + if filename is None: + filename = "vyos_ospfv3_config.cfg" + + def load_from_file(*args, **kwargs): + output = load_fixture(filename) + return output + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_ospfv3_merged_new_config(self): + set_module_args( + dict( + config=dict( + redistribute=[dict(route_type="bgp")], + parameters=dict(router_id="192.0.2.10"), + areas=[ + dict( + area_id="2", + export_list="export1", + import_list="import1", + range=[ + dict(address="2001:db10::/32"), + dict(address="2001:db20::/32"), + dict(address="2001:db30::/32"), + ], + ), + dict( + area_id="3", + range=[dict(address="2001:db40::/32")], + ), + ], + ), + state="merged", + ) + ) + commands = [ + "set protocols ospfv3 redistribute bgp", + "set protocols ospfv3 parameters router-id '192.0.2.10'", + "set protocols ospfv3 area 2 range 2001:db10::/32", + "set protocols ospfv3 area 2 range 2001:db20::/32", + "set protocols ospfv3 area 2 range 2001:db30::/32", + "set protocols ospfv3 area '2'", + "set protocols ospfv3 area 2 export-list export1", + "set protocols ospfv3 area 2 import-list import1", + "set protocols ospfv3 area '3'", + "set protocols ospfv3 area 3 range 2001:db40::/32", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv3_merged_idem(self): + set_module_args( + dict( + config=dict( + areas=[ + dict( + area_id="12", + export_list="export1", + import_list="import1", + range=[ + dict(address="2001:db11::/32"), + dict(address="2001:db22::/32"), + dict(address="2001:db33::/32"), + ], + ), + dict( + area_id="13", + range=[dict(address="2001:db44::/32")], + ), + ], + ), + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospfv3_merged_update_existing(self): + set_module_args( + dict( + config=dict( + redistribute=[dict(route_type="bgp")], + parameters=dict(router_id="192.0.2.10"), + areas=[ + dict( + area_id="12", + export_list="export1", + import_list="import1", + range=[ + dict(address="2001:db11::/32"), + dict(address="2001:db22::/32"), + dict(address="2001:db33::/32"), + ], + ), + dict( + area_id="13", + range=[ + dict(address="2001:db44::/32"), + dict(address="2001:db55::/32"), + ], + ), + ], + ), + state="merged", + ) + ) + commands = [ + "set protocols ospfv3 redistribute bgp", + "set protocols ospfv3 parameters router-id '192.0.2.10'", + "set protocols ospfv3 area 13 range 2001:db55::/32", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv3_replaced(self): + set_module_args( + dict( + config=dict( + redistribute=[dict(route_type="bgp")], + parameters=dict(router_id="192.0.2.10"), + areas=[ + dict( + area_id="12", + export_list="export1", + import_list="import1", + range=[ + dict(address="2001:db10::/32"), + dict(address="2001:db22::/32"), + dict(address="2001:db33::/32"), + ], + ), + dict( + area_id="14", + range=[dict(address="2001:db40::/32")], + ), + ], + ), + state="replaced", + ) + ) + commands = [ + "set protocols ospfv3 redistribute bgp", + "set protocols ospfv3 parameters router-id '192.0.2.10'", + "delete protocols ospfv3 area 12 range 2001:db11::/32", + "set protocols ospfv3 area 12 range 2001:db10::/32", + "delete protocols ospfv3 area 13", + "set protocols ospfv3 area '14'", + "set protocols ospfv3 area 14 range 2001:db40::/32", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv3_replaced_idem(self): + set_module_args( + dict( + config=dict( + areas=[ + dict( + area_id="12", + export_list="export1", + import_list="import1", + range=[ + dict(address="2001:db11::/32"), + dict(address="2001:db22::/32"), + dict(address="2001:db33::/32"), + ], + ), + dict( + area_id="13", + range=[dict(address="2001:db44::/32")], + ), + ], + ), + state="replaced", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_ospfv3_deleted_no_config(self): + set_module_args(dict(config=None, state="deleted")) + commands = ["delete protocols ospfv3"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_ospfv3_gathered(self): + set_module_args(dict(state="gathered")) + result = self.execute_module( + changed=False, filename="vyos_ospfv3_config.cfg" + ) + gather_dict = { + "areas": [ + { + "area_id": "12", + "export_list": "export1", + "import_list": "import1", + "range": [ + {"address": "2001:db11::/32"}, + {"address": "2001:db22::/32"}, + {"address": "2001:db33::/32"}, + ], + }, + {"area_id": "13", "range": [{"address": "2001:db44::/32"}]}, + ], + } + self.assertEqual(sorted(gather_dict), sorted(result["gathered"])) + + def test_vyos_ospfv3_parsed(self): + parsed_str = """set protocols ospfv3 area 2 export-list 'export1' +set protocols ospfv3 area 2 import-list 'import1' +set protocols ospfv3 area 2 range '2001:db10::/32' +set protocols ospfv3 area 2 range '2001:db20::/32' +set protocols ospfv3 area 2 range '2001:db30::/32' +set protocols ospfv3 area 3 range '2001:db40::/32' +set protocols ospfv3 parameters router-id '192.0.2.10' +set protocols ospfv3 redistribute 'bgp'""" + set_module_args(dict(running_config=parsed_str, state="parsed")) + result = self.execute_module(changed=False) + parsed_dict = { + "areas": [ + { + "area_id": "2", + "export_list": "export1", + "import_list": "import1", + "range": [ + {"address": "2001:db10::/32"}, + {"address": "2001:db20::/32"}, + {"address": "2001:db30::/32"}, + ], + }, + {"area_id": "3", "range": [{"address": "2001:db40::/32"}]}, + ], + "parameters": {"router_id": "192.0.2.10"}, + "redistribute": [{"route_type": "bgp"}], + } + self.assertEqual(sorted(parsed_dict), sorted(result["parsed"])) + + def test_vyos_ospfv3_rendered(self): + set_module_args( + dict( + config=dict( + redistribute=[dict(route_type="bgp")], + parameters=dict(router_id="192.0.2.10"), + areas=[ + dict( + area_id="2", + export_list="export1", + import_list="import1", + range=[ + dict(address="2001:db10::/32"), + dict(address="2001:db20::/32"), + dict(address="2001:db30::/32"), + ], + ), + dict( + area_id="3", + range=[dict(address="2001:db40::/32")], + ), + ], + ), + state="rendered", + ) + ) + commands = [ + "set protocols ospfv3 redistribute bgp", + "set protocols ospfv3 parameters router-id '192.0.2.10'", + "set protocols ospfv3 area 2 range 2001:db10::/32", + "set protocols ospfv3 area 2 range 2001:db20::/32", + "set protocols ospfv3 area 2 range 2001:db30::/32", + "set protocols ospfv3 area '2'", + "set protocols ospfv3 area 2 export-list export1", + "set protocols ospfv3 area 2 import-list import1", + "set protocols ospfv3 area '3'", + "set protocols ospfv3 area 3 range 2001:db40::/32", + ] + result = self.execute_module(changed=False) + self.assertEqual( + sorted(result["rendered"]), sorted(commands), result["rendered"] + ) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ping.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ping.py new file mode 100644 index 00000000..e3076103 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_ping.py @@ -0,0 +1,107 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_ping +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosPingModule(TestVyosModule): + + module = vyos_ping + + def setUp(self): + super(TestVyosPingModule, self).setUp() + self.mock_run_commands = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_ping.run_commands" + ) + self.run_commands = self.mock_run_commands.start() + + def tearDown(self): + super(TestVyosPingModule, self).tearDown() + self.mock_run_commands.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + commands = kwargs["commands"] + output = list() + + for command in commands: + filename = str(command).split(" | ")[0].replace(" ", "_") + output.append(load_fixture("vyos_ping_%s" % filename)) + return output + + self.run_commands.side_effect = load_from_file + + def test_vyos_ping_expected_success(self): + """ Test for successful pings when destination should be reachable """ + set_module_args(dict(count=2, dest="10.10.10.10")) + self.execute_module() + + def test_vyos_ping_expected_failure(self): + """ Test for unsuccessful pings when destination should not be reachable """ + set_module_args(dict(count=4, dest="10.10.10.20", state="absent")) + self.execute_module() + + def test_vyos_ping_unexpected_success(self): + """ Test for successful pings when destination should not be reachable - FAIL. """ + set_module_args(dict(count=2, dest="10.10.10.10", state="absent")) + self.execute_module(failed=True) + + def test_vyos_ping_unexpected_failure(self): + """ Test for unsuccessful pings when destination should be reachable - FAIL. """ + set_module_args(dict(count=4, dest="10.10.10.20")) + self.execute_module(failed=True) + + def test_vyos_ping_failure_stats(self): + """Test for asserting stats when ping fails""" + set_module_args(dict(count=4, dest="10.10.10.20")) + result = self.execute_module(failed=True) + self.assertEqual(result["packet_loss"], "100%") + self.assertEqual(result["packets_rx"], 0) + self.assertEqual(result["packets_tx"], 4) + + def test_vyos_ping_success_stats(self): + """Test for asserting stats when ping passes""" + set_module_args(dict(count=2, dest="10.10.10.10")) + result = self.execute_module() + self.assertEqual(result["packet_loss"], "0%") + self.assertEqual(result["packets_rx"], 2) + self.assertEqual(result["packets_tx"], 2) + self.assertEqual(result["rtt"]["min"], 12) + self.assertEqual(result["rtt"]["avg"], 17) + self.assertEqual(result["rtt"]["max"], 22) + self.assertEqual(result["rtt"]["mdev"], 10) + + def test_vyos_ping_success_stats_with_options(self): + set_module_args(dict(count=10, ttl=128, size=512, dest="10.10.10.11")) + result = self.execute_module() + self.assertEqual(result["packet_loss"], "0%") + self.assertEqual(result["packets_rx"], 10) + self.assertEqual(result["packets_tx"], 10) + self.assertEqual(result["rtt"]["min"], 1) + self.assertEqual(result["rtt"]["avg"], 3) + self.assertEqual(result["rtt"]["max"], 21) + self.assertEqual(result["rtt"]["mdev"], 5) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_static_route.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_static_route.py new file mode 100644 index 00000000..21f11394 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_static_route.py @@ -0,0 +1,73 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_static_route +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule + + +class TestVyosStaticRouteModule(TestVyosModule): + + module = vyos_static_route + + def setUp(self): + super(TestVyosStaticRouteModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_static_route.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_static_route.load_config" + ) + + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestVyosStaticRouteModule, self).tearDown() + + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = "" + self.load_config.return_value = dict(diff=None, session="session") + + def test_vyos_static_route_present(self): + set_module_args( + dict( + prefix="172.26.0.0/16", + next_hop="172.26.4.1", + admin_distance="1", + ) + ) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "set protocols static route 172.26.0.0/16 next-hop 172.26.4.1 distance 1" + ], + ) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_static_routes.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_static_routes.py new file mode 100644 index 00000000..85c08422 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_static_routes.py @@ -0,0 +1,285 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_static_routes +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosStaticRoutesModule(TestVyosModule): + + module = vyos_static_routes + + def setUp(self): + super(TestVyosStaticRoutesModule, self).setUp() + self.mock_get_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + ) + self.load_config = self.mock_load_config.start() + + self.mock_get_resource_connection_config = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + ) + self.get_resource_connection_config = ( + self.mock_get_resource_connection_config.start() + ) + + self.mock_get_resource_connection_facts = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + ) + self.get_resource_connection_facts = ( + self.mock_get_resource_connection_facts.start() + ) + + self.mock_execute_show_command = patch( + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data" + ) + self.execute_show_command = self.mock_execute_show_command.start() + + def tearDown(self): + super(TestVyosStaticRoutesModule, self).tearDown() + self.mock_get_resource_connection_config.stop() + self.mock_get_resource_connection_facts.stop() + self.mock_get_config.stop() + self.mock_load_config.stop() + self.mock_execute_show_command.stop() + + def load_fixtures(self, commands=None): + def load_from_file(*args, **kwargs): + return load_fixture("vyos_static_routes_config.cfg") + + self.execute_show_command.side_effect = load_from_file + + def test_vyos_static_routes_merged(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="192.0.2.48/28", + next_hops=[ + dict( + forward_router_address="192.0.2.9" + ), + dict( + forward_router_address="192.0.2.10" + ), + ], + ) + ], + ) + ] + ) + ], + state="merged", + ) + ) + commands = [ + "set protocols static route 192.0.2.48/28", + "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", + "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_static_routes_merged_idempotent(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="192.0.2.32/28", + next_hops=[ + dict( + forward_router_address="192.0.2.9" + ), + dict( + forward_router_address="192.0.2.10" + ), + ], + ) + ], + ) + ] + ) + ], + state="merged", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_static_routes_replaced(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="192.0.2.48/28", + next_hops=[ + dict( + forward_router_address="192.0.2.9" + ), + dict( + forward_router_address="192.0.2.10" + ), + ], + ) + ], + ) + ] + ) + ], + state="replaced", + ) + ) + commands = [ + "set protocols static route 192.0.2.48/28", + "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", + "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_static_routes_replaced_idempotent(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="192.0.2.32/28", + next_hops=[ + dict( + forward_router_address="192.0.2.9" + ), + dict( + forward_router_address="192.0.2.10" + ), + ], + ) + ], + ) + ] + ) + ], + state="replaced", + ) + ) + + self.execute_module(changed=False, commands=[]) + + def test_vyos_static_routes_overridden(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="192.0.2.48/28", + next_hops=[ + dict( + forward_router_address="192.0.2.9" + ), + dict( + forward_router_address="192.0.2.10" + ), + ], + ) + ], + ) + ] + ) + ], + state="overridden", + ) + ) + commands = [ + "delete protocols static route 192.0.2.32/28", + "set protocols static route 192.0.2.48/28", + "set protocols static route 192.0.2.48/28 next-hop '192.0.2.9'", + "set protocols static route 192.0.2.48/28 next-hop '192.0.2.10'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_static_routes_overridden_idempotent(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + routes=[ + dict( + dest="192.0.2.32/28", + next_hops=[ + dict( + forward_router_address="192.0.2.9" + ), + dict( + forward_router_address="192.0.2.10" + ), + ], + ) + ], + ) + ] + ) + ], + state="overridden", + ) + ) + self.execute_module(changed=False, commands=[]) + + def test_vyos_static_routes_deleted(self): + set_module_args( + dict( + config=[dict(address_families=[dict(afi="ipv4")])], + state="deleted", + ) + ) + commands = ["delete protocols static route"] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_system.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_system.py new file mode 100644 index 00000000..c22f7c18 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_system.py @@ -0,0 +1,116 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_system +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosSystemModule(TestVyosModule): + + module = vyos_system + + def setUp(self): + super(TestVyosSystemModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_system.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_system.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestVyosSystemModule, self).tearDown() + + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None): + self.get_config.return_value = load_fixture("vyos_config_config.cfg") + + def test_vyos_system_hostname(self): + set_module_args(dict(host_name="foo")) + commands = ["set system host-name 'foo'"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_system_clear_hostname(self): + set_module_args(dict(host_name="foo", state="absent")) + commands = ["delete system host-name"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_remove_single_name_server(self): + set_module_args(dict(name_server=["8.8.4.4"], state="absent")) + commands = ["delete system name-server '8.8.4.4'"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_system_domain_name(self): + set_module_args(dict(domain_name="example2.com")) + commands = ["set system domain-name 'example2.com'"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_system_clear_domain_name(self): + set_module_args(dict(domain_name="example.com", state="absent")) + commands = ["delete system domain-name"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_system_domain_search(self): + set_module_args( + dict(domain_search=["foo.example.com", "bar.example.com"]) + ) + commands = [ + "set system domain-search domain 'foo.example.com'", + "set system domain-search domain 'bar.example.com'", + ] + self.execute_module(changed=True, commands=commands) + + def test_vyos_system_clear_domain_search(self): + set_module_args(dict(domain_search=[])) + commands = ["delete system domain-search domain"] + self.execute_module(changed=True, commands=commands) + + def test_vyos_system_no_change(self): + set_module_args( + dict( + host_name="router", + domain_name="example.com", + name_server=["8.8.8.8", "8.8.4.4"], + ) + ) + result = self.execute_module() + self.assertEqual([], result["commands"]) + + def test_vyos_system_clear_all(self): + set_module_args(dict(state="absent")) + commands = [ + "delete system host-name", + "delete system domain-search domain", + "delete system domain-name", + "delete system name-server", + ] + self.execute_module(changed=True, commands=commands) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_user.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_user.py new file mode 100644 index 00000000..d4c2dbe6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/test_vyos_user.py @@ -0,0 +1,139 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible_collections.vyos.vyos.plugins.modules import vyos_user +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + set_module_args, +) +from .vyos_module import TestVyosModule, load_fixture + + +class TestVyosUserModule(TestVyosModule): + + module = vyos_user + + def setUp(self): + super(TestVyosUserModule, self).setUp() + + self.mock_get_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_user.get_config" + ) + self.get_config = self.mock_get_config.start() + + self.mock_load_config = patch( + "ansible_collections.vyos.vyos.plugins.modules.vyos_user.load_config" + ) + self.load_config = self.mock_load_config.start() + + def tearDown(self): + super(TestVyosUserModule, self).tearDown() + self.mock_get_config.stop() + self.mock_load_config.stop() + + def load_fixtures(self, commands=None, transport="cli"): + self.get_config.return_value = load_fixture("vyos_user_config.cfg") + self.load_config.return_value = dict(diff=None, session="session") + + def test_vyos_user_password(self): + set_module_args(dict(name="ansible", configured_password="test")) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "set system login user ansible authentication plaintext-password test" + ], + ) + + def test_vyos_user_delete(self): + set_module_args(dict(name="ansible", state="absent")) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], ["delete system login user ansible"] + ) + + def test_vyos_user_level(self): + set_module_args(dict(name="ansible", level="operator")) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["set system login user ansible level operator"], + ) + + def test_vyos_user_level_invalid(self): + set_module_args(dict(name="ansible", level="sysadmin")) + self.execute_module(failed=True) + + def test_vyos_user_purge(self): + set_module_args(dict(purge=True)) + result = self.execute_module(changed=True) + self.assertEqual( + sorted(result["commands"]), + sorted( + [ + "delete system login user ansible", + "delete system login user admin", + ] + ), + ) + + def test_vyos_user_update_password_changed(self): + set_module_args( + dict( + name="test", + configured_password="test", + update_password="on_create", + ) + ) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "set system login user test authentication plaintext-password test" + ], + ) + + def test_vyos_user_update_password_on_create_ok(self): + set_module_args( + dict( + name="ansible", + configured_password="test", + update_password="on_create", + ) + ) + self.execute_module() + + def test_vyos_user_update_password_always(self): + set_module_args( + dict( + name="ansible", + configured_password="test", + update_password="always", + ) + ) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "set system login user ansible authentication plaintext-password test" + ], + ) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/vyos_module.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/vyos_module.py new file mode 100644 index 00000000..49d46522 --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/network/vyos/vyos_module.py @@ -0,0 +1,105 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import os +import json + +from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( + AnsibleExitJson, + AnsibleFailJson, + ModuleTestCase, +) + + +fixture_path = os.path.join(os.path.dirname(__file__), "fixtures") +fixture_data = {} + + +def load_fixture(name): + path = os.path.join(fixture_path, name) + + if path in fixture_data: + return fixture_data[path] + + with open(path) as f: + data = f.read() + + try: + data = json.loads(data) + except Exception: + pass + + fixture_data[path] = data + return data + + +class TestVyosModule(ModuleTestCase): + def execute_module( + self, + failed=False, + changed=False, + commands=None, + sort=True, + defaults=False, + filename=None, + ): + self.load_fixtures(commands) + + if failed: + result = self.failed() + self.assertTrue(result["failed"], result) + else: + result = self.changed(changed) + self.assertEqual(result["changed"], changed, result) + + if commands is not None: + if sort: + self.assertEqual( + sorted(commands), + sorted(result["commands"]), + result["commands"], + ) + else: + self.assertEqual( + commands, result["commands"], result["commands"] + ) + + return result + + def failed(self): + with self.assertRaises(AnsibleFailJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertTrue(result["failed"], result) + return result + + def changed(self, changed=False): + with self.assertRaises(AnsibleExitJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertEqual(result["changed"], changed, result) + return result + + def load_fixtures(self, commands=None): + pass diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/utils.py b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/utils.py new file mode 100644 index 00000000..90023ced --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/modules/utils.py @@ -0,0 +1,51 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type +import json + +from ansible_collections.vyos.vyos.tests.unit.compat import unittest +from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes + + +def set_module_args(args): + if "_ansible_remote_tmp" not in args: + args["_ansible_remote_tmp"] = "/tmp" + if "_ansible_keep_remote_files" not in args: + args["_ansible_keep_remote_files"] = False + + args = json.dumps({"ANSIBLE_MODULE_ARGS": args}) + basic._ANSIBLE_ARGS = to_bytes(args) + + +class AnsibleExitJson(Exception): + pass + + +class AnsibleFailJson(Exception): + pass + + +def exit_json(*args, **kwargs): + if "changed" not in kwargs: + kwargs["changed"] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): + kwargs["failed"] = True + raise AnsibleFailJson(kwargs) + + +class ModuleTestCase(unittest.TestCase): + def setUp(self): + self.mock_module = patch.multiple( + basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json + ) + self.mock_module.start() + self.mock_sleep = patch("time.sleep") + self.mock_sleep.start() + set_module_args({}) + self.addCleanup(self.mock_module.stop) + self.addCleanup(self.mock_sleep.stop) diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/requirements.txt b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/requirements.txt new file mode 100644 index 00000000..a9772bea --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tests/unit/requirements.txt @@ -0,0 +1,42 @@ +boto3 +placebo +pycrypto +passlib +pypsrp +python-memcached +pytz +pyvmomi +redis +requests +setuptools > 0.6 # pytest-xdist installed via requirements does not work with very old setuptools (sanity_ok) +unittest2 ; python_version < '2.7' +importlib ; python_version < '2.7' +netaddr +ipaddress +netapp-lib +solidfire-sdk-python + +# requirements for F5 specific modules +f5-sdk ; python_version >= '2.7' +f5-icontrol-rest ; python_version >= '2.7' +deepdiff + +# requirement for Fortinet specific modules +pyFMG + +# requirement for aci_rest module +xmljson + +# requirement for winrm connection plugin tests +pexpect + +# requirement for the linode module +linode-python # APIv3 +linode_api4 ; python_version > '2.6' # APIv4 + +# requirement for the gitlab module +python-gitlab +httmock + +# requirment for kubevirt modules +openshift ; python_version >= '2.7' diff --git a/collections-debian-merged/ansible_collections/vyos/vyos/tox.ini b/collections-debian-merged/ansible_collections/vyos/vyos/tox.ini new file mode 100644 index 00000000..3da0118f --- /dev/null +++ b/collections-debian-merged/ansible_collections/vyos/vyos/tox.ini @@ -0,0 +1,32 @@ +[tox] +minversion = 1.4.2 +envlist = linters +skipsdist = True + +[testenv] +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:black] +install_command = pip install {opts} {packages} +commands = + black -v -l79 {toxinidir} + +[testenv:linters] +install_command = pip install {opts} {packages} +commands = + black -v -l79 --diff --check {toxinidir} + flake8 {posargs} + yamllint -s . + +[testenv:venv] +commands = {posargs} + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125,E402,W503 +max-line-length = 160 +builtins = _ +exclude = .git,.tox,tests/unit/compat/ |