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 adamruzicka committed Oct 30, 2024
1 parent 496c78b commit 0175585
Show file tree
Hide file tree
Showing 24 changed files with 905 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,9 @@ EOF
command -v restorecon && restorecon -RvF <%= ssh_path %> || true

<% if ssh_user != 'root' && host_param('remote_execution_effective_user_method') == 'sudo' -%>
if [ ! -x "$(command -v sudo)" ]; then
$PKG_MANAGER_INSTALL sudo
fi
<% 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 0175585

Please sign in to comment.