File: run.sh

package info (click to toggle)
check-pgbackrest 2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,396 kB
  • sloc: perl: 972; sh: 488; python: 145; makefile: 33
file content (124 lines) | stat: -rw-r--r-- 4,734 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
set -o errexit
set -o nounset
cd "$(dirname "$0")"

usage() {
    echo "Usage:"
    echo "    -A                          Activity step only."
    echo "    -c <cluster_dir>            Cluster directory."
    echo "    -C                          Cleaning step only."
    echo "    -h                          Display this help message."
    echo "    -i                          Initial step only."
}

INIT_ONLY=false
CLEAN_ONLY=false
PROVISION=true
DEPLOY=true
while getopts "Ac:Chi" o; do
    case "${o}" in
        A)
            INIT_ONLY=false
            CLEAN_ONLY=false
            PROVISION=false
            DEPLOY=false
            ACTIVITY=true
            ;;
        c)
            CLUSTER_DIR=${OPTARG}
            ;;
        C)
            CLEAN_ONLY=true
            ;;
        h )
            usage
            exit 0
            ;;
        i)
            INIT_ONLY=true
            ;;
        *)
            usage 1>&2
            exit 1
            ;;
    esac
done
shift $((OPTIND-1))

if $INIT_ONLY; then
    #-------------------------------------------------------------------------------------------------------------------
    echo '-------------------- Init --------------------' && date
    #-------------------------------------------------------------------------------------------------------------------
    # This section is intended to update the GitHub Action Runner (Ubuntu)
    echo 'Update apt'
    sudo apt-get update
    echo '--------------------'
    echo 'Whoami?'
    whoami
    echo '--------------------'
    echo 'Docker installed?'
    docker version
    echo '--------------------'
    echo 'Ansible installed?'
    ansible --version
    echo '--------------------'
    echo 'Install ansible dependencies'
    pipx inject ansible-core docker-py
    ansible-galaxy collection install ansible.posix
    ansible-galaxy collection install community.crypto
    ansible-galaxy collection install community.docker
    ansible-galaxy collection install community.general
    ansible-galaxy collection install community.postgresql
    ansible-galaxy collection install telekom_mms.icinga_director
    echo '--------------------'
    echo 'Install MinIO Python SDK'
    pip install minio
    echo '--------------------'
    echo 'Install Azure Storage Blobs client library for Python'
    pip install azure-storage-blob

    # Exit with success
    exit 0;
fi

if $CLEAN_ONLY; then
    #-------------------------------------------------------------------------------------------------------------------
    echo '-------------------- Clean --------------------' && date
    #-------------------------------------------------------------------------------------------------------------------
    if [ -e $CLUSTER_DIR ]; then
        ansible-playbook platforms/deprovision.yml -e cluster_dir=$CLUSTER_DIR
        sudo rm --force --preserve-root --recursive $CLUSTER_DIR
    fi

    # Exit with success
    exit 0;
fi

if $PROVISION; then
    #-----------------------------------------------------------------------------------------------------------------------
    echo '-------------------- Provision --------------------' && date
    #-----------------------------------------------------------------------------------------------------------------------
    export ANSIBLE_ROLES_PATH=${ANSIBLE_ROLES_PATH:+$ANSIBLE_ROLES_PATH:}$(pwd)/roles
    export ANSIBLE_LOOKUP_PLUGINS=${ANSIBLE_LOOKUP_PLUGINS:+$ANSIBLE_LOOKUP_PLUGINS:}$(pwd)/plugins/lookup
    : "${CLUSTER_DIR:?Variable not set or empty}"
    echo "CLUSTER_DIR=$CLUSTER_DIR"
    ansible-playbook platforms/provision.yml -e cluster_dir=$CLUSTER_DIR
    ansible-playbook platforms/system-config.yml -i "$CLUSTER_DIR/inventory.docker.yml" -e cluster_dir=$CLUSTER_DIR
fi

if $DEPLOY; then
    #-----------------------------------------------------------------------------------------------------------------------
    echo '-------------------- Deploy --------------------' && date
    #-----------------------------------------------------------------------------------------------------------------------
    export ANSIBLE_HOST_KEY_CHECKING=False
    export ANSIBLE_REMOTE_USER="root"
    ansible-playbook playbooks/deploy.yml -i "$CLUSTER_DIR/inventory" -e cluster_dir=$CLUSTER_DIR
fi

if $ACTIVITY; then
    #-----------------------------------------------------------------------------------------------------------------------
    echo '-------------------- Simulate basic activity --------------------' && date
    #-----------------------------------------------------------------------------------------------------------------------
    ansible-playbook playbooks/activity.yml -i "$CLUSTER_DIR/inventory"
fi