From 9f46c3ba0c12a986c00cd315adfc1028f60ffb83 Mon Sep 17 00:00:00 2001 From: Om Kumar Date: Mon, 6 Jul 2015 20:44:54 +0530 Subject: [PATCH] Adds Ubuntu and Debian to ironic-python-agent Support-list Adds support for Ubuntu and Debian to ironic-python-agent. This will enable building ramdisk with Ubuntu and Debian as base OS. Updated README to further clarify what the element does. Change-Id: I194f85b051974d8ccb197a0993a67761046cfe98 --- elements/ironic-agent/README.rst | 16 ++++++++-- .../install.d/60-ironic-agent-install | 30 ++++++++++++------ .../install.d/ironic-python-agent.conf | 20 ++++++++++++ .../install.d/ironic-python-agent.init | 31 +++++++++++++++++++ .../install.d/ironic-python-agent.service | 12 +++++++ elements/ironic-agent/package-installs.yaml | 2 +- elements/ironic-agent/pkg-map | 21 +++++++++++++ .../post-install.d/80-ironic-agent | 18 ++++++++++- 8 files changed, 137 insertions(+), 13 deletions(-) create mode 100755 elements/ironic-agent/install.d/ironic-python-agent.conf create mode 100755 elements/ironic-agent/install.d/ironic-python-agent.init create mode 100755 elements/ironic-agent/install.d/ironic-python-agent.service create mode 100644 elements/ironic-agent/pkg-map diff --git a/elements/ironic-agent/README.rst b/elements/ironic-agent/README.rst index 2ca48926..eb1dc5bd 100644 --- a/elements/ironic-agent/README.rst +++ b/elements/ironic-agent/README.rst @@ -1,5 +1,17 @@ ============ ironic-agent ============ -Build ramdisk with ironic-python-agent. -Works only on Fedora, therefore fedora element is mandatory. +Builds a ramdisk with ironic-python-agent. More information can be found at: + https://github.com/openstack/ironic-python-agent/ + +Beyond installing the ironic-python-agent, this element does the following: + +* Installs the ``dhcp-all-interfaces`` so the node, upon booting, attempts to + obtain an IP address on all available network interfaces. +* Disables the ``iptables`` service on SysV and systemd based systems. +* Disables the ``ufw`` service on Upstart based systems. +* Installs packages required for the operation of the ironic-python-agent:: + ``qemu-utils`` ``parted`` ``hdparm`` ``util-linux`` ``genisoimage`` +* When installing from source, ``python-dev`` and ``gcc`` are also installed + in order to support source based installation of ironic-python-agent and its + dependencies. diff --git a/elements/ironic-agent/install.d/60-ironic-agent-install b/elements/ironic-agent/install.d/60-ironic-agent-install index becf97af..9c9e4bbc 100755 --- a/elements/ironic-agent/install.d/60-ironic-agent-install +++ b/elements/ironic-agent/install.d/60-ironic-agent-install @@ -6,6 +6,7 @@ fi set -eu set -o pipefail +SCRIPTDIR=$(dirname $0) install-packages python-dev qemu-utils parted hdparm util-linux genisoimage gcc # Install the latest version of pip and setuptools which has some @@ -18,13 +19,24 @@ pip install -U setuptools pip install -r /tmp/ironic-python-agent/requirements.txt pip install /tmp/ironic-python-agent -sudo echo $'[Unit] -Description=Ironic Python Agent\n -[Service] -ExecStart=/usr/bin/ironic-python-agent -Restart=always -RestartSec=30s\n -[Install] -WantedBy=multi-user.target\n' > /usr/lib/systemd/system/ironic-python-agent.service +if [ ! -f /usr/bin/ironic-python-agent ]; then + ln -s /usr/local/bin/ironic-python-agent /usr/bin/ironic-python-agent +fi -sudo systemctl enable ironic-python-agent.service +case "$DIB_INIT_SYSTEM" in + upstart) + install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.conf /etc/init/ironic-python-agent.conf + ;; + systemd) + install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/ironic-python-agent.service + systemctl enable ironic-python-agent.service + ;; + sysv) + install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.init /etc/init.d/ironic-python-agent.init + update-rc.d ironic-python-agent.init defaults + ;; + *) + echo "Unsupported init system" + exit 1 + ;; +esac diff --git a/elements/ironic-agent/install.d/ironic-python-agent.conf b/elements/ironic-agent/install.d/ironic-python-agent.conf new file mode 100755 index 00000000..e043cad1 --- /dev/null +++ b/elements/ironic-agent/install.d/ironic-python-agent.conf @@ -0,0 +1,20 @@ +# ironic-python-agent - Openstack Ironic Python Agnet +# +# The ironic-python-agent helps ironic in deploying instances. + +description "Ironic Python Agnet" + +start on runlevel [2345] +stop on runlevel [!2345] + +respawn +respawn limit 10 5 +umask 022 + +expect stop + +pre-start script + echo Starting Ironic Python Agnet +end script + +exec /usr/bin/ironic-python-agent diff --git a/elements/ironic-agent/install.d/ironic-python-agent.init b/elements/ironic-agent/install.d/ironic-python-agent.init new file mode 100755 index 00000000..83035c26 --- /dev/null +++ b/elements/ironic-agent/install.d/ironic-python-agent.init @@ -0,0 +1,31 @@ +#!/bin/sh -e +### BEGIN INIT INFO +# Provides: ironic-python-agent +# Required-Start: $local_fs networking +# Required-Stop: $local_fs +# Default-Start: S +# Default-Stop: 0 6 +# X-Start-Before: +# Short-Description: Ironic Python Agent +# Description: Starts Ironic Python Agent for instance deployment +### END INIT INFO + +NAME=ironic-python-agent +INIT_NAME=/etc/init.d/${NAME} +SCRIPT_NAME=/usr/bin/${NAME} + +[ -x $SCRIPT_NAME ] || exit 0 + +case "$1" in + start) + $SCRIPT_NAME + ;; + stop) + ;; + *) + echo "Usage: $INIT_NAME {start|stop}" + exit 1 + ;; +esac + +exit 0 diff --git a/elements/ironic-agent/install.d/ironic-python-agent.service b/elements/ironic-agent/install.d/ironic-python-agent.service new file mode 100755 index 00000000..a4593caf --- /dev/null +++ b/elements/ironic-agent/install.d/ironic-python-agent.service @@ -0,0 +1,12 @@ +[Unit] +Description=Ironic Python Agent +After=network.target + +[Service] +ExecStart=/usr/bin/ironic-python-agent +Restart=always +RestartSec=30s + +[Install] +WantedBy=multi-user.target + diff --git a/elements/ironic-agent/package-installs.yaml b/elements/ironic-agent/package-installs.yaml index a4bd4f99..79df9f9a 100644 --- a/elements/ironic-agent/package-installs.yaml +++ b/elements/ironic-agent/package-installs.yaml @@ -1 +1 @@ -scsi-target-utils: +tgt: diff --git a/elements/ironic-agent/pkg-map b/elements/ironic-agent/pkg-map new file mode 100644 index 00000000..636567b6 --- /dev/null +++ b/elements/ironic-agent/pkg-map @@ -0,0 +1,21 @@ +{ + "distro": { + "rhel": { + "tgt": "targetcli" + }, + "centos":{ + "tgt": "scsi-target-utils" + } + }, + "family": { + "redhat": { + "tgt": "scsi-target-utils" + }, + "debian": { + "tgt": "tgt" + } + }, + "default": { + "tgt": "tgt" + } +} diff --git a/elements/ironic-agent/post-install.d/80-ironic-agent b/elements/ironic-agent/post-install.d/80-ironic-agent index eb000981..440f161c 100755 --- a/elements/ironic-agent/post-install.d/80-ironic-agent +++ b/elements/ironic-agent/post-install.d/80-ironic-agent @@ -9,4 +9,20 @@ set -o pipefail install-packages -e python-dev git cloud-init rm -rf /tmp/ironic-python-agent -sudo systemctl disable iptables.service +case "$DIB_INIT_SYSTEM" in + upstart) + if [ -f /etc/init/ufw.conf ]; then + mv /etc/init/ufw.conf /etc/init/ufw.conf.disabled + fi + ;; + systemd) + systemctl disable iptables.service + ;; + sysv) + update-rc.d iptables disable + ;; + *) + echo "Unsupported init system" + exit 1 + ;; +esac