[salt.sh] Armband extra repo for forked reclass
[fuel.git] / mcp / patches / scripts / 0003-salt-master-setup-Group-APT-install-formulas.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., Enea AB and others.
3 :
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
12
13 Instead of calling `apt install` for each salt formula package that
14 we miss, construct a list and install them all at once.
15
16 While at it, disable colored output on terminals that don't support
17 it, like vt220 (used in OPNFV CI).
18
19 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
20 ---
21  salt-master-init.sh  |  6 ++++++
22  salt-master-setup.sh | 12 +++++++-----
23  2 files changed, 13 insertions(+), 5 deletions(-)
24
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
31      done;
32
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}"
36 +        return 0
37 +    fi
38 +
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"
55 -                    exit 1
56 -                  fi
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}
61            done
62 +          if ! $SUDO apt-get install -qqq -y ${_FORMULAS_SALT_MASTER}; then
63 +            echo -e "\nInstall ${_FORMULAS_SALT_MASTER} failed.\n"
64 +            exit 1
65 +          fi
66          ;;
67        rhel)
68          # TODO