Manages snmp_server resource module
Version added: 1.0.0
- This module manages the snmp server attributes of Vyos network devices
Note
- Tested against vyos 1.3.8, 1.4.1
- This module works with connection
network_cli
. - The Configuration defaults of the Vyos network devices are supposed to hinder idempotent behavior of plays
# Using merged
# Before State:
# 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: "[email protected]"
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:
# 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'
# set service snmp community switches authorization 'rw'
# set service snmp contact '[email protected]'
# set service snmp listen-address 20.1.1.1
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# 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:~$
#
# Module Execution:
#
# "after": {
# "communities": [
# {
# "clients": [
# "1.1.1.1",
# "12.1.1.10"
# ],
# "name": "bridges"
# },
# {
# "authorization_type": "rw",
# "name": "switches"
# }
# ],
# "contact": "[email protected]",
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# },
# {
# "address": "20.1.1.1"
# }
# ],
# "snmp_v3": {
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# }
# ]
# }
# },
# "before": {},
# "changed": true,
# "commands": [
# "set service snmp community switches authorization rw",
# "set service snmp community bridges client 1.1.1.1",
# "set service snmp community bridges client 12.1.1.10",
# "set service snmp listen-address 20.1.1.1",
# "set service snmp listen-address 100.1.2.1 port 33",
# "set service snmp v3 user admin_user auth type sha",
# "set service snmp v3 user admin_user auth plaintext-key ********",
# "set service snmp v3 user admin_user privacy type aes",
# "set service snmp v3 user admin_user privacy plaintext-key ********",
# "set service snmp contact [email protected]"
# ],
#
# 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'
# set service snmp community switches authorization 'rw'
# set service snmp contact '[email protected]'
# set service snmp listen-address 20.1.1.1
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# 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'
- 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
# After State:
# vyos@vyos:~$ show configuration commands | grep snmp
# set service snmp community bridges network '1.1.1.0/24'
# set service snmp community bridges network '12.1.1.0/24'
# set service snmp community switches
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp location 'RDU, NC'
# set service snmp v3 group default view 'default'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# set service snmp v3 user admin_user auth type 'sha'
# set service snmp v3 user admin_user group 'default'
# set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'
# set service snmp v3 user admin_user privacy type 'aes'
# set service snmp v3 user guest_user2 auth plaintext-key 'opq1234567'
# set service snmp v3 user guest_user2 auth type 'sha'
# 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:~$
#
#
# Module Execution:
# "after": {
# "communities": [
# {
# "name": "bridges",
# "networks": [
# "1.1.1.0/24",
# "12.1.1.0/24"
# ]
# },
# {
# "name": "switches"
# }
# ],
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# }
# ],
# "location": "RDU, NC",
# "snmp_v3": {
# "groups": [
# {
# "group": "default",
# "view": "default"
# }
# ],
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "group": "default",
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# },
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "guest_user2"
# }
# ],
# "views": [
# {
# "oid": "1",
# "view": "default"
# }
# ]
# }
# },
# "before": {
# "communities": [
# {
# "clients": [
# "1.1.1.1",
# "12.1.1.10"
# ],
# "name": "bridges"
# },
# {
# "authorization_type": "rw",
# "name": "switches"
# }
# ],
# "contact": "[email protected]",
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# },
# {
# "address": "20.1.1.1"
# }
# ],
# "snmp_v3": {
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# }
# ]
# }
# },
# "changed": true,
# "commands": [
# "delete service snmp contact [email protected]",
# "delete service snmp listen-address 20.1.1.1",
# "delete service snmp community switches authorization rw",
# "delete service snmp community bridges client 12.1.1.10",
# "delete service snmp community bridges client 1.1.1.1",
# "set service snmp community bridges network 1.1.1.0/24",
# "set service snmp community bridges network 12.1.1.0/24",
# "set service snmp v3 group default view default",
# "set service snmp v3 user admin_user group default",
# "set service snmp v3 user guest_user2 auth type sha",
# "set service snmp v3 user guest_user2 auth plaintext-key ********",
# "set service snmp v3 user guest_user2 privacy type aes",
# "set service snmp v3 user guest_user2 privacy plaintext-key ********",
# "set service snmp v3 view default oid 1",
# "set service snmp location 'RDU, NC'"
# ],
# Using overridden:
# 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'
# set service snmp community switches authorization 'rw'
# set service snmp contact '[email protected]'
# set service snmp listen-address 20.1.1.1
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# 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'
- 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
# set service snmp community bridges network '1.1.1.0/24'
# set service snmp community bridges network '12.1.1.0/24'
# set service snmp community switches
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp location 'RDU, NC'
# set service snmp v3 group default view 'default'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# set service snmp v3 user admin_user auth type 'sha'
# set service snmp v3 user admin_user group 'default'
# set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'
# set service snmp v3 user admin_user privacy type 'aes'
# set service snmp v3 user guest_user2 auth plaintext-key 'opq1234567'
# set service snmp v3 user guest_user2 auth type 'sha'
# 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:~$
#
#
# Module Execution:
# "after": {
# "communities": [
# {
# "name": "bridges",
# "networks": [
# "1.1.1.0/24",
# "12.1.1.0/24"
# ]
# },
# {
# "name": "switches"
# }
# ],
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# }
# ],
# "location": "RDU, NC",
# "snmp_v3": {
# "groups": [
# {
# "group": "default",
# "view": "default"
# }
# ],
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "group": "default",
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# },
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "guest_user2"
# }
# ],
# "views": [
# {
# "oid": "1",
# "view": "default"
# }
# ]
# }
# },
# "before": {
# "communities": [
# {
# "clients": [
# "1.1.1.1",
# "12.1.1.10"
# ],
# "name": "bridges"
# },
# {
# "authorization_type": "rw",
# "name": "switches"
# }
# ],
# "contact": "[email protected]",
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# },
# {
# "address": "20.1.1.1"
# }
# ],
# "snmp_v3": {
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# }
# ]
# }
# },
# "changed": true,
# "commands": [
# "delete service snmp contact [email protected]",
# "delete service snmp listen-address 20.1.1.1",
# "delete service snmp community switches authorization rw",
# "delete service snmp community bridges client 12.1.1.10",
# "delete service snmp community bridges client 1.1.1.1",
# "set service snmp community bridges network 1.1.1.0/24",
# "set service snmp community bridges network 12.1.1.0/24",
# "set service snmp v3 group default view default",
# "set service snmp v3 user admin_user group default",
# "set service snmp v3 user guest_user2 auth type sha",
# "set service snmp v3 user guest_user2 auth plaintext-key ********",
# "set service snmp v3 user guest_user2 privacy type aes",
# "set service snmp v3 user guest_user2 privacy plaintext-key ********",
# "set service snmp v3 view default oid 1",
# "set service snmp location 'RDU, NC'"
# ],
# Using deleted:
# Before State:
# vyos@vyos:~$ show configuration commands | grep snmp
# set service snmp community bridges network '1.1.1.0/24'
# set service snmp community bridges network '12.1.1.0/24'
# set service snmp community switches
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp location 'RDU, NC'
# set service snmp v3 group default view 'default'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# set service snmp v3 user admin_user auth type 'sha'
# set service snmp v3 user admin_user group 'default'
# set service snmp v3 user admin_user privacy plaintext-key 'abc1234567'
# set service snmp v3 user admin_user privacy type 'aes'
# set service snmp v3 user guest_user2 auth plaintext-key 'opq1234567'
# set service snmp v3 user guest_user2 auth type 'sha'
# 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
- name: Delete Config
vyos.vyos.vyos_snmp_server:
state: deleted
# After State:
# vyos@vyos:~$ show configuration commands | grep snmp
# vyos@vyos:~$
#
# Module Execution:
# "after": {},
# "before": {
# "communities": [
# {
# "name": "bridges",
# "networks": [
# "1.1.1.0/24",
# "12.1.1.0/24"
# ]
# },
# {
# "name": "switches"
# }
# ],
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# }
# ],
# "location": "RDU, NC",
# "snmp_v3": {
# "groups": [
# {
# "group": "default",
# "view": "default"
# }
# ],
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "group": "default",
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# },
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "guest_user2"
# }
# ],
# "views": [
# {
# "oid": "1",
# "view": "default"
# }
# ]
# }
# },
# "changed": true,
# "commands": [
# "delete service snmp"
# ],
# 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: "[email protected]"
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": [
# "set service snmp community switches authorization rw",
# "set service snmp community bridges client 1.1.1.1",
# "set service snmp community bridges client 12.1.1.10",
# "set service snmp listen-address 20.1.1.1",
# "set service snmp listen-address 100.1.2.1 port 33",
# "set service snmp v3 user admin_user auth type sha",
# "set service snmp v3 user admin_user auth plaintext-key ********",
# "set service snmp v3 user admin_user privacy type aes",
# "set service snmp v3 user admin_user privacy plaintext-key ********",
# "set service snmp contact [email protected]"
# ]
#
# Using Gathered:
# 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'
# set service snmp community switches authorization 'rw'
# set service snmp contact '[email protected]'
# set service snmp listen-address 20.1.1.1
# set service snmp listen-address 100.1.2.1 port '33'
# set service snmp v3 user admin_user auth plaintext-key 'abc1234567'
# 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'
- name: Gather SNMP server config
vyos.vyos.vyos_snmp_server:
state: gathered
# Module Execution:
# "gathered": {
# "communities": [
# {
# "clients": [
# "1.1.1.1",
# "12.1.1.10"
# ],
# "name": "bridges"
# },
# {
# "authorization_type": "rw",
# "name": "switches"
# }
# ],
# "contact": "[email protected]",
# "listen_addresses": [
# {
# "address": "100.1.2.1",
# "port": 33
# },
# {
# "address": "20.1.1.1"
# }
# ],
# "snmp_v3": {
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "admin_user"
# }
# ]
# }
# },
# Using parsed:
# _parsed_snmp.cfg
# set service snmp community routers authorization 'ro'
# set service snmp community routers client '203.0.113.10'
# set service snmp community routers client '203.0.113.20'
# set service snmp community routers network '192.0.2.0/24'
# set service snmp community routers network '2001::/64'
# set service snmp contact '[email protected]'
# set service snmp listen-address 172.16.254.36 port '161'
# set service snmp listen-address 2001::1
# set service snmp location 'UK, London'
# set service snmp trap-target 203.0.113.10
# set service snmp v3 engineid '000000000000000000000002'
# set service snmp v3 group default mode 'ro'
# set service snmp v3 group default view 'default'
# set service snmp v3 user vyos auth plaintext-key 'vyos12345678'
# set service snmp v3 user vyos auth type 'sha'
# set service snmp v3 user vyos group 'default'
# set service snmp v3 user vyos privacy plaintext-key 'vyos12345678'
# set service snmp v3 user vyos privacy type 'aes'
# set service snmp v3 view default oid 1
- name: Parse SNMP server config
vyos.vyos.vyos_snmp_server:
running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}"
state: parsed
# Module Execution:
# "parsed": {
# "communities": [
# {
# "authorization_type": "ro",
# "clients": [
# "203.0.113.10",
# "203.0.113.20"
# ],
# "name": "routers",
# "networks": [
# "192.0.2.0/24",
# "2001::/64"
# ]
# }
# ],
# "contact": "[email protected]",
# "listen_addresses": [
# {
# "address": "172.16.254.36",
# "port": 161
# },
# {
# "address": "2001::1"
# }
# ],
# "location": "UK, London",
# "snmp_v3": {
# "engine_id": "000000000000000000000002",
# "groups": [
# {
# "group": "default",
# "mode": "ro",
# "view": "default"
# }
# ],
# "users": [
# {
# "authentication": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "sha"
# },
# "group": "default",
# "privacy": {
# "plaintext_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
# "type": "aes"
# },
# "user": "vyos"
# }
# ],
# "views": [
# {
# "oid": "1",
# "view": "default"
# }
# ]
# },
# "trap_target": {
# "address": "203.0.113.10"
# }
# }
#
Common return values are documented here, the following are the fields unique to this module:
- Gomathi Selvi Srinivasan (@GomathiselviS)