Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd-resolved cannot be fully disabled because /etc/resolv.conf is managed #203

Closed
jcbollinger opened this issue Jul 15, 2021 · 3 comments · Fixed by #252
Closed

systemd-resolved cannot be fully disabled because /etc/resolv.conf is managed #203

jcbollinger opened this issue Jul 15, 2021 · 3 comments · Fixed by #252
Labels
bug Something isn't working

Comments

@jcbollinger
Copy link

jcbollinger commented Jul 15, 2021

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: all
  • Ruby: all
  • Distribution: Ubuntu 20.04 (client)
  • Module version: 3.0.0, 3.1.0

How to reproduce (e.g Puppet code you use)

class demo {
  class { 'systemd':
    manage_resolved => true,
    resolved_ensure => 'stopped',
  }

  file { '/etc/resolv.conf':
    ensure => 'file',
  }
}

What are you seeing

Catalog compilation fails with with a duplicate resource declaration error.

What behaviour did you expect instead

File[/etc/resolv.conf] should not be managed when systemd-resolved is managed to the stopped state.

Output log

Duplicate declaration: File[/etc/resolv.conf] is already declared at (.../modules/systemd/manifests/resolved.pp, line: 77); cannot redeclare (.../modules/demo/manifests/init.pp, line: 7) (file: .../modules/demo/spec/fixtures/modules/demo/manifests/init.pp, line: 7, column: 3) on node ...

Any additional information you'd like to impart

Just stopping systemd-resolved on a system that has had it configured completely breaks name resolution. Something else needs to manage /etc/resolv.conf afterward, or at least to update it once, but the module interferes with that.

For context, on domain-joined Ubuntu 20.04, systemd-resolved needs to be disabled in order for sssd to authenticate users against Active Directory.

Here is the RSpec test used to demonstrate the issue:

# frozen_string_literal: true

require 'spec_helper'

describe 'demo' do
  on_supported_os.each do |os, os_facts|
    context "on #{os}" do
      let(:facts) { os_facts.merge(systemd_internal_services: { 'systemd-resolved.service' => 'enabled' }) }

      it { is_expected.to compile }
    end
  end
end
@kenyon kenyon added the bug Something isn't working label Aug 3, 2021
@traylenator
Copy link
Contributor

traylenator commented Feb 17, 2022

Agree it would be nice to get this or someway of safely exiting systemd-resolved once it is deployed

Background is that if you stop

systemd  stop systemd-resolved

Then both of the possible targets of /etc/resolv.conf are left behind i.e

  • /run/systemd/resolve/stub-resolv.conf
  • /run/systemd/resolve/resolv.conf

so setting use_stuf_file => false at the same time to restore symlink to /run/systemd/resolve/resolv.conf
may seem like a good idea until you reboot and /run/systemd/resolve is not there.

In a non puppet world it would be

rm -f /etc/resolv.conf
systemctl restart NetworkManager

but that is very OS dependent of course.

How about something like

exec{'install_working_resolve_conf':
     command  => `cp /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf`
     onlyif         => `resolv.conf  is a symlink one of  /run/systemd/resolve/stub-resolv.conf or  /run/systemd/resolve/resolv.conf`
}

all a bit fiddly.

@traylenator
Copy link
Contributor

On the very fine point I agree when the service is stopped /etc/resolv.conf should not be managed as that is only going to end badly.

@ekohl
Copy link
Member

ekohl commented Feb 17, 2022

It feels to me like we should document that resolv.conf gets left behind and it's up to the user of this module to find some other content. As @traylenator correctly states: the replacement is not always the same. Some may end up with a static resolv.conf file, others may use NetworkManagers and there are probably a few more options out there. Trying to solve it here will just end poorly.

op-ct pushed a commit to op-ct/puppet-systemd that referenced this issue Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants