diff --git a/roles/tanzu/opsman/configure-bosh/tasks/main.yml b/roles/tanzu/opsman/configure-bosh/tasks/main.yml index bf1a389..2480ec0 100644 --- a/roles/tanzu/opsman/configure-bosh/tasks/main.yml +++ b/roles/tanzu/opsman/configure-bosh/tasks/main.yml @@ -1,17 +1,17 @@ --- - name: Create BOSH AZ resource pool - community.vmware.vmware_resource_pool: - hostname: "{{ bosh_vcenter_url }}" - username: "{{ bosh_vcenter_username }}" - password: "{{ bosh_vcenter_password }}" - validate_certs: false + ansible.builtin.include_role: + name: vsphere/vsphere-resource-pool + vars: + vcenter_ip: "{{ bosh_vcenter_url }}" + vcenter_username: "{{ bosh_vcenter_username }}" + vcenter_password: "{{ bosh_vcenter_password }}" datacenter: "{{ bosh_vcenter_datacenter }}" - cluster: "{{ bosh_vcenter_cluster }}" + cluster_name: "{{ bosh_vcenter_cluster }}" resource_pool: "{{ bosh_az_resource_pool }}" - state: present - delegate_to: localhost when: bosh_az_resource_pool != "" + - name: Fetch NSX Manager cert ansible.builtin.shell: | set -o pipefail && \ diff --git a/roles/tanzu/opsman/install-opsman/tasks/main.yml b/roles/tanzu/opsman/install-opsman/tasks/main.yml index 09975f3..9293042 100644 --- a/roles/tanzu/opsman/install-opsman/tasks/main.yml +++ b/roles/tanzu/opsman/install-opsman/tasks/main.yml @@ -5,16 +5,16 @@ opsman_env: | {{ lookup('template', 'env.yml') | from_yaml }} -- name: Create resource pool - community.vmware.vmware_resource_pool: - hostname: "{{ opsman_vcenter_url }}" - username: "{{ opsman_vcenter_username }}" - password: "{{ opsman_vcenter_password }}" - validate_certs: false +- name: Create resource pool for Opsman + ansible.builtin.include_role: + name: vsphere/vsphere-resource-pool + vars: + vcenter_ip: "{{ opsman_vcenter_url }}" + vcenter_username: "{{ opsman_vcenter_username }}" + vcenter_password: "{{ opsman_vcenter_password }}" datacenter: "{{ opsman_vcenter_datacenter }}" - cluster: "{{ opsman_vcenter_cluster }}" + cluster_name: "{{ opsman_vcenter_cluster }}" resource_pool: "{{ opsman_vcenter_resource_pool }}" - state: present when: opsman_vcenter_resource_pool != "Resources" - name: Deploy Opsman VM diff --git a/roles/ubuntu-server/tasks/main.yml b/roles/ubuntu-server/tasks/main.yml index 0aa8982..4d4ccab 100644 --- a/roles/ubuntu-server/tasks/main.yml +++ b/roles/ubuntu-server/tasks/main.yml @@ -1,14 +1,14 @@ --- -- name: Create resource pool - community.vmware.vmware_resource_pool: - hostname: "{{ vcsa_hostname }}" - username: "{{ vcsa_username }}" - password: "{{ vcsa_password }}" - validate_certs: false +- name: Create resource pool for Ubuntu VM + ansible.builtin.include_role: + name: vsphere/vsphere-resource-pool + vars: + vcenter_ip: "{{ vcsa_hostname }}" + vcenter_username: "{{ vcsa_username }}" + vcenter_password: "{{ vcsa_password }}" datacenter: "{{ datacenter }}" - cluster: "{{ cluster }}" + cluster_name: "{{ cluster }}" resource_pool: "{{ vm_resource_pool }}" - state: present when: vm_resource_pool is defined - name: Deploy Ubuntu OVA diff --git a/roles/vsphere/vsphere-resource-pool/tasks/main.yml b/roles/vsphere/vsphere-resource-pool/tasks/main.yml new file mode 100644 index 0000000..acec5cf --- /dev/null +++ b/roles/vsphere/vsphere-resource-pool/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Add resource pool to vCenter + community.vmware.vmware_resource_pool: + hostname: "{{ vcenter_ip }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: false + datacenter: "{{ datacenter }}" + cluster: "{{ cluster_name }}" + resource_pool: "{{ resource_pool }}" + state: present + delegate_to: localhost \ No newline at end of file diff --git a/roles/vsphere/vsphere-resource-pools/tasks/main.yml b/roles/vsphere/vsphere-resource-pools/tasks/main.yml index bb65194..5f3fa7e 100644 --- a/roles/vsphere/vsphere-resource-pools/tasks/main.yml +++ b/roles/vsphere/vsphere-resource-pools/tasks/main.yml @@ -16,15 +16,14 @@ {% endfor %} ] -- name: Add resource pool to vCenter - community.vmware.vmware_resource_pool: - hostname: "{{ nested_vcenter.ip }}" - username: "{{ nested_vcenter.username }}" - password: "{{ nested_vcenter.password }}" - validate_certs: false +- name: Add resource pools to vCenter + ansible.builtin.include_role: + name: vsphere/vsphere-resource-pool + vars: + vcenter_ip: "{{ nested_vcenter.ip }}" + vcenter_username: "{{ nested_vcenter.username }}" + vcenter_password: "{{ nested_vcenter.password }}" datacenter: "{{ nested_vcenter.datacenter }}" - cluster: "{{ item.cluster_name }}" + cluster_name: "{{ item.cluster_name }}" resource_pool: "{{ item.resource_pool }}" - state: present loop: "{{ resource_pools_to_add }}" - delegate_to: localhost