refactor: rework ci and testing #3

Merged
xoxys merged 14 commits from refactor-ci into main 2023-01-31 19:09:30 +00:00
4 changed files with 73 additions and 71 deletions
Showing only changes of commit ffa15a72a3 - Show all commits

View File

@ -9,73 +9,73 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = """ DOCUMENTATION = """
--- name: proxmox
name: proxmox plugin_type: inventory
plugin_type: inventory short_description: Proxmox VE inventory source
short_description: Proxmox VE inventory source version_added: 1.1.0
version_added: 1.1.0
description:
- Get inventory hosts from the proxmox service.
- "Uses a configuration file as an inventory source, it must end in C(.proxmox.yml) or C(.proxmox.yaml) and has a C(plugin: xoxys.general.proxmox) entry."
extends_documentation_fragment:
- inventory_cache
options:
plugin:
description: The name of this plugin, it should always be set to C(xoxys.general.proxmox) for this plugin to recognize it as it's own.
required: yes
choices: ["xoxys.general.proxmox"]
api_host:
description: description:
- Specify the target host of the Proxmox VE cluster. - Get inventory hosts from the proxmox service.
type: str - "Uses a configuration file as an inventory source, it must end in C(.proxmox.yml) or C(.proxmox.yaml) and has a C(plugin: xoxys.general.proxmox) entry."
required: true extends_documentation_fragment:
api_user: - inventory_cache
description: options:
- Specify the user to authenticate with. plugin:
type: str description: The name of this plugin, it should always be set to C(xoxys.general.proxmox) for this plugin to recognize it as it's own.
required: true required: yes
api_password: choices: ["xoxys.general.proxmox"]
description: api_host:
- Specify the password to authenticate with. description:
- You can use C(PROXMOX_PASSWORD) environment variable. - Specify the target host of the Proxmox VE cluster.
type: str type: str
api_token_id: required: true
description: api_user:
- Specify the token ID. description:
type: str - Specify the user to authenticate with.
api_token_secret: type: str
description: required: true
- Specify the token secret. api_password:
type: str description:
verify_ssl: - Specify the password to authenticate with.
description: - You can use C(PROXMOX_PASSWORD) environment variable.
- If C(false), SSL certificates will not be validated. type: str
- This should only be used on personally controlled sites using self-signed certificates. api_token_id:
type: bool description:
default: True - Specify the token ID.
auth_timeout: type: str
description: Proxmox VE authentication timeout. api_token_secret:
type: int description:
default: 5 - Specify the token secret.
exclude_vmid: type: str
description: VMID's to exclude from inventory. verify_ssl:
type: list description:
default: [] - If C(false), SSL certificates will not be validated.
elements: str - This should only be used on personally controlled sites using self-signed certificates.
exclude_state: type: bool
description: VM states to exclude from inventory. default: True
type: list auth_timeout:
default: [] description: Proxmox VE authentication timeout.
elements: str type: int
group: default: 5
description: Group to place all hosts into. exclude_vmid:
type: string description: VMID's to exclude from inventory.
default: proxmox type: list
want_facts: default: []
description: Toggle, if C(true) the plugin will retrieve host facts from the server elements: str
type: boolean exclude_state:
default: True description: VM states to exclude from inventory.
type: list
default: []
elements: str
group:
description: Group to place all hosts into.
type: string
default: proxmox
want_facts:
description: Toggle, if C(true) the plugin will retrieve host facts from the server
type: boolean
default: True
requirements:
- "proxmoxer"
""" # noqa """ # noqa
EXAMPLES = """ EXAMPLES = """
@ -187,7 +187,7 @@ class InventoryModule(BaseInventoryPlugin):
except Exception: # noqa except Exception: # noqa
pass pass
if networks and type(networks) is list: if networks and isinstance(networks, list):
for network in networks: for network in networks:
for ip_address in network["ip-addresses"]: for ip_address in network["ip-addresses"]:
address = validate(ip_address["ip-address"]) address = validate(ip_address["ip-address"])

View File

@ -78,6 +78,7 @@ options:
C(-P)/C(--policy) to specify rules." C(-P)/C(--policy) to specify rules."
required: false required: false
type: str type: str
default: ""
state: state:
description: description:
- The state this rules fragment should be in. - The state this rules fragment should be in.

View File

@ -955,18 +955,18 @@ def create_vm(
# If update, ensure existing disks are not recreated. # If update, ensure existing disks are not recreated.
if update: if update:
for k, _v in disks.items(): for k, v in disks.items():
if results["disks"].get(k): if results["disks"].get(k):
storage_id = results["disks"][k]["storage_id"] storage_id = results["disks"][k]["storage_id"]
storage_opts = results["disks"][k]["storage_opts"] storage_opts = results["disks"][k]["storage_opts"]
opts = ",".join(disks[k]["opts"]) opts = ",".join(v["opts"])
kwargs[k.rstrip(string.digits)][k] = f"{storage_id}:{storage_opts},{opts}" kwargs[k.rstrip(string.digits)][k] = f"{storage_id}:{storage_opts},{opts}"
for k, _v in nets.items(): for k, v in nets.items():
if results["nets"].get(k): if results["nets"].get(k):
net_id = results["nets"][k]["net_id"] net_id = results["nets"][k]["net_id"]
net_opts = results["nets"][k]["net_opts"] net_opts = results["nets"][k]["net_opts"]
opts = ",".join(nets[k]["opts"]) opts = ",".join(v["opts"])
kwargs[k.rstrip(string.digits)][k] = f"{net_id}={net_opts},{opts}" kwargs[k.rstrip(string.digits)][k] = f"{net_id}={net_opts},{opts}"
# Convert all dict in kwargs to elements. # Convert all dict in kwargs to elements.

View File

@ -31,6 +31,7 @@ options:
- New value of the variable - New value of the variable
required: False required: False
type: str type: str
default: ""
state: state:
required: False required: False
default: "present" default: "present"