diff --git a/changelogs/fragments/1483-virt_who_config.yml b/changelogs/fragments/1483-virt_who_config.yml new file mode 100644 index 0000000000..27aca761ef --- /dev/null +++ b/changelogs/fragments/1483-virt_who_config.yml @@ -0,0 +1,2 @@ +minor_changes: + - virt_who_config - add a new module to support virt_who_config (https://github.com/theforeman/foreman-ansible-modules/issues/1483) diff --git a/galaxy.yml b/galaxy.yml index 3e39af5593..a79689d6b4 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -20,6 +20,7 @@ authors: - "Christoffer Reijer " - "Dave Thomas <11580510+dthomastx@users.noreply.github.com>" - "Deric Crago " + - "Dirk Goetz " - "Eric D. Helms " - "Eric L " - "Ethan " diff --git a/meta/runtime.yml b/meta/runtime.yml index 9e34e240ec..0db3a05768 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -80,6 +80,7 @@ action_groups: - templates_import - user - usergroup + - virt_who_config - wait_for_task plugin_routing: modules: diff --git a/plugins/modules/virt_who_config.py b/plugins/modules/virt_who_config.py new file mode 100644 index 0000000000..5677735e2a --- /dev/null +++ b/plugins/modules/virt_who_config.py @@ -0,0 +1,222 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: virt_who_config +version_added: 3.15.0 +short_description: Manage Virt Who Configs +description: + - Manage Virt Who Configs +author: + - "Dirk Goetz (@dgoetz)" +options: + name: + description: + - The name of the Virt Who Configuration + type: str + required: true + interval: + description: + - The interval to run Virt Who + choices: + - 60 + - 120 + - 240 + - 480 + - 720 + - 1440 + - 2880 + - 4320 + type: int + required: true + filtering_mode: + description: + - The filtering mode for Hypervisors + - 0 means no filtering, 1 means whitelist, 2 means blacklist + choices: + - 0 + - 1 + - 2 + type: int + required: true + whitelist: + description: + - Hypervisor whitelist, applicable only when filtering mode is set to 1 + - Wildcards and regular expressions are supported, multiple records must be separated by comma + type: str + blacklist: + description: + - Hypervisor blacklist, applicable only when filtering mode is set to 2 + - Wildcards and regular expressions are supported, multiple records must be separated by comma + type: str + filter_host_parents: + description: + - Applicable only for esx provider type + - Only hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will be reported + - Wildcards and regular expressions are supported, multiple records must be separated by comma + - Put the value into the double-quotes if it contains special characters like comma + - All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end + type: str + exclude_host_parents: + description: + - Applicable only for esx provider type + - Hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will NOT be reported + - Wildcards and regular expressions are supported, multiple records must be separated by comma + - Put the value into the double-quotes if it contains special characters like comma + - All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end + type: str + hypervisor_id: + description: + - Specifies how the hypervisor will be identified + choices: + - hostname + - uuid + - hwuuid + type: str + required: true + hypervisor_type: + description: + - Hypervisor type + choices: + - esx + - hyperv + - libvirt + - kubevirt + - ahv + type: str + required: true + hypervisor_server: + description: + - Fully qualified host name or IP address of the hypervisor + type: str + hypervisor_username: + description: + - Account name by which virt-who is to connect to the hypervisor + type: str + hypervisor_password: + description: + - Hypervisor password, required for all hypervisor types except for libvirt/kubevirt + type: str + satellite_url: + description: + - Foreman server FQDN + type: str + required: true + debug: + description: + - Enable debugging output + type: bool + kubeconfig_path: + description: + - Configuration file containing details about how to connect to the cluster and authentication details + type: str + http_proxy_id: + description: + - HTTP proxy that should be used for communication between the server on which virt-who is running and the hypervisors and virtualization managers + type: str + no_proxy: + description: + - A comma-separated list of hostnames or domains or ip addresses to ignore proxy settings for + - Optionally this may be set to * to bypass proxy settings for all hostnames domains or ip addresses + type: str + prism_flavor: + description: + - Select the Prism flavor you are connecting to + choices: + - central + - element + type: str + ahv_internal_debug: + description: + - Enable debugging output is required to enable AHV internal debug + - It provides extra AHV debug information when both options are enabled + type: bool +extends_documentation_fragment: + - theforeman.foreman.foreman + - theforeman.foreman.foreman.organization + - theforeman.foreman.foreman.entity_state +''' + +EXAMPLES = ''' +- name: "Create a Virt Who Configuration" + theforeman.foreman.virt_who_config: + username: "admin" + password: "changeme" + server_url: "https://foreman.example.com" + organization: "Default Organization" + name: "A Virt Who Configuration" + interval: 120 + filtering_mode: 0 + hypervisor_id: "hostname" + hypervisor_type: "libvirt" + satellite_url: "foreman.example.com" + state: "present" +''' + +RETURN = ''' +entity: + description: Final state of the affected entities grouped by their type. + returned: success + type: dict + contains: + activation_keys: + description: List of Virt Who Configs + type: list + elements: dict +''' + + +from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import KatelloEntityAnsibleModule + + +class KatelloConfigModule(KatelloEntityAnsibleModule): + pass + + +def main(): + module = KatelloConfigModule( + foreman_spec=dict( + name=dict(required=True), + interval=dict(required=True, type='int', choices=[60, 120, 240, 480, 720, 1440, 2880, 4320]), + filtering_mode=dict(required=True, type='int', choices=[0, 1, 2]), + whitelist=dict(), + blacklist=dict(), + filter_host_parents=dict(), + exclude_host_parents=dict(), + hypervisor_id=dict(required=True, choices=['hostname', 'uuid', 'hwuuid']), + hypervisor_type=dict(required=True, choices=['esx', 'hyperv', 'libvirt', 'kubevirt', 'ahv']), + hypervisor_server=dict(), + hypervisor_username=dict(), + hypervisor_password=dict(no_log=True), + satellite_url=dict(required=True), + debug=dict(type='bool'), + kubeconfig_path=dict(), + http_proxy_id=dict(type='entity', resource_type='http_proxies', scope=['organization']), + no_proxy=dict(), + prism_flavor=dict(choices=['central', 'element']), + ahv_internal_debug=dict(type='bool'), + ), + ) + with module.api_connection(): + module.run() + + +if __name__ == '__main__': + main() diff --git a/tests/fixtures/apidoc/virt_who_config.json b/tests/fixtures/apidoc/virt_who_config.json new file mode 100644 index 0000000000..e1c9baf7ae --- /dev/null +++ b/tests/fixtures/apidoc/virt_who_config.json @@ -0,0 +1 @@ +{"docs":{"name":"Foreman","info":"\n\u003cp\u003eForeman API v2 is currently the default API version.\u003c/p\u003e\n","copyright":"","doc_url":"../../apidoc/v2","api_url":"/api","resources":[{"doc_url":"../../apidoc/v2/configs","id":"configs","api_url":"/api","name":"Configs","short_description":null,"full_description":"","version":"v2","formats":null,"metadata":null,"methods":[{"doc_url":"../../apidoc/v2/configs/index","name":"index","apis":[{"api_url":"/foreman_virt_who_configure/api/v2/configs","http_method":"GET","short_description":"List of virt-who configurations","deprecated":null},{"api_url":"/foreman_virt_who_configure/api/v2/organizations/:organization_id/configs","http_method":"GET","short_description":"List of virt-who configurations per organization","deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"location_id","full_name":"location_id","description":"\n\u003cp\u003eSet the current location context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"organization_id","description":"\n\u003cp\u003eSet the current organization context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"search","full_name":"search","description":"\n\u003cp\u003efilter results\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"order","full_name":"order","description":"\n\u003cp\u003eSort and order by a searchable field, e.g. \u0026#39;\u0026lt;field\u0026gt; DESC\u0026#39;\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"page","full_name":"page","description":"\n\u003cp\u003ePage number, starting at 1\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Must be a number.","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"per_page","full_name":"per_page","description":"\n\u003cp\u003eNumber of results per page to return, \u0026#39;all\u0026#39; to return all results\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Must match regular expression \u003ccode\u003e/\\A([1-9]\\d*|all)\\Z$/\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false}],"returns":[],"examples":[],"metadata":null,"see":[],"headers":[],"show":true},{"doc_url":"../../apidoc/v2/configs/show","name":"show","apis":[{"api_url":"/foreman_virt_who_configure/api/v2/configs/:id","http_method":"GET","short_description":"Show a virt-who configuration","deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"location_id","full_name":"location_id","description":"\n\u003cp\u003eSet the current location context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"organization_id","description":"\n\u003cp\u003eSet the current organization context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"id","full_name":"id","description":"","required":true,"allow_nil":false,"allow_blank":false,"validator":"string from 2 to 128 characters containing only alphanumeric characters, space, '_', '-' with no leading or trailing space..","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false}],"returns":[],"examples":[],"metadata":null,"see":[],"headers":[],"show":true},{"doc_url":"../../apidoc/v2/configs/deploy_script","name":"deploy_script","apis":[{"api_url":"/foreman_virt_who_configure/api/v2/configs/:id/deploy_script","http_method":"GET","short_description":"Renders a deploy script for the specified virt-who configuration","deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"location_id","full_name":"location_id","description":"\n\u003cp\u003eSet the current location context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"organization_id","description":"\n\u003cp\u003eSet the current organization context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"id","full_name":"id","description":"","required":true,"allow_nil":false,"allow_blank":false,"validator":"string from 2 to 128 characters containing only alphanumeric characters, space, '_', '-' with no leading or trailing space..","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false}],"returns":[],"examples":[],"metadata":null,"see":[],"headers":[],"show":true},{"doc_url":"../../apidoc/v2/configs/create","name":"create","apis":[{"api_url":"/foreman_virt_who_configure/api/v2/configs","http_method":"POST","short_description":"Create a virt-who configuration","deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"location_id","full_name":"location_id","description":"\n\u003cp\u003eSet the current location context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"organization_id","description":"\n\u003cp\u003eSet the current organization context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"foreman_virt_who_configure_config","full_name":"foreman_virt_who_configure_config","description":"","required":true,"allow_nil":false,"allow_blank":false,"validator":"Hash","expected_type":"hash","metadata":null,"show":true,"validations":[],"deprecated":false,"params":[{"name":"name","full_name":"foreman_virt_who_configure_config[name]","description":"\n\u003cp\u003eConfiguration name\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"interval","full_name":"foreman_virt_who_configure_config[interval]","description":"\n\u003cp\u003eConfiguration interval in minutes\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003e60\u003c/code\u003e, \u003ccode\u003e120\u003c/code\u003e, \u003ccode\u003e240\u003c/code\u003e, \u003ccode\u003e480\u003c/code\u003e, \u003ccode\u003e720\u003c/code\u003e, \u003ccode\u003e1440\u003c/code\u003e, \u003ccode\u003e2880\u003c/code\u003e, \u003ccode\u003e4320\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"filtering_mode","full_name":"foreman_virt_who_configure_config[filtering_mode]","description":"\n\u003cp\u003eHypervisor filtering mode, 0 means no filtering, 1 means whitelist, 2 means blacklist\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003e0\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e2\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"whitelist","full_name":"foreman_virt_who_configure_config[whitelist]","description":"\n\u003cp\u003eHypervisor whitelist, applicable only when filtering mode is set to 1. Wildcards and regular expressions are supported, multiple records must be separated by comma.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"blacklist","full_name":"foreman_virt_who_configure_config[blacklist]","description":"\n\u003cp\u003eHypervisor blacklist, applicable only when filtering mode is set to 2. Wildcards and regular expressions are supported, multiple records must be separated by comma.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"filter_host_parents","full_name":"foreman_virt_who_configure_config[filter_host_parents]","description":"\n\u003cp\u003eApplicable only for esx provider type. Only hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will be reported. Wildcards and regular expressions are supported, multiple records must be separated by comma. Put the value into the double-quotes if it contains special characters like comma. All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"exclude_host_parents","full_name":"foreman_virt_who_configure_config[exclude_host_parents]","description":"\n\u003cp\u003eApplicable only for esx provider type. Hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will \u003cstrong\u003eNOT\u003c/strong\u003e be reported. Wildcards and regular expressions are supported, multiple records must be separated by comma. Put the value into the double-quotes if it contains special characters like comma. All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_id","full_name":"foreman_virt_who_configure_config[hypervisor_id]","description":"\n\u003cp\u003eSpecifies how the hypervisor will be identified.\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003ehostname\u003c/code\u003e, \u003ccode\u003euuid\u003c/code\u003e, \u003ccode\u003ehwuuid\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_type","full_name":"foreman_virt_who_configure_config[hypervisor_type]","description":"\n\u003cp\u003eHypervisor type\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003eesx\u003c/code\u003e, \u003ccode\u003ehyperv\u003c/code\u003e, \u003ccode\u003elibvirt\u003c/code\u003e, \u003ccode\u003ekubevirt\u003c/code\u003e, \u003ccode\u003eahv\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_server","full_name":"foreman_virt_who_configure_config[hypervisor_server]","description":"\n\u003cp\u003eFully qualified host name or IP address of the hypervisor\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_username","full_name":"foreman_virt_who_configure_config[hypervisor_username]","description":"\n\u003cp\u003eAccount name by which virt-who is to connect to the hypervisor.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_password","full_name":"foreman_virt_who_configure_config[hypervisor_password]","description":"\n\u003cp\u003eHypervisor password, required for all hypervisor types except for libvirt/kubevirt.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"satellite_url","full_name":"foreman_virt_who_configure_config[satellite_url]","description":"\n\u003cp\u003eForeman server FQDN\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"debug","full_name":"foreman_virt_who_configure_config[debug]","description":"\n\u003cp\u003eEnable debugging output\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003etrue\u003c/code\u003e, \u003ccode\u003efalse\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e0\u003c/code\u003e.","expected_type":"boolean","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"kubeconfig_path","full_name":"foreman_virt_who_configure_config[kubeconfig_path]","description":"\n\u003cp\u003eConfiguration file containing details about how to connect to the cluster and authentication details.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"http_proxy_id","full_name":"foreman_virt_who_configure_config[http_proxy_id]","description":"\n\u003cp\u003eHTTP proxy that should be used for communication between the server on which virt-who is running and the hypervisors and virtualization managers.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"no_proxy","full_name":"foreman_virt_who_configure_config[no_proxy]","description":"\n\u003cp\u003eIgnore proxy. A comma-separated list of hostnames or domains or ip addresses to ignore proxy settings for. Optionally this may be set to * to bypass proxy settings for all hostnames domains or ip addresses.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"foreman_virt_who_configure_config[organization_id]","description":"\n\u003cp\u003eOrganization of the virt-who configuration\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"prism_flavor","full_name":"foreman_virt_who_configure_config[prism_flavor]","description":"\n\u003cp\u003eSelect the Prism flavor you are connecting to\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003ecentral\u003c/code\u003e, \u003ccode\u003eelement\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"ahv_internal_debug","full_name":"foreman_virt_who_configure_config[ahv_internal_debug]","description":"\n\u003cp\u003eOption Enable debugging output is required to enable AHV internal debug. It provides extra AHV debug information when both options are enabled\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003etrue\u003c/code\u003e, \u003ccode\u003efalse\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e0\u003c/code\u003e.","expected_type":"boolean","metadata":null,"show":true,"validations":[],"deprecated":false}]}],"returns":[],"examples":[],"metadata":null,"see":[],"headers":[],"show":true},{"doc_url":"../../apidoc/v2/configs/update","name":"update","apis":[{"api_url":"/foreman_virt_who_configure/api/v2/configs/:id","http_method":"PUT","short_description":"Update a virt-who configuration","deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"location_id","full_name":"location_id","description":"\n\u003cp\u003eSet the current location context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"organization_id","description":"\n\u003cp\u003eSet the current organization context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"id","full_name":"id","description":"\n\u003cp\u003eConfiguration numeric identifier\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Must be a number.","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"foreman_virt_who_configure_config","full_name":"foreman_virt_who_configure_config","description":"","required":true,"allow_nil":false,"allow_blank":false,"validator":"Hash","expected_type":"hash","metadata":null,"show":true,"validations":[],"deprecated":false,"params":[{"name":"name","full_name":"foreman_virt_who_configure_config[name]","description":"\n\u003cp\u003eConfiguration name\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"interval","full_name":"foreman_virt_who_configure_config[interval]","description":"\n\u003cp\u003eConfiguration interval in minutes\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003e60\u003c/code\u003e, \u003ccode\u003e120\u003c/code\u003e, \u003ccode\u003e240\u003c/code\u003e, \u003ccode\u003e480\u003c/code\u003e, \u003ccode\u003e720\u003c/code\u003e, \u003ccode\u003e1440\u003c/code\u003e, \u003ccode\u003e2880\u003c/code\u003e, \u003ccode\u003e4320\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"filtering_mode","full_name":"foreman_virt_who_configure_config[filtering_mode]","description":"\n\u003cp\u003eHypervisor filtering mode, 0 means no filtering, 1 means whitelist, 2 means blacklist\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003e0\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e2\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"whitelist","full_name":"foreman_virt_who_configure_config[whitelist]","description":"\n\u003cp\u003eHypervisor whitelist, applicable only when filtering mode is set to 1. Wildcards and regular expressions are supported, multiple records must be separated by comma.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"blacklist","full_name":"foreman_virt_who_configure_config[blacklist]","description":"\n\u003cp\u003eHypervisor blacklist, applicable only when filtering mode is set to 2. Wildcards and regular expressions are supported, multiple records must be separated by comma.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"filter_host_parents","full_name":"foreman_virt_who_configure_config[filter_host_parents]","description":"\n\u003cp\u003eApplicable only for esx provider type. Only hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will be reported. Wildcards and regular expressions are supported, multiple records must be separated by comma. Put the value into the double-quotes if it contains special characters like comma. All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"exclude_host_parents","full_name":"foreman_virt_who_configure_config[exclude_host_parents]","description":"\n\u003cp\u003eApplicable only for esx provider type. Hosts which parent (usually ComputeResource) name is specified in comma-separated list in this option will \u003cstrong\u003eNOT\u003c/strong\u003e be reported. Wildcards and regular expressions are supported, multiple records must be separated by comma. Put the value into the double-quotes if it contains special characters like comma. All new line characters will be removed in resulting configuration file, white spaces are removed from beginning and end.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_id","full_name":"foreman_virt_who_configure_config[hypervisor_id]","description":"\n\u003cp\u003eSpecifies how the hypervisor will be identified.\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003ehostname\u003c/code\u003e, \u003ccode\u003euuid\u003c/code\u003e, \u003ccode\u003ehwuuid\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_type","full_name":"foreman_virt_who_configure_config[hypervisor_type]","description":"\n\u003cp\u003eHypervisor type\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003eesx\u003c/code\u003e, \u003ccode\u003ehyperv\u003c/code\u003e, \u003ccode\u003elibvirt\u003c/code\u003e, \u003ccode\u003ekubevirt\u003c/code\u003e, \u003ccode\u003eahv\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_server","full_name":"foreman_virt_who_configure_config[hypervisor_server]","description":"\n\u003cp\u003eFully qualified host name or IP address of the hypervisor\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_username","full_name":"foreman_virt_who_configure_config[hypervisor_username]","description":"\n\u003cp\u003eAccount name by which virt-who is to connect to the hypervisor.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"hypervisor_password","full_name":"foreman_virt_who_configure_config[hypervisor_password]","description":"\n\u003cp\u003eHypervisor password, required for all hypervisor types except for libvirt/kubevirt.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"satellite_url","full_name":"foreman_virt_who_configure_config[satellite_url]","description":"\n\u003cp\u003eForeman server FQDN\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"debug","full_name":"foreman_virt_who_configure_config[debug]","description":"\n\u003cp\u003eEnable debugging output\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003etrue\u003c/code\u003e, \u003ccode\u003efalse\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e0\u003c/code\u003e.","expected_type":"boolean","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"kubeconfig_path","full_name":"foreman_virt_who_configure_config[kubeconfig_path]","description":"\n\u003cp\u003eConfiguration file containing details about how to connect to the cluster and authentication details.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"http_proxy_id","full_name":"foreman_virt_who_configure_config[http_proxy_id]","description":"\n\u003cp\u003eHTTP proxy that should be used for communication between the server on which virt-who is running and the hypervisors and virtualization managers.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"no_proxy","full_name":"foreman_virt_who_configure_config[no_proxy]","description":"\n\u003cp\u003eIgnore proxy. A comma-separated list of hostnames or domains or ip addresses to ignore proxy settings for. Optionally this may be set to * to bypass proxy settings for all hostnames domains or ip addresses.\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"String","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"foreman_virt_who_configure_config[organization_id]","description":"\n\u003cp\u003eOrganization of the virt-who configuration\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"prism_flavor","full_name":"foreman_virt_who_configure_config[prism_flavor]","description":"\n\u003cp\u003eSelect the Prism flavor you are connecting to\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003ecentral\u003c/code\u003e, \u003ccode\u003eelement\u003c/code\u003e.","expected_type":"string","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"ahv_internal_debug","full_name":"foreman_virt_who_configure_config[ahv_internal_debug]","description":"\n\u003cp\u003eOption Enable debugging output is required to enable AHV internal debug. It provides extra AHV debug information when both options are enabled\u003c/p\u003e\n","required":false,"allow_nil":true,"allow_blank":false,"validator":"Must be one of: \u003ccode\u003etrue\u003c/code\u003e, \u003ccode\u003efalse\u003c/code\u003e, \u003ccode\u003e1\u003c/code\u003e, \u003ccode\u003e0\u003c/code\u003e.","expected_type":"boolean","metadata":null,"show":true,"validations":[],"deprecated":false}]}],"returns":[],"examples":[],"metadata":null,"see":[],"headers":[],"show":true},{"doc_url":"../../apidoc/v2/configs/destroy","name":"destroy","apis":[{"api_url":"/foreman_virt_who_configure/api/v2/configs/:id","http_method":"DELETE","short_description":"Delete a virt-who configuration","deprecated":null}],"formats":null,"full_description":"","errors":[],"params":[{"name":"location_id","full_name":"location_id","description":"\n\u003cp\u003eSet the current location context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"organization_id","full_name":"organization_id","description":"\n\u003cp\u003eSet the current organization context for the request\u003c/p\u003e\n","required":false,"allow_nil":false,"allow_blank":false,"validator":"Integer","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false},{"name":"id","full_name":"id","description":"\n\u003cp\u003eConfiguration numeric identifier\u003c/p\u003e\n","required":true,"allow_nil":false,"allow_blank":false,"validator":"Must be a number.","expected_type":"numeric","metadata":null,"show":true,"validations":[],"deprecated":false}],"returns":[],"examples":[],"metadata":null,"see":[],"headers":[],"show":true}],"headers":[],"deprecated":false}],"link_extension":".html"}} \ No newline at end of file diff --git a/tests/test_playbooks/tasks/virt_who_config.yml b/tests/test_playbooks/tasks/virt_who_config.yml new file mode 100644 index 0000000000..c386f825b5 --- /dev/null +++ b/tests/test_playbooks/tasks/virt_who_config.yml @@ -0,0 +1,27 @@ +--- +- name: "Create/update Virt Who config" + vars: + virt_who_config_name: "Test Virt Who config" + virt_who_config_state: "present" + virt_who_config_organization: "Test Organization" + virt_who_config: + username: "{{ foreman_username }}" + password: "{{ foreman_password }}" + server_url: "{{ foreman_server_url }}" + organization: "{{ virt_who_config_organization }}" + name: "{{ virt_who_config_name }}" + interval: "{{ virt_who_config_interval | default(120) }}" + filtering_mode: "{{ virt_who_config_filtering_mode | default(0) }}" + hypervisor_id: "{{ virt_who_config_hypervisor_id | default('hostname') }}" + hypervisor_type: "{{ virt_who_config_hypervisor_type | default('libvirt') }}" + satellite_url: "{{ virt_who_config_satellite_url | default('foreman.example.com') }}" + state: "{{ virt_who_config_organization }}" +- assert: + fail_msg: "Creating/updating Virt Who config failed! (expected_change: {{ expected_change | default('unknown') }})" + that: + - result.changed == expected_change + when: expected_change is defined +- include_tasks: _assert_diff.yml + vars: + module: virt_who_config +... diff --git a/tests/test_playbooks/virt_who_config.yml b/tests/test_playbooks/virt_who_config.yml new file mode 100644 index 0000000000..1d76a11f33 --- /dev/null +++ b/tests/test_playbooks/virt_who_config.yml @@ -0,0 +1,9 @@ +--- +- hosts: localhost + collections: + - theforeman.foreman + gather_facts: false + vars_files: + - vars/server.yml + tasks: + - include_tasks: tasks/virt_who_config.yml