Merge "Do not automatically start os-refresh-config."

This commit is contained in:
Jenkins 2013-07-22 08:14:15 +00:00 committed by Gerrit Code Review
commit a7ede4152d
4 changed files with 7 additions and 77 deletions

View File

@ -2,7 +2,7 @@
[os-refresh-config-{{resource}}]
triggers=post.add,post.delete.post.update
path=Resources.{{resource}}.Metadata
action=service os-refresh-config start
action=os-refresh-config 2>&1 | logger -t os-refresh-config
runas=root
{{/heat.refresh}}

View File

@ -11,37 +11,3 @@ pip install /opt/stack/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 /opt/stack/os-config-refresh/$d
done
# Upstart
if [ -d /etc/init ] ; then
cat > /etc/init/os-refresh-config.conf <<eof
start on runlevel [2345]
task
exec os-refresh-config
eof
# Systemd
elif [ -d /lib/systemd/system ] ; then
cat > /lib/systemd/system/os-refresh-config.service <<eof
[Unit]
Description=Refresh Config on state change
After=cloud-final.service
Before=crond.service
[Service]
ExecStart=/bin/os-refresh-config
[Install]
WantedBy=multi-user.target
eof
# Make systemd take notice of it
systemctl daemon-reload
# Enable the service
systemctl enable os-refresh-config.service
else
echo Only systems with systemd or upstart are supported.
exit 1
fi

View File

@ -1,9 +1,12 @@
#!/bin/bash
install -m 0755 -o root -g root $(dirname $0)/cfn-hup-wrapper /usr/local/bin/cfn-hup-wrapper
# This cannot be an os-apply-config template as this is what runs
# os-apply-config for the first time.
cat > /etc/cron.d/cfn-hup <<EOF
# This is a workaround for cfn-hup not actually being a daemon
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * root cfn-hup-wrapper
# Ensure cfn-hup has a configuration
@reboot root os-refresh-config 2>&1 | logger -t os-refresh-config
# This is a workaround for cfn-hup not actually being a daemon
*/5 * * * * root cfn-hup --no-daemon
EOF

View File

@ -1,39 +0,0 @@
#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import fcntl
import os
import random
import subprocess
import sys
import time
if len(sys.argv) > 1:
max_sleep = int(sys.argv[1])
else:
max_sleep = 59
randskew = random.randint(0, max_sleep)
time.sleep(randskew)
with open('/run/os-refresh-config-cfn-hup.lock', 'a') as lock:
fcntl.flock(lock, fcntl.LOCK_EX)
lock.seek(0)
lock.truncate()
lock.write('Lock held by process id %s\n' % os.getpid())
lock.flush()
try:
subprocess.check_call(['cfn-hup', '--no-daemon'])
except subprocess.CalledProcessError as e:
sys.stderr.write("%s\n" % e)
sys.exit(e.returncode)