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))
|
- $.networks.customNetworks.select($this.joinNet($, $securityGroupName))
|
||||||
|
|
||||||
- $preparedUserData: $.prepareUserData()
|
- $preparedUserData: $.prepareUserData()
|
||||||
- $userData: $preparedUserData.data
|
|
||||||
- $userDataFormat: $preparedUserData.format
|
|
||||||
# Create MQ queue to communicate with the VM
|
# Create MQ queue to communicate with the VM
|
||||||
- $.agent.prepare()
|
- $.agent.prepare()
|
||||||
- $template:
|
- $template:
|
||||||
@ -126,8 +124,8 @@ Methods:
|
|||||||
flavor: $.flavor
|
flavor: $.flavor
|
||||||
image: $.image
|
image: $.image
|
||||||
availability_zone: $.availabilityZone
|
availability_zone: $.availabilityZone
|
||||||
user_data: $userData
|
user_data: $preparedUserData.data
|
||||||
user_data_format: $userDataFormat
|
user_data_format: $preparedUserData.format
|
||||||
key_name: $.keyname
|
key_name: $.keyname
|
||||||
outputs:
|
outputs:
|
||||||
format('{0}-assigned-ips', $.name):
|
format('{0}-assigned-ips', $.name):
|
||||||
|
@ -21,27 +21,68 @@ Extends:
|
|||||||
- LinuxInstance
|
- LinuxInstance
|
||||||
|
|
||||||
Methods:
|
Methods:
|
||||||
prepareUserData:
|
prepareUserData:
|
||||||
Body:
|
Body:
|
||||||
- $environment: $.find(std:Environment).require()
|
- $environment: $.find(std:Environment).require()
|
||||||
- $resources: new(sys:Resources)
|
- $resources: new(sys:Resources)
|
||||||
- $configFile: $resources.string('Agent-v2.template')
|
- $configFile: $resources.string('Agent-v2.template')
|
||||||
- $initScript: $resources.string('linux-init.sh')
|
- $initScript: $resources.string('linux-init.sh')
|
||||||
- $configReplacements:
|
- $muranoScript: $resources.string('murano-init.sh')
|
||||||
"%RABBITMQ_HOST%": config(rabbitmq, host)
|
- $muranoAgentConf: $resources.string('murano-agent.conf')
|
||||||
"%RABBITMQ_PORT%": config(rabbitmq, port)
|
- $muranoAgentService: $resources.string('murano-agent.service')
|
||||||
"%RABBITMQ_USER%": config(rabbitmq, login)
|
- $muranoAgent: $resources.string('murano-agent')
|
||||||
"%RABBITMQ_PASSWORD%": config(rabbitmq, password)
|
- $configReplacements:
|
||||||
"%RABBITMQ_VHOST%": config(rabbitmq, virtual_host)
|
"%RABBITMQ_HOST%": config(rabbitmq, host)
|
||||||
"%RABBITMQ_SSL%": str(config(rabbitmq, ssl)).toLower()
|
"%RABBITMQ_PORT%": config(rabbitmq, port)
|
||||||
"%RABBITMQ_INPUT_QUEUE%": $.agent.queueName()
|
"%RABBITMQ_USER%": config(rabbitmq, login)
|
||||||
"%RESULT_QUEUE%": $environment.agentListener.queueName()
|
"%RABBITMQ_PASSWORD%": config(rabbitmq, password)
|
||||||
- $scriptReplacements:
|
"%RABBITMQ_VHOST%": config(rabbitmq, virtual_host)
|
||||||
"%AGENT_CONFIG_BASE64%": base64encode($configFile.replace($configReplacements))
|
"%RABBITMQ_SSL%": str(config(rabbitmq, ssl)).toLower()
|
||||||
"%INTERNAL_HOSTNAME%": $.name
|
"%RABBITMQ_INPUT_QUEUE%": $.agent.queueName()
|
||||||
"%MURANO_SERVER_ADDRESS%": coalesce(config(file_server), config(rabbitmq, host))
|
"%RESULT_QUEUE%": $environment.agentListener.queueName()
|
||||||
"%CA_ROOT_CERT_BASE64%": ""
|
- $scriptReplacements:
|
||||||
- Return:
|
"%AGENT_CONFIG_BASE64%": base64encode($configFile.replace($configReplacements))
|
||||||
data: $initScript.replace($scriptReplacements)
|
"%INTERNAL_HOSTNAME%": $.name
|
||||||
format: HEAT_CFNTOOLS
|
"%MURANO_SERVER_ADDRESS%": coalesce(config(file_server), config(rabbitmq, host))
|
||||||
|
"%CA_ROOT_CERT_BASE64%": ""
|
||||||
|
- $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%'
|
AgentConfigBase64='%AGENT_CONFIG_BASE64%'
|
||||||
|
|
||||||
if [[ ! -d /etc/murano ]]; then
|
if [ ! -d /etc/murano ]; then
|
||||||
mkdir /etc/murano
|
mkdir /etc/murano
|
||||||
fi
|
fi
|
||||||
echo $AgentConfigBase64 | base64 -d > /etc/murano/agent.conf
|
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