diff options
author | Gaige B Paulsen <gaige@cluetrust.com> | 2024-11-25 16:08:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 16:08:54 -0500 |
commit | bf38875af0a7e5166ce0330f16441b7d8b434e6a (patch) | |
tree | a01b371d37ae88136eec0d50868da6aebcea1414 /plugins/modules | |
parent | 04c837af1cf89ff42adc42062df48a0dd209a0e1 (diff) | |
download | vyos.vyos-bf38875af0a7e5166ce0330f16441b7d8b434e6a.tar.gz vyos.vyos-bf38875af0a7e5166ce0330f16441b7d8b434e6a.zip |
T6910: fix documentation and argspecs are out of alignment (#358)
chore: update firewall_rules from module
fix: update firewall_global from resource model
chore: update to sync with resource module
chore: update README
fix: comment and formatting
fix: formatting issues
fix: missing imports
fix: import and metadata violations
fix: interface fixes
fix: move the arg spec comment
fix: update interface docs
fix: remove comments for non-RM versions
* T6910: fix documentation and argspecs
* T6910: docs: update per review
* T6910: docs: fix missing pipe
Diffstat (limited to 'plugins/modules')
-rw-r--r-- | plugins/modules/vyos_bgp_address_family.py | 86 | ||||
-rw-r--r-- | plugins/modules/vyos_bgp_global.py | 165 | ||||
-rw-r--r-- | plugins/modules/vyos_firewall_global.py | 363 | ||||
-rw-r--r-- | plugins/modules/vyos_firewall_interfaces.py | 4 | ||||
-rw-r--r-- | plugins/modules/vyos_firewall_rules.py | 103 | ||||
-rw-r--r-- | plugins/modules/vyos_hostname.py | 3 | ||||
-rw-r--r-- | plugins/modules/vyos_interfaces.py | 74 | ||||
-rw-r--r-- | plugins/modules/vyos_l3_interfaces.py | 55 | ||||
-rw-r--r-- | plugins/modules/vyos_lag_interfaces.py | 28 | ||||
-rw-r--r-- | plugins/modules/vyos_lldp_global.py | 178 | ||||
-rw-r--r-- | plugins/modules/vyos_lldp_interfaces.py | 252 | ||||
-rw-r--r-- | plugins/modules/vyos_logging_global.py | 12 | ||||
-rw-r--r-- | plugins/modules/vyos_ntp_global.py | 414 | ||||
-rw-r--r-- | plugins/modules/vyos_ospf_interfaces.py | 78 | ||||
-rw-r--r-- | plugins/modules/vyos_ospfv2.py | 370 | ||||
-rw-r--r-- | plugins/modules/vyos_ospfv3.py | 73 | ||||
-rw-r--r-- | plugins/modules/vyos_prefix_lists.py | 25 | ||||
-rw-r--r-- | plugins/modules/vyos_route_maps.py | 56 | ||||
-rw-r--r-- | plugins/modules/vyos_snmp_server.py | 22 | ||||
-rw-r--r-- | plugins/modules/vyos_static_routes.py | 40 |
20 files changed, 1364 insertions, 1037 deletions
diff --git a/plugins/modules/vyos_bgp_address_family.py b/plugins/modules/vyos_bgp_address_family.py index d6f89259..b3756e2e 100644 --- a/plugins/modules/vyos_bgp_address_family.py +++ b/plugins/modules/vyos_bgp_address_family.py @@ -1,27 +1,9 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2021 Red Hat +# Copyright 2024 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_bgp_address_family """ @@ -33,8 +15,8 @@ __metaclass__ = type DOCUMENTATION = """ module: vyos_bgp_address_family -version_added: 2.1.0 -short_description: BGP Address Family Resource Module. +version_added: 1.0.0 +short_description: BGP Address Family resource module description: - This module manages BGP address family configuration of interfaces on devices running VYOS. author: Gomathi Selvi Srinivasan (@GomathiselviS) @@ -45,7 +27,7 @@ options: suboptions: as_number: description: - - AS number. + - AS number type: int address_family: description: BGP address-family parameters. @@ -259,6 +241,7 @@ options: - overridden default: merged """ + EXAMPLES = """ # Using merged # Before state @@ -1161,6 +1144,53 @@ EXAMPLES = """ # ] """ +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - sample command 1 + - sample command 2 + - sample command 3 +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - sample command 1 + - sample command 2 + - sample command 3 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + from ansible.module_utils.basic import AnsibleModule from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.bgp_address_family.bgp_address_family import ( @@ -1179,9 +1209,15 @@ def main(): """ module = AnsibleModule( argument_spec=Bgp_address_familyArgs.argument_spec, - mutually_exclusive=[], - required_if=[], - supports_check_mode=False, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, ) result = Bgp_address_family(module).execute_module() diff --git a/plugins/modules/vyos_bgp_global.py b/plugins/modules/vyos_bgp_global.py index f9c0eeb3..7d47e4ad 100644 --- a/plugins/modules/vyos_bgp_global.py +++ b/plugins/modules/vyos_bgp_global.py @@ -1,27 +1,9 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2021 Red Hat +# Copyright 2024 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_bgp_global """ @@ -33,11 +15,12 @@ __metaclass__ = type DOCUMENTATION = """ module: vyos_bgp_global -version_added: 2.0.0 -short_description: BGP Global Resource Module. +version_added: 1.0.0 +short_description: BGP global resource module description: - This module manages BGP global configuration of interfaces on devices running VYOS. -author: Gomathi Selvi Srinivasan (@GomathiselviS) +author: +- Gomathi Selvi Srinivasan (@GomathiselviS) options: config: description: A dict of BGP global configuration for interfaces. @@ -45,22 +28,25 @@ options: suboptions: as_number: description: - - AS number. + - AS number. type: int aggregate_address: description: - - BGP aggregate network. + - BGP aggregate network. type: list elements: dict suboptions: prefix: - description: BGP aggregate network. + description: + - BGP aggregate network. type: str as_set: - description: Generate AS-set path information for this aggregate address. + description: + - Generate AS-set path information for this aggregate address. type: bool summary_only: - description: Announce the aggregate summary network only. + description: + - Announce the aggregate summary network only. type: bool maximum_paths: description: BGP multipaths @@ -79,19 +65,24 @@ options: elements: dict suboptions: address: - description: BGP neighbor address (v4/v6). + description: + - BGP neighbor address (v4/v6). type: str advertisement_interval: - description: Minimum interval for sending routing updates. + description: + - Minimum interval for sending routing updates. type: int allowas_in: - description: Number of occurrences of AS number. + description: + - Number of occurrences of AS number. type: int as_override: - description: AS for routes sent to this neighbor to be the local AS. + description: + - AS for routes sent to this neighbor to be the local AS. type: bool attribute_unchanged: - description: BGP attributes are sent unchanged. + description: + - BGP attributes are sent unchanged. type: dict suboptions: as_path: @@ -104,47 +95,58 @@ options: description: next_hop type: bool capability: - description: Advertise capabilities to this neighbor. + description: + - Advertise capabilities to this neighbor. type: dict suboptions: dynamic: - description: Advertise dynamic capability to this neighbor. + description: + - Advertise dynamic capability to this neighbor. type: bool orf: - description: Advertise ORF capability to this neighbor. + description: + - Advertise ORF capability to this neighbor. type: str - choices: ['send', 'receive'] + choices: + - send + - receive default_originate: - description: Send default route to this neighbor + description: + - Send default route to this neighbor type: str description: - description: description text + description: + - Description of the neighbor type: str disable_capability_negotiation: - description: Disbale capability negotiation with the neighbor + description: + - Disbale capability negotiation with the neighbor type: bool disable_connected_check: - description: Disable check to see if EBGP peer's address is a connected route. + description: + - Disable check to see if EBGP peer's address is a connected route. type: bool disable_send_community: - description: Disable sending community attributes to this neighbor. + description: + - Disable sending community attributes to this neighbor. type: str choices: ['extended', 'standard'] distribute_list: - description: Access-list to filter route updates to/from this neighbor. + description: Access-list to filter route updates to/from this neighbor. type: list elements: dict suboptions: action: - description: Access-list to filter outgoing/incoming route updates to this neighbor + description: Access-list to filter outgoing/incoming route updates to this neighbor type: str choices: ['export', 'import'] acl: description: Access-list number. type: int ebgp_multihop: - description: Allow this EBGP neighbor to not be on a directly connected network. Specify - the number hops. + description: + - Allow this EBGP neighbor to not be on a directly connected network. Specify + the number hops. type: int filter_list: description: As-path-list to filter route updates to/from this neighbor. @@ -162,11 +164,11 @@ options: description: local as number not to be prepended to updates from EBGP peers type: int maximum_prefix: - description: Maximum number of prefixes to accept from this neighbor + description: Maximum number of prefixes to accept from this neighbor nexthop-self Nexthop for routes sent to this neighbor to be the local router. type: int nexthop_self: - description: Nexthop for routes sent to this neighbor to be the local router. + description: Nexthop for routes sent to this neighbor to be the local router. type: bool override_capability: description: Ignore capability negotiation with specified neighbor. @@ -178,7 +180,7 @@ options: description: BGP MD5 password type: str peer_group_name: - description: IPv4 peer group for this peer + description: IPv4 peer group for this peer type: str peer_group: description: True if all the configs under this neighbor key is for peer group template. @@ -232,10 +234,10 @@ options: description: Enable strict capability negotiation type: bool unsuppress_map: - description: Route-map to selectively unsuppress suppressed routes + description: Route-map to selectively unsuppress suppressed routes type: str update_source: - description: Source IP of routing updates + description: Source IP of routing updates type: str weight: description: Default weight for routes from this neighbor @@ -361,7 +363,7 @@ options: description: Compare MEDs between different peers in the same AS type: bool disable_network_import_check: - description: Disable IGP route check for network statements + description: Disable IGP route check for network statements type: bool distance: description: Administrative distances for BGP routes @@ -424,8 +426,8 @@ options: 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 - """ + EXAMPLES = """ # Using merged # Before state @@ -1405,6 +1407,53 @@ EXAMPLES = """ # ] """ +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - set protocols bgp 65536 redistribute static route-map map01 + - set protocols bgp 65536 network 203.0.113.0/24 route-map map01 + - set protocols bgp 65536 parameters always-compare-med +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - set protocols bgp 65536 redistribute static route-map map01 + - set protocols bgp 65536 network 203.0.113.0/24 route-map map01 + - set protocols bgp 65536 parameters always-compare-med +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + from ansible.module_utils.basic import AnsibleModule from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.bgp_global.bgp_global import ( @@ -1423,9 +1472,15 @@ def main(): """ module = AnsibleModule( argument_spec=Bgp_globalArgs.argument_spec, - mutually_exclusive=[], - required_if=[], - supports_check_mode=False, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, ) result = Bgp_global(module).execute_module() diff --git a/plugins/modules/vyos_firewall_global.py b/plugins/modules/vyos_firewall_global.py index befe5e73..e952ae50 100644 --- a/plugins/modules/vyos_firewall_global.py +++ b/plugins/modules/vyos_firewall_global.py @@ -31,16 +31,24 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_firewall_global -short_description: FIREWALL global resource module -description: This module manage global policies or configurations for firewall on +short_description: Firewall global resource module +description: +- This module manage global policies or configurations for firewall on VyOS devices. -version_added: 1.0.0 +version_added: '1.0.0' notes: -- Tested against VyOS 1.1.8 (helium). -- This module works with connection C(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +- Tested against VyOS 1.3.8. +- This module works with connection C(ansible.netcommon.network_cli). + See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: - Rohit Thakur (@rohitthakur2590) options: @@ -50,7 +58,8 @@ options: type: dict suboptions: route_redirects: - description: -A dictionary of Firewall icmp redirect and source route global + description: + - A dictionary of Firewall ICMP redirect and source route global configuration options. type: list elements: dict @@ -151,7 +160,8 @@ options: elements: dict suboptions: address: - description: IP address. + description: + - IP address. type: str network_group: description: @@ -185,7 +195,8 @@ options: elements: dict suboptions: address: - description: IP address. + description: + - IP address. type: str port_group: description: @@ -200,7 +211,7 @@ options: required: true description: description: - - Allows you to specify a brief description for the port group. + - A brief description for the port group. type: str members: description: @@ -209,7 +220,8 @@ options: elements: dict suboptions: port: - description: Defines the number. + description: + - Specified port. type: str log_martians: description: @@ -235,7 +247,8 @@ options: elements: dict suboptions: connection_type: - description: Specifies connection type. + description: + - Specifies connection type. type: str choices: - established @@ -255,6 +268,7 @@ options: type: bool log_level: description: + - Specify log level for packets logged. - Only available in 1.4+ type: str choices: @@ -268,7 +282,8 @@ options: - debug running_config: description: - - The module, by default, will connect to the remote device and retrieve the current + - > + 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 @@ -288,7 +303,6 @@ options: - rendered - parsed default: merged - """ EXAMPLES = """ # Using merged @@ -314,6 +328,7 @@ EXAMPLES = """ - connection_type: established action: accept log: true + log_level: emerg - connection_type: invalid action: reject route_redirects: @@ -353,19 +368,20 @@ EXAMPLES = """ # "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'" +# "set firewall global-options ip-src-route 'enable'", +# "set firewall global-options receive-redirects 'disable'", +# "set firewall global-options send-redirects 'enable'", +# "set firewall global-options config-trap 'enable'", +# "set firewall global-options state-policy established action 'accept'", +# "set firewall global-options state-policy established log 'enable'", +# "set firewall global-options state-policy established log-level 'emerg'", +# "set firewall global-options state-policy invalid action 'reject'", +# "set firewall global-options broadcast-ping 'enable'", +# "set firewall global-options all-ping 'enable'", +# "set firewall global-options log-martians 'enable'", +# "set firewall global-options twa-hazards-protection 'enable'", +# "set firewall global-options syn-cookies 'enable'", +# "set firewall global-options source-validation 'strict'" # ] # # "after": { @@ -435,36 +451,48 @@ EXAMPLES = """ # ------------- # # 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 global-options all-ping 'enable' +# set firewall global-options broadcast-ping 'enable' +# set firewall global-options config-trap 'enable' +# set firewall global-options ip-src-route 'enable' +# set firewall global-options log-martians 'enable' +# set firewall global-options receive-redirects 'disable' +# set firewall global-options send-redirects 'enable' +# set firewall global-options source-validation 'strict' +# set firewall global-options state-policy established action 'accept' +# set firewall global-options state-policy established log 'enable' +# set firewall global-options state-policy invalid action 'reject' +# set firewall global-options syn-cookies 'enable' +# set firewall global-options twa-hazards-protection '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' + running_config: | + set firewall global-options all-ping 'enable' + set firewall global-options broadcast-ping 'enable' + set firewall global-options config-trap 'enable' + set firewall global-options ip-src-route 'enable' + set firewall global-options log-martians 'enable' + set firewall global-options receive-redirects 'disable' + set firewall global-options send-redirects 'enable' + set firewall global-options source-validation 'strict' + set firewall global-options state-policy established action 'accept' + set firewall global-options state-policy established log 'enable' + set firewall global-options state-policy invalid action 'reject' + set firewall global-options syn-cookies 'enable' + set firewall global-options twa-hazards-protection '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' @@ -474,16 +502,6 @@ EXAMPLES = """ 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 # # @@ -568,6 +586,8 @@ EXAMPLES = """ # } # } # + + # # Using deleted # @@ -575,25 +595,26 @@ EXAMPLES = """ # ------------- # # 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 global-options all-ping 'enable' +# set firewall global-options broadcast-ping 'enable' +# set firewall global-options config-trap 'enable' +# set firewall global-options ip-src-route 'enable' +# set firewall global-options log-martians 'enable' +# set firewall global-options receive-redirects 'disable' +# set firewall global-options send-redirects 'enable' +# set firewall global-options source-validation 'strict' +# set firewall global-options state-policy established action 'accept' +# set firewall global-options state-policy established log 'enable' +# set firewall global-options state-policy invalid action 'reject' +# set firewall global-options syn-cookies 'enable' +# set firewall global-options twa-hazards-protection '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: @@ -606,6 +627,7 @@ EXAMPLES = """ ping: group: state: deleted + # # # ------------------------ @@ -675,18 +697,18 @@ EXAMPLES = """ # "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" +# "delete firewall global-options source-validation", +# "delete firewall global-options group", +# "delete firewall global-options log-martians", +# "delete firewall global-options ip-src-route", +# "delete firewall global-options receive-redirects", +# "delete firewall global-options send-redirects", +# "delete firewall global-options config-trap", +# "delete firewall global-options state-policy", +# "delete firewall global-options syn-cookies", +# "delete firewall global-options broadcast-ping", +# "delete firewall global-options all-ping", +# "delete firewall global-options twa-hazards-protection" # ] # # "after": [] @@ -696,6 +718,8 @@ EXAMPLES = """ # vyos@192# run show configuration commands | grep firewall # set 'firewall' # + + # # Using replaced # @@ -703,25 +727,25 @@ EXAMPLES = """ # ------------- # # vyos@vyos:~$ show configuration commands| grep firewall -# set firewall all-ping 'enable' -# set firewall broadcast-ping 'enable' -# set firewall config-trap 'enable' +# set firewall global-options all-ping 'enable' +# set firewall global-options broadcast-ping 'enable' +# set firewall global-options config-trap 'enable' +# set firewall global-options ip-src-route 'enable' +# set firewall global-options log-martians 'enable' +# set firewall global-options receive-redirects 'disable' +# set firewall global-options send-redirects 'enable' +# set firewall global-options source-validation 'strict' +# set firewall global-options state-policy established action 'accept' +# set firewall global-options state-policy established log 'enable' +# set firewall global-options state-policy invalid action 'reject' +# set firewall global-options syn-cookies 'enable' +# set firewall global-options twa-hazards-protection '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: @@ -926,9 +950,19 @@ EXAMPLES = """ # ------------- # # 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 global-options all-ping 'enable' +# set firewall global-options broadcast-ping 'enable' +# set firewall global-options config-trap 'enable' +# set firewall global-options ip-src-route 'enable' +# set firewall global-options log-martians 'enable' +# set firewall global-options receive-redirects 'disable' +# set firewall global-options send-redirects 'enable' +# set firewall global-options source-validation 'strict' +# set firewall global-options state-policy established action 'accept' +# set firewall global-options state-policy established log 'enable' +# set firewall global-options state-policy invalid action 'reject' +# set firewall global-options syn-cookies 'enable' +# set firewall global-options twa-hazards-protection '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' @@ -938,27 +972,29 @@ EXAMPLES = """ # 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 global-options all-ping 'enable' +# set firewall global-options broadcast-ping 'enable' +# set firewall global-options config-trap 'enable' +# set firewall global-options ip-src-route 'enable' +# set firewall global-options log-martians 'enable' +# set firewall global-options receive-redirects 'disable' +# set firewall global-options send-redirects 'enable' +# set firewall global-options source-validation 'strict' +# set firewall global-options state-policy established action 'accept' +# set firewall global-options state-policy established log 'enable' +# set firewall global-options state-policy invalid action 'reject' +# set firewall global-options syn-cookies 'enable' +# set firewall global-options twa-hazards-protection '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' @@ -968,17 +1004,7 @@ EXAMPLES = """ # 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: state: gathered @@ -1068,9 +1094,19 @@ EXAMPLES = """ # ------------- # # 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 global-options all-ping 'enable' +# set firewall global-options broadcast-ping 'enable' +# set firewall global-options config-trap 'enable' +# set firewall global-options ip-src-route 'enable' +# set firewall global-options log-martians 'enable' +# set firewall global-options receive-redirects 'disable' +# set firewall global-options send-redirects 'enable' +# set firewall global-options source-validation 'strict' +# set firewall global-options state-policy established action 'accept' +# set firewall global-options state-policy established log 'enable' +# set firewall global-options state-policy invalid action 'reject' +# set firewall global-options syn-cookies 'enable' +# set firewall global-options twa-hazards-protection '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' @@ -1080,16 +1116,6 @@ EXAMPLES = """ # 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 @@ -1158,44 +1184,66 @@ EXAMPLES = """ # "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'" +# "set firewall global-options ip-src-route 'enable'", +# "set firewall global-options receive-redirects 'disable'", +# "set firewall global-options send-redirects 'enable'", +# "set firewall global-options config-trap 'enable'", +# "set firewall global-options state-policy established action 'accept'", +# "set firewall global-options state-policy established log 'enable'", +# "set firewall global-options state-policy invalid action 'reject'", +# "set firewall global-options broadcast-ping 'enable'", +# "set firewall global-options all-ping 'enable'", +# "set firewall global-options log-martians 'enable'", +# "set firewall global-options twa-hazards-protection 'enable'", +# "set firewall global-options syn-cookies 'enable'", +# "set firewall global-options source-validation 'strict'" # ] # -# """ RETURN = """ before: - description: The configuration prior to the model invocation. - returned: always - type: list + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict sample: > - The configuration returned will always be in the same format - of the parameters above. + This output will always be in the same format as the + module argspec. after: - description: The resulting configuration model invocation. + description: The resulting configuration after module execution. returned: when changed - type: list + type: dict sample: > - The configuration returned will always be in the same format - of the parameters above. + This output will always be in the same format as the + module argspec. 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'] + sample: + - "set firewall group address-group ENG-HOSTS" + - "set firewall group address-group ENG-HOSTS address 192.0.3.1" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - "set firewall group address-group ENG-HOSTS" + - "set firewall group address-group ENG-HOSTS address 192.0.3.1" +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. + """ @@ -1218,9 +1266,12 @@ def main(): 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_globalArgs.argument_spec, required_if=required_if, diff --git a/plugins/modules/vyos_firewall_interfaces.py b/plugins/modules/vyos_firewall_interfaces.py index 2feabe49..ae17bc13 100644 --- a/plugins/modules/vyos_firewall_interfaces.py +++ b/plugins/modules/vyos_firewall_interfaces.py @@ -40,8 +40,8 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ --- module: vyos_firewall_interfaces -version_added: '2.10.0' -short_description: Manage firewall rules attributes of interfaces on VyOS devices +version_added: '1.0.0' +short_description: Firewall interfaces resource module description: Manage firewall rules of interfaces on VyOS network devices. (1.3-) author: - Rohit Thakur (@rohitthakur2590) diff --git a/plugins/modules/vyos_firewall_rules.py b/plugins/modules/vyos_firewall_rules.py index fd2e7d55..d8c7a1c9 100644 --- a/plugins/modules/vyos_firewall_rules.py +++ b/plugins/modules/vyos_firewall_rules.py @@ -32,21 +32,25 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = { - 'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'network' + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", } DOCUMENTATION = """ +--- module: vyos_firewall_rules -short_description: FIREWALL rules resource module +version_added: '1.0.0' +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(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: - Rohit Thakur (@rohitthakur2590) +- Gaige B. Paulsen (@gaige) +notes: +- Tested against VyOS 1.3.8. +- This module works with connection C(ansible.netcommon.network_cli). + See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). + options: config: description: A dictionary of Firewall rule-set options. @@ -69,8 +73,8 @@ options: suboptions: filter: description: - - Filter type (exclusive to "name"). - - Supported in 1.4 and later. + - Filter type (exclusive to "name"). + - Supported in 1.4 and later. type: str choices: ['input', 'output', 'forward'] name: @@ -84,14 +88,14 @@ options: - 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) - - jump (Jump to another rule-set, 1.4+) + - jump (Jump to another rule-set, 1.4+) type: str choices: ['drop', 'reject', 'accept', 'jump'] default_jump_target: description: - - Default jump target if the default action is jump. - - Only valid in 1.4 and later. - - Only valid when default_action = jump. + - Default jump target if the default action is jump. + - Only valid in 1.4 and later. + - Only valid when default_action = jump. type: str description: description: @@ -257,6 +261,8 @@ options: ipsec: description: - Inbound ip sec packets. + - VyOS 1.4 and older match-ipsec/match-none + - VyOS 1.5 and later require -in/-out suffixes type: str choices: - match-ipsec @@ -299,7 +305,7 @@ options: type: str log: description: - - Log matching packets. + - Option to log packets matching rule. type: str choices: ['disable', 'enable'] outbound_interface: @@ -503,7 +509,16 @@ options: - syn, ack, fin, rst, urg, psh, all (1.3-) - syn, ack, fin, rst, urg, psh, cwr, ecn (1.4+) type: str - choices: ['ack', 'cwr', 'ecn', 'fin', 'psh', 'rst', 'syn', 'urg', 'all'] + choices: + - ack + - cwr + - ecn + - fin + - psh + - rst + - syn + - urg + - all invert: description: - Invert the match. @@ -564,7 +579,6 @@ options: - rendered - parsed default: merged - """ EXAMPLES = """ # Using deleted to delete firewall rules based on rule-set name @@ -1230,7 +1244,6 @@ EXAMPLES = """ description: Rule 502 is configured by Ansible ipsec: match-ipsec state: overridden - # # # ------------------------- @@ -1366,6 +1379,7 @@ EXAMPLES = """ # - name: Gather listed firewall rules with provided configurations vyos.vyos.vyos_firewall_rules: + config: state: gathered # # @@ -1514,7 +1528,6 @@ EXAMPLES = """ invalid: false related: true state: rendered - # # # ------------------------- @@ -1550,7 +1563,7 @@ EXAMPLES = """ # Using parsed # # -- name: Parsed the provided input commands. +- name: Parse the commands for provided configuration vyos.vyos.vyos_firewall_rules: running_config: "set firewall group address-group 'inbound' @@ -1599,19 +1612,19 @@ EXAMPLES = """ """ RETURN = """ before: - description: The configuration prior to the model invocation. - returned: always + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: dict sample: > - The configuration returned will always be in the same format - of the parameters above. + This output will always be in the same format as the + module argspec. after: - description: The resulting configuration model invocation. + description: The resulting configuration after module execution. returned: when changed type: dict sample: > - The configuration returned will always be in the same format - of the parameters above. + This output will always be in the same format as the + module argspec. commands: description: The set of commands pushed to the remote device. returned: always @@ -1622,13 +1635,42 @@ commands: - "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'" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + 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'" +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. + """ 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 +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(): @@ -1652,9 +1694,10 @@ def main(): supports_check_mode=True, mutually_exclusive=mutually_exclusive, ) + result = Firewall_rules(module).execute_module() module.exit_json(**result) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/plugins/modules/vyos_hostname.py b/plugins/modules/vyos_hostname.py index bc039b55..480b011f 100644 --- a/plugins/modules/vyos_hostname.py +++ b/plugins/modules/vyos_hostname.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2022 Red Hat +# Copyright 2024 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -209,7 +209,6 @@ EXAMPLES = """ # } """ - RETURN = """ before: description: The configuration prior to the module execution. diff --git a/plugins/modules/vyos_interfaces.py b/plugins/modules/vyos_interfaces.py index c7a2168f..b679a226 100644 --- a/plugins/modules/vyos_interfaces.py +++ b/plugins/modules/vyos_interfaces.py @@ -31,25 +31,31 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_interfaces -short_description: Interfaces resource module +version_added: '2.9.0' +short_description: Manages interface attributes of VyOS network devices. 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 +- This module supports managing base attributes of Ethernet, Bonding, + VXLAN, Loopback and Virtual Tunnel Interfaces. notes: -- Tested against VyOS 1.1.8 (helium). -- This module works with connection C(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). -- The examples use the stdout_callback as yaml to produce task outputs. +- Tested against VyOS 1.3.8 +- This module works with connection C(ansible.netcommon.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. + description: The provided interface configuration. type: list elements: dict suboptions: @@ -75,9 +81,9 @@ options: 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. + - Set the value to C(true) to administratively enable the interface or C(false) to disable it. type: bool + aliases: ['enable'] mtu: description: - MTU for a specific interface. Refer to vendor documentation for valid values. @@ -117,6 +123,7 @@ options: C(false) to disable it. type: bool default: true + aliases: ['enable'] mtu: description: - MTU for the virtual sub-interface. @@ -145,7 +152,6 @@ options: - parsed default: merged """ - EXAMPLES = """ # Using merged @@ -825,29 +831,50 @@ EXAMPLES = """ # 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. + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list + sample: > + This output will always be in the same format as the + module argspec. after: - description: The configuration as structured data after module completion. + description: The resulting configuration after module execution. returned: when changed - sample: > - The configuration returned will always be in the same format - of the parameters above. type: list + sample: > + This output will always be in the same format as the + module argspec. 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' + - 'set interfaces ethernet eth1 mtu 1200' + - 'set interfaces ethernet eth2 vif 100 description VIF 100' +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - 'set interfaces ethernet eth1 mtu 1200' + - 'set interfaces ethernet eth2 vif 100 description VIF 100' +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. + """ @@ -875,6 +902,7 @@ def main(): ("state", "parsed", ("running_config",)), ] mutually_exclusive = [("config", "running_config")] + module = AnsibleModule( argument_spec=InterfacesArgs.argument_spec, required_if=required_if, diff --git a/plugins/modules/vyos_l3_interfaces.py b/plugins/modules/vyos_l3_interfaces.py index 0849c296..0d2a5dae 100644 --- a/plugins/modules/vyos_l3_interfaces.py +++ b/plugins/modules/vyos_l3_interfaces.py @@ -31,21 +31,28 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_l3_interfaces -short_description: L3 interfaces resource module +version_added: '1.0.0' +short_description: Layer 3 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). +- Tested against VyOS 1.3. - This module works with connection C(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: -- Nilashish Chakraborty (@NilashishC) - Rohit Thakur (@rohitthakur2590) +- Nilashish Chakraborty (@nilashishc) options: config: - description: The provided L3 interfaces configuration. + description: + - The provided L3 interfaces configuration. type: list elements: dict suboptions: @@ -73,36 +80,38 @@ options: address: description: - IPv6 address of the interface. + - C(auto-config) to use SLAAC to chose an address. type: str vifs: description: - - Virtual sub-interfaces L3 configurations. + - List of virtual sub-interfaces (VIFs) of the interface. elements: dict type: list suboptions: vlan_id: description: - - Identifier for the virtual sub-interface. + - Identifier for the VIF. type: int ipv4: description: - - List of IPv4 addresses of the virtual interface. + - List of IPv4 addresses of the VIF. type: list elements: dict suboptions: address: description: - - IPv4 address of the virtual interface. + - IPv4 address of the VIF. type: str ipv6: description: - - List of IPv6 addresses of the virtual interface. + - List of IPv6 addresses of the VIF. type: list elements: dict suboptions: address: description: - - IPv6 address of the virtual interface. + - IPv6 address of the virtual VIF + - C(auto-config) to use SLAAC to chose an address. type: str running_config: description: @@ -122,9 +131,9 @@ options: - replaced - overridden - deleted - - parsed - - gathered - rendered + - gathered + - parsed default: merged """ EXAMPLES = """ @@ -163,7 +172,6 @@ EXAMPLES = """ - address: '2001:db8:1400::3/38' state: merged - # After state: # ------------- # @@ -216,7 +224,7 @@ EXAMPLES = """ - name: eth3 ipv6: - - address: 2001:db8::11/32 + - address: '2001:db8::11/32' state: replaced # After state: @@ -273,7 +281,6 @@ EXAMPLES = """ - address: dhcpv6 state: overridden - # After state # ------------ # @@ -315,8 +322,7 @@ EXAMPLES = """ # 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) +- name: Delete L3 attributes of given interfaces (Note - This won't delete the interface itself) vyos.vyos.vyos_l3_interfaces: config: - name: eth1 @@ -515,24 +521,27 @@ EXAMPLES = """ """ RETURN = """ before: - description: The configuration as structured data prior to module invocation. + description: The configuration prior to the module invocation. returned: always type: list sample: > The configuration returned will always be in the same format - of the parameters above. + of the parameters above. after: - description: The configuration as structured data after module completion. + description: The resulting configuration module invocation. returned: when changed type: list sample: > The configuration returned will always be in the same format - of the parameters above. + 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'] + sample: + - 'set interfaces ethernet eth1 192.0.2.14/2' + - 'set interfaces ethernet eth3 vif 101 address 198.51.100.130/25' + """ diff --git a/plugins/modules/vyos_lag_interfaces.py b/plugins/modules/vyos_lag_interfaces.py index 0605f068..090021ad 100644 --- a/plugins/modules/vyos_lag_interfaces.py +++ b/plugins/modules/vyos_lag_interfaces.py @@ -31,17 +31,23 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_lag_interfaces +version_added: '1.0.0' short_description: LAG interfaces resource module -description: This module manages attributes of link aggregation groups on VyOS network - devices. -version_added: 1.0.0 +description: This module manages attributes of link aggregation groups on VyOS network devices. +author: +- Rohit Thakur (@rohitthakur2590) notes: -- Tested against VyOS 1.1.8 (helium). +- Tested against VyOS 1.3.8. - This module works with connection C(ansible.netcommon.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. @@ -453,8 +459,7 @@ EXAMPLES = """ # 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) +- name: Delete LAG attributes of given interfaces (Note - This won't delete the interface itself) vyos.vyos.vyos_lag_interfaces: config: - name: bond2 @@ -718,19 +723,19 @@ EXAMPLES = """ """ RETURN = """ before: - description: The configuration as structured data prior to module invocation. + description: The configuration prior to the module invocation. returned: always type: list sample: > The configuration returned will always be in the same format - of the parameters above. + of the parameters above. after: - description: The configuration as structured data after module completion. + description: The resulting configuration module invocation. returned: when changed type: list sample: > The configuration returned will always be in the same format - of the parameters above. + of the parameters above. commands: description: The set of commands pushed to the remote device. returned: always @@ -738,6 +743,7 @@ commands: sample: - 'set interfaces bonding bond2' - 'set interfaces bonding bond2 hash-policy layer2' + """ diff --git a/plugins/modules/vyos_lldp_global.py b/plugins/modules/vyos_lldp_global.py index 5d215f68..e2f7914e 100644 --- a/plugins/modules/vyos_lldp_global.py +++ b/plugins/modules/vyos_lldp_global.py @@ -31,15 +31,21 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_lldp_global +version_added: '1.0.0' 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). +- Tested against VyOS 1.3.8 - This module works with connection C(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: - Rohit Thakur (@rohitthakur2590) @@ -91,7 +97,6 @@ options: - rendered - parsed default: merged - """ EXAMPLES = """ # Using merged @@ -116,32 +121,24 @@ EXAMPLES = """ # 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 -# } +# 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: # ------------- @@ -179,23 +176,16 @@ EXAMPLES = """ # ------------------------ # # -# "before": [ -# { -# "snmp": "enable" -# }, -# { -# "address": "192.0.2.11" -# }, -# { -# "legacy_protocols": [ -# "cdp", -# "fdp" -# ] -# } -# { -# "enable": true -# } +# "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", @@ -204,21 +194,15 @@ EXAMPLES = """ # "set service lldp legacy-protocols sonmp" # ] # -# "after": [ -# { -# "address": "192.0.2.14" -# }, -# { -# "legacy_protocols": [ -# "cdp", -# "edp", -# "sonmp" -# ] -# } -# { -# "enable": true -# } +# "after": { +# "address": "192.0.2.14" +# "legacy_protocols": [ +# "cdp", +# "edp", +# "sonmp" # ] +# "enable": true +# } # # After state: # ------------- @@ -251,32 +235,24 @@ EXAMPLES = """ # Module Execution Results # ------------------------ # -# "before": [ -# { -# "address": "192.0.2.14" -# }, -# { -# "legacy_protocols": [ -# "cdp", -# "edp", -# "sonmp" -# ] -# } -# { -# "enable": true -# } +# "before": { +# "address": "192.0.2.14" +# "legacy_protocols": [ +# "cdp", +# "edp", +# "sonmp" # ] +# "enable": true +# } # # "commands": [ -# "delete service lldp management-address", -# "delete service lldp legacy-protocols" -# ] +# "delete service lldp management-address", +# "delete service lldp legacy-protocols" +# ] # -# "after": [ -# { -# "enable": true -# } -# ] +# "after": { +# "enable": true +# } # # After state # ------------ @@ -303,8 +279,7 @@ EXAMPLES = """ # Module Execution Result # ------------------------- # -# "gathered": [ -# { +# "gathered": { # "config_trap": true, # "group": { # "address_group": [ @@ -406,10 +381,10 @@ EXAMPLES = """ # # # "rendered": [ -# "set service lldp legacy-protocols 'cdp'", -# "set service lldp", -# "set service lldp management-address '192.0.2.17'" -# ] +# "set service lldp legacy-protocols 'cdp'", +# "set service lldp", +# "set service lldp management-address '192.0.2.17'" +# ] # @@ -431,30 +406,29 @@ EXAMPLES = """ # # # "parsed": { -# "address": "192.0.2.11", -# "enable": true, -# "legacy_protocols": [ -# "cdp", -# "fdp" -# ] -# } -# +# "address": "192.0.2.11", +# "enable": true, +# "legacy_protocols": [ +# "cdp", +# "fdp" +# ] +# } """ RETURN = """ before: - description: The configuration as structured data prior to module invocation. + description: The configuration prior to the module invocation. returned: always - type: list + type: dict sample: > The configuration returned will always be in the same format - of the parameters above. + of the parameters above. after: - description: The configuration as structured data after module completion. + description: The resulting configuration after module invocation. returned: when changed - type: list + type: dict sample: > The configuration returned will always be in the same format - of the parameters above. + of the parameters above. commands: description: The set of commands pushed to the remote device. returned: always @@ -462,6 +436,7 @@ commands: sample: - set service lldp legacy-protocols sonmp - set service lldp management-address '192.0.2.14' + """ @@ -485,15 +460,18 @@ def main(): ("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_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) diff --git a/plugins/modules/vyos_lldp_interfaces.py b/plugins/modules/vyos_lldp_interfaces.py index 6628f65b..14160c76 100644 --- a/plugins/modules/vyos_lldp_interfaces.py +++ b/plugins/modules/vyos_lldp_interfaces.py @@ -31,33 +31,40 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_lldp_interfaces +version_added: '1.0.0' 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(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +- Tested against VyOS 1.3.8 +- This module works with connection C(ansible.netcommon.network_cli). + See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: -- Rohit Thakur (@rohitthakur2590) + - Rohit Thakur (@rohitthakur2590) options: config: - description: A list of lldp interfaces configurations. + description: A list of LLDP interfaces configurations. type: list elements: dict suboptions: name: description: - - Name of the lldp interface. + - Name of the LLDP interface. type: str required: true enable: + default: true description: - - to disable lldp on the interface. + - Disable LLDP on the interfaces. type: bool - default: true location: description: - LLDP-MED location data. @@ -76,9 +83,11 @@ options: ca_type: description: LLDP-MED Civic Address type. type: int + required: true ca_value: description: LLDP-MED Civic Address value. type: str + required: true country_code: description: Country Code type: str @@ -120,16 +129,16 @@ options: type: str state: description: - - The state of the configuration after module completion. + - The state of the configuration after module completion. type: str choices: - - merged - - replaced - - overridden - - deleted - - rendered - - parsed - - gathered + - merged + - replaced + - overridden + - deleted + - rendered + - parsed + - gathered default: merged """ EXAMPLES = """ @@ -158,18 +167,19 @@ EXAMPLES = """ longitude: 222.267255W latitude: 33.524449N state: merged - # # # ------------------------- # Module Execution Result # ------------------------- # -# before": [] +# 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 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'", @@ -180,34 +190,33 @@ EXAMPLES = """ # "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": { +# "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: # ------------- @@ -301,33 +310,31 @@ EXAMPLES = """ # "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" +# "after": { +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" +# } # }, -# { -# "location": { -# "coordinate_based": { -# "altitude": 2200, -# "datum": "WGS84", -# "latitude": "33.524449N", -# "longitude": "222.267255W" -# } -# }, -# "name": "eth1" -# } -# ] +# "name": "eth2" +# }, +# { +# "location": { +# "coordinate_based": { +# "altitude": 2200, +# "datum": "WGS84", +# "latitude": "33.524449N", +# "longitude": "222.267255W" +# } +# }, +# "name": "eth1" +# } # # After state: # ------------- @@ -373,49 +380,49 @@ EXAMPLES = """ # ------------------------- # # "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" +# { +# "enable": false, +# "location": { +# "civic_based": { +# "ca_info": [ +# { +# "ca_type": 0, +# "ca_value": "ENGLISH" +# } +# ], +# "country_code": "US" # } -# ] -# -# "commands": [ -# "delete service lldp interface eth2 location", -# "delete service lldp interface eth2 disable", -# "set service lldp interface eth2 location elin 0000000911" +# }, +# "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": [ +# { +# "location": { +# "elin": 0000000911 +# }, +# "name": "eth2" +# } +# ] # # # After state @@ -433,7 +440,7 @@ EXAMPLES = """ # vyos@vyos# run show configuration commands | grep lldp # set service lldp interface eth2 location elin '0000000911' # -- name: Delete lldp interface attributes of given interfaces. +- name: Delete LLDP interface attributes of given interfaces. vyos.vyos.vyos_lldp_interfaces: config: - name: eth2 @@ -444,11 +451,17 @@ EXAMPLES = """ # Module Execution Results # ------------------------ # - before: [{location: {elin: 0000000911}, name: eth2}] -# "commands": [ -# "commands": [ -# "delete service lldp interface eth2" -# ] +# "before": [ +# { +# "location": { +# "elin": 0000000911 +# }, +# "name": "eth2" +# } +# ] +# "commands": [ +# "delete service lldp interface eth2" +# ] # # "after": [] # After state @@ -617,14 +630,14 @@ before: type: list sample: > The configuration returned will always be in the same format - of the parameters above. + 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. + of the parameters above. commands: description: The set of commands pushed to the remote device. returned: always @@ -632,6 +645,7 @@ commands: sample: - "set service lldp interface eth2 'disable'" - "delete service lldp interface eth1 location" + """ diff --git a/plugins/modules/vyos_logging_global.py b/plugins/modules/vyos_logging_global.py index 06ebe48d..069d5080 100644 --- a/plugins/modules/vyos_logging_global.py +++ b/plugins/modules/vyos_logging_global.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2021 Red Hat +# Copyright 2024 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -698,7 +698,7 @@ EXAMPLES = """ RETURN = """ before: description: The configuration prior to the module execution. - returned: when state is I(merged), I(replaced), I(overridden), I(deleted) or I(purged) + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: dict sample: > This output will always be in the same format as the @@ -712,7 +712,7 @@ after: module argspec. commands: description: The set of commands pushed to the remote device. - returned: when state is I(merged), I(replaced), I(overridden), I(deleted) or I(purged) + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: - "set system syslog console facility local7 level err" @@ -720,7 +720,7 @@ commands: - "set system syslog global archive size 111" rendered: description: The provided configuration in the task rendered in device-native format (offline). - returned: when state is I(rendered) + returned: when I(state) is C(rendered) type: list sample: - "set system syslog host 172.16.0.1 port 223" @@ -728,14 +728,14 @@ rendered: - "set system syslog global facility cron level debug" gathered: description: Facts about the network resource gathered from the remote device as structured data. - returned: when state is I(gathered) + returned: when I(state) is C(gathered) type: list sample: > This output will always be in the same format as the module argspec. parsed: description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. - returned: when state is I(parsed) + returned: when I(state) is C(parsed) type: list sample: > This output will always be in the same format as the diff --git a/plugins/modules/vyos_ntp_global.py b/plugins/modules/vyos_ntp_global.py index 0fe56ad0..4fd9891b 100644 --- a/plugins/modules/vyos_ntp_global.py +++ b/plugins/modules/vyos_ntp_global.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2021 Red Hat +# Copyright 2024 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -13,75 +13,78 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type - DOCUMENTATION = """ - module: vyos_ntp_global - version_added: 2.4.0 - short_description: Manages ntp modules of Vyos network devices - description: - - This module manages ntp configuration on devices running Vyos - author: Varshitha Yataluru (@YVarshitha) - notes: - - Tested against vyos 1.3 - - This module works with connection C(network_cli). - options: - config: - description: List of configurations for ntp module - type: dict +module: vyos_ntp_global +version_added: 1.0.0 +short_description: NTP global resource module +description: +- This module manages ntp configuration on devices running Vyos +author: +- Varshitha Yataluru (@YVarshitha) +notes: +- Tested against vyos 1.3 +- This module works with connection C(network_cli). +- "VyOS v.1.4+ uses chronyd, and path changes from `system` to `service`" +options: + config: + description: List of configurations for ntp module + type: dict + suboptions: + allow_clients: + description: Network Time Protocol (NTP) server options + type: list + elements: str + listen_addresses: + description: local IP addresses for service to listen on + type: list + elements: str + servers: + description: Network Time Protocol (NTP) server + type: list + elements: dict suboptions: - allow_clients: - description: Network Time Protocol (NTP) server options - type: list - elements: str - listen_addresses: - description: local IP addresses for service to listen on - type: list - elements: str - servers: - description: Network Time Protocol (NTP) server - type: list - elements: dict - suboptions: - server: - description: server name for NTP - type: str - options: - description: server options for NTP - type: list - elements: str - choices: - - noselect - - dynamic - - pool - - preempt - - prefer - 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 ntp). - - The states I(replaced) and I(overridden) have identical - behaviour for this module. - - The state I(parsed) reads the configuration from C(show configuration commands | grep ntp) 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: - - deleted - - merged - - overridden - - replaced - - gathered - - rendered - - parsed - default: merged + server: + description: server name for NTP + type: str + options: + description: + - server options for NTP + - "`dynamic` changed to `pool` after v1.3" + type: list + elements: str + choices: + - noselect + - dynamic + - pool + - preempt + - prefer + 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 ntp). + - The states I(replaced) and I(overridden) have identical + behaviour for this module. + - The state I(parsed) reads the configuration from C(show configuration commands | grep ntp) 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: + - deleted + - merged + - overridden + - replaced + - gathered + - rendered + - parsed + default: merged """ -EXAMPLES = """ +EXAMPLES = """ # # ------------------- # # 1. Using merged # # ------------------- @@ -89,9 +92,9 @@ EXAMPLES = """ # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # # Task @@ -140,20 +143,20 @@ EXAMPLES = """ # }, # "changed": true, # "commands": [ -# "set system ntp allow-clients address 10.6.6.0/24", -# "set system ntp listen-address 10.1.3.1", -# "set system ntp server 203.0.113.0 prefer" +# "set service ntp allow-clients address 10.6.6.0/24", +# "set service ntp listen-address 10.1.3.1", +# "set service ntp server 203.0.113.0 prefer" # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.6.6.0/24' -# set system ntp listen-address '10.1.3.1' -# set system ntp server 203.0.113.0 prefer, -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.6.6.0/24' +# set service ntp listen-address '10.1.3.1' +# set service ntp server 203.0.113.0 prefer, +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ @@ -164,25 +167,25 @@ EXAMPLES = """ # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.4.9.0/24' -# set system ntp allow-clients address '10.4.7.0/24' -# set system ntp allow-clients address '10.1.2.0/24' -# set system ntp allow-clients address '10.2.3.0/24' -# set system ntp listen-address '10.1.9.16' -# set system ntp listen-address '10.5.3.2' -# set system ntp listen-address '10.7.9.21' -# set system ntp listen-address '10.8.9.4' -# set system ntp listen-address '10.4.5.1' -# set system ntp server 10.3.6.5 noselect -# set system ntp server 10.3.6.5 dynamic -# set system ntp server 10.3.6.5 preempt -# set system ntp server 10.3.6.5 prefer -# set system ntp server server4 noselect -# set system ntp server server4 dynamic -# set system ntp server server5 -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.4.9.0/24' +# set service ntp allow-clients address '10.4.7.0/24' +# set service ntp allow-clients address '10.1.2.0/24' +# set service ntp allow-clients address '10.2.3.0/24' +# set service ntp listen-address '10.1.9.16' +# set service ntp listen-address '10.5.3.2' +# set service ntp listen-address '10.7.9.21' +# set service ntp listen-address '10.8.9.4' +# set service ntp listen-address '10.4.5.1' +# set service ntp server 10.3.6.5 noselect +# set service ntp server 10.3.6.5 dynamic +# set service ntp server 10.3.6.5 preempt +# set service ntp server 10.3.6.5 prefer +# set service ntp server server4 noselect +# set service ntp server server4 dynamic +# set service ntp server server5 +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # # Task @@ -275,32 +278,32 @@ EXAMPLES = """ # }, # "changed": true, # "commands": [ -# "delete system ntp allow-clients address 10.4.7.0/24", -# "delete system ntp allow-clients address 10.2.3.0/24", -# "delete system ntp allow-clients address 10.1.2.0/24", -# "delete system ntp allow-clients address 10.4.9.0/24", -# "delete system ntp listen-address 10.7.9.21", -# "delete system ntp listen-address 10.4.5.1", -# "delete system ntp listen-address 10.5.3.2", -# "delete system ntp listen-address 10.8.9.4", -# "delete system ntp listen-address 10.1.9.16", -# "delete system ntp server 10.3.6.5", -# "delete system ntp server server4", -# "delete system ntp server server5", -# "set system ntp allow-clients address 10.6.6.0/24", -# "set system ntp listen-address 10.1.3.1", -# "set system ntp server 203.0.113.0 prefer" +# "delete service ntp allow-clients address 10.4.7.0/24", +# "delete service ntp allow-clients address 10.2.3.0/24", +# "delete service ntp allow-clients address 10.1.2.0/24", +# "delete service ntp allow-clients address 10.4.9.0/24", +# "delete service ntp listen-address 10.7.9.21", +# "delete service ntp listen-address 10.4.5.1", +# "delete service ntp listen-address 10.5.3.2", +# "delete service ntp listen-address 10.8.9.4", +# "delete service ntp listen-address 10.1.9.16", +# "delete service ntp server 10.3.6.5", +# "delete service ntp server server4", +# "delete service ntp server server5", +# "set service ntp allow-clients address 10.6.6.0/24", +# "set service ntp listen-address 10.1.3.1", +# "set service ntp server 203.0.113.0 prefer" # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.6.6.0/24' -# set system ntp listen-address '10.1.3.1' -# set system ntp server 203.0.113.0 prefer, -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.6.6.0/24' +# set service ntp listen-address '10.1.3.1' +# set service ntp server 203.0.113.0 prefer, +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # # ------------------- @@ -310,12 +313,12 @@ EXAMPLES = """ # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.6.6.0/24' -# set system ntp listen-address '10.1.3.1' -# set system ntp server 203.0.113.0 prefer, -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.6.6.0/24' +# set service ntp listen-address '10.1.3.1' +# set service ntp server 203.0.113.0 prefer, +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # Task @@ -406,31 +409,31 @@ EXAMPLES = """ # }, # "changed": true, # "commands": [ -# "delete system ntp allow-clients address 10.6.6.0/24", -# "delete system ntp listen-address 10.1.3.1", -# "delete system ntp server ser", -# "set system ntp allow-clients address 10.3.3.0/24", -# "set system ntp listen-address 10.7.8.1", -# "set system ntp server server1 dynamic", -# "set system ntp server server1 prefer", -# "set system ntp server server2 noselect", -# "set system ntp server server2 preempt", -# "set system ntp server serv" +# "delete service ntp allow-clients address 10.6.6.0/24", +# "delete service ntp listen-address 10.1.3.1", +# "delete service ntp server ser", +# "set service ntp allow-clients address 10.3.3.0/24", +# "set service ntp listen-address 10.7.8.1", +# "set service ntp server server1 dynamic", +# "set service ntp server server1 prefer", +# "set service ntp server server2 noselect", +# "set service ntp server server2 preempt", +# "set service ntp server serv" # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.3.3.0/24' -# set system ntp listen-address '10.7.8.1' -# set system ntp server serv -# set system ntp server server1 dynamic -# set system ntp server server1 prefer -# set system ntp server server2 noselect -# set system ntp server server2 preempt -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.3.3.0/24' +# set service ntp listen-address '10.7.8.1' +# set service ntp server serv +# set service ntp server server1 dynamic +# set service ntp server server1 prefer +# set service ntp server server2 noselect +# set service ntp server server2 preempt +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # 4. Using gathered @@ -439,16 +442,16 @@ EXAMPLES = """ # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.3.3.0/24' -# set system ntp listen-address '10.7.8.1' -# set system ntp server serv -# set system ntp server server1 dynamic -# set system ntp server server1 prefer -# set system ntp server server2 noselect -# set system ntp server server2 preempt -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.3.3.0/24' +# set service ntp listen-address '10.7.8.1' +# set service ntp server serv +# set service ntp server server1 dynamic +# set service ntp server server1 prefer +# set service ntp server server2 noselect +# set service ntp server server2 preempt +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # Task @@ -499,16 +502,16 @@ EXAMPLES = """ # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.3.3.0/24' -# set system ntp listen-address '10.7.8.1' -# set system ntp server serv -# set system ntp server server1 dynamic -# set system ntp server server1 prefer -# set system ntp server server2 noselect -# set system ntp server server2 preempt -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.3.3.0/24' +# set service ntp listen-address '10.7.8.1' +# set service ntp server serv +# set service ntp server server1 dynamic +# set service ntp server server1 prefer +# set service ntp server server2 noselect +# set service ntp server server2 preempt +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ @@ -519,16 +522,16 @@ EXAMPLES = """ # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp allow-clients address '10.3.3.0/24' -# set system ntp listen-address '10.7.8.1' -# set system ntp server serv -# set system ntp server server1 dynamic -# set system ntp server server1 prefer -# set system ntp server server2 noselect -# set system ntp server server2 preempt -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp allow-clients address '10.3.3.0/24' +# set service ntp listen-address '10.7.8.1' +# set service ntp server serv +# set service ntp server server1 dynamic +# set service ntp server server1 prefer +# set service ntp server server2 noselect +# set service ntp server server2 preempt +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # # Task @@ -591,20 +594,20 @@ EXAMPLES = """ # }, # "changed": true, # "commands": [ -# "delete system ntp allow-clients", -# "delete system ntp listen-address", -# "delete system ntp server serv", -# "delete system ntp server server1", -# "delete system ntp server server2" +# "delete service ntp allow-clients", +# "delete service ntp listen-address", +# "delete service ntp server serv", +# "delete service ntp server server1", +# "delete service ntp server server2" # # ] # After state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ @@ -615,9 +618,9 @@ EXAMPLES = """ # # Before state: # # ------------- # vyos@vyos:~$ show configuration commands | grep ntp -# set system ntp server time1.vyos.net -# set system ntp server time2.vyos.net -# set system ntp server time3.vyos.net +# set service ntp server time1.vyos.net +# set service ntp server time2.vyos.net +# set service ntp server time3.vyos.net # vyos@vyos:~$ # Task @@ -645,16 +648,16 @@ EXAMPLES = """ # # Task output: # # ------------- # "rendered": [ -# "set system ntp allow-clients address 10.7.7.0/24", -# "set system ntp allow-clients address 10.8.8.0/24", -# "set system ntp listen-address 10.7.9.1", -# "set system ntp server server7", -# "set system ntp server server45 noselect", -# "set system ntp server server45 prefer", -# "set system ntp server server45 pool", -# "set system ntp server time1.vyos.net", -# "set system ntp server time2.vyos.net", -# "set system ntp server time3.vyos.net" +# "set service ntp allow-clients address 10.7.7.0/24", +# "set service ntp allow-clients address 10.8.8.0/24", +# "set service ntp listen-address 10.7.9.1", +# "set service ntp server server7", +# "set service ntp server server45 noselect", +# "set service ntp server server45 prefer", +# "set service ntp server server45 pool", +# "set service ntp server time1.vyos.net", +# "set service ntp server time2.vyos.net", +# "set service ntp server time3.vyos.net" # ] @@ -664,15 +667,15 @@ EXAMPLES = """ # # sample_config.cfg: # # ------------- -# "set system ntp allow-clients address 10.7.7.0/24", -# "set system ntp listen-address 10.7.9.1", -# "set system ntp server server45 noselect", -# "set system ntp allow-clients addres 10.8.6.0/24", -# "set system ntp listen-address 10.5.4.1", -# "set system ntp server server45 dynamic", -# "set system ntp server time1.vyos.net", -# "set system ntp server time2.vyos.net", -# "set system ntp server time3.vyos.net" +# "set service ntp allow-clients address 10.7.7.0/24", +# "set service ntp listen-address 10.7.9.1", +# "set service ntp server server45 noselect", +# "set service ntp allow-clients addres 10.8.6.0/24", +# "set service ntp listen-address 10.5.4.1", +# "set service ntp server server45 dynamic", +# "set service ntp server time1.vyos.net", +# "set service ntp server time2.vyos.net", +# "set service ntp server time3.vyos.net" # Task: # ------------- @@ -714,6 +717,7 @@ EXAMPLES = """ # ] # } """ + RETURN = """ before: description: The configuration prior to the module execution. @@ -749,7 +753,6 @@ rendered: - set system ntp server server2 noselect - set system ntp server server2 preempt - set system ntp server server_add preempt - gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) @@ -766,7 +769,6 @@ parsed: module argspec. """ - from ansible.module_utils.basic import AnsibleModule from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ntp_global.ntp_global import ( diff --git a/plugins/modules/vyos_ospf_interfaces.py b/plugins/modules/vyos_ospf_interfaces.py index 33290581..f86acb7a 100644 --- a/plugins/modules/vyos_ospf_interfaces.py +++ b/plugins/modules/vyos_ospf_interfaces.py @@ -1,27 +1,9 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2020 Red Hat +# Copyright 2024 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 """ @@ -153,6 +135,7 @@ options: - rendered default: merged """ + EXAMPLES = """ # Using merged # @@ -881,6 +864,53 @@ EXAMPLES = """ # ], """ +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - "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'" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - "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'" +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + from ansible.module_utils.basic import AnsibleModule from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.ospf_interfaces.ospf_interfaces import ( @@ -899,8 +929,14 @@ def main(): """ module = AnsibleModule( argument_spec=Ospf_interfacesArgs.argument_spec, - mutually_exclusive=[], - required_if=[], + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], supports_check_mode=True, ) diff --git a/plugins/modules/vyos_ospfv2.py b/plugins/modules/vyos_ospfv2.py index 10e49740..a72b7fd2 100644 --- a/plugins/modules/vyos_ospfv2.py +++ b/plugins/modules/vyos_ospfv2.py @@ -31,16 +31,23 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_ospfv2 +version_added: '1.0.0' 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(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +- Tested against VyOS 1.3.8 +- This module works with connection C(ansible.netcommon.network_cli). + See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: - Rohit Thakur (@rohitthakur2590) options: @@ -358,7 +365,6 @@ options: - gathered - rendered default: merged - """ EXAMPLES = """ # Using merged @@ -378,54 +384,54 @@ EXAMPLES = """ 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 + 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 # # @@ -909,52 +915,51 @@ EXAMPLES = """ 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 + 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 - # # # ------------------------- @@ -1061,8 +1066,8 @@ EXAMPLES = """ # "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 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" @@ -1102,7 +1107,7 @@ EXAMPLES = """ # ], # "range": [ # { -# "address": "192.0.42.0/24", +# "address": "1.1.2.0/24", # "cost": 10 # } # ] @@ -1168,7 +1173,7 @@ EXAMPLES = """ # 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 area 4 range 1.1.2.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' @@ -1203,54 +1208,54 @@ EXAMPLES = """ 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 + 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 # # @@ -1260,7 +1265,6 @@ EXAMPLES = """ # # # "rendered": [ -# [ # "set protocols ospf mpls-te enable", # "set protocols ospf mpls-te router-address '192.0.11.11'", # "set protocols ospf redistribute bgp", @@ -1303,38 +1307,38 @@ EXAMPLES = """ # Using parsed # # -- name: Parse the commands for provided structured configuration +- name: Parse the commands for provided 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'" + 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 # # @@ -1755,7 +1759,6 @@ EXAMPLES = """ # After state # ------------ # vyos@192# run show configuration commands | grep ospf -# """ RETURN = """ before: @@ -1779,6 +1782,7 @@ commands: sample: - "set protocols ospf parameters router-id 192.0.1.1" - "set protocols ospf passive-interface 'eth1'" + """ @@ -1802,9 +1806,11 @@ def main(): ("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=Ospfv2Args.argument_spec, required_if=required_if, diff --git a/plugins/modules/vyos_ospfv3.py b/plugins/modules/vyos_ospfv3.py index 8dbaaeee..81b26327 100644 --- a/plugins/modules/vyos_ospfv3.py +++ b/plugins/modules/vyos_ospfv3.py @@ -31,18 +31,24 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} 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(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +version_added: '1.0.0' +short_description: OSPFv3 resource module +description: This resource module configures and manages attributes of OSPFv3 routes on VyOS network devices. author: - Rohit Thakur (@rohitthakur2590) +notes: +- Tested against VyOS 1.3.8 +- This module works with connection C(ansible.netcommon.network_cli). + See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). options: config: description: A provided OSPFv3 route configuration. @@ -91,7 +97,12 @@ options: route_type: description: Route type to redistribute. type: str - choices: [bgp, connected, kernel, ripng, static] + choices: + - bgp + - connected + - kernel + - ripng + - static route_map: description: Route map references. type: str @@ -116,7 +127,6 @@ options: - gathered - rendered default: merged - """ EXAMPLES = """ # Using merged @@ -135,18 +145,18 @@ EXAMPLES = """ parameters: router_id: 192.0.2.10 areas: - - area_id: '2' + - 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' + - area_id: 3 range: - address: '2001:db40::/32' state: merged - # # # ------------------------- @@ -242,18 +252,18 @@ EXAMPLES = """ parameters: router_id: 192.0.2.10 areas: - - area_id: '2' + - 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' + - area_id: 4 range: - address: '2001:db60::/32' state: replaced - # # # ------------------------- @@ -367,18 +377,18 @@ EXAMPLES = """ parameters: router_id: 192.0.2.10 areas: - - area_id: '2' + - 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' + - area_id: 3 range: - address: '2001:db40::/32' state: rendered - # # # ------------------------- @@ -404,17 +414,17 @@ EXAMPLES = """ # Using parsed # # -- name: Parse the commands to provide structured configuration. +- name: Parse the commands from the provided 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'" + 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 # # @@ -627,8 +637,9 @@ commands: returned: always type: list sample: - - "set protocols ospf parameters router-id 192.0.1.1" - - "set protocols ospfv3 area 2 range '2001:db10::/32'" + - "set protocols ospfv3 parameters router-id '192.0.2.10'" + - "set protocols ospfv3 redistribute 'bgp'" + """ @@ -652,9 +663,11 @@ def main(): ("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=Ospfv3Args.argument_spec, required_if=required_if, diff --git a/plugins/modules/vyos_prefix_lists.py b/plugins/modules/vyos_prefix_lists.py index c0d50d31..71d52b32 100644 --- a/plugins/modules/vyos_prefix_lists.py +++ b/plugins/modules/vyos_prefix_lists.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2021 Red Hat +# Copyright 2024 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -1244,24 +1244,23 @@ EXAMPLES = """ """ RETURN = """ - before: - description: The configuration prior to the module invocation. - returned: when state is I(merged), I(replaced), I(overridden) or I(deleted) - type: list + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict sample: > This output will always be in the same format as the module argspec. after: - description: The resulting configuration after the module invocation. + description: The resulting configuration after module execution. returned: when changed - type: list + type: dict sample: > This output will always be in the same format as the module argspec. commands: - description: The set of commands pushed to the remote device for the required configurations to take place. - returned: when state is I(merged), I(replaced), I(overridden) or I(deleted) + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: - set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible' @@ -1269,7 +1268,7 @@ commands: - set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks' rendered: description: The provided configuration in the task rendered in device-native format (offline). - returned: when state is I(rendered) + returned: when I(state) is C(rendered) type: list sample: - set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible' @@ -1277,22 +1276,20 @@ rendered: - set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks' gathered: description: Facts about the network resource gathered from the remote device as structured data. - returned: when state is I(gathered) + returned: when I(state) is C(gathered) type: list sample: > This output will always be in the same format as the module argspec. parsed: description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. - returned: when state is I(parsed) + returned: when I(state) is C(parsed) type: list sample: > This output will always be in the same format as the module argspec. - """ - from ansible.module_utils.basic import AnsibleModule from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.prefix_lists.prefix_lists import ( diff --git a/plugins/modules/vyos_route_maps.py b/plugins/modules/vyos_route_maps.py index bff6859d..67d327a6 100644 --- a/plugins/modules/vyos_route_maps.py +++ b/plugins/modules/vyos_route_maps.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2021 Red Hat +# Copyright 2024 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -15,13 +15,13 @@ __metaclass__ = type DOCUMENTATION = """ module: vyos_route_maps -version_added: 2.3.0 -short_description: Route Map Resource Module. +version_added: "1.0.0" +short_description: Route Map resource module description: - This module manages route map configurations on devices running VYOS. author: Ashwini Mhatre (@amhatre) notes: -- Tested against vyos 1.2. +- Tested against vyos 1.3.8 - This module works with connection C(network_cli). options: config: @@ -259,6 +259,7 @@ options: - parsed default: merged """ + EXAMPLES = """ # Using merged # Before state @@ -916,6 +917,53 @@ EXAMPLES = """ # ], """ +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - "set policy route-map test3 rule 1 set local-preference 6" + - "set policy route-map test3 rule 1 set metric 4" + - "set policy route-map test3 rule 1 set tag 4" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - "set policy route-map test3 rule 1 set local-preference 6" + - "set policy route-map test3 rule 1 set metric 4" + - "set policy route-map test3 rule 1 set tag 4" +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + from ansible.module_utils.basic import AnsibleModule from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.argspec.route_maps.route_maps import ( diff --git a/plugins/modules/vyos_snmp_server.py b/plugins/modules/vyos_snmp_server.py index 5eb69b88..87ddb794 100644 --- a/plugins/modules/vyos_snmp_server.py +++ b/plugins/modules/vyos_snmp_server.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2022 Red Hat +# Copyright 2024 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -15,12 +15,12 @@ __metaclass__ = type DOCUMENTATION = """ module: vyos_snmp_server -version_added: 2.7.0 +version_added: "1.0.0" short_description: Manages snmp_server resource module description: This module manages the snmp server attributes of Vyos network devices author: Gomathi Selvi Srinivasan (@GomathiselviS) notes: - - Tested against vyos 1.1.8 + - Tested against vyos 1.3.8 - This module works with connection C(network_cli). - The Configuration defaults of the Vyos network devices are supposed to hinder idempotent behavior of plays @@ -261,8 +261,8 @@ options: - The state the configuration should be left in type: str """ -EXAMPLES = """ +EXAMPLES = """ # Using merged # Before State: @@ -1058,19 +1058,17 @@ commands: returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: - set service snmp community routers authorization 'ro' - set service snmp community routers client '203.0.113.10' - set service snmp community routers client '203.0.113.20' - set service snmp community routers network '192.0.2.0/24' + - "set service snmp community routers authorization 'ro'" + - "set service snmp community routers client '203.0.113.10'" + - "set service snmp community routers network '192.0.2.0/24'" rendered: description: The provided configuration in the task rendered in device-native format (offline). returned: when I(state) is C(rendered) type: list sample: - set service snmp community routers authorization 'ro' - set service snmp community routers client '203.0.113.10' - set service snmp community routers client '203.0.113.20' - set service snmp community routers network '192.0.2.0/24' + - "set service snmp community routers authorization 'ro'" + - "set service snmp community routers client '203.0.113.10'" + - "set service snmp community routers network '192.0.2.0/24'" gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) diff --git a/plugins/modules/vyos_static_routes.py b/plugins/modules/vyos_static_routes.py index df9c501e..76fccaf9 100644 --- a/plugins/modules/vyos_static_routes.py +++ b/plugins/modules/vyos_static_routes.py @@ -31,15 +31,22 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type +ANSIBLE_METADATA = { + "metadata_version": "1.1", + "status": ["preview"], + "supported_by": "network", +} DOCUMENTATION = """ +--- module: vyos_static_routes +version_added: '1.0.0' 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(ansible.netcommon.network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +- Tested against VyOS 1.3.8. +- This module works with connection C(ansible.netcommon.network_cli). + See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). author: - Rohit Thakur (@rohitthakur2590) options: @@ -163,7 +170,6 @@ EXAMPLES = """ - forward_router_address: '2001:db8:2000:2::1' - forward_router_address: '2001:db8:2000:2::2' state: merged - # # # ------------------------- @@ -708,12 +714,12 @@ EXAMPLES = """ - address_families: - afi: ipv6 routes: - - dest: 2001:db8:1000::/36 + - 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 + - forward_router_address: '2001:db8:2000:2::1' + - forward_router_address: '2001:db8:2000:2::2' state: rendered # # @@ -739,13 +745,13 @@ EXAMPLES = """ # - 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'" + 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 # # @@ -878,14 +884,14 @@ RETURN = """ before: description: The configuration prior to the model invocation. returned: always - type: list + 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: list + type: dict sample: > The configuration returned will always be in the same format of the parameters above. @@ -896,6 +902,7 @@ commands: 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'" + """ @@ -930,6 +937,7 @@ def main(): supports_check_mode=True, mutually_exclusive=mutually_exclusive, ) + result = Static_routes(module).execute_module() module.exit_json(**result) |