From 86ab28cfb01507041bef1dcb66a5e71e3ef3ab42 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Fri, 14 Jul 2017 19:04:42 +0200 Subject: [PATCH] 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 --- playbooks/library/network_metadata.py | 19 ++++++++----------- .../bifrost-configdrives-dynamic/README.md | 4 +++- .../tasks/main.yml | 2 +- .../list_of_nameservers-cea9e03675bf56bf.yaml | 7 +++++++ 4 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/list_of_nameservers-cea9e03675bf56bf.yaml diff --git a/playbooks/library/network_metadata.py b/playbooks/library/network_metadata.py index 4c3c35057..222f6ed67 100644 --- a/playbooks/library/network_metadata.py +++ b/playbooks/library/network_metadata.py @@ -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, diff --git a/playbooks/roles/bifrost-configdrives-dynamic/README.md b/playbooks/roles/bifrost-configdrives-dynamic/README.md index 5ec1171ed..144e66b63 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/README.md +++ b/playbooks/roles/bifrost-configdrives-dynamic/README.md @@ -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. diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml index 8aef2b189..b8ba40c47 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml @@ -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') }}" diff --git a/releasenotes/notes/list_of_nameservers-cea9e03675bf56bf.yaml b/releasenotes/notes/list_of_nameservers-cea9e03675bf56bf.yaml new file mode 100644 index 000000000..12ede28be --- /dev/null +++ b/releasenotes/notes/list_of_nameservers-cea9e03675bf56bf.yaml @@ -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. +