Browse code

Patch cloud-init to update systemd resolved.conf file

Change-Id: Id9894397c4130591accb40875886a59e00468023
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4055
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Tested-by: Anish Swaminathan <anishs@vmware.com>

Vinay Kulkarni authored on 2017/10/17 13:10:17
Showing 2 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 
3 3
 Name:           cloud-init
4 4
 Version:        0.7.9
5
-Release:        12%{?dist}
5
+Release:        13%{?dist}
6 6
 Summary:        Cloud instance init scripts
7 7
 Group:          System Environment/Base
8 8
 License:        GPLv3
... ...
@@ -20,6 +20,7 @@ Patch4:         resizePartitionUUID.patch
20 20
 Patch5:         datasource-guestinfo.patch
21 21
 Patch6:         systemd-service-changes.patch
22 22
 Patch7:         makecheck.patch
23
+Patch8:         systemd-resolved-config.patch
23 24
 
24 25
 BuildRequires:  python3
25 26
 BuildRequires:  python3-libs
... ...
@@ -64,6 +65,7 @@ ssh keys and to let the user run various scripts.
64 64
 %patch5 -p1
65 65
 %patch6 -p1
66 66
 %patch7 -p1
67
+%patch8 -p1
67 68
 
68 69
 find systemd -name cloud*.service | xargs sed -i s/StandardOutput=journal+console/StandardOutput=journal/g
69 70
 
... ...
@@ -134,6 +136,8 @@ rm -rf $RPM_BUILD_ROOT
134 134
 
135 135
 
136 136
 %changelog
137
+*   Mon Oct 16 2017 Vinay Kulkarni <kulakrniv@vmware.com> 0.7.9-13
138
+-   Support configuration of systemd resolved.conf
137 139
 *   Wed Sep 20 2017 Alexey Makhalov <amakhalov@vmware.com> 0.7.9-12
138 140
 -   Requires net-tools or toybox
139 141
 *   Wed Sep 20 2017 Anish Swaminathan <anishs@vmware.com> 0.7.9-11
140 142
new file mode 100644
... ...
@@ -0,0 +1,51 @@
0
+diff -uNr cloud-init-0.7.9-orig/cloudinit/config/cc_resolv_conf.py cloud-init-0.7.9/cloudinit/config/cc_resolv_conf.py
1
+--- cloud-init-0.7.9-orig/cloudinit/config/cc_resolv_conf.py	2017-10-16 18:28:37.374850375 +0000
2
+@@ -55,10 +55,10 @@
3
+ 
4
+ frequency = PER_INSTANCE
5
+ 
6
+-distros = ['fedora', 'rhel', 'sles']
7
++distros = ['fedora', 'rhel', 'sles', 'photon']
8
+ 
9
+ 
10
+-def generate_resolv_conf(template_fn, params, target_fname="/etc/resolv.conf"):
11
++def generate_resolv_conf(template_fn, params, target_fname="/etc/systemd/resolved.conf"):
12
+     flags = []
13
+     false_flags = []
14
+ 
15
+@@ -104,12 +104,13 @@
16
+     if "resolv_conf" not in cfg:
17
+         log.warn("manage_resolv_conf True but no parameters provided!")
18
+ 
19
+-    template_fn = cloud.get_template_filename('resolv.conf')
20
++    template_fn = cloud.get_template_filename('systemd.resolved.conf')
21
+     if not template_fn:
22
+-        log.warn("No template found, not rendering /etc/resolv.conf")
23
++        log.warn("No template found, not rendering /etc/systemd/resolved.conf")
24
+         return
25
+ 
26
+     generate_resolv_conf(template_fn=template_fn, params=cfg["resolv_conf"])
27
++    util.subp(["systemctl", "restart", "systemd-resolved"])
28
+     return
29
+ 
30
+ # vi: ts=4 expandtab
31
+diff -uNr cloud-init-0.7.9-orig/templates/systemd.resolved.conf.tmpl cloud-init-0.7.9/templates/systemd.resolved.conf.tmpl
32
+--- cloud-init-0.7.9-orig/templates/systemd.resolved.conf.tmpl	1970-01-01 00:00:00.000000000 +0000
33
+@@ -0,0 +1,15 @@
34
++## template:jinja
35
++# Your system has been configured with 'manage-resolv-conf' set to true.
36
++# As a result, cloud-init has written this file with configuration data
37
++# that it has been provided. Cloud-init, by default, will write this file
38
++# a single time (PER_ONCE).
39
++#
40
++[Resolve]
41
++LLMNR=false
42
++{% if nameservers is defined %}
43
++DNS={% for server in nameservers %}{{server}} {% endfor %}
44
++{% endif %}
45
++
46
++{% if searchdomains is defined %}
47
++Domains={% for search in searchdomains %}{{search}} {% endfor %}
48
++{% endif %}