Open jeromeza opened 2 weeks ago
So far I've achieved this (I think partially as I keep breaking things) by setting these in the ./clusters/cluster.yaml file:
parent_folder: "...."
folder_absolute_path: '....'
Then in the ./roles/vsphere_vm/tasks/main.yml by adjusting the vSphere folder creations:
- name: Create the vCenter folder by the same name as the cluster, only if it doesn't exist
community.vmware.vcenter_folder:
hostname: "{{ vcenter.ip }}"
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
datacenter_name: "{{ vcenter.datacenter }}"
validate_certs: no
folder_name: "{{ item[0] }}"
folder_type: vm
parent_folder: "{{ item[1] if item[1] not in ['', '/'] else omit }}"
state: present
loop: "{{ path_pairs }}"
when: 0 > 1
#when: vcenter.parent_folder is defined and vcenter.parent_folder is string
- name: Create the vCenter folder by the same name as the cluster, only if it doesn't exist
community.vmware.vcenter_folder:
hostname: "{{ vcenter.ip }}"
username: "{{ vcenter.username }}"
password: "{{ vcenter.password }}"
datacenter_name: "{{ vcenter.datacenter }}"
validate_certs: no
folder_name: "{{ cluster }}"
folder_type: vm
parent_folder: "{{ parent_folder | default(omit) }}"
state: present
when: 0 > 1
Is there an easier, better, safer way of accomplishing this?
Default behaviour is to create your cluster in a cluster named folder in VMware, however this becomes an issue in VMware clusters where you have no permissions to do so - e.g. you have access to one absolute folder and that's that (you can't create any sub folders underneath it).
Older versions of this playbook had a folder_absolute_path you could set, which avoided this behaviour.
What's the easiest way to turn off folder creation and just have VMs deploy to a base folder you set?