cloud-init resolv.conf not being setup

General support questions
vamfoom
Posts: 21
Joined: 2014/05/24 01:28:37

cloud-init resolv.conf not being setup

Postby vamfoom » 2018/04/13 22:27:20

I have the following in my user-data file for cloud-init, but this doesn't seem to work:

Code: Select all

#cloud-config
manage_resolv_conf: true
resolv_conf:
  nameservers: ['10.1.1.100]
  searchdomains:
    - myawesomedomain.com
  domain: myawesomedomain.com
  options:
    rotate: true
    timeout: 1


But this is written in resolv.conf instead:

Code: Select all

# cat /etc/resolv.conf
; Created by cloud-init on instance boot automatically, do not edit.
;
# Generated by NetworkManager
nameserver 10.0.2.3
search localdomain


I haven't the slightest clue where that IP came from. what am I missing?

User avatar
TrevorH
Forum Moderator
Posts: 22285
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: cloud-init resolv.conf not being setup

Postby TrevorH » 2018/04/14 12:08:56

# Generated by NetworkManager


Whatever was in there has been overwritten by NM when it started up. Check in /etc/sysconfig/network-scripts/ifcfg-* files for lines like DNS1= and remove them. If all else fails, add PEERDNS=no to them.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

vamfoom
Posts: 21
Joined: 2014/05/24 01:28:37

Re: cloud-init resolv.conf not being setup

Postby vamfoom » 2018/04/17 00:25:00

I figured it out after playing with it for a little while.

Turns out cloud-init by default doesn't run the resolv_conf module. I had to enable this module in cloud_config_module.

desertcat
Posts: 299
Joined: 2014/08/07 02:17:29

Re: cloud-init resolv.conf not being setup

Postby desertcat » 2018/04/17 23:00:52

vamfoom wrote:I have the following in my user-data file for cloud-init, but this doesn't seem to work:

Code: Select all

#cloud-config
manage_resolv_conf: true
resolv_conf:
  nameservers: ['10.1.1.100]
  searchdomains:
    - myawesomedomain.com
  domain: myawesomedomain.com
  options:
    rotate: true
    timeout: 1


But this is written in resolv.conf instead:

Code: Select all

# cat /etc/resolv.conf
; Created by cloud-init on instance boot automatically, do not edit.
;
# Generated by NetworkManager
nameserver 10.0.2.3
search localdomain


I haven't the slightest clue where that IP came from. what am I missing?


Just a quick heads up: I was prowling (that's what cats do) the RHEL 7.5 features, and from what I saw it is far more "cloud" intensive. CentOS is a clone of RHEL so I'm sure that CentOS 7.5 when it comes out within the next 4-8 weeks is likewise to be more "cloud" intensive as well. Stay tuned. For a preview of what you are likely to see in CentOS 7.5 look at the early reviews of RHEL 7.5

vamfoom
Posts: 21
Joined: 2014/05/24 01:28:37

Re: cloud-init resolv.conf not being setup

Postby vamfoom » 2018/04/17 23:13:13

I figured out why resolv.conf was not being changed via cloud-init. Turns out the resolv_conf cloud-init module isn't enabled by default so you have to enable it. Ideally, every module should be enabled or at least a log entry should be made to indicate unknown module. Took me a couple of hours of trial-and-error plus googling.