Skip to content

Commit

Permalink
Fixes #37919 - make sure sudo is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard authored and nadjaheitmann committed Oct 18, 2024
1 parent 2556ac5 commit a0d5f06
Show file tree
Hide file tree
Showing 24 changed files with 903 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ description: |
file.
-%>

# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
<%= indent(2) { snippet 'pkg_manager' } -%>
fi

<% if !host_param('remote_execution_ssh_keys').blank? %>
<% ssh_user = host_param('remote_execution_ssh_user') || 'root' %>

Expand Down Expand Up @@ -58,6 +63,7 @@ EOF
command -v restorecon && restorecon -RvF <%= ssh_path %> || true

<% if ssh_user != 'root' && host_param('remote_execution_effective_user_method') == 'sudo' -%>
$PKG_MANAGER_INSTALL sudo
<% if @host.operatingsystem.family == 'Redhat' || @host.operatingsystem.family == 'Debian' -%>
echo "<%= ssh_user %> ALL = (root) NOPASSWD : ALL" > /etc/sudoers.d/<%= ssh_user %>
echo "Defaults:<%= ssh_user %> !requiretty" >> /etc/sudoers.d/<%= ssh_user %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,45 @@ runcmd:
/usr/sbin/hwclock --systohc
- |

# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi


- |
echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,45 @@ runcmd:

- |

# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi


- |
echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,45 @@ runcmd:
/usr/sbin/hwclock --systohc
- |

# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi


- |
echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,45 @@ echo "Performing initial puppet run for --tags no_such_tag"



# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi



PATH=/usr/bin:/usr/sbin:/bin:/sbin:$PATH shutdown -r +1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,45 @@ else
fi


# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,45 @@



# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi



echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,45 @@



# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi



echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,45 @@ cp /etc/resolv.conf /mnt/etc



# Select package manager for the OS (sets the $PKG_MANAGER* variables)
if [ -z "$PKG_MANAGER" ]; then
if [ -f /etc/os-release ] ; then
. /etc/os-release
fi

if [ "${NAME%.*}" = 'FreeBSD' ]; then
PKG_MANAGER='pkg'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} delete -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} install -y"
elif [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/amazon-linux-release -o -f /etc/system-release ]; then
PKG_MANAGER='dnf'
if [ -f /etc/redhat-release -a "${VERSION_ID%.*}" -le 7 ]; then
PKG_MANAGER='yum'
elif [ -f /etc/system-release ]; then
PKG_MANAGER='yum'
fi
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} upgrade -y"
elif [ -f /etc/debian_version ]; then
PKG_MANAGER='apt-get'
PKG_MANAGER_INSTALL="${PKG_MANAGER} install -y"
PKG_MANAGER_REMOVE="${PKG_MANAGER} remove -y"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' -o APT::Get::Upgrade-Allow-New='true' upgrade -y"
elif [ -f /etc/arch-release ]; then
PKG_MANAGER='pacman'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --noconfirm -S"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --noconfirm -R"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --noconfirm -S"
elif [ x$ID = xopensuse-tumbleweed -o x$ID = xsles ]; then
PKG_MANAGER='zypper'
PKG_MANAGER_INSTALL="${PKG_MANAGER} --non-interactive install --auto-agree-with-licenses"
PKG_MANAGER_REMOVE="${PKG_MANAGER} --non-interactive remove"
PKG_MANAGER_UPGRADE="${PKG_MANAGER} --non-interactive update"
fi
fi



echo "blacklist amodule" >> /etc/modprobe.d/blacklist.conf
Expand Down
Loading

0 comments on commit a0d5f06

Please sign in to comment.