summaryrefslogtreecommitdiff
path: root/hot/software-config/boot-config/templates/fragments/configure_config_agent.sh
blob: 36fc7255aa1bf30fd1435a3f446c9545e1bdf160 (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
#!/bin/bash
set -eux

# os-apply-config templates directory
oac_templates=/usr/libexec/os-apply-config/templates
mkdir -p $oac_templates/etc

# initial /etc/os-collect-config.conf
cat <<EOF >/etc/os-collect-config.conf
[DEFAULT]
command = os-refresh-config
EOF

# template for building os-collect-config.conf for polling heat
cat <<EOF >$oac_templates/etc/os-collect-config.conf
$occ_conf
EOF
mkdir -p $oac_templates/var/run/heat-config

# template for writing heat deployments data to a file
echo "{{deployments}}" > $oac_templates/var/run/heat-config/heat-config

# os-refresh-config scripts directory.
# For older version, this path might be `/opt/stack/os-config-refresh`
orc_scripts=/usr/libexec/os-refresh-config
for d in pre-configure.d configure.d migration.d post-configure.d; do
    install -m 0755 -o root -g root -d $orc_scripts/$d
done

# os-refresh-config script for running os-apply-config
cat <<EOF >$orc_scripts/configure.d/20-os-apply-config
$orc_oac
EOF
chmod 700 $orc_scripts/configure.d/20-os-apply-config

# os-refresh-config script for running heat config hooks
cat <<EOF >$orc_scripts/configure.d/55-heat-config
$heat_config_script
EOF
chmod 700 $orc_scripts/configure.d/55-heat-config

# config hook for shell scripts
hooks_dir=/var/lib/heat-config/hooks
mkdir -p $hooks_dir

# install hook for configuring with shell scripts
cat <<EOF >$hooks_dir/script
$hook_script
EOF
chmod 755 $hooks_dir/script

# install heat-config-notify command
cat <<EOF >/usr/bin/heat-config-notify
$heat_config_notify
EOF
chmod 755 /usr/bin/heat-config-notify

# run once to write out /etc/os-collect-config.conf
os-collect-config --one-time --debug
cat /etc/os-collect-config.conf

# run again to poll for deployments and run hooks
os-collect-config --one-time --debug