-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·48 lines (40 loc) · 2.01 KB
/
entrypoint.sh
File metadata and controls
executable file
·48 lines (40 loc) · 2.01 KB
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
#!/bin/bash
#
# Used as the entrypoint for the installer image. Must be kept in sync
# with the directories in that file.
#
export PATH=$HOME/google-cloud-sdk/bin:$PATH
# When running with an invalid user, correct it by adding cloud-user (also
# part of the image definition). Ansible requires getpwnam() to start.
# Also set the default to localhost to become: no to avoid the need to
# sudo.
if ! whoami &>/dev/null; then
echo "cloud-user$(id -u):x:$(id -u):0:cloud-user:$HOME:/sbin/nologin" >> /etc/passwd
mkdir -p "${WORK}/inventory/host_vars/localhost"
echo "ansible_become: no" > "${WORK}/inventory/host_vars/localhost/00_skip_root.yaml"
# SSH requires the file to be owned by the current user, but Docker copies
# files in as root. Remove the file and recreate it.
keyfile="${HOME}/.ssh/google_compute_engine"
if key=$( cat "${keyfile}" ); then
rm -f "${keyfile}"
echo "${key}" > "${keyfile}"
chmod 0600 "${keyfile}"
fi
fi
# Provide a "files_dir" variable that points to playbooks/files
mkdir -p "${WORK}/inventory/group_vars/all"
echo "files_dir: ${WORK}/playbooks/files" > "${WORK}/inventory/group_vars/all/00_default_files_dir.yaml"
# Set inventory_dir for legacy support for old configs - Ansible 2.4 no longer has inventory_dir set on
# localhost
# DEPRECATED: will be removed when all config switches over
mkdir -p "${WORK}/inventory/host_vars/localhost"
echo "inventory_dir: ${WORK}/inventory" > "${WORK}/inventory/host_vars/localhost/01_default_inventory_dir.yaml"
find "${WORK}/playbooks/files" | xargs -L1 -I {} ln -fs {} "${WORK}/inventory/"
find "${WORK}/playbooks/files" -name *.yaml -or -name vars | xargs -L1 -I {} ln -fs {} "${WORK}/inventory/group_vars/all"
if [[ -n "${OPENSHIFT_ANSIBLE_COMMIT-}" ]]; then
pushd /usr/share/ansible/openshift-ansible &>/dev/null
git checkout "${OPENSHIFT_ANSIBLE_COMMIT}" || ( git fetch origin && git checkout "${OPENSHIFT_ANSIBLE_COMMIT}" )
popd &>/dev/null
fi
gcloud auth activate-service-account --key-file="${WORK}/playbooks/files/gce.json"
exec "$@"