Remove stale offline option to scripts
[icn.git] / env / metal3 / 03_launch_prereq.sh
1 #!/usr/bin/env bash
2 set -eux -o pipefail
3
4 LIBDIR="$(dirname "$PWD")"
5
6 source $LIBDIR/lib/logging.sh
7 source $LIBDIR/lib/common.sh
8
9 if [[ $EUID -ne 0 ]]; then
10     echo "launch script must be run as root"
11     exit 1
12 fi
13
14 function install_ironic_container {
15     # set password for mariadb
16     mariadb_password=$(echo $(date;hostname)|sha256sum |cut -c-20)
17
18     # Start image downloader container
19     docker run -d --net host --privileged --name ipa-downloader \
20         --env-file "${PWD}/ironic.env" \
21         -v "$IRONIC_DATA_DIR:/shared" "${IPA_DOWNLOADER_IMAGE}" /usr/local/bin/get-resource.sh
22
23     docker wait ipa-downloader
24
25     if [ ! -e "$IRONIC_DATA_DIR/html/images/ironic-python-agent.kernel" ] ||
26        [ ! -e "$IRONIC_DATA_DIR/html/images/ironic-python-agent.initramfs" ]; then
27         echo "Failed to get ironic-python-agent"
28         exit 1
29     fi
30
31     # Start dnsmasq, http, mariadb, and ironic containers using same image
32     # See this file for env vars you can set, like IP, DHCP_RANGE, INTERFACE
33     docker run -d --net host --privileged --name dnsmasq \
34         --env-file "${PWD}/ironic.env" \
35         -v "$IRONIC_DATA_DIR:/shared" --entrypoint /bin/rundnsmasq "${IRONIC_IMAGE}"
36
37     # For available env vars, see:
38     docker run -d --net host --privileged --name httpd \
39         --env-file "${PWD}/ironic.env" \
40         -v "$IRONIC_DATA_DIR:/shared" --entrypoint /bin/runhttpd "${IRONIC_IMAGE}"
41
42     # https://github.com/metal3-io/ironic/blob/master/runmariadb.sh
43     docker run -d --net host --privileged --name mariadb \
44         --env-file "${PWD}/ironic.env" \
45         -v "$IRONIC_DATA_DIR:/shared" --entrypoint /bin/runmariadb \
46         --env "MARIADB_PASSWORD=$mariadb_password" "${IRONIC_IMAGE}"
47
48     # See this file for additional env vars you may want to pass, like IP and INTERFACE
49     docker run -d --net host --privileged --name ironic \
50         --env-file "${PWD}/ironic.env" \
51         --env "MARIADB_PASSWORD=$mariadb_password" \
52         -v "$IRONIC_DATA_DIR:/shared" "${IRONIC_IMAGE}"
53
54     # Start Ironic Inspector
55     docker run -d --net host --privileged --name ironic-inspector \
56         --env-file "${PWD}/ironic.env" \
57         -v "$IRONIC_DATA_DIR:/shared" "${IRONIC_INSPECTOR_IMAGE}"
58 }
59
60 function create_ironic_env {
61     cat <<EOF > ${PWD}/ironic.env
62 PROVISIONING_INTERFACE=provisioning
63 DHCP_RANGE=172.22.0.10,172.22.0.100
64 IPA_BASEURI=https://images.rdoproject.org/train/rdo_trunk/current-tripleo
65 DEPLOY_KERNEL_URL=http://172.22.0.1/images/ironic-python-agent.kernel
66 DEPLOY_RAMDISK_URL=http://172.22.0.1/images/ironic-python-agent.initramfs
67 IRONIC_ENDPOINT=http://172.22.0.1:6385/v1/
68 IRONIC_INSPECTOR_ENDPOINT=http://172.22.0.1:5050/v1/
69 CACHEURL=http://172.22.0.1/images
70 IRONIC_FAST_TRACK=false
71 EOF
72 }
73
74 function install {
75     create_ironic_env
76     install_ironic_container
77 }
78
79 install