number5 / cloud-init Goto Github PK
View Code? Open in Web Editor NEWunofficial mirror of Ubuntu's cloud-init
Home Page: https://github.com/canonical/cloud-init
License: Other
unofficial mirror of Ubuntu's cloud-init
Home Page: https://github.com/canonical/cloud-init
License: Other
I am struggling when setting up nameservers at server boot time.
Setup
My setup is a virtual machine (CentOS8 - qemu version) managed by libvirt.
Cloud init version in CentOS8 vm
[root@services log]# cloud-init -v
/bin/cloud-init 18.5
Network setup:
<network xmlns:dnsmasq='http://libvirt.org/schemas/network/dnsmasq/1.0'>
<name>okd_network</name>
<bridge name="virbr1" />
<forward mode="nat">
<nat>
<port start='0' end='65535'/>
</nat>
</forward>
<ip address='10.0.5.1' netmask='255.255.255.0'>
<dhcp>
<host mac="52:54:10:00:05:57" name="services.sandbox.okd.local" ip="10.0.5.57"/>
<host mac="52:54:10:00:05:58" name="bootstrap.sandbox.okd.local" ip="10.0.5.58"/>
<host mac="52:54:10:00:05:59" name="control-plane-0.sandbox.okd.local" ip="10.0.5.59"/>
</dhcp>
</ip>
<dnsmasq:options>
<dnsmasq:option value="dhcp-option=option:dns-server,10.0.5.57,8.8.8.8"/>
<dnsmasq:option value="log-dhcp"/>
</dnsmasq:options>
</network>
By running this command under my host dhcping -s 10.0.5.1 -c 10.0.5.57 -h 52:54:10:00:05:57
I obtain this in my log journalctl -f -u libvirtd
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 available DHCP subnet: 10.0.5.1/255.255.255.0
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 DHCPREQUEST(virbr1) 10.0.5.57 52:54:10:00:05:57
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 tags: known, virbr1
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: Ignoring domain sandbox.okd.local for DHCP host name services
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 DHCPACK(virbr1) 10.0.5.57 52:54:10:00:05:57 services
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 next server: 10.0.5.1
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 1 option: 53 message-type 5
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 54 server-identifier 10.0.5.1
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 51 lease-time 1h
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 58 T1 30m
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 59 T2 52m30s
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 1 netmask 255.255.255.0
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 28 broadcast 10.0.5.255
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 4 option: 3 router 10.0.5.1
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 8 option: 12 hostname services
déc. 25 21:46:52 linux-4.home dnsmasq-dhcp[746134]: 3159352927 sent size: 8 option: 6 dns-server 10.0.5.57, 8.8.8.8
=> the dns-server returned by the netmasq dhcp is well defined to 10.0.5.57
and 8.8.8.8
.
After the VM has booted I've got this log cloud-init.log
2020-12-25 15:12:41,143 - stages.py[DEBUG]: applying net config names for {'version': 2, 'ethernets': {'eth0': {'match': {'mac_address': '52:54:10:00:05:57'}, 'addresses': ['10.0.5.57'], 'gateway4': '10.0.5.1', 'nameservers': {'addresses': ['127.0.0.1', '8.8.8.8']}}}}
IP and gateway addresses are well defined, however I expect to have 10.0.5.57
and 8.8.8.8
for nameservers.
Checking the network /etc/sysconfig/network-scripts/ifcfg-eth0
I've got this:
# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
DNS1=127.0.0.1
DNS2=8.8.8.8
GATEWAY=10.0.5.1
IPADDR=10.0.5.57
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
DNS1 and DNS2 do not match my expected value from dhcp setup.
If I check the /etc/resolv.conf
content I have got :
[root@services log]# cat /etc/resolv.conf
# Generated by NetworkManager
search sandbox.okd.local
nameserver 127.0.0.1
nameserver 8.8.8.8
Which correspond to the DNS1 and DNS2 values unwanted values.
If I ran dhclient
my resolv.conf is defined with expected nameservers
[root@services log]# cat /etc/resolv.conf
; generated by /usr/sbin/dhclient-script
nameserver 10.0.5.57
nameserver 8.8.8.8
So the dhcp is well defined.
What can I do to ensure that DNS1 and DNS2 will correspond to the nameservers defined in DHCP libvirt network setup ?
Generation complete.
* Stopping System V runlevel compatibility�[74G[ OK ]
Cloud-init v. 0.7.5 running 'modules:final' at Wed, 12 Nov 2014 05:43:10 +0000. Up 27.73 seconds.
2014-11-12 05:43:10,646 - util.py[WARNING]: Running ssh-authkey-fingerprints (<module 'cloudinit.config.cc_ssh_authkey_fingerprints' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyc'>) failed
ec2:
ec2: #############################################################
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
-----END SSH HOST KEY KEYS-----
Cloud-init v. 0.7.5 finished at Wed, 12 Nov 2014 05:43:10 +0000. Datasource DataSourceEc2. Up 27.88 seconds
cloud-init/cloudinit/config/cc_chef.py
Line 73 in a64b738
Hello - I noticed while getting cloud-init to bootstrap Chef that the "chef_license" entry caused Cloud-init to fail:
2021-02-23 18:36:24,030 - util.py[DEBUG]: Running module chef (<module 'cloudinit.config.cc_chef' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_chef.py'>) failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 848, in _run_modules
ran, _r = cc.run(run_name, mod.handle, func_args,
File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
results = functor(*args)
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_chef.py", line 445, in handle
util.ensure_dirs(param_paths)
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1504, in ensure_dirs
ensure_dir(d, mode)
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1557, in ensure_dir
os.makedirs(path)
File "/usr/lib/python3.8/os.py", line 223, in makedirs
mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: ''
Please let me know if you have any issues replicating.
As a heads up we do have an official mirror now:
https://github.com/cloud-init/cloud-init
Hi,
we're managing VMs that are initialized via cloud-init and noticed that after each reboot, the /etc/hosts is back to its "templated version" rather than what the config management system had updated it to.
I suppose that this line https://github.com/number5/cloud-init/blob/master/cloudinit/config/cc_update_etc_hosts.py#L24 is why it does that - is there any objection to changing this to PER_ONCE instead of PER_ALWAYS ?
If so, is there a plan to make this configurable via cloud.cfg ? OR - am I on the wrong track here :) ?
Thanks!
Alex
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.