mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
* proxmox: create a common base
Add a doc_fragment to share the documentation regarding authentication
parameters (api_host, api_user, api_password, api_token_id,
api_token_secret as well as the lone validate_certs).
Add a module_utils to hold common code such as the argument spec (again
related to authentication paramters), a helper function to convert from
Proxmox boolean representation to python and the base class
ProxmoxAnsible.
For now it only handles the connection to Proxmox VE API but more can be
added in the future.
To check if everything is well in place add three new modules:
proxmox_{domain,group,user}_info.
And finaly tests these new modules.
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Add tests/integration/targets/proxmox/aliases
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 51a08ea398
)
Co-authored-by: Tristan Le Guern <tleguern@bouledef.eu>
This commit is contained in:
parent
b1d1391be5
commit
d5c24e67e8
11 changed files with 784 additions and 0 deletions
4
tests/integration/targets/proxmox/aliases
Normal file
4
tests/integration/targets/proxmox/aliases
Normal file
|
@ -0,0 +1,4 @@
|
|||
unsupported
|
||||
proxmox_domain_info
|
||||
proxmox_group_info
|
||||
proxmox_user_info
|
111
tests/integration/targets/proxmox/tasks/main.yml
Normal file
111
tests/integration/targets/proxmox/tasks/main.yml
Normal file
|
@ -0,0 +1,111 @@
|
|||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# Copyright: (c) 2020, Tristan Le Guern <tleguern at bouledef.eu>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: List domains
|
||||
proxmox_domain_info:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is not changed
|
||||
- results.proxmox_domains is defined
|
||||
|
||||
- name: Retrieve info about pve
|
||||
proxmox_domain_info:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
domain: pve
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is not changed
|
||||
- results.proxmox_domains is defined
|
||||
- results.proxmox_domains|length == 1
|
||||
- results.proxmox_domains[0].type == 'pve'
|
||||
|
||||
- name: List groups
|
||||
proxmox_group_info:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is not changed
|
||||
- results.proxmox_groups is defined
|
||||
|
||||
- name: List users
|
||||
proxmox_user_info:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is not changed
|
||||
- results.proxmox_users is defined
|
||||
|
||||
- name: Retrieve info about api_user using name and domain
|
||||
proxmox_user_info:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
user: "{{ user }}"
|
||||
domain: "{{ domain }}"
|
||||
register: results_user_domain
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results_user_domain is not changed
|
||||
- results_user_domain.proxmox_users is defined
|
||||
- results_user_domain.proxmox_users|length == 1
|
||||
- results_user_domain.proxmox_users[0].domain == "{{ domain }}"
|
||||
- results_user_domain.proxmox_users[0].user == "{{ user }}"
|
||||
- results_user_domain.proxmox_users[0].userid == "{{ user }}@{{ domain }}"
|
||||
|
||||
- name: Retrieve info about api_user using userid
|
||||
proxmox_user_info:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
userid: "{{ user }}@{{ domain }}"
|
||||
register: results_userid
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results_userid is not changed
|
||||
- results_userid.proxmox_users is defined
|
||||
- results_userid.proxmox_users|length == 1
|
||||
- results_userid.proxmox_users[0].domain == "{{ domain }}"
|
||||
- results_userid.proxmox_users[0].user == "{{ user }}"
|
||||
- results_userid.proxmox_users[0].userid == "{{ user }}@{{ domain }}"
|
Loading…
Add table
Add a link
Reference in a new issue