Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

folder creation vmware #111

Open
jeromeza opened this issue Nov 6, 2024 · 1 comment
Open

folder creation vmware #111

jeromeza opened this issue Nov 6, 2024 · 1 comment

Comments

@jeromeza
Copy link

jeromeza commented Nov 6, 2024

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?

@jeromeza
Copy link
Author

jeromeza commented Nov 6, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant