summaryrefslogtreecommitdiff
path: root/plugins/modules
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/modules')
-rw-r--r--plugins/modules/vyos_banner.py1
-rw-r--r--plugins/modules/vyos_bgp_address_family.py279
-rw-r--r--plugins/modules/vyos_bgp_global.py289
-rw-r--r--plugins/modules/vyos_command.py21
-rw-r--r--plugins/modules/vyos_config.py20
-rw-r--r--plugins/modules/vyos_facts.py9
-rw-r--r--plugins/modules/vyos_firewall_global.py150
-rw-r--r--plugins/modules/vyos_firewall_interfaces.py161
-rw-r--r--plugins/modules/vyos_firewall_rules.py235
-rw-r--r--plugins/modules/vyos_hostname.py41
-rw-r--r--plugins/modules/vyos_interfaces.py111
-rw-r--r--plugins/modules/vyos_l3_interfaces.py90
-rw-r--r--plugins/modules/vyos_lag_interfaces.py89
-rw-r--r--plugins/modules/vyos_lldp_global.py15
-rw-r--r--plugins/modules/vyos_lldp_interfaces.py131
-rw-r--r--plugins/modules/vyos_logging.py59
-rw-r--r--plugins/modules/vyos_logging_global.py14
-rw-r--r--plugins/modules/vyos_ntp_global.py150
-rw-r--r--plugins/modules/vyos_ospf_interfaces.py182
-rw-r--r--plugins/modules/vyos_ospfv2.py197
-rw-r--r--plugins/modules/vyos_ospfv3.py72
-rw-r--r--plugins/modules/vyos_ping.py7
-rw-r--r--plugins/modules/vyos_prefix_lists.py2
-rw-r--r--plugins/modules/vyos_route_maps.py61
-rw-r--r--plugins/modules/vyos_snmp_server.py259
-rw-r--r--plugins/modules/vyos_static_routes.py114
-rw-r--r--plugins/modules/vyos_system.py5
-rw-r--r--plugins/modules/vyos_user.py8
-rw-r--r--plugins/modules/vyos_vlan.py18
29 files changed, 1409 insertions, 1381 deletions
diff --git a/plugins/modules/vyos_banner.py b/plugins/modules/vyos_banner.py
index 0ee10f5..6b1da84 100644
--- a/plugins/modules/vyos_banner.py
+++ b/plugins/modules/vyos_banner.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
# (c) 2017, Ansible by Red Hat, inc
diff --git a/plugins/modules/vyos_bgp_address_family.py b/plugins/modules/vyos_bgp_address_family.py
index ba56309..d6f8925 100644
--- a/plugins/modules/vyos_bgp_address_family.py
+++ b/plugins/modules/vyos_bgp_address_family.py
@@ -28,6 +28,7 @@ The module file for vyos_bgp_address_family
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -264,39 +265,39 @@ EXAMPLES = """
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
# vyos@vyos:~$
- - name: Merge provided configuration with device configuration
- vyos.vyos.vyos_bgp_address_family:
- config:
- as_number: "100"
- address_family:
- - afi: "ipv4"
- redistribute:
- - protocol: "static"
- metric: 50
- neighbors:
- - neighbor_address: "20.33.1.1/24"
- address_family:
- - afi: "ipv4"
- allowas_in: 4
- as_override: True
- attribute_unchanged:
- med: True
- - afi: "ipv6"
- default_originate: "map01"
- distribute_list:
- - action: "export"
- acl: 10
- - neighbor_address: "100.11.34.12"
- address_family:
- - afi: "ipv4"
- maximum_prefix: 45
- nexthop_self: True
- route_map:
- - action: "export"
- route_map: "map01"
- - action: "import"
- route_map: "map01"
- weight: 50
+- name: Merge provided configuration with device configuration
+ vyos.vyos.vyos_bgp_address_family:
+ config:
+ as_number: "100"
+ address_family:
+ - afi: "ipv4"
+ redistribute:
+ - protocol: "static"
+ metric: 50
+ neighbors:
+ - neighbor_address: "20.33.1.1/24"
+ address_family:
+ - afi: "ipv4"
+ allowas_in: 4
+ as_override: true
+ attribute_unchanged:
+ med: true
+ - afi: "ipv6"
+ default_originate: "map01"
+ distribute_list:
+ - action: "export"
+ acl: 10
+ - neighbor_address: "100.11.34.12"
+ address_family:
+ - afi: "ipv4"
+ maximum_prefix: 45
+ nexthop_self: true
+ route_map:
+ - action: "export"
+ route_map: "map01"
+ - action: "import"
+ route_map: "map01"
+ weight: 50
# After State:
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
@@ -410,33 +411,32 @@ EXAMPLES = """
# set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight '50'
# vyos@vyos:~$
- - name: Replace provided configuration with device configuration
- vyos.vyos.vyos_bgp_address_family:
- config:
- as_number: "100"
- neighbors:
- - neighbor_address: "100.11.34.12"
- address_family:
- - afi: "ipv4"
- allowas_in: 4
- as_override: True
- attribute_unchanged:
- med: True
- - afi: "ipv6"
- default_originate: "map01"
- distribute_list:
- - action: "export"
- acl: 10
- - neighbor_address: "20.33.1.1/24"
- address_family:
- - afi: "ipv6"
- maximum_prefix: 45
- nexthop_self: True
-
- state: replaced
+- name: Replace provided configuration with device configuration
+ vyos.vyos.vyos_bgp_address_family:
+ config:
+ as_number: "100"
+ neighbors:
+ - neighbor_address: "100.11.34.12"
+ address_family:
+ - afi: "ipv4"
+ allowas_in: 4
+ as_override: true
+ attribute_unchanged:
+ med: true
+ - afi: "ipv6"
+ default_originate: "map01"
+ distribute_list:
+ - action: "export"
+ acl: 10
+ - neighbor_address: "20.33.1.1/24"
+ address_family:
+ - afi: "ipv6"
+ maximum_prefix: 45
+ nexthop_self: true
+ state: replaced
# After State:
-
+#
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
# set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50'
# set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast
@@ -600,31 +600,31 @@ EXAMPLES = """
# set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list export '10'
# vyos@vyos:~$
- - name: Override
- vyos.vyos.vyos_bgp_address_family:
- config:
- as_number: "100"
- neighbors:
- - neighbor_address: "100.11.34.12"
- address_family:
- - afi: "ipv6"
- maximum_prefix: 45
- nexthop_self: True
- route_map:
- - action: "import"
- route_map: "map01"
- address_family:
- - afi: "ipv4"
- aggregate_address:
- - prefix: "60.9.2.0/24"
- summary_only: True
- - afi: "ipv6"
- redistribute:
- - protocol: "static"
- metric: 50
- state: overridden
+- name: Override
+ vyos.vyos.vyos_bgp_address_family:
+ config:
+ as_number: "100"
+ neighbors:
+ - neighbor_address: "100.11.34.12"
+ address_family:
+ - afi: "ipv6"
+ maximum_prefix: 45
+ nexthop_self: true
+ route_map:
+ - action: "import"
+ route_map: "map01"
+ address_family:
+ - afi: "ipv4"
+ aggregate_address:
+ - prefix: "60.9.2.0/24"
+ summary_only: true
+ - afi: "ipv6"
+ redistribute:
+ - protocol: "static"
+ metric: 50
+ state: overridden
-# Aft=validate-moduleser State
+# After State
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
# set protocols bgp 100 address-family ipv4-unicast aggregate-address 60.9.2.0/24 summary-only
@@ -799,18 +799,18 @@ EXAMPLES = """
# set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast route-map import 'map01'
# vyos@vyos:~$
- - name: Delete
- vyos.vyos.vyos_bgp_address_family:
- config:
- as_number: "100"
- neighbors:
- - neighbor_address: "20.33.1.1/24"
- address_family:
- - afi: "ipv6"
- - neighbor_address: "100.11.34.12"
- address_family:
- - afi: "ipv4"
- state: deleted
+- name: Delete
+ vyos.vyos.vyos_bgp_address_family:
+ config:
+ as_number: "100"
+ neighbors:
+ - neighbor_address: "20.33.1.1/24"
+ address_family:
+ - afi: "ipv6"
+ - neighbor_address: "100.11.34.12"
+ address_family:
+ - afi: "ipv4"
+ state: deleted
# After State:
@@ -961,12 +961,13 @@ EXAMPLES = """
# set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop
- - name: parse configs
- vyos.vyos.vyos_bgp_address_family:
- running_config: "{{ lookup('file', './parsed.cfg') }}"
- state: parsed
+- name: parse configs
+ vyos.vyos.vyos_bgp_address_family:
+ running_config: "{{ lookup('file', './parsed.cfg') }}"
+ state: parsed
-# Module Execution:
+# Module execution result:
+#
# "parsed": {
# "address_family": [
# {
@@ -1044,12 +1045,12 @@ EXAMPLES = """
# set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med
# set protocols bgp 100 neighbor 100.11.34.12
- - name: gather configs
- vyos.vyos.vyos_bgp_address_family:
- state: gathered
-
-# Module Execution:
+- name: gather configs
+ vyos.vyos.vyos_bgp_address_family:
+ state: gathered
+# Module execution result:
+#
# "gathered": {
# "address_family": [
# {
@@ -1108,40 +1109,40 @@ EXAMPLES = """
# Using rendered:
- - name: Render
- vyos.vyos.vyos_bgp_address_family:
- config:
- as_number: "100"
- address_family:
- - afi: "ipv4"
- redistribute:
- - protocol: "static"
- metric: 50
- neighbors:
- - neighbor_address: "20.33.1.1/24"
- address_family:
- - afi: "ipv4"
- allowas_in: 4
- as_override: True
- attribute_unchanged:
- med: True
- - afi: "ipv6"
- default_originate: "map01"
- distribute_list:
- - action: "export"
- acl: 10
- - neighbor_address: "100.11.34.12"
- address_family:
- - afi: "ipv4"
- maximum_prefix: 45
- nexthop_self: True
- route_map:
- - action: "export"
- route_map: "map01"
- - action: "import"
- route_map: "map01"
- weight: 50
- state: rendered
+- name: Render
+ vyos.vyos.vyos_bgp_address_family:
+ config:
+ as_number: "100"
+ address_family:
+ - afi: "ipv4"
+ redistribute:
+ - protocol: "static"
+ metric: 50
+ neighbors:
+ - neighbor_address: "20.33.1.1/24"
+ address_family:
+ - afi: "ipv4"
+ allowas_in: 4
+ as_override: true
+ attribute_unchanged:
+ med: true
+ - afi: "ipv6"
+ default_originate: "map01"
+ distribute_list:
+ - action: "export"
+ acl: 10
+ - neighbor_address: "100.11.34.12"
+ address_family:
+ - afi: "ipv4"
+ maximum_prefix: 45
+ nexthop_self: true
+ route_map:
+ - action: "export"
+ route_map: "map01"
+ - action: "import"
+ route_map: "map01"
+ weight: 50
+ state: rendered
# Module Execution:
@@ -1158,8 +1159,6 @@ EXAMPLES = """
# "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map import map01",
# "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight 50"
# ]
-
-
"""
from ansible.module_utils.basic import AnsibleModule
diff --git a/plugins/modules/vyos_bgp_global.py b/plugins/modules/vyos_bgp_global.py
index 1e3578d..f9c0eeb 100644
--- a/plugins/modules/vyos_bgp_global.py
+++ b/plugins/modules/vyos_bgp_global.py
@@ -28,6 +28,7 @@ The module file for vyos_bgp_global
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -432,63 +433,62 @@ EXAMPLES = """
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
# vyos@vyos:~$
- - name: Merge provided configuration with device configuration
- vyos.vyos.vyos_bgp_global:
- config:
- as_number: "65536"
- aggregate_address:
- - prefix: "203.0.113.0/24"
- as_set: true
- - prefix: "192.0.2.0/24"
- summary_only: true
- network:
- - address: "192.1.13.0/24"
- backdoor: true
- redistribute:
- - protocol: "kernel"
- metric: 45
- - protocol: "connected"
- route_map: "map01"
- maximum_paths:
- - path: "ebgp"
- count: 20
- - path: "ibgp"
- count: 55
- timers:
- keepalive: 35
- bgp_params:
- bestpath:
- as_path: "confed"
- compare_routerid: true
- default:
- no_ipv4_unicast: true
- router_id: "192.1.2.9"
- confederation:
- - peers: 20
- - peers: 55
- - identifier: 66
- neighbor:
- - address: "192.0.2.25"
- disable_connected_check: true
- timers:
- holdtime: 30
- keepalive: 10
- - address: "203.0.113.5"
- attribute_unchanged:
- as_path: true
- med: true
- ebgp_multihop: 2
- remote_as: 101
- update_source: "192.0.2.25"
- - address: "5001::64"
- maximum_prefix: 34
- distribute_list:
- - acl: 20
- action: "export"
- - acl: 40
- action: "import"
-
- state: merged
+- name: Merge provided configuration with device configuration
+ vyos.vyos.vyos_bgp_global:
+ config:
+ as_number: "65536"
+ aggregate_address:
+ - prefix: "203.0.113.0/24"
+ as_set: true
+ - prefix: "192.0.2.0/24"
+ summary_only: true
+ network:
+ - address: "192.1.13.0/24"
+ backdoor: true
+ redistribute:
+ - protocol: "kernel"
+ metric: 45
+ - protocol: "connected"
+ route_map: "map01"
+ maximum_paths:
+ - path: "ebgp"
+ count: 20
+ - path: "ibgp"
+ count: 55
+ timers:
+ keepalive: 35
+ bgp_params:
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ router_id: "192.1.2.9"
+ confederation:
+ - peers: 20
+ - peers: 55
+ - identifier: 66
+ neighbor:
+ - address: "192.0.2.25"
+ disable_connected_check: true
+ timers:
+ holdtime: 30
+ keepalive: 10
+ - address: "203.0.113.5"
+ attribute_unchanged:
+ as_path: true
+ med: true
+ ebgp_multihop: 2
+ remote_as: 101
+ update_source: "192.0.2.25"
+ - address: "5001::64"
+ maximum_prefix: 34
+ distribute_list:
+ - acl: 20
+ action: "export"
+ - acl: 40
+ action: "import"
+ state: merged
# After State
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
@@ -688,26 +688,25 @@ EXAMPLES = """
# set protocols bgp 65536 timers keepalive '35'
# vyos@vyos:~$
- - name: Replace
- vyos.vyos.vyos_bgp_global:
- config:
- as_number: "65536"
- network:
- - address: "203.0.113.0/24"
- route_map: map01
- redistribute:
- - protocol: "static"
- route_map: "map01"
- neighbor:
- - address: "192.0.2.40"
- advertisement_interval: 72
- capability:
- orf: "receive"
- bgp_params:
- bestpath:
- as_path: "confed"
-
- state: replaced
+- name: Replace
+ vyos.vyos.vyos_bgp_global:
+ config:
+ as_number: "65536"
+ network:
+ - address: "203.0.113.0/24"
+ route_map: map01
+ redistribute:
+ - protocol: "static"
+ route_map: "map01"
+ neighbor:
+ - address: "192.0.2.40"
+ advertisement_interval: 72
+ capability:
+ orf: "receive"
+ bgp_params:
+ bestpath:
+ as_path: "confed"
+ state: replaced
# After state:
# vyos@vyos:~$ show configuration commands | match "set protocols bgp"
@@ -885,11 +884,11 @@ EXAMPLES = """
# set protocols bgp 65536 redistribute static route-map 'map01'
# vyos@vyos:~$
- - name: Delete configuration
- vyos.vyos.vyos_bgp_global:
- config:
- as_number: "65536"
- state: deleted
+- name: Delete configuration
+ vyos.vyos.vyos_bgp_global:
+ config:
+ as_number: "65536"
+ state: deleted
# After state:
@@ -975,11 +974,11 @@ EXAMPLES = """
# vyos@vyos:~$
- - name: Purge configuration
- vyos.vyos.vyos_bgp_global:
- config:
- as_number: "65536"
- state: purged
+- name: Purge configuration
+ vyos.vyos.vyos_bgp_global:
+ config:
+ as_number: "65536"
+ state: purged
# After state:
@@ -1120,12 +1119,11 @@ EXAMPLES = """
# vyos@vyos:~$ ^C
# vyos@vyos:~$
-
- - name: Delete configuration
- vyos.vyos.vyos_bgp_global:
- config:
- as_number: "65536"
- state: deleted
+- name: Delete configuration
+ vyos.vyos.vyos_bgp_global:
+ config:
+ as_number: "65536"
+ state: deleted
# Module Execution:
#
@@ -1176,9 +1174,9 @@ EXAMPLES = """
# set protocols bgp 65536 redistribute static route-map 'map01'
# vyos@vyos:~$ ^C
- - name: gather configs
- vyos.vyos.vyos_bgp_global:
- state: gathered
+- name: gather configs
+ vyos.vyos.vyos_bgp_global:
+ state: gathered
# Module Execution:
# "gathered": {
@@ -1268,12 +1266,12 @@ EXAMPLES = """
# set protocols bgp 65536 parameters distance global local '10'
# set protocols bgp 65536 redistribute static route-map 'map01'
- - name: parse configs
- vyos.vyos.vyos_bgp_global:
- running_config: "{{ lookup('file', './parsed.cfg') }}"
- state: parsed
- tags:
- - parsed
+- name: parse configs
+ vyos.vyos.vyos_bgp_global:
+ running_config: "{{ lookup('file', './parsed.cfg') }}"
+ state: parsed
+ tags:
+ - parsed
# Module execution:
# "parsed": {
@@ -1340,49 +1338,48 @@ EXAMPLES = """
# Using rendered:
# --------------
- - name: Render
- vyos.vyos.vyos_bgp_global:
- config:
- as_number: "65536"
- network:
- - address: "203.0.113.0/24"
- route_map: map01
- redistribute:
- - protocol: "static"
- route_map: "map01"
- bgp_params:
- always_compare_med: true
- dampening:
- start_suppress_time: 5
- max_suppress_time: 20
- half_life: 33
- re_use: 60
- distance:
- - type: "internal"
- value: 20
- - type: "local"
- value: 10
- - type: "external"
- value: 66
- bestpath:
- as_path: "confed"
- compare_routerid: true
- default:
- no_ipv4_unicast: true
- neighbor:
- - address: "192.0.2.43"
- disable_connected_check: true
- advertisement_interval: 72
- capability:
- dynamic: true
- timers:
- holdtime: 30
- keepalive: 10
- - address: "203.0.113.0"
- capability:
- orf: "receive"
-
- state: rendered
+- name: Render
+ vyos.vyos.vyos_bgp_global:
+ config:
+ as_number: "65536"
+ network:
+ - address: "203.0.113.0/24"
+ route_map: map01
+ redistribute:
+ - protocol: "static"
+ route_map: "map01"
+ bgp_params:
+ always_compare_med: true
+ dampening:
+ start_suppress_time: 5
+ max_suppress_time: 20
+ half_life: 33
+ re_use: 60
+ distance:
+ - type: "internal"
+ value: 20
+ - type: "local"
+ value: 10
+ - type: "external"
+ value: 66
+ bestpath:
+ as_path: "confed"
+ compare_routerid: true
+ default:
+ no_ipv4_unicast: true
+ neighbor:
+ - address: "192.0.2.43"
+ disable_connected_check: true
+ advertisement_interval: 72
+ capability:
+ dynamic: true
+ timers:
+ holdtime: 30
+ keepalive: 10
+ - address: "203.0.113.0"
+ capability:
+ orf: "receive"
+ state: rendered
# Module Execution:
# "rendered": [
@@ -1406,8 +1403,6 @@ EXAMPLES = """
# "set protocols bgp 65536 parameters bestpath compare-routerid",
# "set protocols bgp 65536 parameters default no-ipv4-unicast"
# ]
-
-
"""
from ansible.module_utils.basic import AnsibleModule
diff --git a/plugins/modules/vyos_command.py b/plugins/modules/vyos_command.py
index 2ed920c..bacbe26 100644
--- a/plugins/modules/vyos_command.py
+++ b/plugins/modules/vyos_command.py
@@ -17,6 +17,7 @@
#
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -97,26 +98,26 @@ EXAMPLES = """
- name: show configuration on ethernet devices eth0 and eth1
vyos.vyos.vyos_command:
commands:
- - show interfaces ethernet {{ item }}
+ - show interfaces ethernet {{ item }}
with_items:
- - eth0
- - eth1
+ - eth0
+ - eth1
- name: run multiple commands and check if version output contains specific version
string
vyos.vyos.vyos_command:
commands:
- - show version
- - show hardware cpu
+ - show version
+ - show hardware cpu
wait_for:
- - result[0] contains 'VyOS 1.1.7'
+ - result[0] contains 'VyOS 1.1.7'
- name: run command that requires answering a prompt
vyos.vyos.vyos_command:
commands:
- - command: rollback 1
- prompt: Proceed with reboot? [confirm][y]
- answer: y
+ - command: rollback 1
+ prompt: Proceed with reboot? [confirm][y]
+ answer: y
"""
RETURN = """
@@ -164,7 +165,7 @@ def parse_commands(module, warnings):
if not item["command"].startswith("show"):
warnings.append(
"Only show commands are supported when using check mode, not "
- "executing %s" % item["command"]
+ "executing %s" % item["command"],
)
commands.remove(item)
diff --git a/plugins/modules/vyos_config.py b/plugins/modules/vyos_config.py
index 2a03d0c..bf5d421 100644
--- a/plugins/modules/vyos_config.py
+++ b/plugins/modules/vyos_config.py
@@ -17,6 +17,7 @@
#
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -128,14 +129,14 @@ EXAMPLES = """
- name: configure the remote device
vyos.vyos.vyos_config:
lines:
- - set system host-name {{ inventory_hostname }}
- - set service lldp
- - delete service dhcp-server
+ - set system host-name {{ inventory_hostname }}
+ - set service lldp
+ - delete service dhcp-server
- name: backup and load from file
vyos.vyos.vyos_config:
src: vyos.cfg
- backup: yes
+ backup: true
- name: render a Jinja2 template onto the VyOS router
vyos.vyos.vyos_config:
@@ -145,11 +146,11 @@ EXAMPLES = """
vyos.vyos.vyos_config:
lines:
# - set int eth eth2 description 'OUTSIDE'
- - set interface ethernet eth2 description 'OUTSIDE'
+ - set interface ethernet eth2 description 'OUTSIDE'
- name: configurable backup path
vyos.vyos.vyos_config:
- backup: yes
+ backup: true
backup_options:
filename: backup.cfg
dir_path: /home/user
@@ -205,9 +206,12 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import
run_commands,
)
+
DEFAULT_COMMENT = "configured by vyos_config"
-CONFIG_FILTERS = [re.compile(r"set system login user \S+ authentication encrypted-password")]
+CONFIG_FILTERS = [
+ re.compile(r"set system login user \S+ authentication encrypted-password"),
+]
def get_candidate(module):
@@ -312,7 +316,7 @@ def run(module, result):
if result.get("filtered"):
result["warnings"].append(
- "Some configuration commands were removed, please see the filtered key"
+ "Some configuration commands were removed, please see the filtered key",
)
result["changed"] = True
diff --git a/plugins/modules/vyos_facts.py b/plugins/modules/vyos_facts.py
index ae7543c..a999bd3 100644
--- a/plugins/modules/vyos_facts.py
+++ b/plugins/modules/vyos_facts.py
@@ -5,6 +5,7 @@
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
"""
The module file for vyos_facts
@@ -75,15 +76,15 @@ EXAMPLES = """
# Collect only the interfaces facts
- vyos.vyos.vyos_facts:
gather_subset:
- - '!all'
- - '!min'
+ - '!all'
+ - '!min'
gather_network_resources:
- - interfaces
+ - interfaces
# Do not collect interfaces facts
- vyos.vyos.vyos_facts:
gather_network_resources:
- - '!interfaces'
+ - '!interfaces'
# Collect interfaces and minimal default facts
- vyos.vyos.vyos_facts:
diff --git a/plugins/modules/vyos_firewall_global.py b/plugins/modules/vyos_firewall_global.py
index 78db9f3..205ef13 100644
--- a/plugins/modules/vyos_firewall_global.py
+++ b/plugins/modules/vyos_firewall_global.py
@@ -28,6 +28,7 @@ The module file for vyos_firewall_global
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -297,30 +298,30 @@ EXAMPLES = """
all: true
broadcast: true
state_policy:
- - connection_type: established
- action: accept
- log: true
- - connection_type: invalid
- action: reject
+ - connection_type: established
+ action: accept
+ log: true
+ - connection_type: invalid
+ action: reject
route_redirects:
- - afi: ipv4
- ip_src_route: true
- icmp_redirects:
- send: true
- receive: false
+ - afi: ipv4
+ ip_src_route: true
+ icmp_redirects:
+ send: true
+ receive: false
group:
address_group:
- - name: MGMT-HOSTS
- description: This group has the Management hosts address list
- members:
- - address: 192.0.1.1
- - address: 192.0.1.3
- - address: 192.0.1.5
+ - name: MGMT-HOSTS
+ description: This group has the Management hosts address list
+ members:
+ - address: 192.0.1.1
+ - address: 192.0.1.3
+ - address: 192.0.1.5
network_group:
- - name: MGMT
- description: This group has the Management network addresses
- members:
- - address: 192.0.1.0/24
+ - name: MGMT
+ description: This group has the Management network addresses
+ members:
+ - address: 192.0.1.0/24
state: merged
#
#
@@ -676,6 +677,7 @@ EXAMPLES = """
# ]
#
# "after": []
+#
# After state
# ------------
# vyos@192# run show configuration commands | grep firewall
@@ -707,7 +709,7 @@ EXAMPLES = """
# set firewall state-policy invalid action 'reject'
# set firewall syn-cookies 'enable'
# set firewall twa-hazards-protection 'enable'
-#
+
- name: Replace firewall global attributes configuration.
vyos.vyos.vyos_firewall_global:
config:
@@ -716,39 +718,39 @@ EXAMPLES = """
log_martians: true
syn_cookies: true
twa_hazards_protection: true
- ping:
+ ping: null
all: true
broadcast: true
state_policy:
- - connection_type: established
- action: accept
- log: true
- - connection_type: invalid
- action: reject
+ - connection_type: established
+ action: accept
+ log: true
+ - connection_type: invalid
+ action: reject
route_redirects:
- - afi: ipv4
- ip_src_route: true
- icmp_redirects:
- send: true
- receive: false
+ - afi: ipv4
+ ip_src_route: true
+ icmp_redirects:
+ send: true
+ receive: false
group:
address_group:
- - name: SALES-HOSTS
- description: Sales office hosts address list
- members:
- - address: 192.0.2.1
- - address: 192.0.2.2
- - address: 192.0.2.3
- - name: ENG-HOSTS
- description: Sales office hosts address list
- members:
- - address: 192.0.3.1
- - address: 192.0.3.2
+ - name: SALES-HOSTS
+ description: Sales office hosts address list
+ members:
+ - address: 192.0.2.1
+ - address: 192.0.2.2
+ - address: 192.0.2.3
+ - name: ENG-HOSTS
+ description: Sales office hosts address list
+ members:
+ - address: 192.0.3.1
+ - address: 192.0.3.2
network_group:
- - name: MGMT
- description: This group has the Management network addresses
- members:
- - address: 192.0.1.0/24
+ - name: MGMT
+ description: This group has the Management network addresses
+ members:
+ - address: 192.0.1.0/24
state: replaced
#
#
@@ -966,7 +968,6 @@ EXAMPLES = """
#
- name: Gather firewall global config with provided configurations
vyos.vyos.vyos_firewall_global:
- config:
state: gathered
#
#
@@ -1089,40 +1090,41 @@ EXAMPLES = """
log_martians: true
syn_cookies: true
twa_hazards_protection: true
- ping:
+ ping: null
all: true
broadcast: true
state_policy:
- - connection_type: established
- action: accept
- log: true
- - connection_type: invalid
- action: reject
+ - connection_type: established
+ action: accept
+ log: true
+ - connection_type: invalid
+ action: reject
route_redirects:
- - afi: ipv4
- ip_src_route: true
- icmp_redirects:
- send: true
- receive: false
+ - afi: ipv4
+ ip_src_route: true
+ icmp_redirects: null
+ send: true
+ receive: false
group:
address_group:
- - name: SALES-HOSTS
- description: Sales office hosts address list
- members:
- - address: 192.0.2.1
- - address: 192.0.2.2
- - address: 192.0.2.3
- - name: ENG-HOSTS
- description: Sales office hosts address list
- members:
- - address: 192.0.3.1
- - address: 192.0.3.2
+ - name: SALES-HOSTS
+ description: Sales office hosts address list
+ members:
+ - address: 192.0.2.1
+ - address: 192.0.2.2
+ - address: 192.0.2.3
+ - name: ENG-HOSTS
+ description: Sales office hosts address list
+ members:
+ - address: 192.0.3.1
+ - address: 192.0.3.2
network_group:
- - name: MGMT
- description: This group has the Management network addresses
- members:
- - address: 192.0.1.0/24
+ - name: MGMT
+ description: This group has the Management network addresses
+ members:
+ - address: 192.0.1.0/24
state: rendered
+
#
#
# -------------------------
diff --git a/plugins/modules/vyos_firewall_interfaces.py b/plugins/modules/vyos_firewall_interfaces.py
index f651263..11f3e52 100644
--- a/plugins/modules/vyos_firewall_interfaces.py
+++ b/plugins/modules/vyos_firewall_interfaces.py
@@ -28,6 +28,7 @@ The module file for vyos_firewall_interfaces
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -123,34 +124,34 @@ EXAMPLES = """
- name: Merge the provided configuration with the existing running configuration
vyos.vyos.vyos_firewall_interfaces:
config:
- - access_rules:
- - afi: ipv4
- rules:
- - name: INBOUND
- direction: in
- - name: OUTBOUND
- direction: out
- - name: LOCAL
- direction: local
- - afi: ipv6
- rules:
- - name: V6-LOCAL
- direction: local
- name: eth1
- - access_rules:
- - afi: ipv4
- rules:
- - name: INBOUND
- direction: in
- - name: OUTBOUND
- direction: out
- - name: LOCAL
- direction: local
- - afi: ipv6
- rules:
- - name: V6-LOCAL
- direction: local
- name: eth3
+ - access_rules:
+ - afi: ipv4
+ rules:
+ - name: INBOUND
+ direction: in
+ - name: OUTBOUND
+ direction: out
+ - name: LOCAL
+ direction: local
+ - afi: ipv6
+ rules:
+ - name: V6-LOCAL
+ direction: local
+ name: eth1
+ - access_rules:
+ - afi: ipv4
+ rules:
+ - name: INBOUND
+ direction: in
+ - name: OUTBOUND
+ direction: out
+ - name: LOCAL
+ direction: local
+ - afi: ipv6
+ rules:
+ - name: V6-LOCAL
+ direction: local
+ name: eth3
state: merged
#
#
@@ -295,15 +296,16 @@ EXAMPLES = """
- name: Merge the provided configuration with the existing running configuration
vyos.vyos.vyos_firewall_interfaces:
config:
- - access_rules:
- - afi: ipv4
- rules:
- - name: OUTBOUND
- direction: in
- - name: INBOUND
- direction: out
- name: eth1
+ - access_rules:
+ - afi: ipv4
+ rules:
+ - name: OUTBOUND
+ direction: in
+ - name: INBOUND
+ direction: out
+ name: eth1
state: merged
+
#
#
# -------------------------
@@ -494,27 +496,29 @@ EXAMPLES = """
# set interfaces ethernet eth3 firewall local name 'LOCAL'
# set interfaces ethernet eth3 firewall out name 'OUTBOUND'
#
-- name: Replace device configurations of listed firewall interfaces with provided
+- name: >-
+ Replace device configurations of listed firewall interfaces with provided
configurations
vyos.vyos.vyos_firewall_interfaces:
config:
- - name: eth1
- access_rules:
- - afi: ipv4
- rules:
- - name: OUTBOUND
- direction: out
- - afi: ipv6
- rules:
- - name: V6-LOCAL
- direction: local
- - name: eth3
- access_rules:
- - afi: ipv4
- rules:
- - name: INBOUND
- direction: in
+ - name: eth1
+ access_rules:
+ - afi: ipv4
+ rules:
+ - name: OUTBOUND
+ direction: out
+ - afi: ipv6
+ rules:
+ - name: V6-LOCAL
+ direction: local
+ - name: eth3
+ access_rules:
+ - afi: ipv4
+ rules:
+ - name: INBOUND
+ direction: in
state: replaced
+
#
#
# -------------------------
@@ -682,12 +686,12 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_firewall_interfaces:
config:
- - name: eth3
- access_rules:
- - afi: ipv4
- rules:
- - name: INBOUND
- direction: out
+ - name: eth3
+ access_rules:
+ - afi: ipv4
+ rules:
+ - name: INBOUND
+ direction: out
state: overridden
#
#
@@ -809,8 +813,8 @@ EXAMPLES = """
- name: Delete firewall interfaces based on interface name.
vyos.vyos.vyos_firewall_interfaces:
config:
- - name: eth1
- - name: eth3
+ - name: eth1
+ - name: eth3
state: deleted
#
#
@@ -938,10 +942,10 @@ EXAMPLES = """
- name: Delete firewall interfaces config per afi.
vyos.vyos.vyos_firewall_interfaces:
config:
- - name: eth1
- access_rules:
- - afi: ipv4
- - afi: ipv6
+ - name: eth1
+ access_rules:
+ - afi: ipv4
+ - afi: ipv6
state: deleted
#
#
@@ -964,7 +968,6 @@ EXAMPLES = """
# set firewall name 'LOCAL'
# set firewall name 'OUTBOUND'
-
# Using deleted without config
#
# Before state
@@ -986,7 +989,6 @@ EXAMPLES = """
#
- name: Delete firewall interfaces config when empty config provided.
vyos.vyos.vyos_firewall_interfaces:
- config:
state: deleted
#
#
@@ -1010,7 +1012,6 @@ EXAMPLES = """
# Using parsed
#
-#
- name: Parse the provided configuration
vyos.vyos.vyos_firewall_interfaces:
running_config:
@@ -1121,7 +1122,6 @@ EXAMPLES = """
#
- name: Gather listed firewall interfaces.
vyos.vyos.vyos_firewall_interfaces:
- config:
state: gathered
#
#
@@ -1198,17 +1198,18 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_firewall_interfaces:
config:
- - name: eth2
- access_rules:
- - afi: ipv4
- rules:
- - direction: in
- name: INGRESS
- - direction: out
- name: OUTGRESS
- - direction: local
- name: DROP
+ - name: eth2
+ access_rules:
+ - afi: ipv4
+ rules:
+ - direction: in
+ name: INGRESS
+ - direction: out
+ name: OUTGRESS
+ - direction: local
+ name: DROP
state: rendered
+
#
#
# -------------------------
@@ -1222,8 +1223,6 @@ EXAMPLES = """
# "set interfaces ethernet eth2 firewall local name 'DROP'",
# "set interfaces ethernet eth2 firewall local ipv6-name 'LOCAL'"
# ]
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_firewall_rules.py b/plugins/modules/vyos_firewall_rules.py
index c219f54..06a300f 100644
--- a/plugins/modules/vyos_firewall_rules.py
+++ b/plugins/modules/vyos_firewall_rules.py
@@ -28,6 +28,7 @@ The module file for vyos_firewall_rules
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -440,13 +441,13 @@ EXAMPLES = """
# set firewall name Downlink rule 502 action 'reject'
# set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'
# set firewall name Downlink rule 502 ipsec 'match-ipsec'
-#
+
- name: Delete attributes of given firewall rules.
vyos.vyos.vyos_firewall_rules:
config:
- - afi: ipv4
- rule_sets:
- - name: Downlink
+ - afi: ipv4
+ rule_sets:
+ - name: Downlink
state: deleted
#
#
@@ -517,11 +518,10 @@ EXAMPLES = """
# set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible'
# set firewall name Downlink rule 502 ipsec 'match-ipsec'
-#
- name: Delete attributes of given firewall rules.
vyos.vyos.vyos_firewall_rules:
config:
- - afi: ipv4
+ - afi: ipv4
state: deleted
#
#
@@ -617,7 +617,6 @@ EXAMPLES = """
#
- name: Delete attributes of given firewall rules.
vyos.vyos.vyos_firewall_rules:
- config:
state: deleted
#
#
@@ -673,48 +672,47 @@ EXAMPLES = """
- name: Merge the provided configuration with the existing running configuration
vyos.vyos.vyos_firewall_rules:
config:
- - afi: ipv6
- rule_sets:
- - name: UPLINK
- description: This is ipv6 specific rule-set
- default_action: accept
- rules:
- - number: 1
- action: accept
- description: Fwipv6-Rule 1 is configured by Ansible
- ipsec: match-ipsec
- - number: 2
- action: accept
- description: Fwipv6-Rule 2 is configured by Ansible
- ipsec: match-ipsec
-
- - afi: ipv4
- rule_sets:
- - name: INBOUND
- description: IPv4 INBOUND rule set
- default_action: accept
- rules:
- - number: 101
- action: accept
- description: Rule 101 is configured by Ansible
- ipsec: match-ipsec
- - number: 102
- action: reject
- description: Rule 102 is configured by Ansible
- ipsec: match-ipsec
- - number: 103
- action: accept
- description: Rule 103 is configured by Ansible
- destination:
- group:
- address_group: inbound
- source:
- address: 192.0.2.0
- state:
- established: true
- new: false
- invalid: false
- related: true
+ - afi: ipv6
+ rule_sets:
+ - name: UPLINK
+ description: This is ipv6 specific rule-set
+ default_action: accept
+ rules:
+ - number: 1
+ action: accept
+ description: Fwipv6-Rule 1 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 2
+ action: accept
+ description: Fwipv6-Rule 2 is configured by Ansible
+ ipsec: match-ipsec
+ - afi: ipv4
+ rule_sets:
+ - name: INBOUND
+ description: IPv4 INBOUND rule set
+ default_action: accept
+ rules:
+ - number: 101
+ action: accept
+ description: Rule 101 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 102
+ action: reject
+ description: Rule 102 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 103
+ action: accept
+ description: Rule 103 is configured by Ansible
+ destination:
+ group:
+ address_group: inbound
+ source:
+ address: 192.0.2.0
+ state:
+ established: true
+ new: false
+ invalid: false
+ related: true
state: merged
#
#
@@ -889,28 +887,30 @@ EXAMPLES = """
# set firewall name INBOUND rule 103 state new 'disable'
# set firewall name INBOUND rule 103 state related 'enable'
#
-- name: Replace device configurations of listed firewall rules with provided configurations
+- name: >-
+ Replace device configurations of listed firewall rules with provided
+ configurations
vyos.vyos.vyos_firewall_rules:
config:
- - afi: ipv6
- rule_sets:
- - name: UPLINK
- description: This is ipv6 specific rule-set
- default_action: accept
- - afi: ipv4
- rule_sets:
- - name: INBOUND
- description: IPv4 INBOUND rule set
- default_action: accept
- rules:
- - number: 101
- action: accept
- description: Rule 101 is configured by Ansible
- ipsec: match-ipsec
- - number: 104
- action: reject
- description: Rule 104 is configured by Ansible
- ipsec: match-none
+ - afi: ipv6
+ rule_sets:
+ - name: UPLINK
+ description: This is ipv6 specific rule-set
+ default_action: accept
+ - afi: ipv4
+ rule_sets:
+ - name: INBOUND
+ description: IPv4 INBOUND rule set
+ default_action: accept
+ rules:
+ - number: 101
+ action: accept
+ description: Rule 101 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 104
+ action: reject
+ description: Rule 104 is configured by Ansible
+ ipsec: match-none
state: replaced
#
#
@@ -1074,21 +1074,22 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_firewall_rules:
config:
- - afi: ipv4
- rule_sets:
- - name: Downlink
- description: IPv4 INBOUND rule set
- default_action: accept
- rules:
- - number: 501
- action: accept
- description: Rule 501 is configured by Ansible
- ipsec: match-ipsec
- - number: 502
- action: reject
- description: Rule 502 is configured by Ansible
- ipsec: match-ipsec
+ - afi: ipv4
+ rule_sets:
+ - name: Downlink
+ description: IPv4 INBOUND rule set
+ default_action: accept
+ rules:
+ - number: 501
+ action: accept
+ description: Rule 501 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 502
+ action: reject
+ description: Rule 502 is configured by Ansible
+ ipsec: match-ipsec
state: overridden
+
#
#
# -------------------------
@@ -1224,7 +1225,6 @@ EXAMPLES = """
#
- name: Gather listed firewall rules with provided configurations
vyos.vyos.vyos_firewall_rules:
- config:
state: gathered
#
#
@@ -1340,39 +1340,40 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_firewall_rules:
config:
- - afi: ipv6
- rule_sets:
- - name: UPLINK
- description: This is ipv6 specific rule-set
- default_action: accept
- - afi: ipv4
- rule_sets:
- - name: INBOUND
- description: IPv4 INBOUND rule set
- default_action: accept
- rules:
- - number: 101
- action: accept
- description: Rule 101 is configured by Ansible
- ipsec: match-ipsec
- - number: 102
- action: reject
- description: Rule 102 is configured by Ansible
- ipsec: match-ipsec
- - number: 103
- action: accept
- description: Rule 103 is configured by Ansible
- destination:
- group:
- address_group: inbound
- source:
- address: 192.0.2.0
- state:
- established: true
- new: false
- invalid: false
- related: true
+ - afi: ipv6
+ rule_sets:
+ - name: UPLINK
+ description: This is ipv6 specific rule-set
+ default_action: accept
+ - afi: ipv4
+ rule_sets:
+ - name: INBOUND
+ description: IPv4 INBOUND rule set
+ default_action: accept
+ rules:
+ - number: 101
+ action: accept
+ description: Rule 101 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 102
+ action: reject
+ description: Rule 102 is configured by Ansible
+ ipsec: match-ipsec
+ - number: 103
+ action: accept
+ description: Rule 103 is configured by Ansible
+ destination:
+ group:
+ address_group: inbound
+ source:
+ address: 192.0.2.0
+ state:
+ established: true
+ new: false
+ invalid: false
+ related: true
state: rendered
+
#
#
# -------------------------
@@ -1454,8 +1455,6 @@ EXAMPLES = """
# ]
# }
# ]
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_hostname.py b/plugins/modules/vyos_hostname.py
index 46b692a..bc039b5 100644
--- a/plugins/modules/vyos_hostname.py
+++ b/plugins/modules/vyos_hostname.py
@@ -10,6 +10,7 @@ The module file for vyos_hostname
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -73,96 +74,104 @@ options:
"""
EXAMPLES = """
-# Using state: merged
+# Using merged
+#
# Before state:
# -------------
# test#show configuration commands | grep host-name
# set system host-name 'vyostest'
-# Merged play:
-# ------------
+
- name: Apply the provided configuration
vyos.vyos.vyos_hostname:
config:
hostname: vyos
state: merged
+
# Commands Fired:
# ---------------
# "commands": [
# "hostname vyos",
# ],
+#
# After state:
# ------------
# test#show configuration commands | grep host-name
# set system host-name 'vyos'
-# Using state: deleted
+# Using deleted
+#
# Before state:
# -------------
# test#show configuration commands | grep host-name
# set system host-name 'vyos'
-# Deleted play:
-# -------------
+#
- name: Remove all existing configuration
vyos.vyos.vyos_hostname:
state: deleted
+
# Commands Fired:
# ---------------
# "commands": [
# "no hostname vyosTest",
# ],
+#
# After state:
# ------------
# test#show configuration commands | grep host-name
-# Using state: overridden
+# Using overridden
+#
# Before state:
# -------------
# test#show configuration commands | grep host-name
# set system host-name 'vyos'
-# Overridden play:
-# ----------------
+
- name: Override commands with provided configuration
vyos.vyos.vyos_hostname:
config:
hostname: vyosTest
state: overridden
+
# Commands Fired:
# ---------------
# "commands": [
# "hostname vyosTest",
# ],
+#
# After state:
# ------------
# test#show configuration commands | grep host-name
# set system host-name 'vyosTest'
-# Using state: replaced
+# Using replaced
+#
# Before state:
# -------------
# test#show configuration commands | grep host-name
# set system host-name 'vyosTest'
-# Replaced play:
-# --------------
+
- name: Replace commands with provided configuration
vyos.vyos.vyos_hostname:
config:
hostname: vyos
state: replaced
+
# After state:
# ------------
# test#show configuration commands | grep host-name
# set system host-name 'vyos'
-# Using state: gathered
+# Using gathered
+#
# Before state:
# -------------
-#test#show configuration commands | grep host-name
+# test#show configuration commands | grep host-name
# set system host-name 'vyos'
-# Gathered play:
-# --------------
+
- name: Gather listed hostname config
vyos.vyos.vyos_hostname:
state: gathered
+
# Module Execution Result:
# ------------------------
# "gathered": {
diff --git a/plugins/modules/vyos_interfaces.py b/plugins/modules/vyos_interfaces.py
index f0772ab..c7a2168 100644
--- a/plugins/modules/vyos_interfaces.py
+++ b/plugins/modules/vyos_interfaces.py
@@ -28,6 +28,7 @@ The module file for vyos_interfaces
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -167,21 +168,21 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
vyos.vyos.vyos_interfaces:
config:
- - name: eth2
- description: Configured by Ansible
- enabled: true
- vifs:
- - vlan_id: 200
- description: VIF 200 - ETH2
- - name: eth3
- description: Configured by Ansible
- mtu: 1500
- - name: bond1
- description: Bond - 1
- mtu: 1200
- - name: vti2
- description: VTI - 2
- enabled: false
+ - name: eth2
+ description: Configured by Ansible
+ enabled: true
+ vifs:
+ - vlan_id: 200
+ description: VIF 200 - ETH2
+ - name: eth3
+ description: Configured by Ansible
+ mtu: 1500
+ - name: bond1
+ description: Bond - 1
+ mtu: 1200
+ - name: vti2
+ description: VTI - 2
+ enabled: false
state: merged
# Task Output
@@ -299,12 +300,12 @@ EXAMPLES = """
- name: Replace device configurations of listed interfaces with provided configurations
vyos.vyos.vyos_interfaces:
config:
- - name: eth2
- description: Replaced by Ansible
- - name: eth3
- description: Replaced by Ansible
- - name: eth1
- description: Replaced by Ansible
+ - name: eth2
+ description: Replaced by Ansible
+ - name: eth3
+ description: Replaced by Ansible
+ - name: eth1
+ description: Replaced by Ansible
state: replaced
# Task Output
@@ -437,15 +438,15 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_interfaces:
config:
- - name: eth0
- description: Outbound Interface For The Appliance
- speed: auto
- duplex: auto
- - name: eth2
- speed: auto
- duplex: auto
- - name: eth3
- mtu: 1200
+ - name: eth0
+ description: Outbound Interface For The Appliance
+ speed: auto
+ duplex: auto
+ - name: eth2
+ speed: auto
+ duplex: auto
+ - name: eth3
+ mtu: 1200
state: overridden
# Task Output
@@ -576,10 +577,10 @@ EXAMPLES = """
themselves)
vyos.vyos.vyos_interfaces:
config:
- - name: bond1
- - name: eth1
- - name: eth2
- - name: eth3
+ - name: bond1
+ - name: eth1
+ - name: eth2
+ - name: eth3
state: deleted
# Task Output
@@ -693,7 +694,6 @@ EXAMPLES = """
#
- name: Gather listed interfaces with provided configurations
vyos.vyos.vyos_interfaces:
- config:
state: gathered
# Task output
@@ -730,30 +730,31 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_interfaces:
config:
- - name: eth0
- enabled: true
- duplex: auto
- speed: auto
- - name: eth1
- description: Configured by Ansible - Interface 1
- mtu: 1500
- speed: auto
- duplex: auto
- enabled: true
- vifs:
- - vlan_id: 100
- description: Eth1 - VIF 100
- mtu: 400
+ - name: eth0
enabled: true
- - vlan_id: 101
- description: Eth1 - VIF 101
+ duplex: auto
+ speed: auto
+ - name: eth1
+ description: Configured by Ansible - Interface 1
+ mtu: 1500
+ speed: auto
+ duplex: auto
enabled: true
- - name: eth2
- description: Configured by Ansible - Interface 2 (ADMIN DOWN)
- mtu: 600
- enabled: false
+ vifs:
+ - vlan_id: 100
+ description: Eth1 - VIF 100
+ mtu: 400
+ enabled: true
+ - vlan_id: 101
+ description: Eth1 - VIF 101
+ enabled: true
+ - name: eth2
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
+ mtu: 600
+ enabled: false
state: rendered
+
# Task Output
# -----------
# rendered:
diff --git a/plugins/modules/vyos_l3_interfaces.py b/plugins/modules/vyos_l3_interfaces.py
index cdf5842..0849c29 100644
--- a/plugins/modules/vyos_l3_interfaces.py
+++ b/plugins/modules/vyos_l3_interfaces.py
@@ -28,6 +28,7 @@ The module file for vyos_l3_interfaces
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -141,28 +142,28 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
vyos.vyos.vyos_l3_interfaces:
config:
- - name: eth2
- ipv4:
- - address: 192.0.2.10/28
- - address: 198.51.100.40/27
- ipv6:
- - address: 2001:db8:100::2/32
- - address: 2001:db8:400::10/32
-
- - name: eth3
- ipv4:
- - address: 203.0.113.65/26
- vifs:
- - vlan_id: 101
+ - name: eth2
ipv4:
- - address: 192.0.2.71/28
- - address: 198.51.100.131/25
- - vlan_id: 102
+ - address: 192.0.2.10/28
+ - address: 198.51.100.40/27
ipv6:
- - address: 2001:db8:1000::5/38
- - address: 2001:db8:1400::3/38
+ - address: '2001:db8:100::2/32'
+ - address: '2001:db8:400::10/32'
+ - name: eth3
+ ipv4:
+ - address: 203.0.113.65/26
+ vifs:
+ - vlan_id: 101
+ ipv4:
+ - address: 192.0.2.71/28
+ - address: 198.51.100.131/25
+ - vlan_id: 102
+ ipv6:
+ - address: '2001:db8:1000::5/38'
+ - address: '2001:db8:1400::3/38'
state: merged
+
# After state:
# -------------
#
@@ -209,13 +210,13 @@ EXAMPLES = """
- name: Replace device configurations of listed interfaces with provided configurations
vyos.vyos.vyos_l3_interfaces:
config:
- - name: eth2
- ipv4:
- - address: 192.0.2.10/24
+ - name: eth2
+ ipv4:
+ - address: 192.0.2.10/24
- - name: eth3
- ipv6:
- - address: 2001:db8::11/32
+ - name: eth3
+ ipv6:
+ - address: 2001:db8::11/32
state: replaced
# After state:
@@ -265,13 +266,14 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_l3_interfaces:
config:
- - name: eth0
- ipv4:
- - address: dhcp
- ipv6:
- - address: dhcpv6
+ - name: eth0
+ ipv4:
+ - address: dhcp
+ ipv6:
+ - address: dhcpv6
state: overridden
+
# After state
# ------------
#
@@ -317,9 +319,9 @@ EXAMPLES = """
itself)
vyos.vyos.vyos_l3_interfaces:
config:
- - name: eth1
- - name: eth2
- - name: eth3
+ - name: eth1
+ - name: eth2
+ - name: eth3
state: deleted
# After state
@@ -357,7 +359,6 @@ EXAMPLES = """
#
- name: Gather listed l3 interfaces with provided configurations
vyos.vyos.vyos_l3_interfaces:
- config:
state: gathered
#
#
@@ -426,17 +427,18 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_l3_interfaces:
config:
- - name: eth1
- ipv4:
- - address: 192.0.2.14/24
- - name: eth2
- ipv4:
- - address: 192.0.2.10/24
- - address: 192.0.2.11/24
- ipv6:
- - address: 2001:db8::10/32
- - address: 2001:db8::12/32
+ - name: eth1
+ ipv4:
+ - address: 192.0.2.14/24
+ - name: eth2
+ ipv4:
+ - address: 192.0.2.10/24
+ - address: 192.0.2.11/24
+ ipv6:
+ - address: '2001:db8::10/32'
+ - address: '2001:db8::12/32'
state: rendered
+
#
#
# -------------------------
@@ -510,8 +512,6 @@ EXAMPLES = """
# "name": "eth0"
# }
# ]
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_lag_interfaces.py b/plugins/modules/vyos_lag_interfaces.py
index fb36592..0605f06 100644
--- a/plugins/modules/vyos_lag_interfaces.py
+++ b/plugins/modules/vyos_lag_interfaces.py
@@ -28,6 +28,7 @@ The module file for vyos_lag_interfaces
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -136,21 +137,21 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
vyos.vyos.vyos_lag_interfaces:
config:
- - name: bond2
- mode: active-backup
- members:
- - member: eth2
- - member: eth1
- hash_policy: layer2
- primary: eth2
-
- - name: bond3
- mode: active-backup
- hash_policy: layer2+3
- members:
- - member: eth3
- primary: eth3
+ - name: bond2
+ mode: active-backup
+ members:
+ - member: eth2
+ - member: eth1
+ hash_policy: layer2
+ primary: eth2
+ - name: bond3
+ mode: active-backup
+ hash_policy: layer2+3
+ members:
+ - member: eth3
+ primary: eth3
state: merged
+
#
#
# -------------------------
@@ -240,11 +241,11 @@ EXAMPLES = """
- name: Replace device configurations of listed LAGs with provided configurations
vyos.vyos.vyos_lag_interfaces:
config:
- - name: bond3
- mode: 802.3ad
- hash_policy: layer2
- members:
- - member: eth3
+ - name: bond3
+ mode: 802.3ad
+ hash_policy: layer2
+ members:
+ - member: eth3
state: replaced
#
#
@@ -345,14 +346,14 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_lag_interfaces:
config:
- - name: bond3
- mode: active-backup
- members:
- - member: eth1
- - member: eth2
- - member: eth3
- primary: eth3
- hash_policy: layer2
+ - name: bond3
+ mode: active-backup
+ members:
+ - member: eth1
+ - member: eth2
+ - member: eth3
+ primary: eth3
+ hash_policy: layer2
state: overridden
#
#
@@ -456,8 +457,8 @@ EXAMPLES = """
itself)
vyos.vyos.vyos_lag_interfaces:
config:
- - name: bond2
- - name: bond3
+ - name: bond2
+ - name: bond3
state: deleted
#
#
@@ -535,9 +536,8 @@ EXAMPLES = """
# set interfaces ethernet eth1 bond-group 'bond0'
# set interfaces ethernet eth2 bond-group 'bond1'
#
-- name: Gather listed lag interfaces with provided configurations
+- name: Gather listed lag interfaces with provided configurations
vyos.vyos.vyos_lag_interfaces:
- config:
state: gathered
#
#
@@ -636,19 +636,20 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_lag_interfaces:
config:
- - name: bond0
- hash_policy: layer2
- members:
- - member: eth1
- mode: active-backup
- primary: eth1
- - name: bond1
- hash_policy: layer2+3
- members:
- - member: eth2
- mode: active-backup
- primary: eth2
+ - name: bond0
+ hash_policy: layer2
+ members:
+ - member: eth1
+ mode: active-backup
+ primary: eth1
+ - name: bond1
+ hash_policy: layer2+3
+ members:
+ - member: eth2
+ mode: active-backup
+ primary: eth2
state: rendered
+
#
#
# -------------------------
@@ -714,8 +715,6 @@ EXAMPLES = """
# "primary": "eth2"
# }
# ]
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_lldp_global.py b/plugins/modules/vyos_lldp_global.py
index f59327a..5d215f6 100644
--- a/plugins/modules/vyos_lldp_global.py
+++ b/plugins/modules/vyos_lldp_global.py
@@ -28,6 +28,7 @@ The module file for vyos_lldp_global
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -104,8 +105,8 @@ EXAMPLES = """
vyos.vyos.vyos_lldp_global:
config:
legacy_protocols:
- - fdp
- - cdp
+ - fdp
+ - cdp
snmp: enable
address: 192.0.2.11
state: merged
@@ -166,9 +167,9 @@ EXAMPLES = """
vyos.vyos.vyos_lldp_global:
config:
legacy_protocols:
- - edp
- - sonmp
- - cdp
+ - edp
+ - sonmp
+ - cdp
address: 192.0.2.14
state: replaced
#
@@ -395,7 +396,7 @@ EXAMPLES = """
address: 192.0.2.17
enable: true
legacy_protocols:
- - cdp
+ - cdp
state: rendered
#
#
@@ -438,8 +439,6 @@ EXAMPLES = """
# ]
# }
#
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_lldp_interfaces.py b/plugins/modules/vyos_lldp_interfaces.py
index 9260cb6..6628f65 100644
--- a/plugins/modules/vyos_lldp_interfaces.py
+++ b/plugins/modules/vyos_lldp_interfaces.py
@@ -28,6 +28,7 @@ The module file for vyos_lldp_interfaces
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -110,25 +111,25 @@ options:
type: str
running_config:
description:
- - This option is used only with state I(parsed).
- - The value of this option should be the output received from the VyOS device
- by executing the command B(show configuration commands | grep lldp).
- - The state I(parsed) reads the configuration from C(running_config) option and
- transforms it into Ansible structured data as per the resource module's argspec
- and the value is then returned in the I(parsed) key within the result.
+ - This option is used only with state I(parsed).
+ - The value of this option should be the output received from the VyOS device
+ by executing the command B(show configuration commands | grep lldp).
+ - The state I(parsed) reads the configuration from C(running_config) option and
+ transforms it into Ansible structured data as per the resource module's argspec
+ and the value is then returned in the I(parsed) key within the result.
type: str
state:
description:
- - The state of the configuration after module completion.
+ - 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 = """
@@ -142,22 +143,22 @@ EXAMPLES = """
- name: Merge provided configuration with device configuration
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: eth1
- location:
- civic_based:
- country_code: US
- ca_info:
- - ca_type: 0
- ca_value: ENGLISH
-
- - name: eth2
- location:
- coordinate_based:
- altitude: 2200
- datum: WGS84
- longitude: 222.267255W
- latitude: 33.524449N
+ - name: eth1
+ location:
+ civic_based:
+ country_code: US
+ ca_info:
+ - ca_type: 0
+ ca_value: ENGLISH
+ - name: eth2
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
state: merged
+
#
#
# -------------------------
@@ -233,24 +234,25 @@ EXAMPLES = """
# set service lldp interface eth2 location coordinate-based latitude '33.524449N'
# set service lldp interface eth2 location coordinate-based longitude '222.267255W'
#
-- name: Replace device configurations of listed LLDP interfaces with provided configurations
+- name: >-
+ Replace device configurations of listed LLDP interfaces with provided
+ configurations
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: eth2
- location:
- civic_based:
- country_code: US
- ca_info:
- - ca_type: 0
- ca_value: ENGLISH
-
- - name: eth1
- location:
- coordinate_based:
- altitude: 2200
- datum: WGS84
- longitude: 222.267255W
- latitude: 33.524449N
+ - name: eth2
+ location:
+ civic_based:
+ country_code: US
+ ca_info:
+ - ca_type: 0
+ ca_value: ENGLISH
+ - name: eth1
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
state: replaced
#
#
@@ -359,9 +361,9 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: eth2
- location:
- elin: 0000000911
+ - name: eth2
+ location:
+ elin: 0000000911
state: overridden
#
@@ -434,7 +436,7 @@ EXAMPLES = """
- name: Delete lldp interface attributes of given interfaces.
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: eth2
+ - name: eth2
state: deleted
#
#
@@ -525,21 +527,22 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: eth1
- location:
- civic_based:
- country_code: US
- ca_info:
- - ca_type: 0
- ca_value: ENGLISH
- - name: eth2
- location:
- coordinate_based:
- altitude: 2200
- datum: WGS84
- longitude: 222.267255W
- latitude: 33.524449N
+ - name: eth1
+ location:
+ civic_based:
+ country_code: US
+ ca_info:
+ - ca_type: 0
+ ca_value: ENGLISH
+ - name: eth2
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
state: rendered
+
#
#
# -------------------------
@@ -606,8 +609,6 @@ EXAMPLES = """
# "name": "eth1"
# }
# ]
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_logging.py b/plugins/modules/vyos_logging.py
index 7e1dea7..204e4f9 100644
--- a/plugins/modules/vyos_logging.py
+++ b/plugins/modules/vyos_logging.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
# (c) 2017, Ansible by Red Hat, inc
@@ -130,16 +131,29 @@ EXAMPLES = """
- name: Add logging aggregate
vyos.vyos.vyos_logging:
aggregate:
- - {dest: file, name: test1, facility: all, level: info}
- - {dest: file, name: test2, facility: news, level: debug}
+ - dest: file
+ name: test1
+ facility: all
+ level: info
+ - dest: file
+ name: test2
+ facility: news
+ level: debug
state: present
- name: Remove logging aggregate
vyos.vyos.vyos_logging:
aggregate:
- - {dest: console, facility: all, level: info}
- - {dest: console, facility: daemon, level: warning}
- - {dest: file, name: test2, facility: news, level: debug}
+ - dest: console
+ facility: all
+ level: info
+ - dest: console
+ facility: daemon
+ level: warning
+ - dest: file
+ name: test2
+ facility: news
+ level: debug
state: absent
"""
@@ -153,6 +167,7 @@ commands:
"""
import re
+
from copy import deepcopy
from ansible.module_utils._text import to_text
@@ -184,23 +199,37 @@ def spec_to_commands(updates, module):
if w["name"]:
commands.append(
"delete system syslog {0} {1} facility {2} level {3}".format(
- dest, name, facility, level
- )
+ dest,
+ name,
+ facility,
+ level,
+ ),
)
else:
commands.append(
- "delete system syslog {0} facility {1} level {2}".format(dest, facility, level)
+ "delete system syslog {0} facility {1} level {2}".format(
+ dest,
+ facility,
+ level,
+ ),
)
elif state == "present" and w not in have:
if w["name"]:
commands.append(
"set system syslog {0} {1} facility {2} level {3}".format(
- dest, name, facility, level
- )
+ dest,
+ name,
+ facility,
+ level,
+ ),
)
else:
commands.append(
- "set system syslog {0} facility {1} level {2}".format(dest, facility, level)
+ "set system syslog {0} facility {1} level {2}".format(
+ dest,
+ facility,
+ level,
+ ),
)
return commands
@@ -239,7 +268,7 @@ def config_to_dict(module):
"name": name,
"facility": facility,
"level": level,
- }
+ },
)
return obj
@@ -272,7 +301,7 @@ def map_params_to_obj(module, required_if=None):
"facility": module.params["facility"],
"level": module.params["level"],
"state": module.params["state"],
- }
+ },
)
return obj
@@ -293,7 +322,9 @@ def main():
# remove default in aggregate spec, to handle common arguments
remove_default_spec(aggregate_spec)
- argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec))
+ argument_spec = dict(
+ aggregate=dict(type="list", elements="dict", options=aggregate_spec),
+ )
argument_spec.update(element_spec)
diff --git a/plugins/modules/vyos_logging_global.py b/plugins/modules/vyos_logging_global.py
index 18248d6..06ebe48 100644
--- a/plugins/modules/vyos_logging_global.py
+++ b/plugins/modules/vyos_logging_global.py
@@ -10,6 +10,7 @@ The module file for vyos_logging_global
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -220,15 +221,15 @@ EXAMPLES = """
users:
- username: vyos
facilities:
- - facility: local7
- severity: debug
+ - facility: local7
+ severity: debug
global_params:
archive:
file_num: 2
size: 111
facilities:
- - facility: cron
- severity: debug
+ - facility: cron
+ severity: debug
marker_interval: 111
preserve_fqdn: true
state: merged
@@ -396,10 +397,11 @@ EXAMPLES = """
users:
- username: paul
facilities:
- - facility: local7
- severity: err
+ - facility: local7
+ severity: err
state: replaced
+
# Commands Fired:
# ---------------
diff --git a/plugins/modules/vyos_ntp_global.py b/plugins/modules/vyos_ntp_global.py
index 10a2170..0fe56ad 100644
--- a/plugins/modules/vyos_ntp_global.py
+++ b/plugins/modules/vyos_ntp_global.py
@@ -10,6 +10,7 @@ The module file for vyos_ntp_global
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -98,18 +99,18 @@ EXAMPLES = """
- name: Replace the existing ntp config with the new config
vyos.vyos.vyos_ntp_global:
config:
- allow_clients:
- - 10.6.6.0/24
- listen_addresses:
- - 10.1.3.1
- servers:
- - server: 203.0.113.0
- options:
- - prefer
-
-
-# # Task output:
-# # -------------
+ allow_clients:
+ - 10.6.6.0/24
+ listen_addresses:
+ - 10.1.3.1
+ servers:
+ - server: 203.0.113.0
+ options:
+ - prefer
+
+
+# Task output:
+# -------------
# "after": {
# "allow_clients": [
# "10.6.6.0/24"
@@ -189,14 +190,14 @@ EXAMPLES = """
- name: Replace the existing ntp config with the new config
vyos.vyos.vyos_ntp_global:
config:
- allow_clients:
- - 10.6.6.0/24
- listen_addresses:
- - 10.1.3.1
- servers:
- - server: 203.0.113.0
- options:
- - prefer
+ allow_clients:
+ - 10.6.6.0/24
+ listen_addresses:
+ - 10.1.3.1
+ servers:
+ - server: 203.0.113.0
+ options:
+ - prefer
state: replaced
@@ -302,8 +303,6 @@ EXAMPLES = """
# set system ntp server time3.vyos.net
# vyos@vyos:~$
-
-
# # -------------------
# # 3. Using overridden
# # -------------------
@@ -319,30 +318,28 @@ EXAMPLES = """
# set system ntp server time3.vyos.net
# vyos@vyos:~$
-# # Task
-# # -------------
+# Task
+# -------------
- name: Override ntp config
vyos.vyos.vyos_ntp_global:
- config:
- allow_clients:
- - 10.3.3.0/24
- listen_addresses:
- - 10.7.8.1
- servers:
- - server: server1
- options:
- - dynamic
- - prefer
-
- - server: server2
- options:
- - noselect
- - preempt
-
- - server: serv
- state: overridden
-
-
+ config:
+ allow_clients:
+ - 10.3.3.0/24
+ listen_addresses:
+ - 10.7.8.1
+ servers:
+ - server: server1
+ options:
+ - dynamic
+ - prefer
+
+ - server: server2
+ options:
+ - noselect
+ - preempt
+
+ - server: serv
+ state: overridden
# # Task output:
# # -------------
@@ -436,11 +433,8 @@ EXAMPLES = """
# set system ntp server time3.vyos.net
# vyos@vyos:~$
-
-
-# # -------------------
-# # 4. Using gathered
-# # -------------------
+# 4. Using gathered
+# -------------------
# # Before state:
# # -------------
@@ -457,11 +451,11 @@ EXAMPLES = """
# set system ntp server time3.vyos.net
# vyos@vyos:~$
-# # Task
-# # -------------
+# Task
+# -------------
- name: Gather ntp config
vyos.vyos.vyos_ntp_global:
- state: gathered
+ state: gathered
# # Task output:
# # -------------
@@ -626,32 +620,27 @@ EXAMPLES = """
# set system ntp server time3.vyos.net
# vyos@vyos:~$
-# # Task
-# # -------------
+# Task
+# -------------
- name: Render ntp config
vyos.vyos.vyos_ntp_global:
- config:
- allow_clients:
- - 10.7.7.0/24
- - 10.8.8.0/24
- listen_addresses:
- - 10.7.9.1
- servers:
- - server: server7
-
- - server: server45
- options:
- - noselect
- - prefer
- - pool
- - server: time1.vyos.net
-
- - server: time2.vyos.net
-
- - server: time3.vyos.net
-
- state: rendered
-
+ config:
+ allow_clients:
+ - 10.7.7.0/24
+ - 10.8.8.0/24
+ listen_addresses:
+ - 10.7.9.1
+ servers:
+ - server: server7
+ - server: server45
+ options:
+ - noselect
+ - prefer
+ - pool
+ - server: time1.vyos.net
+ - server: time2.vyos.net
+ - server: time3.vyos.net
+ state: rendered
# # Task output:
# # -------------
@@ -685,12 +674,12 @@ EXAMPLES = """
# "set system ntp server time2.vyos.net",
# "set system ntp server time3.vyos.net"
-# # Task:
-# # -------------
+# Task:
+# -------------
- name: Parse externally provided ntp configuration
vyos.vyos.vyos_ntp_global:
- running_config: "{{ lookup('file', './sample_config.cfg') }}"
- state: parsed
+ running_config: "{{ lookup('file', './sample_config.cfg') }}"
+ state: parsed
# # Task output:
# # -------------
@@ -724,7 +713,6 @@ EXAMPLES = """
#
# ]
# }
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_ospf_interfaces.py b/plugins/modules/vyos_ospf_interfaces.py
index 9a78ebd..c232689 100644
--- a/plugins/modules/vyos_ospf_interfaces.py
+++ b/plugins/modules/vyos_ospf_interfaces.py
@@ -28,6 +28,7 @@ The module file for vyos_ospf_interfaces
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -58,7 +59,7 @@ options:
- Address Family Identifier (AFI) for OSPF settings on the interfaces.
type: str
choices: ['ipv4', 'ipv6']
- required: True
+ required: true
authentication:
description:
- Authentication settings on the interface.
@@ -161,29 +162,29 @@ EXAMPLES = """
# @vyos:~$ show configuration commands | match "ospf"
- - name: Merge provided configuration with device configuration
- vyos.vyos.vyos_ospf_interfaces:
- config:
- - name: "eth1"
- address_family:
- - afi: "ipv4"
- transmit_delay: 50
- priority: 26
- network: "point-to-point"
- - afi: "ipv6"
- dead_interval: 39
- - name: "bond2"
- address_family:
- - afi: "ipv4"
- transmit_delay: 45
- bandwidth: 70
- authentication:
- md5_key:
- key_id: 10
- key: "1111111111232345"
- - afi: "ipv6"
- passive: True
- state: merged
+- name: Merge provided configuration with device configuration
+ vyos.vyos.vyos_ospf_interfaces:
+ config:
+ - name: "eth1"
+ address_family:
+ - afi: "ipv4"
+ transmit_delay: 50
+ priority: 26
+ network: "point-to-point"
+ - afi: "ipv6"
+ dead_interval: 39
+ - name: "bond2"
+ address_family:
+ - afi: "ipv4"
+ transmit_delay: 45
+ bandwidth: 70
+ authentication:
+ md5_key:
+ key_id: 10
+ key: "1111111111232345"
+ - afi: "ipv6"
+ passive: true
+ state: merged
# After State:
# --------------
@@ -270,9 +271,6 @@ EXAMPLES = """
# "set interfaces bonding bond2 ipv6 ospfv3 passive"
# ],
-
-
-
# Using replaced:
# Before State:
@@ -288,22 +286,22 @@ EXAMPLES = """
# set interfaces ethernet eth1 ip ospf transmit-delay '50'
# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'
- - name: Replace provided configuration with device configuration
- vyos.vyos.vyos_ospf_interfaces:
- config:
- - name: "eth1"
- address_family:
- - afi: "ipv4"
- cost: 100
- - afi: "ipv6"
- ifmtu: 33
- - name: "bond2"
- address_family:
- - afi: "ipv4"
- transmit_delay: 45
- - afi: "ipv6"
- passive: True
- state: replaced
+- name: Replace provided configuration with device configuration
+ vyos.vyos.vyos_ospf_interfaces:
+ config:
+ - name: "eth1"
+ address_family:
+ - afi: "ipv4"
+ cost: 100
+ - afi: "ipv6"
+ ifmtu: 33
+ - name: "bond2"
+ address_family:
+ - afi: "ipv4"
+ transmit_delay: 45
+ - afi: "ipv6"
+ passive: true
+ state: replaced
# After State:
# -----------
@@ -432,17 +430,18 @@ EXAMPLES = """
# set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33'
# vyos@vyos:~$
- - name: Override device configuration with provided configuration
- vyos.vyos.vyos_ospf_interfaces:
- config:
- - name: "eth0"
- address_family:
- - afi: "ipv4"
- cost: 100
- - afi: "ipv6"
- ifmtu: 33
- passive: True
- state: overridden
+- name: Override device configuration with provided configuration
+ vyos.vyos.vyos_ospf_interfaces:
+ config:
+ - name: "eth0"
+ address_family:
+ - afi: "ipv4"
+ cost: 100
+ - afi: "ipv6"
+ ifmtu: 33
+ passive: true
+ state: overridden
+
# After State:
# -----------
@@ -561,11 +560,11 @@ EXAMPLES = """
# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'
# vyos@vyos:~$
- - name: Delete device configuration
- vyos.vyos.vyos_ospf_interfaces:
- config:
- - name: "eth0"
- state: deleted
+- name: Delete device configuration
+ vyos.vyos.vyos_ospf_interfaces:
+ config:
+ - name: "eth0"
+ state: deleted
# After State:
# -----------
@@ -708,10 +707,10 @@ EXAMPLES = """
# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'
#
- - name: parse configs
- vyos.vyos.vyos_ospf_interfaces:
- running_config: "{{ lookup('file', './parsed.cfg') }}"
- state: parsed
+- name: parse configs
+ vyos.vyos.vyos_ospf_interfaces:
+ running_config: "{{ lookup('file', './parsed.cfg') }}"
+ state: parsed
# Module Execution:
# ----------------
@@ -772,29 +771,29 @@ EXAMPLES = """
# Using rendered:
# --------------
- - name: Render
- vyos.vyos.vyos_ospf_interfaces:
- config:
- - name: "eth1"
- address_family:
- - afi: "ipv4"
- transmit_delay: 50
- priority: 26
- network: "point-to-point"
- - afi: "ipv6"
- dead_interval: 39
- - name: "bond2"
- address_family:
- - afi: "ipv4"
- transmit_delay: 45
- bandwidth: 70
- authentication:
- md5_key:
- key_id: 10
- key: "1111111111232345"
- - afi: "ipv6"
- passive: True
- state: rendered
+- name: Render
+ vyos.vyos.vyos_ospf_interfaces:
+ config:
+ - name: "eth1"
+ address_family:
+ - afi: "ipv4"
+ transmit_delay: 50
+ priority: 26
+ network: "point-to-point"
+ - afi: "ipv6"
+ dead_interval: 39
+ - name: "bond2"
+ address_family:
+ - afi: "ipv4"
+ transmit_delay: 45
+ bandwidth: 70
+ authentication:
+ md5_key:
+ key_id: 10
+ key: "1111111111232345"
+ - afi: "ipv6"
+ passive: true
+ state: rendered
# Module Execution:
# ----------------
@@ -827,9 +826,9 @@ EXAMPLES = """
# set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39'
# vyos@vyos:~$
- - name: gather configs
- vyos.vyos.vyos_ospf_interfaces:
- state: gathered
+- name: gather configs
+ vyos.vyos.vyos_ospf_interfaces:
+ state: gathered
# Module Execution:
# -----------------
@@ -880,11 +879,6 @@ EXAMPLES = """
# "name": "eth3"
# }
# ],
-
-
-
-
-
"""
from ansible.module_utils.basic import AnsibleModule
diff --git a/plugins/modules/vyos_ospfv2.py b/plugins/modules/vyos_ospfv2.py
index 863bc6f..10e4974 100644
--- a/plugins/modules/vyos_ospfv2.py
+++ b/plugins/modules/vyos_ospfv2.py
@@ -28,6 +28,7 @@ The module file for vyos_ospfv2
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -389,42 +390,42 @@ EXAMPLES = """
auto_cost:
reference_bandwidth: 2
neighbor:
- - neighbor_id: 192.0.11.12
- poll_interval: 10
- priority: 2
+ - neighbor_id: 192.0.11.12
+ poll_interval: 10
+ priority: 2
redistribute:
- - route_type: bgp
- metric: 10
- metric_type: 2
+ - route_type: bgp
+ metric: 10
+ metric_type: 2
passive_interface:
- - eth1
- - eth2
+ - 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
+ - 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
#
#
@@ -612,23 +613,23 @@ EXAMPLES = """
vyos.vyos.vyos_ospfv2:
config:
areas:
- - area_id: '2'
- area_type:
- normal: true
- authentication: plaintext-password
- shortcut: enable
- - area_id: '3'
- area_type:
- nssa:
- set: false
- - area_id: '4'
- area_type:
- stub:
- default_cost: 20
- network:
- - address: 192.0.2.0/24
- - address: 192.0.22.0/24
- - address: 192.0.32.0/24
+ - area_id: '2'
+ area_type:
+ normal: true
+ authentication: plaintext-password
+ shortcut: enable
+ - area_id: '3'
+ area_type:
+ nssa:
+ set: false
+ - area_id: '4'
+ area_type:
+ stub:
+ default_cost: 20
+ network:
+ - address: 192.0.2.0/24
+ - address: 192.0.22.0/24
+ - address: 192.0.32.0/24
state: merged
#
#
@@ -920,39 +921,40 @@ EXAMPLES = """
auto_cost:
reference_bandwidth: 2
neighbor:
- - neighbor_id: 192.0.11.12
- poll_interval: 10
- priority: 2
+ - neighbor_id: 192.0.11.12
+ poll_interval: 10
+ priority: 2
redistribute:
- - route_type: bgp
- metric: 10
- metric_type: 2
+ - route_type: bgp
+ metric: 10
+ metric_type: 2
passive_interface:
- - eth1
+ - 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
+ - area_id: '2'
+ area_type:
+ normal: true
+ authentication: plaintext-password
+ shortcut: enable
+ - area_id: '4'
+ area_type:
+ stub:
+ default_cost: 20
+ network:
+ - address: 192.0.2.0/24
+ - address: 192.0.12.0/24
+ - address: 192.0.22.0/24
+ - address: 192.0.32.0/24
+ range:
+ - address: 192.0.42.0/24
+ cost: 10
state: replaced
+
#
#
# -------------------------
@@ -1213,42 +1215,42 @@ EXAMPLES = """
auto_cost:
reference_bandwidth: 2
neighbor:
- - neighbor_id: 192.0.11.12
- poll_interval: 10
- priority: 2
+ - neighbor_id: 192.0.11.12
+ poll_interval: 10
+ priority: 2
redistribute:
- - route_type: bgp
- metric: 10
- metric_type: 2
+ - route_type: bgp
+ metric: 10
+ metric_type: 2
passive_interface:
- - eth1
- - eth2
+ - 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
+ - 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
#
#
@@ -1754,7 +1756,6 @@ EXAMPLES = """
# ------------
# vyos@192# run show configuration commands | grep ospf
#
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_ospfv3.py b/plugins/modules/vyos_ospfv3.py
index 4ff6106..8dbaaee 100644
--- a/plugins/modules/vyos_ospfv3.py
+++ b/plugins/modules/vyos_ospfv3.py
@@ -28,6 +28,7 @@ The module file for vyos_ospfv3
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -130,21 +131,22 @@ EXAMPLES = """
vyos.vyos.vyos_ospfv3:
config:
redistribute:
- - route_type: bgp
+ - route_type: bgp
parameters:
router_id: 192.0.2.10
areas:
- - area_id: '2'
- export_list: export1
- import_list: import1
- range:
- - address: 2001:db10::/32
- - address: 2001:db20::/32
- - address: 2001:db30::/32
- - area_id: '3'
- range:
- - address: 2001:db40::/32
+ - area_id: '2'
+ export_list: export1
+ import_list: import1
+ range:
+ - address: '2001:db10::/32'
+ - address: '2001:db20::/32'
+ - address: '2001:db30::/32'
+ - area_id: '3'
+ range:
+ - address: '2001:db40::/32'
state: merged
+
#
#
# -------------------------
@@ -236,21 +238,22 @@ EXAMPLES = """
vyos.vyos.vyos_ospfv3:
config:
redistribute:
- - route_type: bgp
+ - route_type: bgp
parameters:
router_id: 192.0.2.10
areas:
- - area_id: '2'
- export_list: export1
- import_list: import1
- range:
- - address: 2001:db10::/32
- - address: 2001:db30::/32
- - address: 2001:db50::/32
- - area_id: '4'
- range:
- - address: 2001:db60::/32
+ - area_id: '2'
+ export_list: export1
+ import_list: import1
+ range:
+ - address: '2001:db10::/32'
+ - address: '2001:db30::/32'
+ - address: '2001:db50::/32'
+ - area_id: '4'
+ range:
+ - address: '2001:db60::/32'
state: replaced
+
#
#
# -------------------------
@@ -360,21 +363,22 @@ EXAMPLES = """
vyos.vyos.vyos_ospfv3:
config:
redistribute:
- - route_type: bgp
+ - route_type: bgp
parameters:
router_id: 192.0.2.10
areas:
- - area_id: '2'
- export_list: export1
- import_list: import1
- range:
- - address: 2001:db10::/32
- - address: 2001:db20::/32
- - address: 2001:db30::/32
- - area_id: '3'
- range:
- - address: 2001:db40::/32
+ - area_id: '2'
+ export_list: export1
+ import_list: import1
+ range:
+ - address: '2001:db10::/32'
+ - address: '2001:db20::/32'
+ - address: '2001:db30::/32'
+ - area_id: '3'
+ range:
+ - address: '2001:db40::/32'
state: rendered
+
#
#
# -------------------------
@@ -602,8 +606,6 @@ EXAMPLES = """
# After state
# ------------
# vyos@192# run show configuration commands | grep ospfv3
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_ping.py b/plugins/modules/vyos_ping.py
index 8c0330d..9861939 100644
--- a/plugins/modules/vyos_ping.py
+++ b/plugins/modules/vyos_ping.py
@@ -21,6 +21,7 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -217,10 +218,10 @@ def build_ping(dest, count, size=None, interval=None, source=None, ttl=None):
def parse_rate(rate_info):
rate_re = re.compile(
- r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)"
+ r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)",
)
rate_err_re = re.compile(
- r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)"
+ r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)",
)
if rate_re.match(rate_info):
@@ -233,7 +234,7 @@ def parse_rate(rate_info):
def parse_rtt(rtt_info):
rtt_re = re.compile(
- r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)"
+ r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)",
)
rtt = rtt_re.match(rtt_info)
diff --git a/plugins/modules/vyos_prefix_lists.py b/plugins/modules/vyos_prefix_lists.py
index ed190d4..c0d50d3 100644
--- a/plugins/modules/vyos_prefix_lists.py
+++ b/plugins/modules/vyos_prefix_lists.py
@@ -10,6 +10,7 @@ The module file for vyos_prefix_lists
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -1240,7 +1241,6 @@ EXAMPLES = """
# ]
# }
# ]
-
"""
RETURN = """
diff --git a/plugins/modules/vyos_route_maps.py b/plugins/modules/vyos_route_maps.py
index d49261c..bff6859 100644
--- a/plugins/modules/vyos_route_maps.py
+++ b/plugins/modules/vyos_route_maps.py
@@ -10,6 +10,7 @@ The module file for vyos_route_maps
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -264,35 +265,35 @@ EXAMPLES = """
# vyos@vyos:~$ show configuration commands | match "set policy route-map"
# vyos@vyos:~$
- - name: Merge the provided configuration with the existing running configuration
- register: result
- vyos.vyos.vyos_route_maps: &id001
- config:
- - route_map: test1
- entries:
- - sequence: 1
- description: "test"
- action: permit
- continue: 2
- on_match:
- next: True
- - route_map: test3
- entries:
- - sequence: 1
- action: permit
- match:
- rpki: invalid
- metric: 1
- peer: 192.0.2.32
- set:
- local_preference: 4
- metric: 5
- metric_type: "type-1"
- origin: egp
- originator_id: 192.0.2.34
- tag: 5
- weight: 4
- state: merged
+- name: Merge the provided configuration with the existing running configuration
+ register: result
+ vyos.vyos.vyos_route_maps: &id001
+ config:
+ - route_map: test1
+ entries:
+ - sequence: 1
+ description: "test"
+ action: permit
+ continue: 2
+ on_match:
+ next: true
+ - route_map: test3
+ entries:
+ - sequence: 1
+ action: permit
+ match:
+ rpki: invalid
+ metric: 1
+ peer: 192.0.2.32
+ set:
+ local_preference: 4
+ metric: 5
+ metric_type: "type-1"
+ origin: egp
+ originator_id: 192.0.2.34
+ tag: 5
+ weight: 4
+ state: merged
# After State
# vyos@vyos:~$ show configuration commands | match "set policy route-maps"
# set policy route-map test1 rule 1 description test
@@ -913,8 +914,6 @@ EXAMPLES = """
# "set policy route-map test3 rule 1 match metric 3",
# "set policy route-map test3 rule 1 match peer 192.0.2.35"
# ],
-#
-
"""
from ansible.module_utils.basic import AnsibleModule
diff --git a/plugins/modules/vyos_snmp_server.py b/plugins/modules/vyos_snmp_server.py
index 74bae3f..5eb69b8 100644
--- a/plugins/modules/vyos_snmp_server.py
+++ b/plugins/modules/vyos_snmp_server.py
@@ -10,6 +10,7 @@ The module file for vyos_snmp_server
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
DOCUMENTATION = """
@@ -268,30 +269,29 @@ EXAMPLES = """
# vyos@vyos:~$ show configuration commands | grep snmp
# vyos@vyos:~$
- - name: Merge provided configuration with device configuration
- vyos.vyos.vyos_snmp_server:
- config:
- communities:
- - name: "switches"
- authorization_type: "rw"
- - name: "bridges"
- clients: ["1.1.1.1", "12.1.1.10"]
- contact: "admin2@ex.com"
- listen_addresses:
- - address: "20.1.1.1"
- - address: "100.1.2.1"
- port: 33
- snmp_v3:
- users:
- - user: admin_user
- authentication:
- plaintext_key: "abc1234567"
- type: "sha"
- privacy:
- plaintext_key: "abc1234567"
- type: "aes"
-
- state: merged
+- name: Merge provided configuration with device configuration
+ vyos.vyos.vyos_snmp_server:
+ config:
+ communities:
+ - name: "switches"
+ authorization_type: "rw"
+ - name: "bridges"
+ clients: ["1.1.1.1", "12.1.1.10"]
+ contact: "admin2@ex.com"
+ listen_addresses:
+ - address: "20.1.1.1"
+ - address: "100.1.2.1"
+ port: 33
+ snmp_v3:
+ users:
+ - user: admin_user
+ authentication:
+ plaintext_key: "abc1234567"
+ type: "sha"
+ privacy:
+ plaintext_key: "abc1234567"
+ type: "aes"
+ state: merged
# After State:
@@ -366,9 +366,10 @@ EXAMPLES = """
# ],
#
-# using Replaced:
+# Using replaced
# Before State
+# -------------
# vyos@vyos:~$ show configuration commands | grep snmp
# set service snmp community bridges client '1.1.1.1'
# set service snmp community bridges client '12.1.1.10'
@@ -380,43 +381,42 @@ EXAMPLES = """
# set service snmp v3 user admin_user auth type 'sha'
# set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'
# set service snmp v3 user admin_user privacy type 'aes'
-# vyos@vyos:~$
- - name: Replace
- vyos.vyos.vyos_snmp_server:
- config:
- communities:
- - name: "bridges"
- networks: ["1.1.1.0/24", "12.1.1.0/24"]
- location: "RDU, NC"
- listen_addresses:
- - address: "100.1.2.1"
- port: 33
- snmp_v3:
- groups:
- - group: "default"
- view: "default"
- users:
- - user: admin_user
- authentication:
- plaintext_key: "abc1234567"
- type: "sha"
- privacy:
- plaintext_key: "abc1234567"
- type: "aes"
- group: "default"
- - user: guest_user2
- authentication:
- plaintext_key: "opq1234567"
- type: "sha"
- privacy:
- plaintext_key: "opq1234567"
- type: "aes"
- views:
- - view: "default"
- oid: 1
+- name: Replace SNMP Server configuration
+ vyos.vyos.vyos_snmp_server:
+ config:
+ communities:
+ - name: "bridges"
+ networks: ["1.1.1.0/24", "12.1.1.0/24"]
+ location: "RDU, NC"
+ listen_addresses:
+ - address: "100.1.2.1"
+ port: 33
+ snmp_v3:
+ groups:
+ - group: "default"
+ view: "default"
+ users:
+ - user: admin_user
+ authentication:
+ plaintext_key: "abc1234567"
+ type: "sha"
+ privacy:
+ plaintext_key: "abc1234567"
+ type: "aes"
+ group: "default"
+ - user: guest_user2
+ authentication:
+ plaintext_key: "opq1234567"
+ type: "sha"
+ privacy:
+ plaintext_key: "opq1234567"
+ type: "aes"
+ views:
+ - view: "default"
+ oid: 1
- state: replaced
+ state: replaced
# After State:
# vyos@vyos:~$ show configuration commands | grep snmp
@@ -572,43 +572,41 @@ EXAMPLES = """
# set service snmp v3 user admin_user auth type 'sha'
# set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'
# set service snmp v3 user admin_user privacy type 'aes'
-# vyos@vyos:~$
- - name: Override config
- vyos.vyos.vyos_snmp_server:
- config:
- communities:
- - name: "bridges"
- networks: ["1.1.1.0/24", "12.1.1.0/24"]
- location: "RDU, NC"
- listen_addresses:
- - address: "100.1.2.1"
- port: 33
- snmp_v3:
- groups:
- - group: "default"
- view: "default"
- users:
- - user: admin_user
- authentication:
- plaintext_key: "abc1234567"
- type: "sha"
- privacy:
- plaintext_key: "abc1234567"
- type: "aes"
- group: "default"
- - user: guest_user2
- authentication:
- plaintext_key: "opq1234567"
- type: "sha"
- privacy:
- plaintext_key: "opq1234567"
- type: "aes"
- views:
- - view: "default"
- oid: 1
-
- state: overridden
+- name: Override SNMP server config
+ vyos.vyos.vyos_snmp_server:
+ config:
+ communities:
+ - name: "bridges"
+ networks: ["1.1.1.0/24", "12.1.1.0/24"]
+ location: "RDU, NC"
+ listen_addresses:
+ - address: "100.1.2.1"
+ port: 33
+ snmp_v3:
+ groups:
+ - group: "default"
+ view: "default"
+ users:
+ - user: admin_user
+ authentication:
+ plaintext_key: "abc1234567"
+ type: "sha"
+ privacy:
+ plaintext_key: "abc1234567"
+ type: "aes"
+ group: "default"
+ - user: guest_user2
+ authentication:
+ plaintext_key: "opq1234567"
+ type: "sha"
+ privacy:
+ plaintext_key: "opq1234567"
+ type: "aes"
+ views:
+ - view: "default"
+ oid: 1
+ state: overridden
# After State:
# vyos@vyos:~$ show configuration commands | grep snmp
@@ -771,11 +769,10 @@ EXAMPLES = """
# set service snmp v3 user guest_user2 privacy plaintext-key 'opq1234567'
# set service snmp v3 user guest_user2 privacy type 'aes'
# set service snmp v3 view default oid 1
-# vyos@vyos:~$
- - name: Delete Config
- vyos.vyos.vyos_snmp_server:
- state: deleted
+- name: Delete Config
+ vyos.vyos.vyos_snmp_server:
+ state: deleted
# After State:
# vyos@vyos:~$ show configuration commands | grep snmp
@@ -849,30 +846,29 @@ EXAMPLES = """
# ],
# Using rendered:
- - name: Render provided configuration
- vyos.vyos.vyos_snmp_server:
- config:
- communities:
- - name: "switches"
- authorization_type: "rw"
- - name: "bridges"
- clients: ["1.1.1.1", "12.1.1.10"]
- contact: "admin2@ex.com"
- listen_addresses:
- - address: "20.1.1.1"
- - address: "100.1.2.1"
- port: 33
- snmp_v3:
- users:
- - user: admin_user
- authentication:
- plaintext_key: "abc1234567"
- type: "sha"
- privacy:
- plaintext_key: "abc1234567"
- type: "aes"
-
- state: rendered
+- name: Render provided configuration
+ vyos.vyos.vyos_snmp_server:
+ config:
+ communities:
+ - name: "switches"
+ authorization_type: "rw"
+ - name: "bridges"
+ clients: ["1.1.1.1", "12.1.1.10"]
+ contact: "admin2@ex.com"
+ listen_addresses:
+ - address: "20.1.1.1"
+ - address: "100.1.2.1"
+ port: 33
+ snmp_v3:
+ users:
+ - user: admin_user
+ authentication:
+ plaintext_key: "abc1234567"
+ type: "sha"
+ privacy:
+ plaintext_key: "abc1234567"
+ type: "aes"
+ state: rendered
# Module Execution:
# "rendered": [
@@ -903,11 +899,10 @@ EXAMPLES = """
# set service snmp v3 user admin_user auth type 'sha'
# set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'
# set service snmp v3 user admin_user privacy type 'aes'
-# vyos@vyos:~$
- - name: gather configs
- vyos.vyos.vyos_snmp_server:
- state: gathered
+- name: Gather SNMP server config
+ vyos.vyos.vyos_snmp_server:
+ state: gathered
# Module Execution:
# "gathered": {
@@ -974,10 +969,10 @@ EXAMPLES = """
# set service snmp v3 user vyos privacy type 'aes'
# set service snmp v3 view default oid 1
- - name: parse configs
- vyos.vyos.vyos_snmp_server:
- running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}"
- state: parsed
+- name: Parse SNMP server config
+ vyos.vyos.vyos_snmp_server:
+ running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}"
+ state: parsed
# Module Execution:
# "parsed": {
diff --git a/plugins/modules/vyos_static_routes.py b/plugins/modules/vyos_static_routes.py
index 0761599..df9c501 100644
--- a/plugins/modules/vyos_static_routes.py
+++ b/plugins/modules/vyos_static_routes.py
@@ -28,6 +28,7 @@ The module file for vyos_static_routes
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -143,25 +144,26 @@ EXAMPLES = """
- name: Merge the provided configuration with the existing running configuration
vyos.vyos.vyos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 192.0.2.32/28
- blackhole_config:
- type: blackhole
- next_hops:
- - forward_router_address: 192.0.2.6
- - forward_router_address: 192.0.2.7
- - address_families:
- - afi: ipv6
- routes:
- - dest: 2001:db8:1000::/36
- blackhole_config:
- distance: 2
- next_hops:
- - forward_router_address: 2001:db8:2000:2::1
- - forward_router_address: 2001:db8:2000:2::2
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+ - forward_router_address: 192.0.2.6
+ - forward_router_address: 192.0.2.7
+ - address_families:
+ - afi: ipv6
+ routes:
+ - dest: '2001:db8:1000::/36'
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: '2001:db8:2000:2::1'
+ - forward_router_address: '2001:db8:2000:2::2'
state: merged
+
#
#
# -------------------------
@@ -257,16 +259,16 @@ EXAMPLES = """
- name: Replace device configurations of listed static routes with provided configurations
vyos.vyos.vyos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 192.0.2.32/28
- blackhole_config:
- distance: 2
- next_hops:
- - forward_router_address: 192.0.2.7
- enabled: false
- - forward_router_address: 192.0.2.9
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 192.0.2.7
+ enabled: false
+ - forward_router_address: 192.0.2.9
state: replaced
#
#
@@ -433,12 +435,12 @@ EXAMPLES = """
- name: Overrides all device configuration with provided configuration
vyos.vyos.vyos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 198.0.2.48/28
- next_hops:
- - forward_router_address: 192.0.2.18
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.0.2.48/28
+ next_hops:
+ - forward_router_address: 192.0.2.18
state: overridden
#
#
@@ -543,9 +545,9 @@ EXAMPLES = """
- name: Delete static route based on afi.
vyos.vyos.vyos_static_routes:
config:
- - address_families:
- - afi: ipv4
- - afi: ipv6
+ - address_families:
+ - afi: ipv4
+ - afi: ipv6
state: deleted
#
#
@@ -694,24 +696,24 @@ EXAMPLES = """
- name: Render the commands for provided configuration
vyos.vyos.vyos_static_routes:
config:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 192.0.2.32/28
- blackhole_config:
- type: blackhole
- next_hops:
- - forward_router_address: 192.0.2.6
- - forward_router_address: 192.0.2.7
- - address_families:
- - afi: ipv6
- routes:
- - dest: 2001:db8:1000::/36
- blackhole_config:
- distance: 2
- next_hops:
- - forward_router_address: 2001:db8:2000:2::1
- - forward_router_address: 2001:db8:2000:2::2
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+ - forward_router_address: 192.0.2.6
+ - forward_router_address: 192.0.2.7
+ - address_families:
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 2001:db8:2000:2::1
+ - forward_router_address: 2001:db8:2000:2::2
state: rendered
#
#
@@ -871,8 +873,6 @@ EXAMPLES = """
# set protocols static route6 2001:db8:1000::/36 blackhole distance '2'
# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'
# set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'
-
-
"""
RETURN = """
before:
diff --git a/plugins/modules/vyos_system.py b/plugins/modules/vyos_system.py
index 66a3fd4..96a0e9b 100644
--- a/plugins/modules/vyos_system.py
+++ b/plugins/modules/vyos_system.py
@@ -18,6 +18,7 @@
#
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -90,8 +91,8 @@ EXAMPLES = """
- name: configure domain search suffixes
vyos.vyos.vyos_system:
domain_search:
- - sub1.example.com
- - sub2.example.com
+ - sub1.example.com
+ - sub2.example.com
"""
from ansible.module_utils.basic import AnsibleModule
diff --git a/plugins/modules/vyos_user.py b/plugins/modules/vyos_user.py
index 5494df3..53c45c2 100644
--- a/plugins/modules/vyos_user.py
+++ b/plugins/modules/vyos_user.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
# (c) 2017, Ansible by Red Hat, inc
@@ -154,12 +155,12 @@ EXAMPLES = """
state: present
- name: remove all users except admin
vyos.vyos.vyos_user:
- purge: yes
+ purge: true
- name: set multiple users to level operator
vyos.vyos.vyos_user:
aggregate:
- - name: netop
- - name: netend
+ - name: netop
+ - name: netend
level: operator
state: present
- name: Change Password for User netop
@@ -181,6 +182,7 @@ commands:
"""
import re
+
from copy import deepcopy
from functools import partial
diff --git a/plugins/modules/vyos_vlan.py b/plugins/modules/vyos_vlan.py
index f3e3dc8..49cc125 100644
--- a/plugins/modules/vyos_vlan.py
+++ b/plugins/modules/vyos_vlan.py
@@ -6,6 +6,7 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
@@ -122,8 +123,8 @@ EXAMPLES = """
vyos.vyos.vyos_vlan:
vlan_id: 100
interfaces:
- - eth1
- - eth2
+ - eth1
+ - eth2
- name: Configure virtual interface address
vyos.vyos.vyos_vlan:
@@ -136,14 +137,14 @@ EXAMPLES = """
vlan_id: 100
interfaces: eth0
associated_interfaces:
- - eth0
+ - eth0
- name: vlan intent check
vyos.vyos.vyos_vlan:
vlan_id: 100
associated_interfaces:
- - eth3
- - eth4
+ - eth3
+ - eth4
- name: Delete vlan
vyos.vyos.vyos_vlan:
@@ -164,6 +165,7 @@ commands:
"""
import re
import time
+
from copy import deepcopy
from ansible.module_utils._text import to_text
@@ -224,7 +226,7 @@ def map_obj_to_commands(updates, module):
if not obj_in_want:
for i in h["interfaces"]:
commands.append(
- "delete interfaces ethernet {0} vif {1}".format(i, h["vlan_id"])
+ "delete interfaces ethernet {0} vif {1}".format(i, h["vlan_id"]),
)
return commands
@@ -260,7 +262,7 @@ def map_params_to_obj(module):
"state": module.params["state"],
"interfaces": module.params["interfaces"],
"associated_interfaces": module.params["associated_interfaces"],
- }
+ },
)
return obj
@@ -325,7 +327,7 @@ def check_declarative_intent_params(want, module, result):
for i in w["associated_interfaces"]:
if (set(obj_interface) - set(w["associated_interfaces"])) != set([]):
module.fail_json(
- msg="Interface {0} not configured on vlan {1}".format(i, w["vlan_id"])
+ msg="Interface {0} not configured on vlan {1}".format(i, w["vlan_id"]),
)