community / community.vmware / 0.4.0 / module / vmware_host_dns Manage DNS configuration of an ESXi host system Authors: Christian Kotte (@ckotte), Mario Lenz (@mariolenz) preview | supported by communitycommunity.vmware.vmware_host_dns (0.4.0) — module
Install with ansible-galaxy collection install community.vmware:==0.4.0
collections: - name: community.vmware version: 0.4.0
This module can be used to configure DNS for the default TCP/IP stack on an ESXi host system.
- name: Configure DNS for an ESXi host vmware_host_dns: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' esxi_hostname: '{{ esxi_hostname }}' type: static host_name: esx01 domain: example.local dns_servers: - 192.168.1.10 - 192.168.1.11 search_domains: - subdomain.example.local - example.local delegate_to: localhost
- name: Configure DNS for all ESXi hosts of a cluster vmware_host_dns: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' cluster_name: '{{ cluster_name }}' type: static domain: example.local dns_servers: - 192.168.1.10 - 192.168.1.11 search_domains: - subdomain.example.local - example.local delegate_to: localhost
- name: Configure DNS via DHCP for an ESXi host vmware_host_dns: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' esxi_hostname: '{{ esxi_hostname }}' type: dhcp device: vmk0 delegate_to: localhost
port: default: 443 description: - The port number of the vSphere vCenter or ESXi server. - If the value is not specified in the task, the value of environment variable C(VMWARE_PORT) will be used instead. - Environment variable support added in Ansible 2.6. type: int type: choices: - dhcp - static description: - Type of DNS assignment. Either C(dhcp) or C(static). - A VMkernel adapter needs to be set to DHCP if C(type) is set to C(dhcp). required: true type: str device: description: - The VMkernel network adapter to obtain DNS settings from. - Needs to get its IP through DHCP, a static network configuration combined with a dynamic DNS configuration doesn't work. - The parameter is only required in case of C(type) is set to C(dhcp). type: str domain: description: - The domain name to be used for the ESXi host. type: str verbose: default: false description: - Verbose output of the DNS server configuration change. - Explains if an DNS server was added, removed, or if the DNS server sequence was changed. type: bool hostname: description: - The hostname or IP address of the vSphere vCenter or ESXi server. - If the value is not specified in the task, the value of environment variable C(VMWARE_HOST) will be used instead. - Environment variable support added in Ansible 2.6. type: str password: aliases: - pass - pwd description: - The password of the vSphere vCenter or ESXi server. - If the value is not specified in the task, the value of environment variable C(VMWARE_PASSWORD) will be used instead. - Environment variable support added in Ansible 2.6. type: str username: aliases: - admin - user description: - The username of the vSphere vCenter or ESXi server. - If the value is not specified in the task, the value of environment variable C(VMWARE_USER) will be used instead. - Environment variable support added in Ansible 2.6. type: str host_name: description: - The hostname to be used for the ESXi host. - Cannot be used when configuring a complete cluster. type: str proxy_host: description: - 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 C(VMWARE_PROXY_HOST) will be used instead. - This feature depends on a version of pyvmomi greater than v6.7.1.2018.12 required: false type: str proxy_port: description: - 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 C(VMWARE_PROXY_PORT) will be used instead. required: false type: int dns_servers: description: - A list of DNS servers to be used. - The order of the DNS servers is important as they are used consecutively in order. type: list cluster_name: description: - Name of the cluster from which all host systems will be used. - This parameter is required if C(esxi_hostname) is not specified and you connect to a vCenter. - Cannot be used when you connect directly to an ESXi host. type: str esxi_hostname: description: - Name of the host system to work with. - This parameter is required if C(cluster_name) is not specified and you connect to a vCenter. - Cannot be used when you connect directly to an ESXi host. type: str search_domains: description: - A list of domains to be searched through by the resolver. type: list validate_certs: default: true description: - Allows connection when SSL certificates are not valid. Set to C(false) when certificates are not trusted. - If the value is not specified in the task, the value of environment variable C(VMWARE_VALIDATE_CERTS) will be used instead. - Environment variable support added in Ansible 2.6. - If set to C(yes), please make sure Python >= 2.7.9 is installed on the given machine. type: bool
dns_config_result: description: metadata about host system's DNS configuration returned: always sample: esx01.example.local: changed: true dns_servers: - 192.168.1.10 - 192.168.1.11 dns_servers_changed: - 192.168.1.12 - 192.168.1.13 dns_servers_previous: - 192.168.1.10 - 192.168.1.11 - 192.168.1.12 - 192.168.1.13 domain: example.local host_name: esx01 msg: DNS servers and Search domains changed search_domains: - subdomain.example.local - example.local search_domains_changed: - subdomain.example.local search_domains_previous: - example.local type: dict