From 5d0dafde819b96ff8c74b2af37b4dfcfd9ad97ca Mon Sep 17 00:00:00 2001 From: Mark McClain Date: Thu, 2 Apr 2015 16:57:31 -0400 Subject: [PATCH] Elements to build the Akanda appliance with diskimage-builder --- README.md | 1 + diskimage-builder/README.md | 10 ++++++ diskimage-builder/elements/akanda/README.rst | 3 ++ .../elements/akanda/element-deps | 4 +++ .../install.d/akanda-source-install/70-akanda | 9 +++++ .../akanda/post-install.d/90-fix-locale | 5 +++ .../elements/akanda/source-repository-akanda | 1 + diskimage-builder/elements/ansible/README.md | 11 ++++++ .../cleanup.d/50-remove-source-ansible | 5 +++ .../elements/ansible/element-deps | 1 + .../environment.d/10-ansible-venv-dir.bash | 4 +++ .../30-ansible-package | 4 +++ .../ansible-source-install/30-ansible-source | 35 +++++++++++++++++++ .../elements/pip-and-virtualenv/README.md | 21 +++++++++++ .../elements/pip-and-virtualenv/element-deps | 2 ++ .../package-installs-pip-and-virtualenv | 2 ++ .../get-pip-py-source-install/01-install-pip | 6 ++++ .../source-repository-pip-and-virtualenv | 1 + 18 files changed, 125 insertions(+) create mode 100644 README.md create mode 100644 diskimage-builder/README.md create mode 100644 diskimage-builder/elements/akanda/README.rst create mode 100644 diskimage-builder/elements/akanda/element-deps create mode 100755 diskimage-builder/elements/akanda/install.d/akanda-source-install/70-akanda create mode 100755 diskimage-builder/elements/akanda/post-install.d/90-fix-locale create mode 100644 diskimage-builder/elements/akanda/source-repository-akanda create mode 100644 diskimage-builder/elements/ansible/README.md create mode 100755 diskimage-builder/elements/ansible/cleanup.d/50-remove-source-ansible create mode 100644 diskimage-builder/elements/ansible/element-deps create mode 100755 diskimage-builder/elements/ansible/environment.d/10-ansible-venv-dir.bash create mode 100644 diskimage-builder/elements/ansible/install.d/ansible-package-install/30-ansible-package create mode 100755 diskimage-builder/elements/ansible/install.d/ansible-source-install/30-ansible-source create mode 100644 diskimage-builder/elements/pip-and-virtualenv/README.md create mode 100644 diskimage-builder/elements/pip-and-virtualenv/element-deps create mode 100644 diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-package-install/package-installs-pip-and-virtualenv create mode 100755 diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-source-install/01-install-pip create mode 100644 diskimage-builder/elements/pip-and-virtualenv/source-repository-pip-and-virtualenv diff --git a/README.md b/README.md new file mode 100644 index 0000000..496fac2 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +This repo contains various methods to build an Akanda appliance. diff --git a/diskimage-builder/README.md b/diskimage-builder/README.md new file mode 100644 index 0000000..9c2513f --- /dev/null +++ b/diskimage-builder/README.md @@ -0,0 +1,10 @@ +This directory contains elements necessary to build the Akanda appliance with +the diskimage-builder from the OpenStack project. + +Install via: + +pip install diskimage-builder + +or source at: + +http://git.openstack.org/cgit/openstack/diskimage-builder diff --git a/diskimage-builder/elements/akanda/README.rst b/diskimage-builder/elements/akanda/README.rst new file mode 100644 index 0000000..0d61226 --- /dev/null +++ b/diskimage-builder/elements/akanda/README.rst @@ -0,0 +1,3 @@ +This is the base element for building an Akanda appliance image. + +Ansible is required on the local system. diff --git a/diskimage-builder/elements/akanda/element-deps b/diskimage-builder/elements/akanda/element-deps new file mode 100644 index 0000000..aba5f05 --- /dev/null +++ b/diskimage-builder/elements/akanda/element-deps @@ -0,0 +1,4 @@ +install-static +cloud-init-nocloud +source-repositories +ansible diff --git a/diskimage-builder/elements/akanda/install.d/akanda-source-install/70-akanda b/diskimage-builder/elements/akanda/install.d/akanda-source-install/70-akanda new file mode 100755 index 0000000..743d9b6 --- /dev/null +++ b/diskimage-builder/elements/akanda/install.d/akanda-source-install/70-akanda @@ -0,0 +1,9 @@ +#!/bin/bash +set -eux +set -o pipefail + +APP_SRC_DIR="/tmp/akanda-appliance" + +[ -d "${APP_SRC_DIR}" ] || exit 0 + +ansible-playbook -i "localhost," -c local $APP_SRC_DIR/ansible/main.yml diff --git a/diskimage-builder/elements/akanda/post-install.d/90-fix-locale b/diskimage-builder/elements/akanda/post-install.d/90-fix-locale new file mode 100755 index 0000000..f83fe84 --- /dev/null +++ b/diskimage-builder/elements/akanda/post-install.d/90-fix-locale @@ -0,0 +1,5 @@ +#!/bin/bash + +# ensure the locale is properly setup +sed -i 's/^# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen +locale-gen diff --git a/diskimage-builder/elements/akanda/source-repository-akanda b/diskimage-builder/elements/akanda/source-repository-akanda new file mode 100644 index 0000000..0f837f5 --- /dev/null +++ b/diskimage-builder/elements/akanda/source-repository-akanda @@ -0,0 +1 @@ +akanda git /tmp/akanda-appliance https://github.com/markmcclain/akanda-appliance.git ansible diff --git a/diskimage-builder/elements/ansible/README.md b/diskimage-builder/elements/ansible/README.md new file mode 100644 index 0000000..dfad942 --- /dev/null +++ b/diskimage-builder/elements/ansible/README.md @@ -0,0 +1,11 @@ +Install Ansible. + +Configuration +------------- + +At Present there is no configuration for this element. + +NOTICE +------ +This element is copied from the OpenStack Tripleo project at +http://git.openstack.org/cgit/openstack/tripleo-image-elements/ diff --git a/diskimage-builder/elements/ansible/cleanup.d/50-remove-source-ansible b/diskimage-builder/elements/ansible/cleanup.d/50-remove-source-ansible new file mode 100755 index 0000000..5a8d8b4 --- /dev/null +++ b/diskimage-builder/elements/ansible/cleanup.d/50-remove-source-ansible @@ -0,0 +1,5 @@ +#!/bin/bash + +set -eu + +sudo rm -fr "${TMP_MOUNT_PATH}/opt/stack/tripleo-ansible" diff --git a/diskimage-builder/elements/ansible/element-deps b/diskimage-builder/elements/ansible/element-deps new file mode 100644 index 0000000..7c8922a --- /dev/null +++ b/diskimage-builder/elements/ansible/element-deps @@ -0,0 +1 @@ +pip-and-virtualenv diff --git a/diskimage-builder/elements/ansible/environment.d/10-ansible-venv-dir.bash b/diskimage-builder/elements/ansible/environment.d/10-ansible-venv-dir.bash new file mode 100755 index 0000000..3eb9403 --- /dev/null +++ b/diskimage-builder/elements/ansible/environment.d/10-ansible-venv-dir.bash @@ -0,0 +1,4 @@ +#!/bin/bash +set -ue + +export ANSIBLE_VENV_DIR=${ANSIBLE_VENV_DIR:-"/opt/stack/venvs/ansible"} diff --git a/diskimage-builder/elements/ansible/install.d/ansible-package-install/30-ansible-package b/diskimage-builder/elements/ansible/install.d/ansible-package-install/30-ansible-package new file mode 100644 index 0000000..99caabc --- /dev/null +++ b/diskimage-builder/elements/ansible/install.d/ansible-package-install/30-ansible-package @@ -0,0 +1,4 @@ +#!/bin/bash +set -eux + +install-packages ansible diff --git a/diskimage-builder/elements/ansible/install.d/ansible-source-install/30-ansible-source b/diskimage-builder/elements/ansible/install.d/ansible-source-install/30-ansible-source new file mode 100755 index 0000000..7479a39 --- /dev/null +++ b/diskimage-builder/elements/ansible/install.d/ansible-source-install/30-ansible-source @@ -0,0 +1,35 @@ +#!/bin/bash +# +# Copyright 2014 Hewlett-Packard Development Company, L.P. +# All Rights Reserved. +# +# 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. +# + +set -eux +set -o pipefail + +install-packages build-essential libssl-dev libyaml-dev python-dev libxml2-dev libxslt-dev + +virtualenv $ANSIBLE_VENV_DIR + +set +u +source $ANSIBLE_VENV_DIR/bin/activate +set -u + +$ANSIBLE_VENV_DIR/bin/pip install paramiko PyYAML jinja2 httplib2 + +$ANSIBLE_VENV_DIR/bin/pip install ansible==1.8.1 + +ln -s $ANSIBLE_VENV_DIR/bin/ansible /usr/local/bin/ansible +ln -s $ANSIBLE_VENV_DIR/bin/ansible-playbook /usr/local/bin/ansible-playbook diff --git a/diskimage-builder/elements/pip-and-virtualenv/README.md b/diskimage-builder/elements/pip-and-virtualenv/README.md new file mode 100644 index 0000000..742d307 --- /dev/null +++ b/diskimage-builder/elements/pip-and-virtualenv/README.md @@ -0,0 +1,21 @@ +Install latest pip and virtualenv +================================= + +We have problems with the latest binary package of pip and virtualenv. +Packaged version of pip can be old and virtualenv can also contain its +own version of pip. Issues include downloading packages from a local +pypi mirror that include a wheel package for pip. + +The element follows the instructions from the pip website here: +http://www.pip-installer.org/en/latest/installing.html on how to install +the latest version of pip. That is to download get-pip.py and run this +file. + +We use source-repositories element to download the file so it will be +cached and can be overridden to use package if that is required. + +NOTICE +------ +This element is copied from the OpenStack Tripleo project at +http://git.openstack.org/cgit/openstack/tripleo-image-elements/ + diff --git a/diskimage-builder/elements/pip-and-virtualenv/element-deps b/diskimage-builder/elements/pip-and-virtualenv/element-deps new file mode 100644 index 0000000..73d637d --- /dev/null +++ b/diskimage-builder/elements/pip-and-virtualenv/element-deps @@ -0,0 +1,2 @@ +package-installs +source-repositories diff --git a/diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-package-install/package-installs-pip-and-virtualenv b/diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-package-install/package-installs-pip-and-virtualenv new file mode 100644 index 0000000..534d204 --- /dev/null +++ b/diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-package-install/package-installs-pip-and-virtualenv @@ -0,0 +1,2 @@ +python-pip +python-virtualenv diff --git a/diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-source-install/01-install-pip b/diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-source-install/01-install-pip new file mode 100755 index 0000000..ea3d5ed --- /dev/null +++ b/diskimage-builder/elements/pip-and-virtualenv/install.d/get-pip-py-source-install/01-install-pip @@ -0,0 +1,6 @@ +#!/bin/bash + +set -eux + +python /tmp/get-pip.py +pip install virtualenv diff --git a/diskimage-builder/elements/pip-and-virtualenv/source-repository-pip-and-virtualenv b/diskimage-builder/elements/pip-and-virtualenv/source-repository-pip-and-virtualenv new file mode 100644 index 0000000..98bfb62 --- /dev/null +++ b/diskimage-builder/elements/pip-and-virtualenv/source-repository-pip-and-virtualenv @@ -0,0 +1 @@ +get-pip-py file /tmp/get-pip.py https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py