[fix] Don't set startup state until end of setup

This commit is contained in:
William Wernert
2020-04-28 13:02:27 -04:00
parent 7a456c2c6b
commit e6492d4852
3 changed files with 40 additions and 18 deletions

View File

@@ -339,13 +339,20 @@ configure_minion() {
" - module.run"\ " - module.run"\
"log_file: /opt/so/log/salt/minion" >> "$minion_config" "log_file: /opt/so/log/salt/minion" >> "$minion_config"
systemctl restart salt-minion >> "$setup_log" 2>&1 {
systemctl restart salt-minion;
printf '%s\n' '----';
cat "$minion_config";
} >> "$setup_log" 2>&1
}
checkin_at_boot() {
local minion_config=/etc/salt/minion
echo "Enabling checkin at boot" >> "$setup_log" 2>&1 echo "Enabling checkin at boot" >> "$setup_log" 2>&1
echo "startup_states: highstate" >> "$minion_config" echo "startup_states: highstate" >> "$minion_config"
printf '%s\n' '----' >> "$setup_log" 2>&1
cat "$minion_config" >> "$setup_log" 2>&1
} }
copy_master_config() { copy_master_config() {
@@ -534,7 +541,6 @@ docker_install() {
{ {
yum clean expire-cache; yum clean expire-cache;
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo; yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo;
yum -y update;
yum -y install docker-ce; yum -y install docker-ce;
} >> "$setup_log" 2>&1 } >> "$setup_log" 2>&1
@@ -684,12 +690,6 @@ set_main_ip() {
MAINIP=$(ip route get 1 | awk '{print $7;exit}') MAINIP=$(ip route get 1 | awk '{print $7;exit}')
} }
gen_ca() {
salt_checkin
salt-call state.apply -l info ca >> $setup_log 2>&1
salt-call state.apply -l info ssl >> $setup_log 2>&1
}
get_redirect() { get_redirect() {
whiptail_set_redirect_info whiptail_set_redirect_info
whiptail_set_redirect whiptail_set_redirect
@@ -830,6 +830,9 @@ master_static() {
" masterupdate: $MASTERUPDATES" > "$static_pillar" " masterupdate: $MASTERUPDATES" > "$static_pillar"
echo "elastic:" >> /opt/so/saltstack/pillar/static.sls echo "elastic:" >> /opt/so/saltstack/pillar/static.sls
echo " features: False" >> /opt/so/saltstack/pillar/static.sls echo " features: False" >> /opt/so/saltstack/pillar/static.sls
printf '%s\n' '----' >> "$setup_log" 2>&1
cat "$static_pillar" >> "$setup_log" 2>&1
} }
minio_generate_keys() { minio_generate_keys() {
@@ -1112,8 +1115,11 @@ salt_checkin() {
} >> "$setup_log" 2>&1 } >> "$setup_log" 2>&1
;; ;;
*) *)
salt-call state.apply ca >> "$setup_log" 2>&1 {
salt-call state.apply ssl >> "$setup_log" 2>&1 salt-call state.apply ca;
salt-call state.apply ssl;
} >> "$setup_log" 2>&1
;; ;;
esac esac
} }
@@ -1364,6 +1370,15 @@ update_sudoers() {
fi fi
} }
update_packages() {
if [ "$OS" = 'centos' ]; then
yum -y update >> "$setup_log"
else
apt-get -y update >> "$setup_log"
apt-get -y upgrade >> "$setup_log"
fi
}
ls_heapsize() { ls_heapsize() {
if [ "$total_mem" -ge 32000 ]; then if [ "$total_mem" -ge 32000 ]; then

View File

@@ -257,6 +257,9 @@ if [[ $is_minion ]]; then
fi fi
# Begin install # Begin install
# Set initial percentage to 0
export percentage=0
{ {
if [[ $is_sensor || $is_helix ]]; then if [[ $is_sensor || $is_helix ]]; then
@@ -321,8 +324,8 @@ fi
node_pillar 2>> "$setup_log" node_pillar 2>> "$setup_log"
fi fi
set_progress_str 20 'Generating CA' set_progress_str 20 'Generating CA and checking in'
gen_ca 2>> "$setup_log" salt_checkin 2>> "$setup_log"
if [[ $is_master || $is_helix ]]; then if [[ $is_master || $is_helix ]]; then
set_progress_str 25 'Downloading containers from the internet' set_progress_str 25 'Downloading containers from the internet'
@@ -428,7 +431,13 @@ fi
filter_unused_nics 2>> "$setup_log" filter_unused_nics 2>> "$setup_log"
network_setup 2>> "$setup_log" network_setup 2>> "$setup_log"
set_progress_str 91 'Verifying setup' set_progress_str 91 'Enabling checkin at boot'
checkin_at_boot 2>> "$setup_log"
set_progress_str 92 'Updating packages'
update_packages 2>> "$setup_log"
set_progress_str 93 'Verifying setup'
salt-call -l info state.highstate >> $setup_log 2>&1 salt-call -l info state.highstate >> $setup_log 2>&1
} | whiptail --title "Hybrid Hunter Install" --gauge "Please wait while installing" 6 60 0 } | whiptail --title "Hybrid Hunter Install" --gauge "Please wait while installing" 6 60 0

View File

@@ -28,8 +28,6 @@ export filesystem_nsm
mkdir -p /root/installtmp/pillar/minions mkdir -p /root/installtmp/pillar/minions
export temp_install_dir=/root/installtmp export temp_install_dir=/root/installtmp
export percentage=0
export percentage_str='Getting started' export percentage_str='Getting started'
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive