summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-12-04 15:55:56 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-12-04 17:53:17 +0000
commitf84cc5c7cd78018b501afb0e07cb695a79f51b67 (patch)
tree44cc5e76c5ce58cde3684c89bcc26a9cb8d06853
parent08a05c726dfc08af153a9a64804c74e71e6d2b8c (diff)
downloaddefinitions-baserock/pedroalvarez/installer6.tar.gz
Add the ability to deploy installer systems and add examples.baserock/pedroalvarez/installer6
The installer-x86_64 system is a system that can be used to install other systems in an storage device. This system is intended to be booted by usb, pxeboot... to install a Baserock system in your local disk. The installer system requires the installer.configure extension to generate a configuration file located in /etc/install.conf. With this extension you can specify the following variables in a cluster morphology: - INSTALLER_TARGET_STORAGE_DEVICE: Target storage device to install the Baserock system. - INSTALLER_ROOTFS_TO_INSTALL: The location of the root filesystem that is going to be installed. - INSTALLER_POST_INSTALL_COMMAND: Commands that will be run after the installation finishes. It defaults to `reboot -f`. The installer-utils stratum is required to contain the installer-scripts chunk. This chunk contains the installer script that is going to be installed in /usr/lib/installer/installer.py The clusters/installer-build-system-x86_64.morph file defines the deployment of a installer system as a rawdisk image. This installer system will install a build-system-x86_64 located in /rootfs into the /dev/sda device. Also this cluster defines a subsystem which is the build-system that is going to end up in /rootfs on the installer system.
-rw-r--r--clusters/installer-build-system-x86_64.morph46
-rwxr-xr-xinstaller.configure48
-rw-r--r--strata/installer-utils.morph12
-rw-r--r--strata/installer-utils/installer-scripts.morph4
-rw-r--r--systems/installer-system-x86_64.morph22
5 files changed, 132 insertions, 0 deletions
diff --git a/clusters/installer-build-system-x86_64.morph b/clusters/installer-build-system-x86_64.morph
new file mode 100644
index 00000000..c434d142
--- /dev/null
+++ b/clusters/installer-build-system-x86_64.morph
@@ -0,0 +1,46 @@
+name: installer-build-system-x86_64
+kind: cluster
+description: |
+ This is a cluster morphology that can be used to deploy
+ installer systems. This is done by adding the files needed
+ using a manifest file (installer/manifest) with the INSTALL_FILES
+ extension, and using the installer.configure extension to generate
+ the configuration needed in the system.
+
+ This manifest, which is installing the installer script in
+ /usr/lib/installer/installer.py, in combination of adding
+ "init=/usr/lib/installer/installer.py" as KERNEL_ARGS in the system
+ makes the system run the installer.py script as init script.
+
+ The installer.py script will read the information needed to
+ install the system (where is the root filesystem to install and
+ where to install it) from /etc/install.conf.
+
+ This cluster also deploys a subsystem (a build-system in this case)
+ which is going to be the system that the installer system/script is
+ going to install.
+
+systems:
+- morph: systems/installer-system-x86_64.morph
+ deploy:
+ installer:
+ type: rawdisk
+ location: installer-build-system-x86_64.img
+ KERNEL_ARGS: init=/usr/lib/installer/installer.py
+ DISK_SIZE: 6G
+ HOSTNAME: installer-x86_64
+ INSTALLER_TARGET_STORAGE_DEVICE: /dev/sda
+ INSTALLER_ROOTFS_TO_INSTALL: /rootfs
+ subsystems:
+ - morph: systems/build-system-x86_64.morph
+ deploy:
+ to-install:
+ type: sysroot
+ location: /rootfs
+ INITRAMFS_PATH: boot/initramfs.gz
+ subsystems:
+ - morph: systems/initramfs-x86_64.morph
+ deploy:
+ initramfs:
+ type: initramfs
+ location: boot/initramfs.gz
diff --git a/installer.configure b/installer.configure
new file mode 100755
index 00000000..da2423ec
--- /dev/null
+++ b/installer.configure
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2013 - 2014 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# This is a "morph deploy" configuration extension to configure an installer
+# system. It will create the configuration needed in the installer system
+# to perform an installation. It uses the following variables from the
+# environment:
+#
+# * INSTALLER_TARGET_STORAGE_DEVICE
+# * INSTALLER_ROOTFS_TO_INSTALL
+# * INSTALLER_POST_INSTALL_COMMAND (optional, defaults to `reboot -f`)
+
+import os
+import sys
+import yaml
+
+install_config_file = os.path.join(sys.argv[1], 'etc', 'install.conf')
+
+try:
+ installer_configuration={
+ 'INSTALLER_TARGET_STORAGE_DEVICE': os.environ['INSTALLER_TARGET_STORAGE_DEVICE'],
+ 'INSTALLER_ROOTFS_TO_INSTALL': os.environ['INSTALLER_ROOTFS_TO_INSTALL'],
+ }
+except KeyError, e:
+ print "Not configuring as an installer system"
+ exit(0)
+
+postinstkey = 'INSTALLER_POST_INSTALL_COMMAND'
+installer_configuration[postinstkey] = os.environ.get(postinstkey, 'reboot -f')
+
+with open(install_config_file, 'w') as f:
+ f.write( yaml.dump(installer_configuration, default_flow_style=False) )
+
+print "Configuration of the installer system in %s" % install_config_file
diff --git a/strata/installer-utils.morph b/strata/installer-utils.morph
new file mode 100644
index 00000000..2941a5aa
--- /dev/null
+++ b/strata/installer-utils.morph
@@ -0,0 +1,12 @@
+name: installer-utils
+kind: stratum
+description: stratum for Baserock installer script.
+build-depends:
+- morph: strata/build-essential.morph
+chunks:
+- name: installer-scripts
+ morph: strata/installer-utils/installer-scripts.morph
+ repo: https://github.com/palvarez89/baserock-installer-script.git
+ ref: initial-version
+ unpetrify-ref: master
+ build-depends: []
diff --git a/strata/installer-utils/installer-scripts.morph b/strata/installer-utils/installer-scripts.morph
new file mode 100644
index 00000000..547f2713
--- /dev/null
+++ b/strata/installer-utils/installer-scripts.morph
@@ -0,0 +1,4 @@
+name: installer-scripts
+kind: chunk
+install-commands:
+- install -D -m 755 installer.py "$DESTDIR/usr/lib/installer/installer.py"
diff --git a/systems/installer-system-x86_64.morph b/systems/installer-system-x86_64.morph
new file mode 100644
index 00000000..0b5e4709
--- /dev/null
+++ b/systems/installer-system-x86_64.morph
@@ -0,0 +1,22 @@
+name: installer-system-x86_64
+kind: system
+description: The system that should be used as an Installer to install other Baserock systems.
+arch: x86_64
+strata:
+- name: build-essential
+ morph: strata/build-essential.morph
+- name: core
+ morph: strata/core.morph
+- name: foundation
+ morph: strata/foundation.morph
+- name: bsp-x86_64-generic
+ morph: strata/bsp-x86_64-generic.morph
+- name: morph-utils
+ morph: strata/morph-utils.morph
+- name: installer-utils
+ morph: strata/installer-utils.morph
+configuration-extensions:
+- set-hostname
+- install-files
+- fstab
+- installer