1
votes

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

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

In my centos 7 resolv.conf after initial VM creation:

; 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 idea where that IP for the nameserver came from. Any idea what I'm missing?

1
A single quote is missing in your nameserver's value. Just in case someone (like me) copy-paste the config, modify it slightly, and does not understand why it doesn't work. - Adrian B.

1 Answers

3
votes

I figured it out eventually.

Turns out that on CentOS 7, the resolv_conf cloud-init module doesn't run by default. I had to enable this in cloud_config_modules in my user-data file:

cloud_config_modules: 
  - resolv_conf