added new option and changed the format of the interfaces
Dieser Commit ist enthalten in:
Ursprung
0384f7c17e
Commit
333a906f05
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
release_summary: added nickname_is_hostname config to let the nickname be the hostname of the host
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
namespace: ansible
|
||||
name: netcup
|
||||
version: 0.1.0
|
||||
version: 0.1.1
|
||||
readme: README.md
|
||||
authors:
|
||||
- Sebastian Tobie
|
||||
|
|
|
@ -42,22 +42,25 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
inventory.add_host(nickname, group)
|
||||
else:
|
||||
inventory.add_child(group, nickname)
|
||||
interfaces = []
|
||||
interfaces = dict()
|
||||
for interface in serverinfo["serverInterfaces"]:
|
||||
interfaces.append(
|
||||
dict(
|
||||
driver=interface["driver"],
|
||||
id=interface["id"],
|
||||
ipv4=interface["ipv4IP"],
|
||||
ipv6=interface["ipv6IP"],
|
||||
mac=interface["mac"],
|
||||
)
|
||||
interfaces[interface["mac"]] = dict(
|
||||
driver=interface["driver"],
|
||||
id=interface["id"],
|
||||
ipv4=interface["ipv4IP"],
|
||||
ipv6=interface["ipv6IP"],
|
||||
mac=interface["mac"],
|
||||
)
|
||||
if len(interface["ipv4IP"]) > 0:
|
||||
ansible_host = interface["ipv4IP"][0]
|
||||
inventory.set_variable(nickname, "interfaces", interfaces)
|
||||
inventory.set_variable(nickname, "memory", serverinfo["memory"])
|
||||
inventory.set_variable(nickname, "name", serverinfo["vServerName"])
|
||||
inventory.set_variable(nickname, "cores", serverinfo["cpuCores"])
|
||||
inventory.set_variable(nickname, "up", serverinfo["status"] == "online")
|
||||
if self.config.get("nickname_is_hostname", False):
|
||||
ansible_host = nickname
|
||||
inventory.set_variable(nickname, "ansible_host", ansible_host)
|
||||
|
||||
|
||||
DOCUMENTATION = """
|
||||
|
@ -79,4 +82,10 @@ DOCUMENTATION = """
|
|||
- API password to authenticate againt the api.
|
||||
- This is different from you SCP password and must be set indipendently from the SCP password
|
||||
required: true
|
||||
nickname_is_hostname:
|
||||
version_added: 0.1.1
|
||||
description: use the nickname as hostname
|
||||
type: bool
|
||||
required: false
|
||||
default: false
|
||||
"""
|
||||
|
|
Laden…
In neuem Issue referenzieren