summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_resolv_conf.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/config/cc_resolv_conf.py')
-rw-r--r--cloudinit/config/cc_resolv_conf.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/cloudinit/config/cc_resolv_conf.py b/cloudinit/config/cc_resolv_conf.py
index 466dad03..c51967e2 100644
--- a/cloudinit/config/cc_resolv_conf.py
+++ b/cloudinit/config/cc_resolv_conf.py
@@ -30,7 +30,7 @@ are configured correctly.
**Module frequency:** per instance
-**Supported distros:** alpine, fedora, rhel, sles
+**Supported distros:** alpine, fedora, photon, rhel, sles
**Config keys**::
@@ -47,18 +47,23 @@ are configured correctly.
"""
from cloudinit import log as logging
-from cloudinit.settings import PER_INSTANCE
from cloudinit import templater
+from cloudinit.settings import PER_INSTANCE
from cloudinit import util
LOG = logging.getLogger(__name__)
frequency = PER_INSTANCE
-distros = ['alpine', 'fedora', 'opensuse', 'rhel', 'sles']
+distros = ['alpine', 'fedora', 'opensuse', 'photon', 'rhel', 'sles']
+
+RESOLVE_CONFIG_TEMPLATE_MAP = {
+ '/etc/resolv.conf': 'resolv.conf',
+ '/etc/systemd/resolved.conf': 'systemd.resolved.conf',
+}
-def generate_resolv_conf(template_fn, params, target_fname="/etc/resolv.conf"):
+def generate_resolv_conf(template_fn, params, target_fname):
flags = []
false_flags = []
@@ -104,12 +109,18 @@ def handle(name, cfg, cloud, log, _args):
if "resolv_conf" not in cfg:
log.warning("manage_resolv_conf True but no parameters provided!")
- template_fn = cloud.get_template_filename('resolv.conf')
- if not template_fn:
+ try:
+ template_fn = cloud.get_template_filename(
+ RESOLVE_CONFIG_TEMPLATE_MAP[cloud.distro.resolv_conf_fn])
+ except KeyError:
log.warning("No template found, not rendering /etc/resolv.conf")
return
- generate_resolv_conf(template_fn=template_fn, params=cfg["resolv_conf"])
+ generate_resolv_conf(
+ template_fn=template_fn,
+ params=cfg["resolv_conf"],
+ target_fname=cloud.disro.resolve_conf_fn
+ )
return
# vi: ts=4 expandtab