refactor(global_defaults): consolidate hypervisor auth into shared credential dicts
This commit is contained in:
@@ -4,15 +4,8 @@
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
module_defaults:
|
||||
community.proxmox.proxmox_disk:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
api_password: "{{ hypervisor_cfg.password }}"
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
api_password: "{{ hypervisor_cfg.password }}"
|
||||
node: "{{ hypervisor_cfg.host }}"
|
||||
community.proxmox.proxmox_disk: "{{ _proxmox_auth }}"
|
||||
community.proxmox.proxmox_kvm: "{{ _proxmox_auth_node }}"
|
||||
block:
|
||||
- name: Cleanup Setup Disks
|
||||
community.proxmox.proxmox_disk:
|
||||
|
||||
@@ -88,11 +88,7 @@
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
module_defaults:
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
api_password: "{{ hypervisor_cfg.password }}"
|
||||
node: "{{ hypervisor_cfg.host }}"
|
||||
community.proxmox.proxmox_kvm: "{{ _proxmox_auth_node }}"
|
||||
no_log: true
|
||||
block:
|
||||
- name: Stop Proxmox VM
|
||||
@@ -113,11 +109,7 @@
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
module_defaults:
|
||||
community.vmware.vmware_guest:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
community.vmware.vmware_guest: "{{ _vmware_auth }}"
|
||||
no_log: true
|
||||
block:
|
||||
- name: Power off VMware VM
|
||||
|
||||
@@ -4,18 +4,8 @@
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
module_defaults:
|
||||
community.vmware.vmware_guest:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||
vmware.vmware.vm_powerstate:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||
community.vmware.vmware_guest: "{{ _vmware_auth }}"
|
||||
vmware.vmware.vm_powerstate: "{{ _vmware_auth }}"
|
||||
no_log: true
|
||||
block:
|
||||
- name: Remove CD-ROM from VM in vCenter
|
||||
|
||||
@@ -10,6 +10,31 @@
|
||||
- name: Normalize hypervisor inputs
|
||||
ansible.builtin.include_tasks: hypervisor.yml
|
||||
|
||||
- name: Set VMware module auth defaults
|
||||
when: hypervisor_type == 'vmware'
|
||||
ansible.builtin.set_fact:
|
||||
_vmware_auth:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||
no_log: true
|
||||
|
||||
- name: Set Proxmox module auth defaults
|
||||
when: hypervisor_type == 'proxmox'
|
||||
ansible.builtin.set_fact:
|
||||
_proxmox_auth:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
api_password: "{{ hypervisor_cfg.password }}"
|
||||
_proxmox_auth_node:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
api_password: "{{ hypervisor_cfg.password }}"
|
||||
node: "{{ hypervisor_cfg.host }}"
|
||||
no_log: true
|
||||
|
||||
- name: Normalize system inputs
|
||||
ansible.builtin.include_tasks: system.yml
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
- name: Deploy VM on Proxmox
|
||||
delegate_to: localhost
|
||||
module_defaults:
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ hypervisor_cfg.url }}"
|
||||
api_user: "{{ hypervisor_cfg.username }}"
|
||||
api_password: "{{ hypervisor_cfg.password }}"
|
||||
node: "{{ hypervisor_cfg.host }}"
|
||||
community.proxmox.proxmox_kvm: "{{ _proxmox_auth_node }}"
|
||||
block:
|
||||
- name: Create VM on Proxmox
|
||||
vars:
|
||||
|
||||
@@ -14,24 +14,9 @@
|
||||
- name: Deploy VM in vCenter
|
||||
delegate_to: localhost
|
||||
module_defaults:
|
||||
community.vmware.vmware_guest:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||
community.vmware.vmware_guest_tpm:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||
vmware.vmware.vm_powerstate:
|
||||
hostname: "{{ hypervisor_cfg.url }}"
|
||||
username: "{{ hypervisor_cfg.username }}"
|
||||
password: "{{ hypervisor_cfg.password }}"
|
||||
validate_certs: "{{ hypervisor_cfg.certs | bool }}"
|
||||
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||
community.vmware.vmware_guest: "{{ _vmware_auth }}"
|
||||
community.vmware.vmware_guest_tpm: "{{ _vmware_auth }}"
|
||||
vmware.vmware.vm_powerstate: "{{ _vmware_auth }}"
|
||||
block:
|
||||
# community.vmware: full-featured guest management
|
||||
- name: Create VM in vCenter
|
||||
|
||||
Reference in New Issue
Block a user