puppetlabs / puppet

Server automation framework and application
https://puppet.com/open-source/#osp
Apache License 2.0
7.41k stars 2.19k forks source link

puppet-agent on Debian 12 says: Error: Failed to apply catalog: Resource type 'Augeas' was not found #9181

Closed elofu17 closed 10 months ago

elofu17 commented 10 months ago

The default install of puppet-agent on Debian 12 lacks augeas support.

See bottom of report for my workaround.

Story

When running puppet agent -t on a Debian 12 machine, I get the following error:

root@baz:~# puppet agent -t
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Failed to apply catalog: Resource type 'Augeas' was not found
root@baz:~#

Steps to Reproduce

I have installed a brand new Debian 12 (bookworm) machine (it is an EC2 instance in AWS, based on the official Debian 12 AMI from Debian).

Since the puppet-agent .deb package now seem to be located in the official Debian APT repo, I have not added any custom APT source. (comparison: on my Debian 11 machines I have /etc/apt/sources.list.d/puppet7.list : deb http://apt.puppetlabs.com bullseye puppet7)

echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01_no_recommends
apt update && apt -y full-upgrade
apt -y install puppet-agent

mkdir /var/lib/puppet
echo -e 'vardir = /var/lib/puppet\nssldir = /var/lib/puppet/ssl\nserver = puppet-master2.foo.bar' > /etc/puppet/puppet.conf
puppet ssl bootstrap 
  <I get a signed cerificate>

I declare the node baz.foo.bar in nodes.pp and assign a profile. As long as the profile and manifest don't contain any augeas calls, everything is working fine:

root@baz:~# puppet agent -t
Info: Using environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for baz.foo.bar
Info: Applying configuration version 'ea40e02a'
<...doing my changes...>
Notice: Applied catalog in 3.05 seconds
root@baz:~#

But if I add any augeas call - for example:

  augeas { '/etc/default/puppet: enable puppet daemon':
    changes => [
      'set /files/etc/default/puppet/START yes',
      ],
  }

...then puppet-agent immediately bail with "Error: Failed to apply catalog: Resource type 'Augeas' was not found". (see example run at the top).

Additional Context

Package: puppet-agent Version: 7.23.0-1

I also tried this:

apt install augeas-tools
apt install puppet-module-puppetlabs-augeas-core
apt install puppet-module-camptocamp-augeas
apt install libaugeas-dev
reboot

...but it is still the same.

During my debugging I found that on my Deb11 machines, augeas seem to be installed here: /opt/puppetlabs/puppet/vendor_modules/augeas_core/ Also I see that no .deb libs or packages are installed: dpkg -l | grep aug

Also if I run `puppet module list` it says no module installed: ``` /etc/puppetlabs/code/environments/production/modules (no modules installed) /etc/puppetlabs/code/modules (no modules installed) /opt/puppetlabs/puppet/modules (no modules installed) ``` ...so I'm not sure how and where puppet agent actually manages to find the augeas functions. Perhaps via `puppet config print vendormoduledir` = `/opt/puppetlabs/puppet/vendor_modules`? Compared to the Deb12 machine: Augeas seem to be installed here: `/usr/share/puppet/modules.available/puppetlabs-augeas-core/` Libs and packages are installed. Example from before I manually try to add additional packages: ``` root@baz:~# dpkg -l | grep aug ii augeas-lenses 1.14.0-1 all Set of lenses needed by libaugeas0 to parse config files ii libaugeas0:amd64 1.14.0-1 amd64 Augeas configuration editing library and API ii ruby-augeas 1:0.5.0+gem-1 amd64 Augeas bindings for the Ruby language root@baz:~# ``` ...and after I added the additional packages: ``` root@baz:~# dpkg -l | grep aug ii augeas-lenses 1.14.0-1 all Set of lenses needed by libaugeas0 to parse config files ii augeas-tools 1.14.0-1 amd64 Augeas command line tools ii libaugeas-dev:amd64 1.14.0-1 amd64 Development files for writing applications based on libaugeas0 ii libaugeas0:amd64 1.14.0-1 amd64 Augeas configuration editing library and API ii puppet-module-camptocamp-augeas 1.9.0-2 all Puppet module for Augeas ii puppet-module-puppetlabs-augeas-core 1.1.2-1 all Puppet module for Augeas Core ii ruby-augeas 1:0.5.0+gem-1 amd64 Augeas bindings for the Ruby language root@baz:~# ``` If I run `puppet module list` it says the module installed, **but apparently it is not found/used** since I get that error. ``` root@baz:~# puppet module list /usr/share/puppet/modules └── puppetlabs-augeas_core (v1.1.2) root@baz:~# ``` If I run `puppet config print vendormoduledir` on Deb12 I get `/usr/share/puppet/vendor_modules`.


Now, when writing this report, I thought: what if I put a symlink to that augeas_core module in the vendor_modules dir? ``` root@baz:~# cd /usr/share/puppet/vendor_modules root@baz:/usr/share/puppet/vendor_modules# ln -s /usr/share/puppet/modules.available/puppetlabs-augeas-core root@baz:/usr/share/puppet/vendor_modules# puppet agent -t--noop Info: Using environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Info: Applying configuration version '219979d0' --- /etc/default/puppet 2023-02-10 15:54:26.000000000 +0100 +++ /etc/default/puppet.augnew 2023-12-07 15:54:41.901167922 +0100 @@ -2,3 +2,4 @@ # Startup options DAEMON_OPTS="" +START=yes Notice: /Stage[main]/Profiles::Puppetnode/Augeas[/etc/default/puppet: enable puppet daemon]/returns: current_value 'need_to_run', should be 0 (noop) Notice: Applied catalog in 1.94 seconds root@baz:/usr/share/puppet/vendor_modules# ``` Wheee! It worked. I leave it to you to find the correct solution to this, if this is a bug. If not, should I have run some special command to "register" that available module?
elofu17 commented 10 months ago

The homepage for augeas_core (https://forge.puppet.com/modules/puppetlabs/augeas_core/readme) says:

Setup Requirements: The augeas libraries and ruby bindings must be installed in order to use this module. If you are using puppet-agent packages, then those prerequisites are already satisfied for most platforms.

So for Debian 12, that last sentence don't really apply right now.

To make puppet-agent work the way I'm used to, I currently have to run:

apt install puppet-module-puppetlabs-augeas-core
ln -s /usr/share/puppet/modules.available/puppetlabs-augeas-core /usr/share/puppet/vendor_modules/

I guess you should do something like this to solve this issue:

1 In the puppet-agent .deb package, move puppet-module-puppetlabs-augeas-core from Suggests to Depends (together with 'ruby-augeas' which is already there).

Ok, now the module is installed, but this is not enough. Because even though puppet module list show that it is installed...

root@baz:~# puppet module list
/usr/share/puppet/modules
└── puppetlabs-augeas_core (v1.1.2)

...apparently it is not found since we get the "'Augeas' was not found" message.

2 I assume the module "registration" is done correctly when the above package is installed (it is located here: /usr/share/puppet/modules/augeas_core -> /etc/alternatives/puppet-module-augeas-core -> /usr/share/puppet/modules.available/puppetlabs-augeas-core).

So the bug must be in 'puppet-agent'. It need to be fixed to find and use the installed module somehow.

joshcooper commented 10 months ago

Hi @elofu17 this is a dup of 9149. We will release support for debian 12 in the future and our packages will include core modules.

elofu17 commented 10 months ago

No, this is not a dupe of #9149. However, I see I filed the issue in the wrong git repo, so I have now created https://github.com/puppetlabs/puppet-agent/issues/2445 instead.

kenyon commented 10 months ago

@elofu17 it's not really a duplicate of #9149, but you're using a package created by Debian developers, which is maintained here: https://tracker.debian.org/pkg/puppet-agent

This repo is for Puppet upstream, and https://github.com/puppetlabs/puppet-agent/ is for the packages created by Puppet Labs (Perforce), which don't exist yet for Debian 12, which is what #9149 is about.

Your bug report should go to https://bugs.debian.org/puppet-agent instead.

joshcooper commented 10 months ago

Sorry, yeah "dupe" isn't the right term. I was trying to say that the issue you're running into with Debian provided puppet-agent packages (which is already filed as https://github.com/puppetlabs/puppet-agent/issues/2445#issuecomment-1854314861) will be a non-issue once we ship Debian 12 support and you can just use our packages.