Skip to content

Commit d30c161

Browse files
tikitavialexey-mr
tikitavi
authored andcommitted
rhosp-operator side-by-side automation
Partial-Jira-bug: CEM-25870 Signed-off-by: tikitavi <[email protected]> Change-Id: I9c7397a9ca9923021a8ccc23afef249fc7ca4dbd
1 parent 0160628 commit d30c161

13 files changed

+351
-8
lines changed

rhosp-operator/cleanup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
my_file="$(readlink -e "$0")"
4+
my_dir="$(dirname $my_file)"
5+
6+
export WORKSPACE=${WORKSPACE:-$(pwd)}
7+
8+
rhosp_dir=$my_dir/../rhosp
9+
operator_dir=$my_dir/../operator
10+
11+
source $WORKSPACE/rhosp-environment.sh
12+
source $my_dir/../common/common.sh
13+
source $my_dir/providers/common/common.sh
14+
set +e
15+
ssh $ssh_opts $SSH_USER@$overcloud_ctrlcont_prov_ip $operator_dir/cleanup.sh
16+
source $rhosp_dir/providers/${PROVIDER}/cleanup.sh
17+
rm -rf ~/.tf/.stages

rhosp-operator/create_env.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash -e
2+
3+
my_file="$(readlink -e "$0")"
4+
my_dir="$(dirname $my_file)"
5+
rhosp_dir=$my_dir/../rhosp
6+
operator_dir=$my_dir/../operator
7+
8+
source "$my_dir/../common/common.sh"
9+
source "$rhosp_dir/providers/common/common.sh"
10+
source "$rhosp_dir/providers/common/functions.sh"
11+
12+
export DEPLOYER='operator'
13+
14+
if [[ "$ENABLE_TLS" == 'local' ]] ; then
15+
if [[ -z "$SSL_CAKEY" || -z "$SSL_CACERT" ]] ; then
16+
if [[ ! -e $WORKSPACE/ca.key.pem || ! -e $WORKSPACE/ca.crt.pem ]] ; then
17+
echo "INFO: generate contrail CA certs"
18+
CA_ROOT_CERT=$WORKSPACE/ca.crt.pem CA_ROOT_KEY=$WORKSPACE/ca.key.pem $my_dir/../contrib/create_ca_certs.sh
19+
else
20+
echo "INFO: use existing contrail CA certs"
21+
fi
22+
export SSL_CAKEY="$(cat $WORKSPACE/ca.key.pem)"
23+
export SSL_CACERT="$(cat $WORKSPACE/ca.crt.pem)"
24+
else
25+
echo "INFO: skip local CA generation as it is already provided"
26+
fi
27+
fi
28+
29+
$rhosp_dir/providers/${PROVIDER}/create_env.sh

rhosp-operator/deploy_operator.sh.j2

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash -ex
2+
3+
set -eo pipefail
4+
my_dir=$(dirname $(readlink -e $0))
5+
6+
export DEBUG=true
7+
8+
export AUTH_MODE='keystone'
9+
export IPFABRIC_SERVICE_HOST={{ overcloud_node_ip }}
10+
export KEYSTONE_AUTH_HOST={{ overcloud_node_ip }}
11+
export KEYSTONE_AUTH_PROTO='http'
12+
export KEYSTONE_AUTH_ADMIN_PASSWORD='qwe123QWE'
13+
export KEYSTONE_AUTH_REGION_NAME='regionOne'
14+
export K8S_RESOLV_CONFG_MODE='none'
15+
export CONTAINER_REGISTRY={{ CONTAINER_REGISTRY }}
16+
export CONTRAIL_CONTAINER_TAG={{ CONTRAIL_CONTAINER_TAG }}
17+
18+
export CERT_SIGNER="SelfSignedCA"
19+
export TF_ROOT_CA_KEY_BASE64={{ cakey }}
20+
export TF_ROOT_CA_CERT_BASE64={{ cabundle }}
21+
22+
# TODO(tikitavi): do not install podman
23+
sudo dnf remove -y podman runc
24+
25+
./tf-devstack/operator/run.sh platform
26+
./tf-devstack/operator/run.sh manifest
27+
./tf-devstack/operator/run.sh tf
28+
./tf-devstack/operator/run.sh wait || true

rhosp-operator/functions.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
function collect_deployment_log() {
4+
set +e
5+
#Collecting undercloud logs
6+
local host_name=$(hostname -s)
7+
create_log_dir
8+
mkdir ${TF_LOG_DIR}/${host_name}
9+
collect_system_stats $host_name
10+
collect_openstack_logs $host_name
11+
pushd ${TF_LOG_DIR}/${host_name}
12+
collect_docker_logs $CONTAINER_CLI_TOOL
13+
popd
14+
collect_stack_details ${TF_LOG_DIR}/${host_name}
15+
if [[ -e /var/lib/mistral/overcloud/ansible.log ]] ; then
16+
sudo cp /var/lib/mistral/overcloud/ansible.log ${TF_LOG_DIR}/${host_name}/
17+
fi
18+
19+
#Collecting overcloud logs
20+
local ip=''
21+
for ip in $(get_ctlplane_ips); do
22+
scp $ssh_opts $my_dir/../common/collect_logs.sh $SSH_USER_OVERCLOUD@$ip:
23+
if [[ $EXTERNAL_CONTROLLER_NODES =~ $ip ]] ; then
24+
cat <<EOF | ssh $ssh_opts $SSH_USER_OVERCLOUD@$ip
25+
[[ "$DEBUG" == true ]] && set -x
26+
set +e
27+
export TF_LOG_DIR="/home/$SSH_USER_OVERCLOUD/logs"
28+
cd /home/$SSH_USER_OVERCLOUD
29+
./collect_logs.sh create_log_dir
30+
./collect_logs.sh collect_docker_logs
31+
./collect_logs.sh collect_kubernetes_objects_info
32+
./collect_logs.sh collect_kubernetes_logs
33+
./collect_logs.sh collect_kubernetes_service_statuses
34+
./collect_logs.sh collect_system_stats
35+
./collect_logs.sh collect_openstack_logs
36+
./collect_logs.sh collect_tf_status
37+
./collect_logs.sh collect_tf_logs
38+
./collect_logs.sh collect_core_dumps
39+
40+
[[ ! -f /var/log/ipaclient-install.log ]] || {
41+
sudo cp /var/log/ipaclient-install.log \$TF_LOG_DIR
42+
sudo chown $SSH_USER_OVERCLOUD:$SSH_USER_OVERCLOUD \$TF_LOG_DIR/ipaclient-install.log
43+
sudo chmod 644 \$TF_LOG_DIR/ipaclient-install.log
44+
}
45+
EOF
46+
else
47+
cat <<EOF | ssh $ssh_opts $SSH_USER_OVERCLOUD@$ip
48+
[[ "$DEBUG" == true ]] && set -x
49+
set +e
50+
export TF_LOG_DIR="/home/$SSH_USER_OVERCLOUD/logs"
51+
cd /home/$SSH_USER_OVERCLOUD
52+
./collect_logs.sh create_log_dir
53+
./collect_logs.sh collect_docker_logs $CONTAINER_CLI_TOOL
54+
./collect_logs.sh collect_system_stats
55+
./collect_logs.sh collect_openstack_logs
56+
./collect_logs.sh collect_tf_status
57+
./collect_logs.sh collect_tf_logs
58+
./collect_logs.sh collect_core_dumps
59+
60+
[[ ! -f /var/log/ipaclient-install.log ]] || {
61+
sudo cp /var/log/ipaclient-install.log \$TF_LOG_DIR
62+
sudo chown $SSH_USER_OVERCLOUD:$SSH_USER_OVERCLOUD \$TF_LOG_DIR/ipaclient-install.log
63+
sudo chmod 644 \$TF_LOG_DIR/ipaclient-install.log
64+
}
65+
EOF
66+
fi
67+
local source_name=$(ssh $ssh_opts $SSH_USER_OVERCLOUD@$ip hostname -s)
68+
mkdir ${TF_LOG_DIR}/${source_name}
69+
rsync -a --safe-links -e "ssh $ssh_opts" $SSH_USER_OVERCLOUD@$ip:logs/ ${TF_LOG_DIR}/${source_name}/
70+
done
71+
if [[ "$ENABLE_TLS" == 'ipa' ]] ; then
72+
scp $ssh_opts $my_dir/../common/collect_logs.sh $SSH_USER@$ipa_mgmt_ip:
73+
cat <<EOF | ssh $ssh_opts $SSH_USER@${ipa_mgmt_ip}
74+
[[ "$DEBUG" == true ]] && set -x
75+
set +e
76+
export TF_LOG_DIR="/home/$SSH_USER/logs"
77+
cd /home/$SSH_USER
78+
./collect_logs.sh create_log_dir
79+
./collect_logs.sh collect_system_stats
80+
./collect_logs.sh collect_core_dumps
81+
[[ ! -f /var/log/ipaclient-install.log ]] || {
82+
sudo cp /var/log/ipaclient-install.log \$TF_LOG_DIR
83+
sudo chown $SSH_USER:$SSH_USER \$TF_LOG_DIR/ipaclient-install.log
84+
sudo chmod 644 \$TF_LOG_DIR/ipaclient-install.log
85+
}
86+
[[ ! -f /var/log/ipaserver-install.log ]] || {
87+
sudo cp /var/log/ipaserver-install.log \$TF_LOG_DIR
88+
sudo chown $SSH_USER:$SSH_USER \$TF_LOG_DIR/ipaserver-install.log
89+
sudo chmod 644 \$TF_LOG_DIR/ipaserver-install.log
90+
}
91+
EOF
92+
mkdir ${TF_LOG_DIR}/ipa
93+
rsync -a --safe-links -e "ssh $ssh_opts" $SSH_USER@$ip:logs/ ${TF_LOG_DIR}/ipa/
94+
fi
95+
96+
# Save to archive all yaml files and tripleo templates
97+
tar -czf ${TF_LOG_DIR}/tht.tgz -C ~ *.yaml tripleo-heat-templates
98+
tar -czf ${WORKSPACE}/logs.tgz -C ${TF_LOG_DIR}/.. logs
99+
}
100+

