Skip to content

Commit

Permalink
Merge pull request #41 from jeisenbath/devel-2.1.x
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
jeisenbath authored Oct 2, 2024
2 parents a02645e + bd3309c commit 00be77f
Show file tree
Hide file tree
Showing 27 changed files with 906 additions and 206 deletions.
37 changes: 31 additions & 6 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@ Solarwinds.Orion Release Notes

.. contents:: Topics

v2.1.0
======

Release Summary
---------------

Released 2024-10-02

Major Changes
-------------

- Added module orion_node_interface_info to get interfaces currently monitored for a node.
- Added orion_node_hardware_health module. This module allows for adding and removing hardware health sensors in Solarwinds Orion.

Minor Changes
-------------

- Add a poll_now() function to the OrionModule
- Add a profile_name parameter to orion_node_ncm
- Add correct check_mode logic to orion_ndoe_ncm
- Call poll_now() for SNMP nodes in orion_node_info module. This logic will allow using 'until' task logic to validate node is polling.
- Modified the example playbook for orion_add_node.yml to use the role keyword, and include a task for SNMP poll verification.
- Update get_node() function to also return LastSystemUptimePollUtc
- Updated orion_node module to no longer require snmpv3 credential set.
- Updated orion_update_node exmaples to show updating to SNMPv3.
- orion_node role - added tasks for new modules orion_node_ncm and orion_node_hardware_health

Bugfixes
--------

- Fixed an issue where ansible-lint would complain about missing parameters when a single yaml doc used multiple modules.

v2.0.0
======
Expand Down Expand Up @@ -91,7 +122,6 @@ Release Summary

| Released 2023-12-1

Major Changes
-------------

Expand All @@ -105,7 +135,6 @@ Release Summary

| Released 2023-09-26

Major Changes
-------------

Expand All @@ -124,7 +153,6 @@ Release Summary

| Released 2023-08-27

Minor Changes
-------------

Expand All @@ -143,7 +171,6 @@ Release Summary

| Released 2023-08-10

Minor Changes
-------------

Expand All @@ -165,7 +192,6 @@ Release Summary

| Released 2023-07-14

Minor Changes
-------------

Expand All @@ -186,7 +212,6 @@ Release Summary

| Released 2023-03-18

New Modules
-----------

Expand Down
9 changes: 8 additions & 1 deletion changelogs/.plugin-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins:
callback: {}
cliconf: {}
connection: {}
filter: {}
httpapi: {}
inventory:
orion_nodes_inventory:
Expand Down Expand Up @@ -34,6 +35,11 @@ plugins:
name: orion_node_custom_poller
namespace: ''
version_added: 1.0.0
orion_node_hardware_health:
description: Manage hardware health polling on a node in Solarwinds Orion
name: orion_node_hardware_health
namespace: ''
version_added: null
orion_node_info:
description: Gets info about a Node in Solarwinds Orion NPM
name: orion_node_info
Expand Down Expand Up @@ -83,5 +89,6 @@ plugins:
netconf: {}
shell: {}
strategy: {}
test: {}
vars: {}
version: 2.0.0
version: 2.1.0
32 changes: 32 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,35 @@ releases:
fragments:
- breaking.yml
release_date: '2024-04-18'
2.1.0:
changes:
bugfixes:
- Fixed an issue where ansible-lint would complain about missing parameters
when a single yaml doc used multiple modules.
major_changes:
- Added module orion_node_interface_info to get interfaces currently monitored
for a node.
- Added orion_node_hardware_health module. This module allows for adding and
removing hardware health sensors in Solarwinds Orion.
minor_changes:
- Add a poll_now() function to the OrionModule
- Add a profile_name parameter to orion_node_ncm
- Add correct check_mode logic to orion_ndoe_ncm
- Call poll_now() for SNMP nodes in orion_node_info module. This logic will
allow using 'until' task logic to validate node is polling.
- Modified the example playbook for orion_add_node.yml to use the role keyword,
and include a task for SNMP poll verification.
- Update get_node() function to also return LastSystemUptimePollUtc
- Updated orion_node module to no longer require snmpv3 credential set.
- Updated orion_update_node exmaples to show updating to SNMPv3.
- orion_node role - added tasks for new modules orion_node_ncm and orion_node_hardware_health
release_summary: Released 2024-10-02
fragments:
- 2.1.0.yml
- bugfix.yml
- orion_node_interface_info.yml
- orion_node_ncm.yml
- orion_node_playbook.yml
- role_updates.yml
- utils.yml
release_date: '2024-10-02'
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: solarwinds
name: orion
version: 2.0.0
version: 2.1.0
readme: README.md
authors:
- Josh Eisenbath (@jeisenbath)
Expand Down
90 changes: 51 additions & 39 deletions playbooks/orion_add_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,58 @@
hosts: "{{ target }}"
gather_facts: true # if you don't want to use ansible facts, make sure to then override default caption and IP variables

vars: # Be sure to check out the role README for a full list of variables
solarwinds_server: 127.0.0.1
solarwinds_username: admin
solarwinds_password: changeme2345
orion_node_polling_method: SNMP
orion_node_snmp_version: 2
orion_node_ro_community_string: community
orion_node_discover_interfaces: true
orion_node_volumes:
- /
- /home
- /var/log
# These are the basic pollers for a Linux node
# If you have other pollers enabled, such as Topology Layer 3, you can find a list by adding a node manually,
# then run the following query against the orion database:

# SELECT n.Caption, p.PollerType, p.Enabled
# from Orion.Nodes n
# left join Orion.Pollers as p on p.NetObjectID = n.NodeId
# where n.Caption = 'your_node_caption_here'
orion_node_snmp_pollers:
- name: N.LoadAverage.SNMP.Linux
enabled: true
- name: N.Cpu.SNMP.HrProcessorLoad
enabled: true
- name: N.Memory.SNMP.NetSnmpReal
enabled: true
# Be sure to check out the role README for a full list of variables
roles:
- role: solarwinds.orion.orion_node
solarwinds_server: 127.0.0.1
solarwinds_username: admin
solarwinds_password: changeme2345
orion_node_polling_method: SNMP
orion_node_snmp_version: 2
orion_node_ro_community_string: community
orion_node_discover_interfaces: true
orion_node_volumes:
- /
- /home
- /var/log
# These are the basic pollers for a Linux node
# If you have other pollers enabled, such as Topology Layer 3, you can find a list by adding a node manually,
# then run the following query against the orion database:

# The same can be done for custom pollers, if you have any.
# This query can get a list of Custom Pollers assigned to a node:
# SELECT n.Caption, p.PollerType, p.Enabled
# from Orion.Nodes n
# left join Orion.Pollers as p on p.NetObjectID = n.NodeId
# where n.Caption = 'your_node_caption_here'
orion_node_snmp_pollers:
- name: N.LoadAverage.SNMP.Linux
enabled: true
- name: N.Cpu.SNMP.HrProcessorLoad
enabled: true
- name: N.Memory.SNMP.NetSnmpReal
enabled: true
# The same can be done for custom pollers, if you have any.
# This query can get a list of Custom Pollers assigned to a node:

# SELECT n.Caption, c.CustomPollerName
# from Orion.Nodes n
# left join Orion.NPM.CustomPollerAssignment as c on c.NodeID = n.NodeID
# where n.Caption = 'your_node_caption_here'
# SELECT n.Caption, c.CustomPollerName
# from Orion.Nodes n
# left join Orion.NPM.CustomPollerAssignment as c on c.NodeID = n.NodeID
# where n.Caption = 'your_node_caption_here'

# You can also get a full list of custom pollers available with this query:
# SELECT GroupName, UniqueName
# FROM Orion.NPM.CustomPollers
# Order By GroupName
# You can also get a full list of custom pollers available with this query:
# SELECT GroupName, UniqueName
# FROM Orion.NPM.CustomPollers
# Order By GroupName

