Allows to setup more than one nameserver

There may be a need to specify more than one nameserver on your
instances. This change allows to do it, accepting a list of
nameservers in the ipv4_nameserver setting.

Change-Id: I5022b2cc0d51395379012771e2d1c3c0bc6153f7
This commit is contained in:
Yolanda Robla 2017-07-14 19:04:42 +02:00
parent 531c695a74
commit 86ab28cfb0
4 changed files with 19 additions and 13 deletions

View File

@ -29,7 +29,7 @@ def main():
ipv4_address=dict(required=False),
ipv4_gateway=dict(required=False),
ipv4_interface_mac=dict(required=False),
ipv4_nameserver=dict(required=False),
ipv4_nameserver=dict(required=False, type='list'),
ipv4_subnet_mask=dict(required=False),
vlan_id=dict(required=False),
network_mtu=dict(required=False),
@ -73,9 +73,7 @@ def main():
'type': 'ipv4',
'ip_address': module.params['ipv4_address'],
'netmask': module.params['ipv4_subnet_mask'],
'dns_nameservers': [
module.params['ipv4_nameserver']
],
'dns_nameservers': module.params['ipv4_nameserver'],
'routes': [{
'network': '0.0.0.0',
'netmask': '0.0.0.0',
@ -110,9 +108,7 @@ def main():
'type': 'ipv4',
'ip_address': module.params['ipv4_address'],
'netmask': module.params['ipv4_subnet_mask'],
'dns_nameservers': [
module.params['ipv4_nameserver']
],
'dns_nameservers': module.params['ipv4_nameserver'],
'routes': [{
'network': '0.0.0.0',
'netmask': '0.0.0.0',
@ -128,10 +124,11 @@ def main():
services = []
if module.params['ipv4_nameserver']:
services.append({
'type': 'dns',
'address': module.params['ipv4_nameserver']
})
for item in module.params['ipv4_nameserver']:
services.append({
'type': 'dns',
'address': module.params['ipv4_nameserver']
})
network_metadata = {
'links': links,

View File

@ -44,7 +44,9 @@ node_default_network_interface: This is the default network interface within
required.
ipv4_nameserver: Defines the IPv4 nameserver to configure the node with
initially in order to support name resolution.
initially in order to support name resolution. It accepts
a string with a single nameserver, or a list with several
ones.
ipv4_address: The IPv4 address of the node to be deployed, if applicable.

View File

@ -50,7 +50,7 @@
ipv4_address: "{{ ipv4_address | default('') }}"
ipv4_gateway: "{{ ipv4_gateway | default('') }}"
ipv4_interface_mac: "{{ ipv4_interface_mac | default('') }}"
ipv4_nameserver: "{{ ipv4_nameserver | default('') }}"
ipv4_nameserver: "{% if ipv4_nameserver is string %}['{{ ipv4_nameserver | default('') }}']{% else %}{{ ipv4_nameserver }}{% endif %}"
ipv4_subnet_mask: "{{ ipv4_subnet_mask | default('') }}"
vlan_id: "{{ vlan_id | default('') }}"
network_mtu: "{{ network_mtu | default('1500') }}"

View File

@ -0,0 +1,7 @@
---
features:
- Allows to set more than one nameserver in the
provisioned instances. The ipv4_nameserver setting
can now accept either a string or a list of strings,
allowing to populate all desired nameservers.