aboutsummaryrefslogtreecommitdiffstats
path: root/run.sh
blob: 55f9fdad65a3c70bb2544d93d9e42dffe8109bd8 (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash

# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2018 Orange and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

set -o errexit
set -o nounset
set -o pipefail

labels=$*

RUN_SCRIPT=${0}
RUN_ROOT=$(dirname $(readlink -f ${RUN_SCRIPT}))
export RUN_ROOT=$RUN_ROOT
source ${RUN_ROOT}/scripts/rc.sh

# register our handler
trap submit_bug_report ERR

#-------------------------------------------------------------------------------
# If no labels are set with args, run all
#-------------------------------------------------------------------------------
if [[ $labels = "" ]]; then
  labels="ci prepare configure deploy wait postconfigure check_containers healtcheck"
fi

step_banner "Fetch galaxy roles"
ansible-galaxy install -r requirements.yml

if [[ $labels = *"clean"* ]]; then
  #-------------------------------------------------------------------------------
  # Prepare CI
  #  - install needed packages and verify directory are writable
  #-------------------------------------------------------------------------------
  step_banner "Prepare CI"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i ${RUN_ROOT}/inventory/infra \
    ${RUN_ROOT}/onap-oom-prepare-ci.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "CI prepared"

  #-------------------------------------------------------------------------------
  # Prepare OOM
  #  - create helm servers
  #  - compile OOM helm packages and push them to local server
  #-------------------------------------------------------------------------------
  step_banner "Clean OOM"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i ${RUN_ROOT}/inventory/infra \
    ${RUN_ROOT}/onap-oom-clean.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "OOM cleaned"
fi

if [[ $labels = *"prepare"* ]]; then
  #-------------------------------------------------------------------------------
  # Prepare CI
  #  - install needed packages and verify directory are writable
  #-------------------------------------------------------------------------------
  step_banner "Prepare CI"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i ${RUN_ROOT}/inventory/infra \
    ${RUN_ROOT}/onap-oom-prepare-ci.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "CI prepared"

  #-------------------------------------------------------------------------------
  # Prepare OOM
  #  - create helm servers
  #  - compile OOM helm packages and push them to local server
  #-------------------------------------------------------------------------------
  step_banner "Prepare OOM"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i ${RUN_ROOT}/inventory/infra \
    ${RUN_ROOT}/onap-oom-prepare.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "OOM prepared"
fi

#-------------------------------------------------------------------------------
# Configure OOM
#  - retrieve tenant information
#  - encrypt tenant password
#  - generate OOM configuration
#-------------------------------------------------------------------------------
if [[ $labels = *"configure"* ]]; then
  step_banner "Configure OOM ${DEPLOYMENT_TYPE}"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i inventory/infra \
    ${RUN_ROOT}/onap-oom-configure.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "OOM ${DEPLOYMENT_TYPE} configured"
fi

#-------------------------------------------------------------------------------
# Deploy OOM
#  -  launch installation via HELM
#-------------------------------------------------------------------------------
if [[ $labels = *"deploy"* ]]; then
  step_banner "Deploy OOM"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i inventory/infra \
    ${RUN_ROOT}/onap-oom-deploy.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "OOM deployed"
fi

#-------------------------------------------------------------------------------
# Wait for End of Deployment
#  -  Wait that all pods are started
#-------------------------------------------------------------------------------
if [[ $labels = *"wait"* ]]; then
  step_banner "Wait for end of deployment"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i inventory/infra \
    ${RUN_ROOT}/onap-oom-wait.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "End of deployment done"
fi

#-------------------------------------------------------------------------------
# Postconfigure OOM
#  -  Create VIM in multicloud
#-------------------------------------------------------------------------------
if [[ $labels = *"postconfiguration"* ]]; then
  step_banner "Post configure OOM"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i inventory/infra \
    ${RUN_ROOT}/onap-oom-postconfigure.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "OOM postconfigured"
fi

#-------------------------------------------------------------------------------
# Postinstallation OOM
#  -  Generate /etc/hosts
#-------------------------------------------------------------------------------
if [[ $labels = *"postinstallation"* ]]; then
  step_banner "Post install OOM"
  ansible-playbook ${ANSIBLE_VERBOSE} \
    -i inventory/infra \
    ${RUN_ROOT}/onap-oom-postinstall.yaml --vault-id ${RUN_ROOT}/.vault

  step_banner "OOM postinstalled"
fi