rhosp-operator/run.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash -e
2+
3+
my_file="$(readlink -e "$0")"
4+
my_dir="$(dirname $my_file)"
5+
rhosp_dir=$my_dir/../rhosp
6+
operator_dir=$my_dir/../operator
7+
8+
export WORKSPACE=${WORKSPACE:-$(pwd)}
9+
export ORCHESTRATOR="openstack"
10+
11+
source "$my_dir/../common/functions.sh"
12+
source "$WORKSPACE/rhosp-environment.sh"
13+
14+
source "$my_dir/../common/common.sh"
15+
source "$my_dir/../common/stages.sh"
16+
source "$my_dir/../common/collect_logs.sh"
17+
source "$rhosp_dir/providers/common/common.sh"
18+
source "$rhosp_dir/providers/common//functions.sh"
19+
source "$my_dir/stages.sh"
20+
21+
export DEPLOYER='operator'
22+
23+
#Checking if mandatory variables are defined
24+
ensureVariable ENVIRONMENT_OS
25+
ensureVariable PROVIDER
26+
ensureVariable USE_PREDEPLOYED_NODES
27+
ensureVariable ENABLE_RHEL_REGISTRATION
28+
ensureVariable OPENSTACK_CONTAINER_REGISTRY
29+
ensureVariable OPENSTACK_CONTAINER_TAG
30+
ensureVariable CONTAINER_REGISTRY
31+
ensureVariable CONTRAIL_CONTAINER_TAG
32+
ensureVariable RHOSP_VERSION
33+
ensureVariable RHOSP_MAJOR_VERSION
34+
ensureVariable RHEL_VERSION
35+
ensureVariable RHEL_MAJOR_VERSION
36+
ensureVariable OPENSTACK_VERSION
37+
ensureVariable SSH_USER
38+
if [[ -n "$L3MH_CIDR" ]] && [[ "$RHEL_VERSION" == 'rhosp13' || "$RHEL_VERSION" == 'rhosp16.1' ]] ; then
39+
echo "ERROR: L3MH is unsupported for $RHOSP_VERSION"
40+
exit 1
41+
fi
42+
43+
init_output_logging
44+
45+
46+
# stages declaration
47+
declare -A STAGES=( \
48+
["all"]="build machines tf wait logs" \
49+
["default"]="machines tf wait" \
50+
["master"]="build machines tf wait" \
51+
["platform"]="machines" \
52+
)
53+
54+
# deployment related environment set by any stage and put to tf_stack_profile at the end
55+
declare -A DEPLOYMENT_ENV=(\
56+
['AUTH_URL']=""
57+
)
58+
59+
run_stages $STAGE

