summaryrefslogtreecommitdiffstats
path: root/tools/docker-compose/bootstrap_development.sh
blob: aa9016b4dcfdff00c89c805a41d1c7d0e4d0c77b (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
#!/bin/bash
set +x

# Move to the source directory so we can bootstrap
if [ -f "/awx_devel/manage.py" ]; then
    cd /awx_devel
else
    echo "Failed to find awx source tree, map your development tree volume"
fi

make awx-link

# AWX bootstrapping
make version_file

if [[ -n "$RUN_MIGRATIONS" ]]; then
    # wait for postgres to be ready
    while ! nc -z postgres 5432; do
        echo "Waiting for postgres to be ready to accept connections"; sleep 1;
    done;
    make migrate
else
    wait-for-migrations
fi


# Make sure that the UI statifc file directory exists, if UI is not built yet put a placeholder file in it.
if [ ! -d "/awx_devel/awx/ui/build/awx" ]; then
    mkdir -p /awx_devel/awx/ui/build/awx
    cp /awx_devel/awx/ui/placeholder_index_awx.html /awx_devel/awx/ui/build/awx/index_awx.html
fi

if output=$(awx-manage createsuperuser --noinput --username=admin --email=admin@localhost 2> /dev/null); then
    echo $output
fi
echo "Admin password: ${DJANGO_SUPERUSER_PASSWORD}"

awx-manage create_preload_data
awx-manage register_default_execution_environments

awx-manage provision_instance --hostname="$(hostname)" --node_type="$MAIN_NODE_TYPE"
awx-manage add_receptor_address --instance="$(hostname)" --address="$(hostname)" --port=2222 --canonical

awx-manage register_queue --queuename=controlplane --instance_percent=100
awx-manage register_queue --queuename=default --instance_percent=100

if [[ -n "$RUN_MIGRATIONS" ]]; then
    for (( i=1; i<$CONTROL_PLANE_NODE_COUNT; i++ )); do
        for (( j=i + 1; j<=$CONTROL_PLANE_NODE_COUNT; j++ )); do
            awx-manage register_peers "awx-$i" --peers "awx-$j"
        done
    done

    if [[ $EXECUTION_NODE_COUNT > 0 ]]; then
        awx-manage provision_instance --hostname="receptor-hop" --node_type="hop"
        awx-manage add_receptor_address --instance="receptor-hop" --address="receptor-hop" --port=5555 --canonical
        awx-manage register_peers "receptor-hop" --peers "awx-1"
        for (( e=1; e<=$EXECUTION_NODE_COUNT; e++ )); do
            awx-manage provision_instance --hostname="receptor-$e" --node_type="execution"
            awx-manage register_peers "receptor-$e" --peers "receptor-hop"
        done
    fi
fi

# Create resource entries when using Minikube
if [[ -n "$MINIKUBE_CONTAINER_GROUP" ]]; then
    awx-manage shell < /awx_devel/tools/docker-compose-minikube/_sources/bootstrap_minikube.py
fi