1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., Enea AB and others.
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Tue, 30 Jan 2018 01:23:54 +0100
11 Subject: [PATCH] salt-master-setup: Group APT install formulas
13 Instead of calling `apt install` for each salt formula package that
14 we miss, construct a list and install them all at once.
16 While at it, disable colored output on terminals that don't support
17 it, like vt220 (used in OPNFV CI).
19 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
21 salt-master-init.sh | 6 ++++++
22 salt-master-setup.sh | 12 +++++++-----
23 2 files changed, 13 insertions(+), 5 deletions(-)
25 diff --git a/salt-master-init.sh b/salt-master-init.sh
26 index a4ec138..db90a22 100755
27 --- a/salt-master-init.sh
28 +++ b/salt-master-init.sh
29 @@ -24,6 +24,12 @@ options() {
30 export $(find $path -maxdepth 1 -name '*.env' 2> /dev/null | xargs --no-run-if-empty cat ) > /dev/null
33 + # If terminal does not support color output, stop using it
34 + if ! tput setaf 1 && tput sgr0; then
35 + SALT_OPTS="${SALT_OPTS/--force-color/--no-color}"
39 export MAGENTA='\033[0;95m'
40 export YELLOW='\033[1;33m'
41 export BLUE='\033[0;35m'
42 diff --git a/salt-master-setup.sh b/salt-master-setup.sh
43 index 0dd3036..a0c6311 100755
44 --- a/salt-master-setup.sh
45 +++ b/salt-master-setup.sh
46 @@ -347,15 +347,17 @@ install_salt_formula_pkg()
47 # Set essentials if FORMULAS_SALT_MASTER is not defined at all
48 [ -z ${FORMULAS_SALT_MASTER+x} ] && declare -a FORMULAS_SALT_MASTER=("linux" "reclass" "salt" "memcached")
49 for formula_service in "${FORMULAS_SALT_MASTER[@]}"; do
50 - echo -e "\nConfiguring salt formula ${formula_service} ...\n"
51 + echo -e "Configuring salt formula ${formula_service} ..."
52 [ ! -d "${FORMULAS_PATH}/env/${formula_service}" ] && \
53 - if ! $SUDO apt-get install -y salt-formula-${formula_service}; then
54 - echo -e "\nInstall salt-formula-${formula_service} failed.\n"
57 + _FORMULAS_SALT_MASTER="${_FORMULAS_SALT_MASTER} salt-formula-${formula_service}"
58 + # Create links first, install pkgs later
59 [ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && \
60 ln -sf ${FORMULAS_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service}
62 + if ! $SUDO apt-get install -qqq -y ${_FORMULAS_SALT_MASTER}; then
63 + echo -e "\nInstall ${_FORMULAS_SALT_MASTER} failed.\n"