rhosp-operator/stages.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
function machines() {
3+
$rhosp_dir/run.sh machines
4+
$operator_dir/run.sh machines
5+
}
6+
7+
function operator_tf() {
8+
deploy_operator_file="deploy_operator.sh"
9+
10+
export overcloud_node_ip=$overcloud_cont_prov_ip
11+
export cakey=$(echo "$SSL_CAKEY" | base64 -w 0)
12+
export cabundle=$(echo "$SSL_CACERT" | base64 -w 0)
13+
14+
$my_dir/../common/jinja2_render.py < $my_dir/${deploy_operator_file}.j2 >${deploy_operator_file}
15+
sudo chmod 755 ${deploy_operator_file}
16+
17+
scp $ssh_opts ${deploy_operator_file} $SSH_USER@$overcloud_ctrlcont_prov_ip:
18+
ssh $ssh_opts $SSH_USER@$overcloud_ctrlcont_prov_ip ./deploy_operator.sh
19+
}
20+
21+
function tf() {
22+
$rhosp_dir/run.sh tf
23+
operator_tf
24+
}
25+
26+
function logs() {
27+
collect_deployment_log
28+
}
29+
30+
function is_active() {
31+
# Services to check in wait stage
32+
CONTROLLER_SERVICES['config-database']=""
33+
CONTROLLER_SERVICES['config']+="dnsmasq "
34+
CONTROLLER_SERVICES['_']+="rabbitmq stunnel zookeeper "
35+
if [[ "${CNI}" == "calico" ]]; then
36+
AGENT_SERVICES['vrouter']=""
37+
fi
38+
39+
local agent_nodes=""
40+
local controller_nodes=""
41+
controller_nodes="$(get_ctlplane_ips contrailcontroller)"
42+
agent_nodes=$controller_nodes
43+
agent_nodes+=" $(get_ctlplane_ips controller)"
44+
agent_nodes+=" $(get_ctlplane_ips novacompute)"
45+
agent_nodes+=" $(get_ctlplane_ips contraildpdk)"
46+
agent_nodes+=" $(get_ctlplane_ips contrailsriov)"
47+
check_tf_active $SSH_USER_OVERCLOUD "$controller_nodes $agent_nodes"
48+
check_tf_services $SSH_USER_OVERCLOUD "$controller_nodes" "$agent_nodes"
49+
}
50+
51+
function collect_deployment_env() {
52+
if is_after_stage 'wait' ; then
53+
collect_overcloud_env
54+
fi
55+
}

