Commits vergleichen

...

2 Commits

Autor SHA1 Nachricht Datum
Sebastian Tobie c396f6c628 added additional_info parameter 2023-12-10 22:53:35 +01:00
Sebastian Tobie 026f1240ee fixed changelog 2023-12-10 21:42:48 +01:00
6 geänderte Dateien mit 58 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -5,6 +5,27 @@ stop50.ansible-netcup Release Notes
.. contents:: Topics .. contents:: Topics
v0.1.2
======
Release Summary
---------------
added additional_info parameter
Minor Changes
-------------
- added additional_info to the config. this allows addtional data to be added to the inventory
v0.1.1
======
Release Summary
---------------
added nickname_is_hostname config to let the nickname be the hostname of the host
v0.1.0 v0.1.0
====== ======

Datei anzeigen

@ -20,4 +20,4 @@ plugins:
strategy: {} strategy: {}
test: {} test: {}
vars: {} vars: {}
version: 0.1.0 version: 0.1.2

Datei anzeigen

@ -11,3 +11,19 @@ releases:
name: scp name: scp
namespace: null namespace: null
release_date: '2023-11-26' release_date: '2023-11-26'
0.1.1:
changes:
release_summary: added nickname_is_hostname config to let the nickname be the
hostname of the host
fragments:
- scp-hostname.yml
release_date: '2023-12-10'
0.1.2:
changes:
minor_changes:
- added additional_info to the config. this allows addtional data to be added
to the inventory
release_summary: added additional_info parameter
fragments:
- scp-additional_info.yml
release_date: '2023-12-10'

Datei anzeigen

@ -0,0 +1,4 @@
---
release_summary: added additional_info parameter
minor_changes:
- added additional_info to the config. this allows addtional data to be added to the inventory

Datei anzeigen

@ -1,7 +1,7 @@
--- ---
namespace: ansible namespace: ansible
name: netcup name: netcup
version: 0.1.1 version: 0.1.2
readme: README.md readme: README.md
authors: authors:
- Sebastian Tobie - Sebastian Tobie

Datei anzeigen

@ -32,9 +32,11 @@ class InventoryModule(BaseInventoryPlugin):
inventory.add_group("netcup_offline") inventory.add_group("netcup_offline")
inventory.add_child("netcup", "netcup_online") inventory.add_child("netcup", "netcup_online")
inventory.add_child("netcup", "netcup_offline") inventory.add_child("netcup", "netcup_offline")
additional = self.config.get("additional_info", dict())
for hostname in self.service.getVServers(**self.args): for hostname in self.service.getVServers(**self.args):
serverinfo = self.service.getVServerInformation(vservername=hostname, **self.args) serverinfo = self.service.getVServerInformation(vservername=hostname, **self.args)
nickname = serverinfo["vServerNickname"] or serverinfo["vServerName"] nickname = serverinfo["vServerNickname"] or serverinfo["vServerName"]
ai = additional.get(nickname, dict())
group = "netcup_online" group = "netcup_online"
if serverinfo["status"] != "online": if serverinfo["status"] != "online":
group = "netcup_offline" group = "netcup_offline"
@ -43,14 +45,17 @@ class InventoryModule(BaseInventoryPlugin):
else: else:
inventory.add_child(group, nickname) inventory.add_child(group, nickname)
interfaces = dict() interfaces = dict()
ai_interfaces = ai.pop("interfaces", dict())
for interface in serverinfo["serverInterfaces"]: for interface in serverinfo["serverInterfaces"]:
interfaces[interface["mac"]] = dict( interfaces[interface["mac"]] = dict()
interfaces[interface["mac"]].update(
driver=interface["driver"], driver=interface["driver"],
id=interface["id"], id=interface["id"],
ipv4=interface["ipv4IP"], ipv4=interface["ipv4IP"],
ipv6=interface["ipv6IP"], ipv6=interface["ipv6IP"],
mac=interface["mac"], mac=interface["mac"],
) )
interfaces[interface["mac"]].update(ai_interfaces.pop(interface["mac"], dict()))
if len(interface["ipv4IP"]) > 0: if len(interface["ipv4IP"]) > 0:
ansible_host = interface["ipv4IP"][0] ansible_host = interface["ipv4IP"][0]
inventory.set_variable(nickname, "interfaces", interfaces) inventory.set_variable(nickname, "interfaces", interfaces)
@ -58,7 +63,9 @@ class InventoryModule(BaseInventoryPlugin):
inventory.set_variable(nickname, "name", serverinfo["vServerName"]) inventory.set_variable(nickname, "name", serverinfo["vServerName"])
inventory.set_variable(nickname, "cores", serverinfo["cpuCores"]) inventory.set_variable(nickname, "cores", serverinfo["cpuCores"])
inventory.set_variable(nickname, "up", serverinfo["status"] == "online") inventory.set_variable(nickname, "up", serverinfo["status"] == "online")
if self.config.get("nickname_is_hostname", False): if ai.get("ansible_host", False):
ansible_host = ai.pop("ansible_host")
elif self.config.get("nickname_is_hostname", False):
ansible_host = nickname ansible_host = nickname
inventory.set_variable(nickname, "ansible_host", ansible_host) inventory.set_variable(nickname, "ansible_host", ansible_host)
@ -88,4 +95,10 @@ DOCUMENTATION = """
type: bool type: bool
required: false required: false
default: false default: false
additional_info:
version_added: 0.1.2
description:
required: false
default: {}
type: dict
""" """