From ffa15a72a32e263ce74e2cd7e8d138d86a544ff6 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 30 Jan 2023 22:32:03 +0100 Subject: [PATCH] fix ansible-test sanity errors --- plugins/inventory/proxmox.py | 134 ++++++++++++++++---------------- plugins/modules/iptables_raw.py | 1 + plugins/modules/proxmox_kvm.py | 8 +- plugins/modules/ucr.py | 1 + 4 files changed, 73 insertions(+), 71 deletions(-) diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index c813300..a7068fc 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -9,73 +9,73 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type DOCUMENTATION = """ ---- -name: proxmox -plugin_type: inventory -short_description: Proxmox VE inventory source -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: + name: proxmox + plugin_type: inventory + short_description: Proxmox VE inventory source + version_added: 1.1.0 description: - - Specify the target host of the Proxmox VE cluster. - type: str - required: true - api_user: - description: - - Specify the user to authenticate with. - type: str - required: true - api_password: - description: - - Specify the password to authenticate with. - - You can use C(PROXMOX_PASSWORD) environment variable. - type: str - api_token_id: - description: - - Specify the token ID. - type: str - api_token_secret: - description: - - Specify the token secret. - type: str - verify_ssl: - description: - - If C(false), SSL certificates will not be validated. - - This should only be used on personally controlled sites using self-signed certificates. - type: bool - default: True - auth_timeout: - description: Proxmox VE authentication timeout. - type: int - default: 5 - exclude_vmid: - description: VMID's to exclude from inventory. - type: list - default: [] - elements: str - exclude_state: - 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 - + - 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: + - Specify the target host of the Proxmox VE cluster. + type: str + required: true + api_user: + description: + - Specify the user to authenticate with. + type: str + required: true + api_password: + description: + - Specify the password to authenticate with. + - You can use C(PROXMOX_PASSWORD) environment variable. + type: str + api_token_id: + description: + - Specify the token ID. + type: str + api_token_secret: + description: + - Specify the token secret. + type: str + verify_ssl: + description: + - If C(false), SSL certificates will not be validated. + - This should only be used on personally controlled sites using self-signed certificates. + type: bool + default: True + auth_timeout: + description: Proxmox VE authentication timeout. + type: int + default: 5 + exclude_vmid: + description: VMID's to exclude from inventory. + type: list + default: [] + elements: str + exclude_state: + 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 EXAMPLES = """ @@ -187,7 +187,7 @@ class InventoryModule(BaseInventoryPlugin): except Exception: # noqa pass - if networks and type(networks) is list: + if networks and isinstance(networks, list): for network in networks: for ip_address in network["ip-addresses"]: address = validate(ip_address["ip-address"]) diff --git a/plugins/modules/iptables_raw.py b/plugins/modules/iptables_raw.py index 586fc66..5f0b160 100644 --- a/plugins/modules/iptables_raw.py +++ b/plugins/modules/iptables_raw.py @@ -78,6 +78,7 @@ options: C(-P)/C(--policy) to specify rules." required: false type: str + default: "" state: description: - The state this rules fragment should be in. diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index 75998cc..e7cb082 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -955,18 +955,18 @@ def create_vm( # If update, ensure existing disks are not recreated. if update: - for k, _v in disks.items(): + for k, v in disks.items(): if results["disks"].get(k): storage_id = results["disks"][k]["storage_id"] 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}" - for k, _v in nets.items(): + for k, v in nets.items(): if results["nets"].get(k): net_id = results["nets"][k]["net_id"] 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}" # Convert all dict in kwargs to elements. diff --git a/plugins/modules/ucr.py b/plugins/modules/ucr.py index 5d5dfaf..522d255 100644 --- a/plugins/modules/ucr.py +++ b/plugins/modules/ucr.py @@ -31,6 +31,7 @@ options: - New value of the variable required: False type: str + default: "" state: required: False default: "present"