rhosp/overcloud/04_prepare_heat_templates.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@ if [[ -n "$EXTERNAL_CONTROLLER_NODES" ]] ; then
9090
ExternalContrailConfigIPs: ${EXTERNAL_CONTROLLER_NODES// /,}
9191
ExternalContrailControlIPs: ${EXTERNAL_CONTROLLER_NODES// /,}
9292
ExternalContrailAnalyticsIPs: ${EXTERNAL_CONTROLLER_NODES// /,}
93+
94+
ExtraHostFileEntries:
95+
EOF
96+
97+
for node in ${EXTERNAL_CONTROLLER_NODES} ; do
98+
fqdn=$(ssh $node hostname -f)
99+
short=$(ssh $node hostname -s)
100+
cat <<EOF >>misc_opts.yaml
101+
- "$node $fqdn $short"
93102
EOF
103+
done
94104
fi
95105

96106
if [[ "$CONTROL_PLANE_ORCHESTRATOR" == 'operator' ]] ; then
@@ -101,6 +111,8 @@ if [[ "$CONTROL_PLANE_ORCHESTRATOR" == 'operator' ]] ; then
101111
contrail_internal_api_ssl: True
102112
ComputeExtraConfig:
103113
contrail_internal_api_ssl: True
114+
ContrailAioExtraConfig:
115+
contrail_internal_api_ssl: True
104116
EOF
105117
if [[ "$ENABLE_TLS" == 'ipa' && -n "$SSL_CACERT" ]] ; then
106118
# For operator with selfCA and RHOSP w/ IPA use selfsigned ca file
@@ -126,7 +138,7 @@ echo "INFO: using template $my_dir/${RHOSP_MAJOR_VERSION}_contrail-parameters.ya
126138
cat $my_dir/${RHOSP_MAJOR_VERSION}_contrail-parameters.yaml.template | envsubst > contrail-parameters.yaml
127139

128140
#Changing tripleo-heat-templates/roles_data_contrail_aio.yaml
129-
if [[ -z "$overcloud_ctrlcont_instance" && -z "$overcloud_compute_instance" ]] ; then
141+
if [[ ( -z "$overcloud_ctrlcont_instance" || "$CONTROL_PLANE_ORCHESTRATOR" == 'operator' ) && -z "$overcloud_compute_instance" ]] ; then
130142
role_file=tripleo-heat-templates/roles/ContrailAio.yaml
131143
sed -i -re 's/Count:\s*[[:digit:]]+/Count: 0/' tripleo-heat-templates/environments/contrail/contrail-services.yaml
132144
sed -i -re 's/ContrailAioCount: 0/ContrailAioCount: 1/' tripleo-heat-templates/environments/contrail/contrail-services.yaml

rhosp/overcloud/ctlplane-assignments.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{%- set instances = instances + overcloud_cont_instance.split(',') %}
55
{%- set instances_ips = instances_ips + overcloud_cont_prov_ip.split(',') %}
66
{%- endif %}
7-
{%- if overcloud_ctrlcont_instance is defined and overcloud_ctrlcont_instance|length %}
7+
{%- if overcloud_ctrlcont_instance is defined and overcloud_ctrlcont_instance|length and CONTROL_PLANE_ORCHESTRATOR == 'rhosp' %}
88
{%- set instances = instances + overcloud_ctrlcont_instance.split(',') %}
99
{%- set instances_ips = instances_ips+ overcloud_ctrlcont_prov_ip.split(',') %}
1010
{%- endif %}

rhosp/overcloud/hostname-map.yaml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
{%- set hosts = {} %}
33
{%- set controller_role = 'contrailaio' %}
4-
{%- if overcloud_compute_instance is defined and overcloud_compute_instance|length and
4+
{%- if overcloud_compute_instance is defined and overcloud_compute_instance|length and
55
overcloud_ctrlcont_instance is defined and overcloud_ctrlcont_instance|length %}
66
{%- set controller_role = 'controller' %}
77
{% endif %}
88
{%- if overcloud_cont_instance is defined and overcloud_cont_instance|length %}
99
{%- set _ = hosts.update({controller_role: overcloud_cont_instance.split(',')}) %}
1010
{%- endif %}
11-
{%- if overcloud_ctrlcont_instance is defined and overcloud_ctrlcont_instance|length %}
11+
{%- if overcloud_ctrlcont_instance is defined and overcloud_ctrlcont_instance|length and CONTROL_PLANE_ORCHESTRATOR == 'rhosp' %}
1212
{%- set _ = hosts.update({'contrailcontroller': overcloud_ctrlcont_instance.split(',')}) %}
1313
{%- endif %}
1414
{%- if overcloud_compute_instance is defined and overcloud_compute_instance|length %}

rhosp/overcloud/rhosp16_deploy_overcloud.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if [[ -n "$overcloud_ceph_instance" ]] ; then
4747
fi
4848

4949
role_file="$(pwd)/roles_data.yaml"
50-
if [[ -z "$overcloud_ctrlcont_instance" && -z "$overcloud_compute_instance" ]] ; then
50+
if [[ ( -z "$overcloud_ctrlcont_instance" || $CONTROL_PLANE_ORCHESTRATOR == 'operator' ) && -z "$overcloud_compute_instance" ]] ; then
5151
if [[ -z "$L3MH_CIDR" ]] ; then
5252
roles+=" ContrailAio"
5353
else
@@ -86,7 +86,7 @@ if [[ "$USE_PREDEPLOYED_NODES" == true ]]; then
8686
pre_deploy_nodes_env_files+=" -e ctlplane-assignments.yaml"
8787
pre_deploy_nodes_env_files+=" -e hostname-map.yaml"
8888

89-
if [[ -z "$overcloud_ctrlcont_instance" && -z "$overcloud_compute_instance" ]] ; then
89+
if [[ ( -z "$overcloud_ctrlcont_instance" || $CONTROL_PLANE_ORCHESTRATOR == 'operator' ) && -z "$overcloud_compute_instance" ]] ; then
9090
export OVERCLOUD_ROLES="ContrailAio"
9191
export ContrailAio_hosts="${overcloud_cont_prov_ip//,/ }"
9292
else

0 commit comments

Comments
 (0)