[Bug] - Need to Explicitly Specify `systemd` Provider in Puppet for Amazon Linux 2023
Describe the bug
On Amazon Linux 2, Puppet was able to manage services without the need to explicitly specify the systemd provider. However, on Amazon Linux 2023, I need to explicitly specify the systemd provider to enable and manage services properly.
To Reproduce Steps to reproduce the behavior:
- Define a service in Puppet for Amazon Linux 2 without specifying the provider.
service { 'squid':
ensure => running,
enable => true,
hasstatus => true,
require => File['/etc/sysconfig/squid'],
}
- Run Puppet on an Amazon Linux 2 instance. The service is managed without issues.
- Define the same service in Puppet for Amazon Linux 2023 without specifying the provider.
service { 'squid':
ensure => running,
enable => true,
hasstatus => true,
require => File['/etc/sysconfig/squid'],
}
- Run Puppet on an Amazon Linux 2023 instance. Puppet fails to enable the service with the following error:
Error: Could not enable squid: Execution of '/sbin/chkconfig --add squid' returned 1: error reading information on service squid: No such file or directory
Error: /Stage[main]/Squid/Service[squid]/enable: change from false to true failed: Could not enable squid: Execution of '/sbin/chkconfig --add squid' returned 1: error reading information on service squid: No such file or directory
Expected behavior Puppet should manage services on Amazon Linux 2023 without needing to explicitly specify the systemd provider, similar to how it functions on Amazon Linux 2.
Desktop (please complete the following information):
- OS: Amazon Linux 2023. Version Amazon Linux 2023.5.20240708
- Puppet version: 4.10.4
Additional context Disabling the enable attribute allows Puppet to run without errors:
service { 'squid':
ensure => running,
# enable => true,
hasstatus => true,
require => File['/etc/sysconfig/squid'],
}
Not sure, why specifying the systemd provider explicitly is necessary for Amazon Linux 2023 and consider making it consistent with Amazon Linux 2 where the provider did not need to be specified.
AWS Docs say they retain backwards compatibility with System V service (init) scripts but that does not explain the culprit because AL2 uses systemd by default.
From /etc/init.d/README:
You are looking for the traditional init scripts in /etc/rc.d/init.d,
and they are gone?
Here's an explanation on what's going on:
You are running a systemd-based OS where traditional init scripts have
been replaced by native systemd services files. Service files provide
very similar functionality to init scripts. To make use of service
files simply invoke "systemctl", which will output a list of all
currently running services (and other units). Use "systemctl
list-unit-files" to get a listing of all known unit files, including
stopped, disabled and masked ones. Use "systemctl start
foobar.service" and "systemctl stop foobar.service" to start or stop a
service, respectively. For further details, please refer to
systemctl(1).
Note that traditional init scripts continue to function on a systemd
system. An init script /etc/rc.d/init.d/foobar is implicitly mapped
into a service unit foobar.service during system initialization.
Thank you!
chkconfig --add squid is failing because there's no /etc/rc.d/init.d/squid service to add, and that's your culprit 🙂
From
/etc/init.d/README:You are looking for the traditional init scripts in /etc/rc.d/init.d, and they are gone? Here's an explanation on what's going on: You are running a systemd-based OS where traditional init scripts have been replaced by native systemd services files. Service files provide very similar functionality to init scripts. To make use of service files simply invoke "systemctl", which will output a list of all currently running services (and other units). Use "systemctl list-unit-files" to get a listing of all known unit files, including stopped, disabled and masked ones. Use "systemctl start foobar.service" and "systemctl stop foobar.service" to start or stop a service, respectively. For further details, please refer to systemctl(1). Note that traditional init scripts continue to function on a systemd system. An init script /etc/rc.d/init.d/foobar is implicitly mapped into a service unit foobar.service during system initialization. Thank you!
chkconfig --add squidis failing because there's no/etc/rc.d/init.d/squidservice to add, and that's your culprit 🙂
Thanks for the response.
Yes. I have seen that too. However, it is the same on AL2 and this works without systemd provider.
cat /etc/init.d/README
You are looking for the traditional init scripts in /etc/rc.d/init.d,
and they are gone?
Here's an explanation on what's going on:
You are running a systemd-based OS where traditional init scripts have
been replaced by native systemd services files. Service files provide
very similar functionality to init scripts. To make use of service
files simply invoke "systemctl", which will output a list of all
currently running services (and other units). Use "systemctl
list-unit-files" to get a listing of all known unit files, including
stopped, disabled and masked ones. Use "systemctl start
foobar.service" and "systemctl stop foobar.service" to start or stop a
service, respectively. For further details, please refer to
systemctl(1).
Note that traditional init scripts continue to function on a systemd
system. An init script /etc/rc.d/init.d/foobar is implicitly mapped
into a service unit foobar.service during system initialization.
Thank you!
# cat /etc/system-release
Amazon Linux release 2 (Karoo)
# /sbin/chkconfig --add squid
error reading information on service squid: No such file or directory
@dauletilyassov on al2 there is the squid-sysvinit package providing the /etc/rc.d/init.d/squid service script. There's no such package in al2023. The package provides SysV initscript for squid caching proxy. That's why chkconfig --add woks on al2 and fails on al2023
/etc/rc.d/init.d/squid
#!/bin/bash
# chkconfig: - 90 25
# pidfile: /var/run/squid.pid
# config: /etc/squid/squid.conf
#
### BEGIN INIT INFO
# Provides: squid
# Short-Description: starting and stopping Squid Internet Object Cache
# Description: Squid - Internet Object Cache. Internet object caching is \
# a way to store requested Internet objects (i.e., data available \
# via the HTTP, FTP, and gopher protocols) on a system closer to the \
# requesting site than to the source. Web browsers can then use the \
# local Squid cache as a proxy HTTP server, reducing access time as \
# well as bandwidth consumption.
### END INIT INFO
PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
if [ -f /etc/sysconfig/squid ]; then
. /etc/sysconfig/squid
fi
# don't raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-""}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
SQUID_CONF=${SQUID_CONF:-"/etc/squid/squid.conf"}
# determine the name of the squid binary
[ -f /usr/sbin/squid ] && SQUID=squid
prog="$SQUID"
# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e 's/#.*//g' $SQUID_CONF | \
grep cache_dir | awk '{ print $3 }'`
RETVAL=0
probe() {
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1
[ `id -u` -ne 0 ] && exit 4
# check if the squid conf file is present
[ -f $SQUID_CONF ] || exit 6
}
start() {
probe
parse=`$SQUID -k parse -f $SQUID_CONF 2>&1`
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo -n $"Starting $prog: "
echo_failure
echo
echo "$parse"
return 1
fi
for adir in $CACHE_SWAP; do
if [ ! -d $adir/00 ]; then
echo -n "init_cache_dir $adir... "
$SQUID -z -F -f $SQUID_CONF >> /var/log/squid/squid.out 2>&1
fi
done
echo -n $"Starting $prog: "
$SQUID $SQUID_OPTS -f $SQUID_CONF >> /var/log/squid/squid.out 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
timeout=0;
while : ; do
[ ! -f /var/run/squid.pid ] || break
if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
RETVAL=1
break
fi
sleep 1 && echo -n "."
timeout=$((timeout+1))
done
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID
[ $RETVAL -eq 0 ] && echo_success
[ $RETVAL -ne 0 ] && echo_failure
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
$SQUID -k check -f $SQUID_CONF >> /var/log/squid/squid.out 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
$SQUID -k shutdown -f $SQUID_CONF &
rm -f /var/lock/subsys/$SQUID
timeout=0
while : ; do
[ -f /var/run/squid.pid ] || break
if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
echo
return 1
fi
sleep 2 && echo -n "."
timeout=$((timeout+2))
done
echo_success
echo
else
echo_failure
if [ ! -e /var/lock/subsys/$SQUID ]; then
RETVAL=0
fi
echo
fi
return $RETVAL
}
reload() {
$SQUID $SQUID_OPTS -k reconfigure -f $SQUID_CONF
}
restart() {
stop
start
}
condrestart() {
[ -e /var/lock/subsys/squid ] && restart || :
}
rhstatus() {
status $SQUID && $SQUID -k check -f $SQUID_CONF
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload|force-reload)
reload
;;
restart)
restart
;;
condrestart|try-restart)
condrestart
;;
status)
rhstatus
;;
probe)
probe
;;
*)
echo $"Usage: $0 {start|stop|status|reload|force-reload|restart|try-restart|probe}"
exit 2
esac
exit $?
@dauletilyassov on
al2there is thesquid-sysvinitpackage providing the/etc/rc.d/init.d/squidservice script. There's no such package inal2023. The package providesSysV initscript for squid caching proxy. That's whychkconfig --addwoks onal2and fails onal2023/etc/rc.d/init.d/squid
Hey @elsaco, where do you see that on al2?
cat /etc/rc.d/init.d/squid
cat: /etc/rc.d/init.d/squid: No such file or directory
Just to be clear running chkconfig on AL2 fails with the same error as on AL2023
/sbin/chkconfig --add squid
error reading information on service squid: No such file or directory
Also, this also fails for iptables, squid and named services on AL2023 where systemd provider is not specified
Error: Could not enable iptables: Execution of '/sbin/chkconfig --add iptables' returned 1: error reading information on service iptables: No such file or directory
Error: /Stage[main]/Firewall::Linux::Redhat/Service[iptables]/enable: change from false to true failed: Could not enable iptables: Execution of '/sbin/chkconfig --add iptables' returned 1: error reading information on service iptables: No such file or directory
Error: Could not enable squid: Execution of '/sbin/chkconfig --add squid' returned 1: error reading information on service squid: No such file or directory
Error: /Stage[main]/Squid/Service[squid]/enable: change from false to true failed: Could not enable squid: Execution of '/sbin/chkconfig --add squid' returned 1: error reading information on service squid: No such file or directory
Error: Could not enable named: Execution of '/sbin/chkconfig --add named' returned 1: error reading information on service named: No such file or directory
Error: /Stage[main]/Network::Localdnscache/Service[named]/enable: change from false to true failed: Could not enable named: Execution of '/sbin/chkconfig --add named' returned 1: error reading information on service named: No such file or directory
These are the packages on al2:
squid.x86_64 : The Squid proxy caching server
squid-migration-script.x86_64 : Migration script for squid caching proxy
squid-sysvinit.x86_64 : SysV initscript for squid caching proxy
If you want to manage services the old way installing squid-sysvinit will provide the script. Notice that this package is not a requirement to install squid on al2, only squid-migration-script is.
This is the entire content of the package:
[ec2-user ~]$ rpm -qpl squid-sysvinit-3.5.20-17.amzn2.7.20.x86_64.rpm
/etc/rc.d/init.d/squid
These are the packages on
al2:squid.x86_64 : The Squid proxy caching server squid-migration-script.x86_64 : Migration script for squid caching proxy squid-sysvinit.x86_64 : SysV initscript for squid caching proxyIf you want to manage services the old way installing
squid-sysvinitwill provide the script. Notice that this package is not a requirement to installsquidonal2, onlysquid-migration-scriptis.This is the entire content of the package:
[ec2-user ~]$ rpm -qpl squid-sysvinit-3.5.20-17.amzn2.7.20.x86_64.rpm /etc/rc.d/init.d/squid
This is what I have installed on al2:
yum list installed | grep squid
squid.x86_64 7:3.5.20-17.amzn2.7.1 @amzn2-core
squid-migration-script.x86_64 7:3.5.20-17.amzn2.7.1 @amzn2-core
We do not use squid-sysvinit.x86_64 : SysV initscript for squid caching proxy on al2.
AFAIK, AL2 should be using systemd by default to manage services and I think it does, otherwise this would have failed to enable squid like on AL2023. But for some reason, AL2023 needs systemd provider to be stated explicitly. This happens for at least 3 services, once I move to AL2023. However, this works fine without any errors on al2023.
I am trying to understand what changes on AL2023 have been made so that enabling services without explicit systemd provider won't work. My PR does not have any changes that could have interfered with that.