roles:
- { role: solarwinds.orion.orion_node }
tasks:
- name: Validate SNMP is polling after node add
solarwinds.orion.orion_node_info:
hostname: "{{ solarwinds_server }}"
username: "{{ solarwinds_user }}"
password: "{{ solarwinds_pass }}"
name: "{{ orion_node_caption }}"
delegate_to: localhost
register: orion_node_info
until: orion_node_info.orion_node.lastsystemuptimepollutc
retries: 6
delay: 5
...
2 changes: 1 addition & 1 deletion plugins/doc_fragments/orion_auth_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ModuleDocFragment(object):
- This argument was introduced in orionsdk 0.4.0 to support connecting to either API.
- If using an older version of Solarwinds with orionsdk 0.4.0, define this as port 17778.
required: false
default: 17774
default: '17774'
type: str
verify:
description:
Expand Down
40 changes: 25 additions & 15 deletions plugins/inventory/orion_nodes_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
description: Hostname of the Solarwinds Orion server.
required: true
type: string
orion_username:
orion_username:
description: Username to Authenticate with Orion Server.
required: true
type: string
Expand All @@ -36,7 +36,7 @@
description: Port to connect to the Solarwinds Information Service API. Only supported if orionsdk >= 0.4.0
required: false
type: string
default: 17774
default: '17774'
verify:
description: Verify SSL Certificate for Solarwinds Information Service API.
required: false
Expand All @@ -57,7 +57,7 @@
hostvar_prefix:
description:
- String to prepend to the Orion.Nodes field name when converting to a host variable.
- E.g. 'hostvar_prefix: orion_' generates variables like 'orion_dns', 'orion_ip_address', 'orion_caption'
- For example I(hostvar_prefix=orion_) generates variables like orion_dns, orion_ip_address, orion_caption
required: false
type: string
default: orion_
Expand All @@ -78,7 +78,7 @@
# It will use that DNS field as the host name
# It will also pull in IP_Address and Caption to create host variables from
# In this environment, the nodes have a custom property 'Server_Environment'
# So we will pull that value and create a host variable,
# So we will pull that value and create a host variable,
# then use the keyed_groups function to turn that value into a group.
---
plugin: solarwinds.orion.orion_nodes_inventory
Expand All @@ -104,16 +104,28 @@
from ansible.module_utils._text import to_text, to_native
from ansible.utils.display import Display
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
from distutils.version import LooseVersion
from ansible.module_utils.six import raise_from
try:
from ansible.module_utils.compat.version import LooseVersion # noqa: F401
except ImportError:
try:
from distutils.version import LooseVersion # noqa: F401
except ImportError as exc:
raise_from(ImportError('To use this plugin or module with ansible-core'
' < 2.11, you need to use Python < 3.12 with '
'distutils.version present'), exc)

display = Display()

# 3rd party imports
try:
import requests
HAS_REQUESTS = True
requests.packages.urllib3.disable_warnings()
except ImportError:
HAS_REQUESTS = False
except Exception:
raise Exception

try:
import orionsdk
Expand All @@ -124,8 +136,6 @@

from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, Constructable

requests.packages.urllib3.disable_warnings()


class InventoryModule(BaseInventoryPlugin, Cacheable, Constructable):
NAME = 'solarwinds.orion.orion_nodes_inventory'
Expand Down Expand Up @@ -155,7 +165,7 @@ def parse(self, inventory, loader, path, cache=True):

self._consume_options(config)
except Exception as e:
raise AnsibleParserError('Failed to consume options: {}'.format(to_native(e)))
raise AnsibleParserError('Failed to consume options: {0}'.format(to_native(e)))

cache_key = self.get_cache_key(path)
update_cache = False
Expand Down Expand Up @@ -210,7 +220,7 @@ def _populate_from_source(self):
inv_hostvars[node_hostname] = node_hostvars
self.add_host(node_hostname, node_hostvars)
except Exception as e:
raise AnsibleParserError('Error iterating over query results: {}'.format(to_native(e)))
raise AnsibleParserError('Error iterating over query results: {0}'.format(to_native(e)))

return inv_hostvars

Expand All @@ -231,20 +241,20 @@ def get_orion_nodes(self):
'username': self.get_option('orion_username'),
'password': orion_password,
'port': self.get_option('orion_port'),
'verify': self.get_option('orion_verify'),
'verify': self.get_option('verify'),
}
__SWIS__ = SwisClient(**swis_options)
__SWIS__.query('SELECT uri FROM Orion.Environment')
except Exception as e:
raise AnsibleError('Failed to connect to Orion database: {}'.format(to_native(e)))
raise AnsibleError('Failed to connect to Orion database: {0}'.format(to_native(e)))

hostname_field = self.get_option('hostname_field')
select_string = "SELECT NodeID, node.{}".format(hostname_field)
select_string = "SELECT NodeID, node.{0}".format(hostname_field)
for hostvar_field in self.get_option('hostvar_fields'):
select_string = select_string + ", node.{}".format(hostvar_field)
select_string = select_string + ", node.{0}".format(hostvar_field)
if self.get_option('hostvar_custom_properties'):
for custom_property in self.get_option('hostvar_custom_properties'):
select_string = select_string + ", custom.{0} as {1}".format(custom_property, custom_property)
select_string = select_string + ", custom.{0} as {0}".format(custom_property)

query = "{0} FROM Orion.Nodes as node ".format(select_string)

Expand All @@ -254,7 +264,7 @@ def get_orion_nodes(self):
if self.get_option('filter'):
query = query + self.get_option('filter')

self.display.vvv('Using query "{}"'.format(to_text(query)))
self.display.vvv('Using query "{0}"'.format(to_text(query)))

results = __SWIS__.query(query)

Expand Down
Loading

0 comments on commit 00be77f

Please sign in to comment.