diff --git a/changelogs/fragments/108-add-collection-level-auth-vars.yml b/changelogs/fragments/108-add-collection-level-auth-vars.yml new file mode 100644 index 00000000..256a0cfe --- /dev/null +++ b/changelogs/fragments/108-add-collection-level-auth-vars.yml @@ -0,0 +1,5 @@ +--- +minor_changes: + - >- + Added the option to set environment variables or collection level variables for auth to vcenter. This provides users + with a more centralizedoption for setting things that all roles use like vCenter hostname, username, password, etc diff --git a/docs/authentication.md b/docs/authentication.md new file mode 100644 index 00000000..e059e7d3 --- /dev/null +++ b/docs/authentication.md @@ -0,0 +1,67 @@ +# Authentication Variables + +Each role in this collection has its own set of authentication and proxy variables. It is not convnient to set those variables for every role, so there are options to set the variables for all roles in the collection at once. + +Here is the order of precedence from greatest to least (the first listed variables override all other variables): + +1. Role variables (for example, `info_hostname` for the `info` role) +2. Collection level variables (for example, `vmware_ops_hostname`) +3. Environment variables (for example, `VMWARE_HOST`) + +## Collection and Environment Variables + +The list of collection/environment variables is pulled from the [vars/main.yml](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/vars/main.yml) + +The available collection level variables and their corresponding environment variables can be found below: + +- vmware_ops_hostname + * str, The hostname or IP address of the vSphere vCenter or ESXi host to manage. + * Environment Var: `VMWARE_HOST` + +- vmware_ops_username + * str, The username to use when authenticating to the vSphere vCenter or ESXi host. + * Environment Var: `VMWARE_USER` + +- vmware_ops_password + * str, The password to use when authenticating to the vSphere vCenter or ESXi host. + * Environment Var: `VMWARE_PASSWORD` + +- vmware_ops_validate_certs + * bool, Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + * Environment Var: `VMWARE_VALIDATE_CERTS` + +- vmware_ops_port + * int, The port to use when authenticating to the vSphere vCenter or ESXi host to manage. + * Environment Var: `VMWARE_PORT` + +- vmware_ops_proxy_host + * str, The hostname or IP address of a proxy host to use. If set all requests to the vCenter or ESXi host will go through the proxy host. + * Environment Var: `VMWARE_PROXY_HOST` + +- vmware_ops_proxy_port + * int, The port of a proxy host to use. If set all requests to the vCenter or ESXi host will go through the proxy host. + * Environment Var: `VMWARE_PROXY_PORT` + +## Example Playbook + +```yaml +- name: Example Of Setting Different variables + hosts: localhost + environment: + VMWARE_HOST: myvcenter.local + VMWARE_USER: myadmin + + vars: + # You can avoid exposing the password as an environment variable, and leverage ansible-vault by using the collection level + # variable instead + vmware_ops_password: vaultedPassword! + + roles: + # This role will use VMWARE_HOST, VMWARE_USER, and vmware_ops_password + - role: cloud.vmware_ops.provision_vm + + # This role will use VMWARE_HOST, info_username, and info_password + - role: cloud.vmware_ops.info + info_username: myreader + info_password: readerPassword! +``` diff --git a/roles/cluster_settings/README.md b/roles/cluster_settings/README.md index 072547c6..1474e3b6 100644 --- a/roles/cluster_settings/README.md +++ b/roles/cluster_settings/README.md @@ -7,18 +7,35 @@ A role to define cluster settings in vCenter. N/A ## Role Variables + ### Auth + - **cluster_settings_username**: - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **cluster_settings_password**: - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **cluster_settings_hostname**: - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **cluster_settings_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. + +- **cluster_settings_port**: + - str or int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. + +### Cluster settings - **cluster_settings_cluster_name**: - The name of the cluster in vSphere vCenter to configure. @@ -26,11 +43,6 @@ N/A - **cluster_settings_datacenter_name**: - The name of the datacenter in vSphere vCenter which contains the cluster to configure. -- **cluster_settings_port**: - - str or int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. - -### Cluster settings - #### Distributed Power Management (DPM) - **cluster_settings_dpm_enable**: diff --git a/roles/cluster_settings/defaults/main.yml b/roles/cluster_settings/defaults/main.yml index 5405ad05..3012b679 100644 --- a/roles/cluster_settings/defaults/main.yml +++ b/roles/cluster_settings/defaults/main.yml @@ -1,2 +1,11 @@ --- +cluster_settings_hostname: "{{ vmware_ops_collection_hostname }}" +cluster_settings_username: "{{ vmware_ops_collection_username }}" +cluster_settings_password: "{{ vmware_ops_collection_password }}" +cluster_settings_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +cluster_settings_port: "{{ vmware_ops_collection_port }}" + +cluster_settings_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +cluster_settings_proxy_port: "{{ vmware_ops_collection_proxy_port }}" + cluster_settings_drs_apply_recommendations: false diff --git a/roles/cluster_settings/tasks/main.yml b/roles/cluster_settings/tasks/main.yml index 033b7a78..aac46143 100644 --- a/roles/cluster_settings/tasks/main.yml +++ b/roles/cluster_settings/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/roles/content_library/README.md b/roles/content_library/README.md index 7619184e..8141b946 100644 --- a/roles/content_library/README.md +++ b/roles/content_library/README.md @@ -7,29 +7,41 @@ A role to manage VMWare content libraries. You can create or delete both local a N/A ## Role Variables + ### Auth + - **content_library_username**: - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **content_library_password**: - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **content_library_hostname**: - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **content_library_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. + +- **content_library_port**: + - str or int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. +### Library - **content_library_cluster_name**: - The name of the cluster in vSphere vCenter to configure. - **content_library_datacenter_name**: - The name of the datacenter in vSphere vCenter which contains the cluster to configure. -- **content_library_port**: - - str or int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. - -### Library - **content_library_datastore_name**: - str, The name of the local datastore that should be used as storage for the content library. Required if state is `present` @@ -58,9 +70,14 @@ N/A ### Other - **content_library_proxy_host**: - str, The hostname of a proxy host that should be used for all HTTPs communication by the role. Optional + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **content_library_proxy_port**: - str, The port of a proxy host that should be used for all HTTPs communication by the role. Optional + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ## Example Playbook diff --git a/roles/content_library/defaults/main.yml b/roles/content_library/defaults/main.yml index d28cdde5..f5473496 100644 --- a/roles/content_library/defaults/main.yml +++ b/roles/content_library/defaults/main.yml @@ -1,2 +1,11 @@ --- +content_library_hostname: "{{ vmware_ops_collection_hostname }}" +content_library_username: "{{ vmware_ops_collection_username }}" +content_library_password: "{{ vmware_ops_collection_password }}" +content_library_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +content_library_port: "{{ vmware_ops_collection_port }}" + +content_library_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +content_library_proxy_port: "{{ vmware_ops_collection_proxy_port }}" + content_library_state: present diff --git a/roles/content_library/tasks/main.yml b/roles/content_library/tasks/main.yml index 832feb17..f705800a 100644 --- a/roles/content_library/tasks/main.yml +++ b/roles/content_library/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/roles/deploy_ovf/README.md b/roles/deploy_ovf/README.md index a4a0c921..9882ddd4 100644 --- a/roles/deploy_ovf/README.md +++ b/roles/deploy_ovf/README.md @@ -7,21 +7,33 @@ A role to deploy a VM from an OVF file. The OVF can be located on the `ansible_h N/A ## Role Variables + ### Auth + - **deploy_ovf_username**: - str, Required. The vSphere vCenter or ESXi host username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **deploy_ovf_password**: - str, Required. The vSphere vCenter or ESXi host password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **deploy_ovf_hostname**: - str, Required. The hostname or IP address of the vSphere vCenter or ESXi host. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **deploy_ovf_validate_certs** - bool, Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **deploy_ovf_port**: - str or int, The port used to authenticate to the vSphere vCenter or ESXi host. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Placement @@ -113,10 +125,14 @@ N/A ### Other - **deploy_ovf_proxy_host**: - str, The hostname of a proxy host that should be used for all HTTPs communication by the role. Optional + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **deploy_ovf_proxy_port**: - str, The port of a proxy host that should be used for all HTTPs communication by the role. Optional - + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ## Example Playbook ```yaml diff --git a/roles/deploy_ovf/defaults/main.yml b/roles/deploy_ovf/defaults/main.yml new file mode 100644 index 00000000..bf8ac18b --- /dev/null +++ b/roles/deploy_ovf/defaults/main.yml @@ -0,0 +1,9 @@ +--- +deploy_ovf_hostname: "{{ vmware_ops_collection_hostname }}" +deploy_ovf_username: "{{ vmware_ops_collection_username }}" +deploy_ovf_password: "{{ vmware_ops_collection_password }}" +deploy_ovf_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +deploy_ovf_port: "{{ vmware_ops_collection_port }}" + +deploy_ovf_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +deploy_ovf_proxy_port: "{{ vmware_ops_collection_proxy_port }}" diff --git a/roles/deploy_ovf/tasks/main.yml b/roles/deploy_ovf/tasks/main.yml index c1147212..d347b97c 100644 --- a/roles/deploy_ovf/tasks/main.yml +++ b/roles/deploy_ovf/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Include Input Validation Tasks ansible.builtin.include_tasks: input_validation.yml diff --git a/roles/esxi_maintenance_mode/README.md b/roles/esxi_maintenance_mode/README.md index 6301168d..f8403f14 100644 --- a/roles/esxi_maintenance_mode/README.md +++ b/roles/esxi_maintenance_mode/README.md @@ -9,28 +9,44 @@ N/A ## Role Variables ### Auth + - **esxi_maintenance_mode_hostname**: - str, The hostname of the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **esxi_maintenance_mode_username**: - str, The username to use to authenticate to the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **esxi_maintenance_mode_password**: - str, The password to use to authenticate to the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **esxi_maintenance_mode_port**: - str or int, The port to use to authenticate to the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **esxi_maintenance_mode_validate_certs**: - bool, If true then certificates will be validated when connecting to the ESXi or vCenter for auth. Optional. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Proxy Options - **esxi_maintenance_mode_proxy_host**: - str, Address of a proxy that will receive all HTTPS requests and relay them. + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **esxi_maintenance_mode_proxy_port**: - int, Port of the HTTP proxy that will receive all HTTPS requests and relay them. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Other Options - **esxi_maintenance_mode_enable**: diff --git a/roles/esxi_maintenance_mode/defaults/main.yml b/roles/esxi_maintenance_mode/defaults/main.yml index 30f0b8d3..efbdefb7 100644 --- a/roles/esxi_maintenance_mode/defaults/main.yml +++ b/roles/esxi_maintenance_mode/defaults/main.yml @@ -1,2 +1,11 @@ --- +esxi_maintenance_mode_hostname: "{{ vmware_ops_collection_hostname }}" +esxi_maintenance_mode_username: "{{ vmware_ops_collection_username }}" +esxi_maintenance_mode_password: "{{ vmware_ops_collection_password }}" +esxi_maintenance_mode_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +esxi_maintenance_mode_port: "{{ vmware_ops_collection_port }}" + +esxi_maintenance_mode_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +esxi_maintenance_mode_proxy_port: "{{ vmware_ops_collection_proxy_port }}" + esxi_maintenance_mode_enable: true diff --git a/roles/esxi_maintenance_mode/tasks/main.yml b/roles/esxi_maintenance_mode/tasks/main.yml index 2a286cd5..be66c038 100644 --- a/roles/esxi_maintenance_mode/tasks/main.yml +++ b/roles/esxi_maintenance_mode/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/roles/export_vm_as_ovf/README.md b/roles/export_vm_as_ovf/README.md index dda091f2..757c278f 100644 --- a/roles/export_vm_as_ovf/README.md +++ b/roles/export_vm_as_ovf/README.md @@ -7,21 +7,33 @@ A role to export a VM from vCenter or ESXi as an OVF. The VM is exported to the N/A ## Role Variables + ### Auth + - **export_vm_as_ovf_username**: - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **export_vm_as_ovf_password**: - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **export_vm_as_ovf_hostname**: - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **export_vm_as_ovf_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **export_vm_as_ovf_port**: - - str or int, The port used to authenticate to the vSphere vCenter that contains the VM. + - int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### VM Options - **export_vm_as_ovf_datacenter**: @@ -60,10 +72,14 @@ N/A ### Other - **export_vm_as_ovf_proxy_host**: - str, The hostname of a proxy host that should be used for all HTTPs communication by the role. Optional + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **export_vm_as_ovf_proxy_port**: - str, The port of a proxy host that should be used for all HTTPs communication by the role. Optional - + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ## Example Playbook ```yaml diff --git a/roles/export_vm_as_ovf/defaults/main.yml b/roles/export_vm_as_ovf/defaults/main.yml new file mode 100644 index 00000000..5b82ee1c --- /dev/null +++ b/roles/export_vm_as_ovf/defaults/main.yml @@ -0,0 +1,9 @@ +--- +export_vm_as_ovf_hostname: "{{ vmware_ops_collection_hostname }}" +export_vm_as_ovf_username: "{{ vmware_ops_collection_username }}" +export_vm_as_ovf_password: "{{ vmware_ops_collection_password }}" +export_vm_as_ovf_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +export_vm_as_ovf_port: "{{ vmware_ops_collection_port }}" + +export_vm_as_ovf_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +export_vm_as_ovf_proxy_port: "{{ vmware_ops_collection_proxy_port }}" diff --git a/roles/export_vm_as_ovf/tasks/main.yml b/roles/export_vm_as_ovf/tasks/main.yml index d875c6e3..b1c02f9f 100644 --- a/roles/export_vm_as_ovf/tasks/main.yml +++ b/roles/export_vm_as_ovf/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/roles/info/README.md b/roles/info/README.md index bfec060b..a2a04ebe 100644 --- a/roles/info/README.md +++ b/roles/info/README.md @@ -7,18 +7,28 @@ A role that gathers information from vCenter. N/A ## Role Variables + ### Auth + - **info_username**: - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **info_password**: - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **info_hostname**: - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **info_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Output - **info_expose_outputs_as_variable** diff --git a/roles/info/defaults/main.yml b/roles/info/defaults/main.yml index a7a54607..fe1a165c 100644 --- a/roles/info/defaults/main.yml +++ b/roles/info/defaults/main.yml @@ -1,3 +1,10 @@ +--- +info_hostname: "{{ vmware_ops_collection_hostname }}" +info_username: "{{ vmware_ops_collection_username }}" +info_password: "{{ vmware_ops_collection_password }}" +info_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +info_port: "{{ vmware_ops_collection_port }}" + info_validate_certs: true info_expose_outputs_as_variable: true info_hostport: "{{ info_hostname + ':' + info_port if info_port is defined else info_hostname }}" diff --git a/roles/info/tasks/main.yml b/roles/info/tasks/main.yml index 5793d2d5..f0149ce4 100644 --- a/roles/info/tasks/main.yml +++ b/roles/info/tasks/main.yml @@ -1,3 +1,8 @@ +--- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: License info ansible.builtin.include_tasks: license_info.yml when: info_license diff --git a/roles/manage_folder/README.md b/roles/manage_folder/README.md index caa580eb..d5ea441a 100644 --- a/roles/manage_folder/README.md +++ b/roles/manage_folder/README.md @@ -7,21 +7,33 @@ A role to create, delete, or update a folder or folder tree in vCenter. N/A ## Role Variables + ### Auth + - **manage_folder_username**: - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **manage_folder_password**: - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **manage_folder_hostname**: - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **manage_folder_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **manage_folder_port**: - - str or int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. + - int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Other - **manage_folder_datacenter**: @@ -49,10 +61,14 @@ N/A ### Other - **manage_folder_proxy_host**: - str, The hostname of a proxy host that should be used for all HTTPs communication by the role. Optional + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **manage_folder_proxy_port**: - str, The port of a proxy host that should be used for all HTTPs communication by the role. Optional - + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ## Example Playbook ```yaml diff --git a/roles/manage_folder/defaults/main.yml b/roles/manage_folder/defaults/main.yml index f354f91a..4cb82f33 100644 --- a/roles/manage_folder/defaults/main.yml +++ b/roles/manage_folder/defaults/main.yml @@ -1,4 +1,13 @@ --- +manage_folder_hostname: "{{ vmware_ops_collection_hostname }}" +manage_folder_username: "{{ vmware_ops_collection_username }}" +manage_folder_password: "{{ vmware_ops_collection_password }}" +manage_folder_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +manage_folder_port: "{{ vmware_ops_collection_port }}" + +manage_folder_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +manage_folder_proxy_port: "{{ vmware_ops_collection_proxy_port }}" + manage_folder_state: present manage_folder_parent_folder: "" manage_folder_parse_name_as_path: true diff --git a/roles/manage_folder/tasks/main.yml b/roles/manage_folder/tasks/main.yml index 8c6d6250..6e14fedb 100644 --- a/roles/manage_folder/tasks/main.yml +++ b/roles/manage_folder/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/roles/provision_vcenter/README.md b/roles/provision_vcenter/README.md index a3f38a3f..66d8c061 100644 --- a/roles/provision_vcenter/README.md +++ b/roles/provision_vcenter/README.md @@ -9,20 +9,31 @@ The vCenter Server Appliance ISO should be accessible from the host running thes ## Role Variables ### Auth + - **provision_vcenter_hostname**: - str, The hostname of the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vcenter_username**: - str, The username to use to authenticate to the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vcenter_password**: - str, The password to use to authenticate to the ESXi or vCenter on which you want to deploy the application. Required. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vcenter_port**: - - str or int, The port to use to authenticate to the ESXi or vCenter on which you want to deploy the application. Required. + - str or int, The port to use to authenticate to the ESXi or vCenter on which you want to deploy the application. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vcenter_validate_certs**: - bool, If true then certificates will be validated when connecting to the ESXi or vCenter for auth. Optional. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Replication Options diff --git a/roles/provision_vcenter/defaults/main.yml b/roles/provision_vcenter/defaults/main.yml index b8a071fb..f9487cab 100644 --- a/roles/provision_vcenter/defaults/main.yml +++ b/roles/provision_vcenter/defaults/main.yml @@ -1,4 +1,10 @@ --- +provision_vcenter_hostname: "{{ vmware_ops_collection_hostname }}" +provision_vcenter_username: "{{ vmware_ops_collection_username }}" +provision_vcenter_password: "{{ vmware_ops_collection_password }}" +provision_vcenter_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +provision_vcenter_port: "{{ vmware_ops_collection_port }}" + provision_vcenter_vm_deployment_option: tiny provision_vcenter_vm_network_mode: static provision_vcenter_vm_enable_ssh: true diff --git a/roles/provision_vcenter/tasks/main.yml b/roles/provision_vcenter/tasks/main.yml index 83ad81c0..112aed03 100644 --- a/roles/provision_vcenter/tasks/main.yml +++ b/roles/provision_vcenter/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Validate Inputs ansible.builtin.include_tasks: validate_inputs.yml diff --git a/roles/provision_virtual_esxi/README.md b/roles/provision_virtual_esxi/README.md index 5b8fb776..cfde0d7c 100644 --- a/roles/provision_virtual_esxi/README.md +++ b/roles/provision_virtual_esxi/README.md @@ -12,20 +12,31 @@ When deploying a new VM: ## Role Variables ### Auth + - **provision_virtual_esxi_hostname**: - str, The name of the ESXi or vCenter on which you want to deploy the vm. Required. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_virtual_esxi_username**: - str, The username to use to authenticate to the ESXi or vCenter on which you want to deploy the vm. Required. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_virtual_esxi_password**: - str, The password to use to authenticate to the ESXi or vCenter on which you want to deploy the vm. Required. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_virtual_esxi_validate_certs**: - bool, If true then certificates will be validated when connecting to the ESXi or vCenter for auth. Optional. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_virtual_esxi_port**: - int, The port to use when connecting to the ESXi or vCenter for auth. Optional. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Placement - **provision_virtual_esxi_cluster**: diff --git a/roles/provision_virtual_esxi/defaults/main.yml b/roles/provision_virtual_esxi/defaults/main.yml index 0b8e9c7c..e564fe7f 100644 --- a/roles/provision_virtual_esxi/defaults/main.yml +++ b/roles/provision_virtual_esxi/defaults/main.yml @@ -1,4 +1,10 @@ --- +provision_virtual_esxi_hostname: "{{ vmware_ops_collection_hostname }}" +provision_virtual_esxi_username: "{{ vmware_ops_collection_username }}" +provision_virtual_esxi_password: "{{ vmware_ops_collection_password }}" +provision_virtual_esxi_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +provision_virtual_esxi_port: "{{ vmware_ops_collection_port }}" + # hardware defaults are chosen based on the minimum requirements to run vCenter, # plus a little bit extra for the ESXi system # https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-vcenter-upgrade/GUID-752FCA83-1A9B-499E-9C65-D5625351C0B5.html diff --git a/roles/provision_virtual_esxi/tasks/main.yml b/roles/provision_virtual_esxi/tasks/main.yml index db6e3b02..70c1ddfd 100644 --- a/roles/provision_virtual_esxi/tasks/main.yml +++ b/roles/provision_virtual_esxi/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check General Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/roles/provision_vm/README.md b/roles/provision_vm/README.md index ab947bd7..018935a4 100644 --- a/roles/provision_vm/README.md +++ b/roles/provision_vm/README.md @@ -9,33 +9,44 @@ N/A ## Role Variables + ### Auth + - **provision_vm_username**: (string, Required) - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vm_password**: (string, Required) - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vm_hostname**: (string, Required) - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vm_validate_certs** (boolean) - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. - Default: true + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vm_port** (integer): - The port number of the vSphere vCenter or ESXi server. - If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead. - Default: 443 + - The port number of the vSphere vCenter or ESXi server. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vm_proxy_host** (string): - Address of a proxy that will receive all HTTPS requests and relay them. - The format is a hostname or a IP. - If the value is not specified in the task, the value of environment variable VMWARE_PROXY_HOST will be used instead. + - The address of a proxy that will receive all HTTPS requests and relay them. + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **provision_vm_proxy_port** (integer): - Port of the HTTP proxy that will receive all HTTPS requests and relay them. - If the value is not specified in the task, the value of environment variable VMWARE_PROXY_PORT will be used instead. + - The port of the HTTP proxy that will receive all HTTPS requests and relay them. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Provisioning a VM - **provision_vm_name** (string, Required): diff --git a/roles/provision_vm/defaults/main.yml b/roles/provision_vm/defaults/main.yml index fec02ecb..38f3cfc9 100644 --- a/roles/provision_vm/defaults/main.yml +++ b/roles/provision_vm/defaults/main.yml @@ -1,2 +1,11 @@ --- +provision_vm_hostname: "{{ vmware_ops_collection_hostname }}" +provision_vm_username: "{{ vmware_ops_collection_username }}" +provision_vm_password: "{{ vmware_ops_collection_password }}" +provision_vm_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +provision_vm_port: "{{ vmware_ops_collection_port }}" + +provision_vm_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +provision_vm_proxy_port: "{{ vmware_ops_collection_proxy_port }}" + provision_vm_is_template: false diff --git a/roles/provision_vm/tasks/main.yml b/roles/provision_vm/tasks/main.yml index e62a22ff..2b9aaec4 100644 --- a/roles/provision_vm/tasks/main.yml +++ b/roles/provision_vm/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Manage VM community.vmware.vmware_guest: hostname: "{{ provision_vm_hostname | d(omit) }}" diff --git a/roles/snapshot_management/README.md b/roles/snapshot_management/README.md index abca36b1..cbad11e6 100644 --- a/roles/snapshot_management/README.md +++ b/roles/snapshot_management/README.md @@ -9,32 +9,44 @@ N/A ## Role Variables + ### Auth + - **snapshot_management_username**: (string, Required) - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **snapshot_management_password**: (string, Required) - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **snapshot_management_hostname**: (string, Required) - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **snapshot_management_validate_certs** (boolean) - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **snapshot_management_port** (integer): - The port number of the vSphere vCenter or ESXi server. - - If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead. - - Default: 443 + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **snapshot_management_proxy_host** (string): - The address of a proxy that will receive all HTTPS requests and relay them. - The format is a hostname or an IP. - - If the value is not specified in the task, the value of environment variable VMWARE_PROXY_HOST will be used instead. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **snapshot_management_proxy_port** (integer): - The port of the HTTP proxy that will receive all HTTPS requests and relay them. - - If the value is not specified in the task, the value of environment variable VMWARE_PROXY_PORT will be used instead. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Manage a VM snapshot - **snapshot_management_state**: diff --git a/roles/snapshot_management/defaults/main.yml b/roles/snapshot_management/defaults/main.yml new file mode 100644 index 00000000..b8501e7f --- /dev/null +++ b/roles/snapshot_management/defaults/main.yml @@ -0,0 +1,9 @@ +--- +snapshot_management_hostname: "{{ vmware_ops_collection_hostname }}" +snapshot_management_username: "{{ vmware_ops_collection_username }}" +snapshot_management_password: "{{ vmware_ops_collection_password }}" +snapshot_management_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +snapshot_management_port: "{{ vmware_ops_collection_port }}" + +snapshot_management_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +snapshot_management_proxy_port: "{{ vmware_ops_collection_proxy_port }}" diff --git a/roles/snapshot_management/tasks/main.yml b/roles/snapshot_management/tasks/main.yml index 8f5a8b72..4e31d147 100644 --- a/roles/snapshot_management/tasks/main.yml +++ b/roles/snapshot_management/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Manages virtual machines snapshots in vCenter community.vmware.vmware_guest_snapshot: hostname: "{{ snapshot_management_hostname | d(omit) }}" diff --git a/roles/system_settings/README.md b/roles/system_settings/README.md index aa2d55c5..0b52d507 100644 --- a/roles/system_settings/README.md +++ b/roles/system_settings/README.md @@ -7,18 +7,28 @@ A role to define system settings for vCenter. N/A ## Role Variables + ### Auth + - **system_settings_username**: - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **system_settings_password**: - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **system_settings_hostname**: - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. - **system_settings_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### System settings diff --git a/roles/system_settings/defaults/main.yml b/roles/system_settings/defaults/main.yml index 003f9d43..3eec80bc 100644 --- a/roles/system_settings/defaults/main.yml +++ b/roles/system_settings/defaults/main.yml @@ -1,3 +1,10 @@ +--- +system_settings_hostname: "{{ vmware_ops_collection_hostname }}" +system_settings_username: "{{ vmware_ops_collection_username }}" +system_settings_password: "{{ vmware_ops_collection_password }}" +system_settings_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +system_settings_port: "{{ vmware_ops_collection_port }}" + system_settings_resize_storage: false system_settings_dns_mode_append: false system_settings_proxy: [] diff --git a/roles/system_settings/tasks/main.yml b/roles/system_settings/tasks/main.yml index 135c24a0..19a671c5 100644 --- a/roles/system_settings/tasks/main.yml +++ b/roles/system_settings/tasks/main.yml @@ -1,3 +1,7 @@ +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Configure ntpd ansible.builtin.include_tasks: ntpd.yml diff --git a/roles/vcenter_host_connection/README.md b/roles/vcenter_host_connection/README.md index 89da5528..d596f655 100644 --- a/roles/vcenter_host_connection/README.md +++ b/roles/vcenter_host_connection/README.md @@ -9,20 +9,31 @@ N/A ## Role Variables ### Auth -- **vcenter_host_connection_hostname**: - - str, The hostname of the vCenter to which you want to connect. Required -- **vcenter_host_connection_username**: - - str, The username to use to authenticate to the vCenter to which you want to connect. Required +- **vcenter_host_connection_hostname**: (string, Required) + - The hostname or IP address of the vSphere vCenter. + - If this variable is not set, the collection level variable `vmware_ops_hostname` will be used. If that variable is not set, the environment variable `VMWARE_HOST` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. -- **vcenter_host_connection_password**: - - str, The password to use to authenticate to the ESXi or vCenter to which you want to connect. Required +- **vcenter_host_connection_username**: (string, Required) + - The vSphere vCenter username. + - If this variable is not set, the collection level variable `vmware_ops_username` will be used. If that variable is not set, the environment variable `VMWARE_USER` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. -- **vcenter_host_connection_validate_certs**: - - bool, If true then certificates will be validated when connecting to the vCenter for auth. Optional. +- **vcenter_host_connection_password**: (string, Required) + - The vSphere vCenter password. + - If this variable is not set, the collection level variable `vmware_ops_password` will be used. If that variable is not set, the environment variable `VMWARE_PASSWORD` will be used. At least one of these variables must be set to use this role. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. -- **vcenter_host_connection_port**: - - int, The port of the vCenter to which you want to connect. Optional. +- **vcenter_host_connection_validate_certs** (boolean) + - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. + - If this variable is not set, the collection level variable `vmware_ops_validate_certs` will be used. If that variable is not set, the environment variable `VMWARE_VALIDATE_CERTS` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. + +- **vcenter_host_connection_port** (integer): + - The port number of the vSphere vCenter or ESXi server. + - If this variable is not set, the collection level variable `vmware_ops_port` will be used. If that variable is not set, the environment variable `VMWARE_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ### Placement - **vcenter_host_connection_folder**: @@ -68,11 +79,16 @@ N/A - bool, Reconnect disconnected hosts, if the state is present and the host already exists. Optional ### Other -- **vcenter_host_connection_proxy_host**: - - str, The hostname of a proxy host that should be used for all HTTPs communication by the role. Optional - -- **vcenter_host_connection_proxy_port**: - - str, The port of a proxy host that should be used for all HTTPs communication by the role. Optional +- **vcenter_host_connection_proxy_host** (string): + - The address of a proxy that will receive all HTTPS requests and relay them. + - The format is a hostname or an IP. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_HOST` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. + +- **vcenter_host_connection_proxy_port** (integer): + - The port of the HTTP proxy that will receive all HTTPS requests and relay them. + - If this variable is not set, the collection level variable `vmware_ops_proxy_host` will be used. If that variable is not set, the environment variable `VMWARE_PROXY_PORT` will be used. + - See the [authentication documentation](https://github.com/redhat-cop/cloud.vmware_ops/blob/main/docs/authentication.md) for examples. ## Example Playbook diff --git a/roles/vcenter_host_connection/defaults/main.yml b/roles/vcenter_host_connection/defaults/main.yml new file mode 100644 index 00000000..a9215f57 --- /dev/null +++ b/roles/vcenter_host_connection/defaults/main.yml @@ -0,0 +1,9 @@ +--- +vcenter_host_connection_hostname: "{{ vmware_ops_collection_hostname }}" +vcenter_host_connection_username: "{{ vmware_ops_collection_username }}" +vcenter_host_connection_password: "{{ vmware_ops_collection_password }}" +vcenter_host_connection_validate_certs: "{{ vmware_ops_collection_validate_certs }}" +vcenter_host_connection_port: "{{ vmware_ops_collection_port }}" + +vcenter_host_connection_proxy_host: "{{ vmware_ops_collection_proxy_host }}" +vcenter_host_connection_proxy_port: "{{ vmware_ops_collection_proxy_port }}" diff --git a/roles/vcenter_host_connection/tasks/main.yml b/roles/vcenter_host_connection/tasks/main.yml index 527d8f2f..ecb73e54 100644 --- a/roles/vcenter_host_connection/tasks/main.yml +++ b/roles/vcenter_host_connection/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Import Collection Level Vars + ansible.builtin.include_vars: + file: "{{ role_path }}/../vars/main.yml" + - name: Check General Mandatory Variables Are Defined ansible.builtin.assert: that: diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 00000000..eeac46fd --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,9 @@ +--- +vmware_ops_collection_hostname: "{{ vmware_ops_hostname | default(lookup('ansible.builtin.env', 'VMWARE_HOST')) }}" +vmware_ops_collection_username: "{{ vmware_ops_username | default(lookup('ansible.builtin.env', 'VMWARE_USER')) }}" +vmware_ops_collection_password: "{{ vmware_ops_password | default(lookup('ansible.builtin.env', 'VMWARE_PASSWORD')) }}" +vmware_ops_collection_validate_certs: "{{ vmware_ops_validate_certs | default(lookup('ansible.builtin.env', 'VMWARE_VALIDATE_CERTS')) }}" +vmware_ops_collection_port: "{{ vmware_ops_port | default(lookup('ansible.builtin.env', 'VMWARE_PORT')) }}" + +vmware_ops_collection_proxy_host: "{{ vmware_ops_proxy_host | default(lookup('ansible.builtin.env', 'VMWARE_PROXY_HOST', default=Undefined)) }}" +vmware_ops_collection_proxy_port: "{{ vmware_ops_proxy_port | default(lookup('ansible.builtin.env', 'VMWARE_PROXY_PORT')) }}"