Install murano-agent by cloud-init
Adding a murano-init script to install murano-agent by cloud init in the LinuxMuranoInstance. Change-Id: I080fe14a61b9af468ba1ae2e26dd85196a563449 Targets-blueprint: cloud-init-deployable-agent
This commit is contained in:
parent
b50564d65d
commit
e089f7989e
@ -114,8 +114,6 @@ Methods:
|
||||
- $.networks.customNetworks.select($this.joinNet($, $securityGroupName))
|
||||
|
||||
- $preparedUserData: $.prepareUserData()
|
||||
- $userData: $preparedUserData.data
|
||||
- $userDataFormat: $preparedUserData.format
|
||||
# Create MQ queue to communicate with the VM
|
||||
- $.agent.prepare()
|
||||
- $template:
|
||||
@ -126,8 +124,8 @@ Methods:
|
||||
flavor: $.flavor
|
||||
image: $.image
|
||||
availability_zone: $.availabilityZone
|
||||
user_data: $userData
|
||||
user_data_format: $userDataFormat
|
||||
user_data: $preparedUserData.data
|
||||
user_data_format: $preparedUserData.format
|
||||
key_name: $.keyname
|
||||
outputs:
|
||||
format('{0}-assigned-ips', $.name):
|
||||
|
@ -27,6 +27,10 @@ Methods:
|
||||
- $resources: new(sys:Resources)
|
||||
- $configFile: $resources.string('Agent-v2.template')
|
||||
- $initScript: $resources.string('linux-init.sh')
|
||||
- $muranoScript: $resources.string('murano-init.sh')
|
||||
- $muranoAgentConf: $resources.string('murano-agent.conf')
|
||||
- $muranoAgentService: $resources.string('murano-agent.service')
|
||||
- $muranoAgent: $resources.string('murano-agent')
|
||||
- $configReplacements:
|
||||
"%RABBITMQ_HOST%": config(rabbitmq, host)
|
||||
"%RABBITMQ_PORT%": config(rabbitmq, port)
|
||||
@ -41,7 +45,44 @@ Methods:
|
||||
"%INTERNAL_HOSTNAME%": $.name
|
||||
"%MURANO_SERVER_ADDRESS%": coalesce(config(file_server), config(rabbitmq, host))
|
||||
"%CA_ROOT_CERT_BASE64%": ""
|
||||
- Return:
|
||||
data: $initScript.replace($scriptReplacements)
|
||||
format: HEAT_CFNTOOLS
|
||||
- $muranoReplacements:
|
||||
"%MURANO_AGENT_CONF%": base64encode($muranoAgentConf)
|
||||
"%MURANO_AGENT_SERVICE%": base64encode($muranoAgentService)
|
||||
"%MURANO_AGENT%": base64encode($muranoAgent)
|
||||
|
||||
- $userData: $muranoScript.replace($muranoReplacements) + $initScript.replace($scriptReplacements)
|
||||
- Return:
|
||||
data: $._generateInstanceConfigResources($userData)
|
||||
format: RAW
|
||||
|
||||
_generateInstanceConfigResources:
|
||||
Arguments:
|
||||
- userData:
|
||||
Contract: $.string().notNull()
|
||||
Body:
|
||||
- $environment: $.find(std:Environment).require()
|
||||
- $resources: new(sys:Resources)
|
||||
- $muranoInitConf: $resources.yaml('murano-init.conf')
|
||||
- $bootConfigResourceName: format('boot_config_{0}', $.name)
|
||||
- $bootScriptResourceName: format('boot_script_{0}', $.name)
|
||||
- $userDataResourceName: format('user_data-{0}', $.name)
|
||||
- $template:
|
||||
resources:
|
||||
$bootConfigResourceName:
|
||||
type: 'OS::Heat::CloudConfig'
|
||||
properties:
|
||||
cloud_config: $muranoInitConf
|
||||
$bootScriptResourceName:
|
||||
type: 'OS::Heat::SoftwareConfig'
|
||||
properties:
|
||||
group: ungrouped
|
||||
config: $userData
|
||||
$userDataResourceName:
|
||||
type: 'OS::Heat::MultipartMime'
|
||||
properties:
|
||||
parts:
|
||||
- config: {get_resource: $bootConfigResourceName}
|
||||
- config: {get_resource: $bootScriptResourceName}
|
||||
|
||||
- $environment.stack.updateTemplate($template)
|
||||
- Return: {get_resource: $userDataResourceName}
|
||||
|
@ -15,7 +15,7 @@ service murano-agent stop
|
||||
|
||||
AgentConfigBase64='%AGENT_CONFIG_BASE64%'
|
||||
|
||||
if [[ ! -d /etc/murano ]]; then
|
||||
if [ ! -d /etc/murano ]; then
|
||||
mkdir /etc/murano
|
||||
fi
|
||||
echo $AgentConfigBase64 | base64 -d > /etc/murano/agent.conf
|
||||
|
51
meta/io.murano/Resources/murano-agent
Normal file
51
meta/io.murano/Resources/murano-agent
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: murano-agent
|
||||
# Required-Start: $local_fs $network $named $time $syslog
|
||||
# Required-Stop: $local_fs $network $named $time $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: murano-agent service
|
||||
### END INIT INFO
|
||||
|
||||
SCRIPT="/usr/bin/muranoagent --config-dir /etc/murano"
|
||||
RUNAS=root
|
||||
|
||||
PIDFILE=/var/run/murano.pid
|
||||
LOGFILE=/var/log/murano.log
|
||||
|
||||
start() {
|
||||
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
|
||||
echo 'Service already running' >&2
|
||||
return 1
|
||||
fi
|
||||
echo 'Starting service' >&2
|
||||
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
|
||||
su -c "$CMD" $RUNAS > "$PIDFILE"
|
||||
echo 'Service started' >&2
|
||||
}
|
||||
|
||||
stop() {
|
||||
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
|
||||
echo 'Service not running' >&2
|
||||
return 1
|
||||
fi
|
||||
echo 'Stopping service' >&2
|
||||
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
|
||||
echo 'Service stopped' >&2
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|uninstall}"
|
||||
esac
|
14
meta/io.murano/Resources/murano-agent.conf
Normal file
14
meta/io.murano/Resources/murano-agent.conf
Normal file
@ -0,0 +1,14 @@
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
respawn
|
||||
# the default post-start of 1 second sleep delays respawning enough to
|
||||
# not hit the default of 10 times in 5 seconds. Make it 2 times in 5s.
|
||||
respawn limit 2 5
|
||||
|
||||
# We're logging to syslog
|
||||
console none
|
||||
|
||||
exec start-stop-daemon --start -c root --exec /usr/local/bin/muranoagent -- --config-dir /etc/murano 2>&1 | logger -t murano-agent
|
||||
|
||||
post-start exec sleep 1
|
10
meta/io.murano/Resources/murano-agent.service
Normal file
10
meta/io.murano/Resources/murano-agent.service
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=OpenStack Murano Agent
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/muranoagent --config-dir /etc/murano
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
20
meta/io.murano/Resources/murano-init.conf
Normal file
20
meta/io.murano/Resources/murano-init.conf
Normal file
@ -0,0 +1,20 @@
|
||||
yum_repos:
|
||||
epel-testing:
|
||||
baseurl: http://download.fedoraproject.org/pub/epel/$releasever/$basearch
|
||||
enabled: true
|
||||
failovermethod: priority
|
||||
gpgcheck: false
|
||||
name: Extra Packages for Enterprise Linux - Testing
|
||||
|
||||
package_upgrade: true
|
||||
|
||||
packages:
|
||||
- subversion
|
||||
- git-core
|
||||
- wget
|
||||
- make
|
||||
- gcc
|
||||
- python-pip
|
||||
- python-dev
|
||||
- python-setuptools
|
||||
- python-virtualenv
|
20
meta/io.murano/Resources/murano-init.sh
Normal file
20
meta/io.murano/Resources/murano-init.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
ps cax | grep muranoagent > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "murano-agent service exists"
|
||||
else
|
||||
muranoAgentConf='%MURANO_AGENT_CONF%'
|
||||
echo $muranoAgentConf | base64 -d > /etc/init/murano-agent.conf
|
||||
muranoAgentService='%MURANO_AGENT_SERVICE%'
|
||||
echo $muranoAgentService | base64 -d > /etc/systemd/system/murano-agent.service
|
||||
muranoAgent='%MURANO_AGENT%'
|
||||
echo $muranoAgent | base64 -d > /etc/init.d/murano-agent
|
||||
chmod +x /etc/init.d/murano-agent
|
||||
pip install murano-agent
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user