Skip to content

Unable to set domain or search options in resolv.conf on RHEL 7 #2984

@ubuntu-server-builder

Description

@ubuntu-server-builder

This bug was originally filed in Launchpad as LP: #1712764

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2019-04-24T04:20:23.733274+00:00
date_created = 2017-08-24T08:31:20.456826+00:00
date_fix_committed = None
date_fix_released = None
id = 1712764
importance = undecided
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1712764
milestone = None
owner = r-launchpad-net-c
owner_name = Steven Edgar
private = False
status = expired
submitter = r-launchpad-net-c
submitter_name = Steven Edgar
tags = ['rhel']
duplicates = []

Launchpad user Steven Edgar(r-launchpad-net-c) wrote on 2017-08-24T08:31:20.456826+00:00

I'm running the latest RHEL AMI in AWS, listed as

Red Hat Enterprise Linux 7.4 (HVM), SSD Volume Type - ami-bb9a6bc2

(ID is from the Ireland region).

For a variety of reasons I need to set a different domain on this server than that set in the DHCP option set for the VPC. Changing the option set isn't an option, and neither is creating a separate VPC, for organisational reasons. I need the resolv.conf to contain the line

domain subdomain.example.com

although changing the search line would also appear to be sufficient for my purposes.

Now resolv.conf is managed by NetworkManager, so I could simply alter /etc/sysconfig/network-scripts/ifcfg-eth0 to add in the DOMAIN= line, but that file appears to be managed by cloud-init. What I've been unable to manage is getting cloud-init to add the DOMAIN= line to that file when it regenerates it.

I originally saw this in our custom AMI, which uses RHEL 7.3, but have just verified it in a new EC2 instance started up using the latest AWS provided RHEL 7 AMI. I have also attempted the same configuration using the latest Amazon Linux AMI with identical results. I have to state here that I'm not 100% sure I'm using the correct configuration here, not being that familiar with cloud-init, however a chat on the cloud-init IRC channel indicated the configuration in use isn't obviously incorrect.

In all cases, the ifcfg-eth0 and resolv.conf files are unchanged by the cloud-init settings I've added, and I can find no reference to string 'subdomain.example.com' anywhere under /etc

Note, I've had to edit the attached files to blank the IP addresses and change the domain to example.com due to organisational security rules.

$ uname -a
Linux ip-XXX-XXX-XXX-XXX.example.com 3.10.0-693.el7.x86_64 #1 SMP Thu Jul 6 19:56:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)

$ cloud-init -v
cloud-init 0.7.9

$ cat /etc/cloud/cloud.cfg
users:
 - default

disable_root: 1
ssh_pwauth: 0

mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
resize_rootfs_tmp: /dev
ssh_deletekeys: 0
ssh_genkeytypes: ~
syslog_fix_perms: ~

cloud_init_modules:
 - migrator
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - set_hostname
 - update_hostname
 - update_etc_hosts
 - rsyslog
 - users-groups
 - ssh

cloud_config_modules:
 - mounts
 - locale
 - set-passwords
 - rh_subscription
 - yum-add-repo
 - package-update-upgrade-install
 - timezone
 - puppet
 - chef
 - salt-minion
 - mcollective
 - disable-ec2-metadata
 - runcmd

cloud_final_modules:
 - rightscale_userdata
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message
 - power-state-change

system_info:
  default_user:
    name: ec2-user
    lock_passwd: true
    gecos: Cloud User
    groups: [wheel, adm, systemd-journal]
    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
    shell: /bin/bash
  distro: rhel
  paths:
    cloud_dir: /var/lib/cloud
    templates_dir: /etc/cloud/templates
  ssh_svcname: sshd

vim:syntax=yaml

manage_resolv_conf: true

resolv_conf:
  searchdomains:
    - subdomain.example.com
  domain: subdomain.example.com

=========================================
Amazon Linux AMI 2017.03.1 (HVM), SSD Volume Type - ami-ebd02392

$ cloud-init -v
cloud-init 0.7.6

$ cat /etc/cloud/cloud.cfg

WARNING: Modifications to this file may be overridden by files in

/etc/cloud/cloud.cfg.d

If this is set, 'root' will not be able to ssh in and they

will get a message to login instead as the default user (ec2-user)

disable_root: true

This will cause the set+update hostname module to not operate (if true)

preserve_hostname: true

datasource_list: [ Ec2, None ]

repo_upgrade: security
repo_upgrade_exclude:
 - kernel
 - nvidia*
 - cudatoolkit

mounts:
 - [ ephemeral0, /media/ephemeral0 ]
 - [ swap, none, swap, sw, "0", "0" ]

vim:syntax=yaml

manage_resolv_conf: true

resolv_conf:
  searchdomains:
    - subdomain.example.com
  domain: subdomain.example.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    launchpadMigrated from Launchpad

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions