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

kubevirt: Add hostname and subdomain parameters #57223

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- Added new parameters hostname and subdomain to kubevirt_vm module.
10 changes: 10 additions & 0 deletions lib/ansible/module_utils/kubevirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
VM_COMMON_ARG_SPEC = {
'name': {'required': True},
'namespace': {'required': True},
'hostname': {'type': 'str'},
'subdomain': {'type': 'str'},
'state': {
'default': 'present',
'choices': ['present', 'absent'],
Expand Down Expand Up @@ -329,6 +331,8 @@ def _construct_vm_definition(self, kind, definition, template, params, defaults=
node_affinity = params.get('node_affinity')
vm_affinity = params.get('affinity')
vm_anti_affinity = params.get('anti_affinity')
hostname = params.get('hostname')
subdomain = params.get('subdomain')
template_spec = template['spec']

# Merge additional flat parameters:
Expand Down Expand Up @@ -418,6 +422,12 @@ def _construct_vm_definition(self, kind, definition, template, params, defaults=
'matchExpressions': affinity.get('term').get('match_expressions'),
})

if hostname:
template_spec['hostname'] = hostname

if subdomain:
template_spec['subdomain'] = subdomain

# Define disks
self._define_disks(disks, template_spec, defaults)

Expand Down
11 changes: 11 additions & 0 deletions lib/ansible/plugins/doc_fragments/kubevirt_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ class ModuleDocFragment(object):
description:
- "Specify tablets to be used as input devices"
type: list
hostname:
description:
- "Specifies the hostname of the virtual machine. The hostname will be set either by dhcp, cloud-init if configured or virtual machine
name will be used."
version_added: 2.9
subdomain:
description:
- "If specified, the fully qualified virtual machine hostname will be hostname.subdomain.namespace.svc.cluster_domain. If not specified,
the virtual machine will not have a domain name at all. The DNS entry will resolve to the virtual machine, no matter if the virtual machine
itself can pick up a hostname."
version_added: 2.9
requirements:
- python >= 2.7
- openshift >= 0.8.2
Expand Down