2 ##############################################################################
3 # Copyright (c) 2018 Mirantis Inc., Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 mkdir -p /etc/salt/{master.d,minion.d,proxy.d}
12 if [ ! -z "$SALT_EXT_PILLAR" ]; then
13 cp -avr "/tmp/${SALT_EXT_PILLAR}.conf" /etc/salt/master.d/
16 if [ ! -f /home/ubuntu/.ssh/authorized_keys ]; then
17 install -D -o ubuntu /root/fuel/mcp/scripts/mcp.rsa.pub \
18 /home/ubuntu/.ssh/authorized_keys
21 if ! grep -q localhost /etc/hosts; then
22 # overwrite hosts only on first container up, to preserve cluster nodes
23 cp -a /root/fuel/mcp/scripts/docker-compose/files/hosts /etc/hosts
26 # salt state does not properly configure file_roots in master.conf, hard set it
27 cp -a /root/fuel/mcp/scripts/docker-compose/files/opnfv_master.conf \
28 /etc/salt/master.d/opnfv_master.conf
29 echo 'master: localhost' > /etc/salt/minion.d/opnfv_slave.conf
31 # NOTE: Most Salt and/or reclass tools have issues traversing Docker mounts
32 # or detecting them as directories inside the container.
33 # For now, let's do a lot of copy operations to bypass this.
34 # Later, we will inject the OPNFV patched reclass model during image build.
35 rm -rf /srv/salt/reclass/classes/*
36 cp -ar /root/fuel/mcp/reclass/classes/* /srv/salt/reclass/classes
37 cp -ar /root/fuel/mcp/reclass/nodes/* /srv/salt/reclass/nodes
38 # Sensitive data should stay out of /root/fuel, which is exposed via Jenkins WS
39 cp -a /root/pod_config.yml \
40 /srv/salt/reclass/classes/cluster/all-mcp-arch-common/opnfv/pod_config.yml
43 prefix=/srv/salt/formula/salt-formulas
44 rm -f /root/fuel/mcp/salt-formulas/*/.git
45 cp -ar /root/fuel/mcp/salt-formulas/* ${prefix}/
46 for formula in 'armband' 'opendaylight' 'tacker' 'quagga'; do
47 ln -sf /root/fuel/mcp/salt-formulas/salt-formula-${formula}/* \
51 # Re-create classes.service links that we destroyed above
52 for formula in ${prefix}/*; do
53 if [ -e "${formula}/metadata/service" ] && [[ ! $formula =~ \. ]]; then
54 ln -sf "${formula}/metadata/service" \
55 "/srv/salt/reclass/classes/service/${formula#${prefix}/salt-formula-}"
59 # Create links for salt-formula-* packages to mimic git-style salt-formulas
60 for artifact in /usr/share/salt-formulas/env/_*/*; do
61 ln -sf "${artifact}" "/srv/salt/env/prd/${artifact#/usr/share/salt-formulas/env/}"
63 for artifact in /usr/share/salt-formulas/env/*; do
64 if [[ ! ${artifact} =~ ^_ ]]; then
65 ln -sf "${artifact}" "/srv/salt/env/prd/$(basename ${artifact})"
68 for formula in /usr/share/salt-formulas/reclass/service/*; do
69 ln -sf "${formula}" "/srv/salt/reclass/classes/service/$(basename ${formula})"
72 # Temporary link queens configs to rocky
73 for f in /srv/salt/env/prd/*/files/queens; do
74 if [ ! -d "$f/../rocky" ]; then
75 ln -sf "$f" "$f/../rocky"
79 # Tini init system resembles upstart very much, but needs a little adjustment
80 sed -i -e "s|return 'start/running' in |return 'is running' in |" \
81 -e "s|ret = _default_runlevel|return _default_runlevel|" \
82 /usr/lib/python2.7/dist-packages/salt/modules/upstart.py
84 # Workaround for: https://github.com/salt-formulas/reclass/issues/77
85 sed -i -e 's|\(ignore_overwritten_missing_references\)defaults.|\1|' \
86 /usr/local/lib/python2.7/dist-packages/reclass/settings.py
88 # Remove broken symlinks in /srv/salt, silences recurring warnings
89 find -L /srv/salt /srv/salt/env/prd/_* -maxdepth 1 -type l -delete
91 # Fix up any permissions after above file shuffling
92 chown root:root -R /srv/salt
95 service salt-minion start
97 if [[ $# -lt 1 ]] || [[ "$1" == "--"* ]]; then
98 exec /usr/bin/salt-master --log-file-level=quiet --log-level=info "$@"