[fix] Redirect command outputs within saltify and docker_install

This commit is contained in:
William Wernert
2020-04-22 13:12:12 -04:00
parent 739989473d
commit 0250bf026a

View File

@@ -522,10 +522,10 @@ disable_misc_network_features() {
docker_install() {
if [ $OS = 'centos' ]; then
yum clean expire-cache
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y update
yum -y install docker-ce
yum clean expire-cache >> "$setup_log" 2>&1
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo >> "$setup_log" 2>&1
yum -y update >> "$setup_log" 2>&1
yum -y install docker-ce >> "$setup_log" 2>&1
else
case "$install_type" in
'MASTER' | 'EVAL')
@@ -936,70 +936,76 @@ saltify() {
# Install updates and Salt
if [ $OS = 'centos' ]; then
set_progress_str 6 'Installing various dependencies'
case "$install_type" in
'MASTER' | 'EVAL' | 'MASTERSEARCH' | 'FLEET') # FIXME: should this be separate?
yum instal -y mariadb-devel
;;
yum instal -y mariadb-devel >> "$setup_log" 2>&1
;&
'HELIXSENSOR')
reserve_group_ids
yum -y install epel-release
yum -y install wget https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm
cp /etc/yum.repos.d/salt-py3-latest.repo /etc/yum.repos.d/salt-py3-2019-2.repo
sed -i 's/latest/2019.2/g' /etc/yum.repos.d/salt-py3-2019-2.repo
set_progress_str 6 'Installing various dependencies'
yum -y install sqlite3 argon2 curl jq openssl mariadb-devel
reserve_group_ids >> "$setup_log" 2>&1
yum -y install epel-release >> "$setup_log" 2>&1
yum -y install wget https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm >> "$setup_log" 2>&1
cp /etc/yum.repos.d/salt-py3-latest.repo /etc/yum.repos.d/salt-py3-2019-2.repo >> "$setup_log" 2>&1
sed -i 's/latest/2019.2/g' /etc/yum.repos.d/salt-py3-2019-2.repo >> "$setup_log" 2>&1
yum -y install sqlite3 argon2 curl jq openssl mariadb-devel >> "$setup_log" 2>&1
# Download Ubuntu Keys in case master updates = 1
mkdir -p /opt/so/gpg
wget --inet4-only -O /opt/so/gpg/SALTSTACK-GPG-KEY.pub https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub
wget --inet4-only -O /opt/so/gpg/docker.pub https://download.docker.com/linux/ubuntu/gpg
wget --inet4-only -O /opt/so/gpg/GPG-KEY-WAZUH https://packages.wazuh.com/key/GPG-KEY-WAZUH
cp "$./yum_repos/wazuh.repo" /etc/yum.repos.d/wazuh.repo
mkdir -p /opt/so/gpg >> "$setup_log" 2>&1
wget --inet4-only -O /opt/so/gpg/SALTSTACK-GPG-KEY.pub https://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest/SALTSTACK-GPG-KEY.pub >> "$setup_log" 2>&1
wget --inet4-only -O /opt/so/gpg/docker.pub https://download.docker.com/linux/ubuntu/gpg >> "$setup_log" 2>&1
wget --inet4-only -O /opt/so/gpg/GPG-KEY-WAZUH https://packages.wazuh.com/key/GPG-KEY-WAZUH >> "$setup_log" 2>&1
cp "./yum_repos/wazuh.repo" /etc/yum.repos.d/wazuh.repo >> "$setup_log" 2>&1
set_progress_str 7 'Installing salt-master'
yum -y install salt-master-2019.2.3
systemctl enable salt-master
yum -y install salt-master-2019.2.3 >> "$setup_log" 2>&1
systemctl enable salt-master >> "$setup_log" 2>&1
;;
*)
if [ "$MASTERUPDATES" -eq 1 ]; then
# Create the GPG Public Key for the Salt Repo
cp "$./public_keys/salt.pem" /etc/pki/rpm-gpg/saltstack-signing-key
# Add the Wazuh Key
cp "$./public_keys/wazuh.pem" /etc/pki/rpm-gpg/GPG-KEY-WAZUH
if [ "$MASTERUPDATES" = '1' ]; then
{
# Create the GPG Public Key for the Salt Repo
cp "./public_keys/salt.pem" /etc/pki/rpm-gpg/saltstack-signing-key;
# Add the Wazuh Key
cp "./public_keys/wazuh.pem" /etc/pki/rpm-gpg/GPG-KEY-WAZUH;
# Copy repo files over
cp "$./yum_repos/salt-latest.repo" /etc/yum.repos.d/salt-latest.repo
cp "$./yum_repos/salt-2019-2.repo" /etc/yum.repos.d/salt-2019-2.repo
# Copy repo files over
cp "./yum_repos/salt-latest.repo" /etc/yum.repos.d/salt-latest.repo;
cp "./yum_repos/salt-2019-2.repo" /etc/yum.repos.d/salt-2019-2.repo;
} >> "$setup_log" 2>&1
else
yum -y install https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm
cp /etc/yum.repos.d/salt-py3-latest.repo /etc/yum.repos.d/salt-2019-2.repo
sed -i 's/latest/2019.2/g' /etc/yum.repos.d/salt-2019-2.repo
{
yum -y install https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm;
cp /etc/yum.repos.d/salt-py3-latest.repo /etc/yum.repos.d/salt-2019-2.repo;
sed -i 's/latest/2019.2/g' /etc/yum.repos.d/salt-2019-2.repo;
} >> "$setup_log" 2>&1
fi
;;
esac
cp "$./yum_repos/wazuh.repo" /etc/yum.repos.d/wazuh.repo
yum clean expire-cache
cp "./yum_repos/wazuh.repo" /etc/yum.repos.d/wazuh.repo >> "$setup_log" 2>&1
yum clean expire-cache >> "$setup_log" 2>&1
set_progress_str 8 'Installing salt-minion & python modules'
yum -y install epel-release\
salt-minion-2019.2.3\
python3\
python36-docker\
python36-dateutil\
python36-m2crypto\
python36-mysql\
yum-utils\
device-mapper-persistent-data\
lvm2\
openssl\
jq
yum -y update exclude=salt*
systemctl enable salt-minion
{
yum -y install epel-release\
salt-minion-2019.2.3\
python3\
python36-docker\
python36-dateutil\
python36-m2crypto\
python36-mysql\
yum-utils\
device-mapper-persistent-data\
lvm2\
openssl\
jq;
yum -y update exclude=salt*;
systemctl enable salt-minion
} >> "$setup_log" 2>&1
echo "exclude=salt*" >> /etc/yum.conf
else
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade >> "$setup_log" 2>&1
if [ $OSVER != "xenial" ]; then
# Switch to Python 3 as default if this is not xenial
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10 >> "$setup_log" 2>&1
fi
# Add the pre-requisites for installing docker-ce
apt-get -y install ca-certificates\
@@ -1021,23 +1027,23 @@ saltify() {
if [ "$OSVER" != "xenial" ]; then local py_ver_url_path="/py3"; else local py_ver_url_path="/apt"; fi
# Add saltstack repo(s)
wget --inet4-only -O - https://repo.saltstack.com"$py_ver_url_path"/ubuntu/"$ubuntu_version"/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add -
echo "deb http://repo.saltstack.com/py3/ubuntu/$ubuntu_version/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list
wget --inet4-only -O - https://repo.saltstack.com"$py_ver_url_path"/ubuntu/"$ubuntu_version"/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - >> "$setup_log" 2>&1
echo "deb http://repo.saltstack.com/py3/ubuntu/$ubuntu_version/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list >> "$setup_log" 2>&1
# Add Docker repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - >> "$setup_log" 2>&1
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" >> "$setup_log" 2>&1
# Get gpg keys
mkdir -p /opt/so/gpg
wget --inet4-only -O /opt/so/gpg/SALTSTACK-GPG-KEY.pub https://repo.saltstack.com/apt/ubuntu/"$ubuntu_version"/amd64/latest/SALTSTACK-GPG-KEY.pub
wget --inet4-only -O /opt/so/gpg/docker.pub https://download.docker.com/linux/ubuntu/gpg
wget --inet4-only -O /opt/so/gpg/GPG-KEY-WAZUH https://packages.wazuh.com/key/GPG-KEY-WAZUH
mkdir -p /opt/so/gpg >> "$setup_log" 2>&1
wget --inet4-only -O /opt/so/gpg/SALTSTACK-GPG-KEY.pub https://repo.saltstack.com/apt/ubuntu/"$ubuntu_version"/amd64/latest/SALTSTACK-GPG-KEY.pub >> "$setup_log" 2>&1
wget --inet4-only -O /opt/so/gpg/docker.pub https://download.docker.com/linux/ubuntu/gpg >> "$setup_log" 2>&1
wget --inet4-only -O /opt/so/gpg/GPG-KEY-WAZUH https://packages.wazuh.com/key/GPG-KEY-WAZUH >> "$setup_log" 2>&1
# Get key and install wazuh
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add -
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add - >> "$setup_log" 2>&1
# Add repo
echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list
echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list >> "$setup_log" 2>&1
# Initialize the new repos
apt-get update >> "$setup_log" 2>&1
# FIXME: Install salt-master on Ubuntu?
@@ -1045,25 +1051,25 @@ saltify() {
apt-get -y install sqlite3 argon2 openssl libssl-dev >> "$setup_log" 2>&1
set_progress_str 7 'Installing salt-master'
apt-get -y salt-master=2019.2.3+ds-1 >> "$setup_log" 2>&1
apt-mark hold salt-master
apt-mark hold salt-master >> "$setup_log" 2>&1
;;
*)
# Copy down the gpg keys and install them from the master
mkdir "$temp_install_dir"/gpg
echo "scp the gpg keys and install them from the master"
scp -v -i /root/.ssh/so.key soremote@"$MSRV":/opt/so/gpg/* "$temp_install_dir"/gpg
echo "Using apt-key add to add SALTSTACK-GPG-KEY.pub and GPG-KEY-WAZUH"
apt-key add "$temp_install_dir"/gpg/SALTSTACK-GPG-KEY.pub
apt-key add "$temp_install_dir"/gpg/GPG-KEY-WAZUH
echo "deb http://repo.saltstack.com/apt/ubuntu/$ubuntu_version/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack.list
echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list
mkdir "$temp_install_dir"/gpg >> "$setup_log" 2>&1
echo "scp the gpg keys and install them from the master" >> "$setup_log" 2>&1
scp -v -i /root/.ssh/so.key soremote@"$MSRV":/opt/so/gpg/* "$temp_install_dir"/gpg >> "$setup_log" 2>&1
echo "Using apt-key add to add SALTSTACK-GPG-KEY.pub and GPG-KEY-WAZUH" >> "$setup_log" 2>&1
apt-key add "$temp_install_dir"/gpg/SALTSTACK-GPG-KEY.pub >> "$setup_log" 2>&1
apt-key add "$temp_install_dir"/gpg/GPG-KEY-WAZUH >> "$setup_log" 2>&1
echo "deb http://repo.saltstack.com/apt/ubuntu/$ubuntu_version/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack.list >> "$setup_log" 2>&1
echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list >> "$setup_log" 2>&1
;;
esac
apt-get update >> "$setup_log" 2>&1
set_progress_str 8 'Installing salt-minion & python modules'
apt-get -y install salt-minion=2019.2.3+ds-1\
salt-common=2019.2.3+ds-1 >> "$setup_log" 2>&1
apt-mark hold salt-minion salt-common
apt-mark hold salt-minion salt-common >> "$setup_log" 2>&1
if [ "$OSVER" != 'xenial' ]; then
apt-get -y install python3-dateutil python3-m2crypto python3-mysqldb >> "$setup_log" 2>&1
else