diff options
89 files changed, 5383 insertions, 0 deletions
diff --git a/fuel-build/DOC/BUILD/README.architecture b/fuel-build/DOC/BUILD/README.architecture new file mode 100644 index 0000000..4629763 --- /dev/null +++ b/fuel-build/DOC/BUILD/README.architecture @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + diff --git a/fuel-build/DOC/BUILD/README.build b/fuel-build/DOC/BUILD/README.build new file mode 100644 index 0000000..6cd87e7 --- /dev/null +++ b/fuel-build/DOC/BUILD/README.build @@ -0,0 +1,85 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +How to setup and use the OPNFV/BGS/FUEL build system - work in progress + +1. Build system requirements +---------------------------- +1.1 Host HW/VM requirements +--------------------------- +- A x86_64 host (real iron or VM) with Ubuntu 12.04/14.04 LTS installed +- 100 GB storage +- 8 GB RAM + +1.2 Host SW dependencies +------------------------ +On the host, the following packages must be installed: +- debootstrap (simply available through apt-get install debootstrap) +- docker - see https://docs.docker.com/installation/ubuntulinux/ for installation notes for 12.04 and 14.04 +- git (simply available through apt-get install git) + +2 Setting up the Docker build container +---------------------------------------- +When having installed Docker, add yourself to the docker group: +usermod -a -G docker <userid> + +Also make sure to define rellevant dns servers part of the global dns chain in +in your /etc/default/docker config file, eg. +DOCKER_OPTS=" --dns=8.8.8.8 --dns=8.8.8.4" + +Then restart docker with "service docker restart".: + +3. Setting up OPNFV Gerrit in order to being able to clone the code +------------------------------------------------------------------- +- Start by creating a SSH key, if you don't already have one, create one with ssh-keygen + +- Add your generated public key in OPNFV Gerrit -https://gerrit.opnfv.org/ + (this requires a linuxfoundation account, create one if you do not already have one) + +- Select "SSH Public Keys" to the left and then "Add Key" and paste your public key in. + +4. Clone the OPNFV code git repository +-------------------------------------- + So now we're coming to the fun part! Let's clone the code repository: + git clone ssh://<Linux foundation user>@gerrit.opnfv.org:29418/genesis + + Change the directory to "fuel-build" + cd fuel-build/ + +5. Set up (build) your build environment +---------------------------------------- +YOU DO NOT NEED TO SET UP YOUR BUILD ENVIRONMENT, THE TOP MAKE ALL TARGET WILL DO THAT FOR YOU IF NOT ALREADY DONE, +THE BELOW ACTIONS IN THIS SECTION ARE NOT NEEDED! + +Note and TODO: +The build system will for now partly run as sudo as that is needed for the debootstrap procedure to create the root file +system for the Ubuntu 12.04 Docker image - BUT NOTE, NONE OF THE MAKEFILES OR SCRIPTS SHALL BE EXECUTED WITH SUDO/ROOT PRIVILEDGES! +(TODO: Change the scripts so that no root priviledges will be needed) + +With your ordinary user-, run the following commands from your git root: +cd docker +make (and you will be prompted for your password by sudo) +cd .. + +6. Build your fuel .iso image +----------------------------- +That's it, time to build! +make [all] + +This will: +- If not allready existing, initialize the docker build environment +- If not already done, build fuel from upstream +- Build the defined derivate of fuel (as defined by the structure of this framework) + +If the build is successful, you will find the generated ISO file in the release subdirectory! + +7. Install your stack +--------------------- +Please see DOC/INSTALL/README diff --git a/fuel-build/DOC/BUILD/README.examples b/fuel-build/DOC/BUILD/README.examples new file mode 100644 index 0000000..4629763 --- /dev/null +++ b/fuel-build/DOC/BUILD/README.examples @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + diff --git a/fuel-build/DOC/INSTALL/README b/fuel-build/DOC/INSTALL/README new file mode 100644 index 0000000..456e26d --- /dev/null +++ b/fuel-build/DOC/INSTALL/README @@ -0,0 +1,154 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +This README file describes how to install the OPNFV BGS Stack +============================================================= +1.1 Install Fuel Server +----------------------- +1. Mount the built .iso file (release/opnfv-<version>.iso) as a bootdevice to the fuel server. + +2. Reboot the fuel server. + The system now boots from the ISO image. + +3. Change the grub boot params + When Press Tab to edit . is shown press Tab. + Change showmenu=no to showmenu=yes. + Change netmask=255.255.255.0 to netmask=255.255.0.0. + Press Enter. + +4 Wait until screen Fuel setup . is shown. + Note: This takes about 30 minutes. + +5. Select PXE Setup and change the following fields to appropriate values (example below): + Static Pool Start 10.20.0.3 + Static Pool End 10.20.0.254 + DHCP Pool Start 10.20.128.3 + DHCP Pool End 10.20.128.254 + +6. Select DNS & Hostname and change the following fields to appropriate values: + Hostname <CEE Region name>-fuel + Domain <Domain Name> + Search Domain <Search Domain Name> + Hostname to test DNS <Hostname to test DNS> + +7. Select Time Sync and change the following fields to appropriate values: + NTP Server 1 <Customer NTP server 1> + NTP Server 2 <Customer NTP server 2> + NTP Server 3<Customer NTP server 3> + Note: This step is only to pass the network test, the actual ntp parameters will be set with the pre_deply script. + +8. Start the installation. + Select Quit Setup and press Save and Quit. + Installation starts, wait until a screen with logon credentials is shown. + Note: This takes about 15 minutes. + +10. Enable PXE Booting and put it first in the bios boot order menu. + +11. Reboot the controller- and compute blades. + +12. Connect to Fuel wit a browser towards port 8000 + +13. Create and name a new OpenStack environment, to be installed. + +14. Select Icehouse on Ubuntu . in field OpenStack Release. + +15. Select deployment mode. + Select the Multi-node with HA. + +16. Select compute node mode. + Select KVM as hypervisor. + +17. Select network mode. + Select Neutron with VLAN segmentation. + +18. Select Storage Backends. + Select Ceph for Cinder and default for glance. + + +19. Select additional services. + Check option Install Celiometer (OpenStack Telemetry). + +20. Create the new environment. + +21. Wait for availability nodes. + Wait until all nodes are displayed in top right in <total number of server> TOTAL NODES and <total number of servers> UNALLOCATED NODES. + +22. Open the created environment. + +23. Open the networks tab. + +24. Update the public configuration. + Change the following fields to appropriate values: + IP Range Start to <Public IP Address start> + IP Range End to <Public IP Address end> + CIDR to <CIDR for Public IP Addresses> + Gateway to <Gateway for Public IP Addresses> + Check VLAN tagging. + Set appropriate VLAN id. + +25. Update the management configuration. + Set CIDR to 172.16.255.128/25. + Check VLAN tagging. + Set appropriate VLAN id. + +26. Update the storage configuration. + Set CIDR to the appropriate value + Check VLAN tagging. + Set appropriate VLAN id. + +27. Update the Neutron L2 configuration. + Set VLAN ID range. + +28. Update the Neutron L3 configuration. + Set Internal network CIDR to an appropriate value + Set Internal network gateway to an appropriate value + Set Floating IP ranges. + Set DNS Servers + +29. Save Settings. + +30. Click "verify network" to check the network set-up + +31. Update storage configuration. + +32. Open the nodes tab. + +33. Assign roles. + Check Controller and Telemetry . MongoDB. + Check three nodes to be installed as Controller in pane Assign Role. + Click Apply Changes. + Check Compute. + Check nodes to be installed as Compute nodes in pane Assign Role. + Click Apply Changes. + +34. Configure interfaces. + Check Select All to select all nodes with Control, Telemetry . MongoDB and Compute node roles. + Click Configure Interfaces. + Screen Configure interfaces on number of <number of nodes> nodes is shown. + Assign interfaces (bonded) for mgmt-, admin-, private-, public- and storage networks + +35. Run the pre-deploy script. + Log on as root to the Fuel node. + Print Fuel environment Id (fuel env) + #> id | status | name | mode | release_id | changes <id>| new | <CEE Region name>| ha_compact | 2 | <ite specific information> + +36. Run the pre-deployment script (/opt/opnfv/pre-deploy.sh <id>) + As prompted for-, set the DNS servers to go into /etc/resolv.conf. + As prompted for-, set any Hosts file additions for controllers and compute nodes. You will be prompted for name, FQDN and IP for each entry. Press return when prompted for a name when you have completed your input. + As prompted for-, set NTP upstream configuration for controllers. You will be prompted for a NTP server each entry. Press return when prompted for a NTP server when you have completed your input. + +37. Deploy the environment. + In the Fuel GUI, click Deploy Changes. + +38 Verify the OpenStack Environment + Open the Health Check tab . + Select Select All. + Click Run tests. diff --git a/fuel-build/Makefile b/fuel-build/Makefile new file mode 100644 index 0000000..ea403c8 --- /dev/null +++ b/fuel-build/Makefile @@ -0,0 +1,126 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +############################################################################ +# BEGIN of variables to customize +# +SHELL = /bin/bash + + +ISOSRC = file:$(shell pwd)/fuel-5.1.1.iso +ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC)) +PRODUCT_NAME = "OPNFV_BGS" +VERSION = "P0000" +NEWISO = $(shell pwd)/release/opnfv-${VERSION}.iso +DOCKERIMG = opnfv.org/ubuntu-builder:12.04 +# Note! Invoke with "make VERSION=RXXXX iso" to make release build! +# Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location. +# +# END of variables to customize +############################################################################# +ORIGDIR = $(shell pwd)/origiso + +SUBDIRS := f_isoroot +SUBDIRS += f_opnfv_puppet +SUBDIRS += f_osnaily +SUBDIRS += f_l23network +SUBDIRS += f_resolvconf +SUBDIRS += f_ntp + +# f_example is only an example of how to generate a .deb package and +# should not be enabled in official builds. +#SUBDIRS += f_example + +SUBCLEAN = $(addsuffix .clean,$(SUBDIRS)) + +.PHONY: all +all: + @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1) + make -C docker + @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso + +$(ISOCACHE): + # Clone Fuel + sudo rm -rf fuel-main + git clone https://github.com/stackforge/fuel-main + cd fuel-main && git checkout 5.1.1 + # Setup cgroups for docker-in-docker + sudo /root/enable_dockerx2 + # Need to patch to fix race condition in build + cd fuel-main && patch -p1 < ../fuel-main.patches + # + cd fuel-main && ./prepare-build-env.sh + # Need to patch not supported start-stop-daemon argument + sudo sed -i 's/--no-close//' /etc/init.d/docker + sudo /etc/init.d/docker start + cd fuel-main && make iso + mv fuel-main/build/artifacts/fuel*.iso . + # Remove Fuel + sudo rm -rf fuel-main + +# Used the "docker" target to build within the context of the Docker +# container created by the Makefile in the docker subdirectory. +.PHONY: docker +docker: /.dockerinit + +/.dockerinit: + docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) + +.PHONY: get-iso mount-origiso umount-origiso +mount-origiso: + @echo "Mounting original ISO in $(ORIGDIR)" + @mkdir -p $(ORIGDIR) + @fuseiso $(ISOCACHE) $(ORIGDIR) + +umount-origiso: + @echo "Unmounting original ISO from $(ORIGDIR)" + @fusermount -u $(ORIGDIR) + @rmdir $(ORIGDIR) + +get-iso: + wget $(ISOSRC) -O $(ISOCACHE) + + + @echo "ISO data of source ISO:" >> release/.isodata + @isoinfo -d -i $(ISOCACHE) >> release/.isodata + +.PHONY: $(SUBDIRS) +$(SUBDIRS): + @mkdir -p release/packages/ubuntu/pool/main release/puppet/modules release/isoroot + $(MAKE) -C $@ -f Makefile release + +.PHONY: patch-packages +patch-packages: + ORIGISO=$(ISOCACHE) VERSION=$(VERSION) $(MAKE) -C $@ -f Makefile release + +.PHONY: clean $(SUBCLEAN) +clean: $(SUBCLEAN) + $(MAKE) -C patch-packages -f Makefile clean + @rm -Rf release + @rm -Rf newiso + @rm -f $(NEWISO) + +$(SUBCLEAN): %.clean: + $(MAKE) -C $* -f Makefile clean + +.PHONY: install +install:$(SUBDIRS) patch-packages + install/install.sh live + +.PHONY: uninstall +uninstall: + install/uninstall.sh + +# Todo: Make things smarter - we shouldn't need to clean everything +# betwen make invocations. +.PHONY: iso +iso: clean $(ISOCACHE) $(SUBDIRS) patch-packages + install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODUCT_NAME) $(VERSION) + @printf "\n\nProduct ISO is $(NEWISO)\n\n" diff --git a/fuel-build/README b/fuel-build/README new file mode 100644 index 0000000..c3fcf1d --- /dev/null +++ b/fuel-build/README @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This purpose of this framework is to: + +1) Build fuel baseline from upstream fuel.org repos (builds in a docker container to isolate dependencies from host + and full re-producability) +2) Apply arbitrary changes to the fuel baseline, consistent and non volatile: + - Add arbitrary packages with puppet modules for install and config. to be applied on controllers as well as computes. + - Change any stack-, or other pack config. using puppet + - Apply patches to the baseline. + - Etc. +3) Re factor/rebuild the .iso image for deployment (also builds in a container, for the same reason as mentioned above) +4) Through a pre-deployment script, setting config's not part of the pristine fuel build can be achieved + +For detailed instructions on how to add content, configuration, build and deply - please see: +DOC/ diff --git a/fuel-build/TODO b/fuel-build/TODO new file mode 100644 index 0000000..7e26449 --- /dev/null +++ b/fuel-build/TODO @@ -0,0 +1,8 @@ +############################################ +# Contributors/version/date +# jonas.bjurel@ericsson.com 0.1 2015.01.28 +############################################ +Following items needs to be done to achieve an OPNFV/BGS R1 Stack: +1) Rebase to Fuel 6.0/6.1 +2) Add support for CentOS 6.5 +3) Add build-support and manifests for Open daylight Ubuntu and CentOS diff --git a/fuel-build/add_opnfv_packages b/fuel-build/add_opnfv_packages new file mode 100644 index 0000000..44af92e --- /dev/null +++ b/fuel-build/add_opnfv_packages @@ -0,0 +1,23 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Format of this file: +# +#TEXT>old package>url for replacement package +# +# Note! No spaces! +# The TEXT can be anything it is just for information display. +# Iff the packages is new, i.e. not replacing an existing package +# the old package should be specified as NONE. +# Note! For new packages a puppet manifest must actually install it. +# Easiest is to just add it to add_packages.pp. (The same might +# of course be true for an exising package if it isn't already +# is being installed). +# diff --git a/fuel-build/apply_patches b/fuel-build/apply_patches new file mode 100644 index 0000000..6925ff6 --- /dev/null +++ b/fuel-build/apply_patches @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Format of this file: +# +#TR>old package>url for replacement package +# +# Note! No spaces! +# Example: +#FIX>foo_0.0.1.deb>https://example.org/foo_0.0.2.deb + diff --git a/fuel-build/docker/Makefile b/fuel-build/docker/Makefile new file mode 100644 index 0000000..4f00de8 --- /dev/null +++ b/fuel-build/docker/Makefile @@ -0,0 +1,32 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +CONTEXT1 := opnfv.org/ubuntu:12.04 +CONTEXT2 := opnfv.org/ubuntu-builder:12.04 + +.PHONY: docker all + +all: create-docker-ubuntu populate-docker-ubuntu + ./runcontext ${CONTEXT2} make test + +.PHONY: create-docker-ubuntu +create-docker-ubuntu: + /usr/bin/docker run --rm -i -t ${CONTEXT1} date || \ + sudo mkimage/mkimage.sh -t opnfv.org/ubuntu:12.04 debootstrap --include=ubuntu-minimal --components=main,universe precise + +.PHONY: populate-docker-ubuntu +populate-docker-ubuntu: + /usr/bin/docker build --rm=true -t opnfv.org/ubuntu-builder:12.04 ubuntu-builder + /usr/bin/docker tag -f opnfv.org/ubuntu-builder:12.04 opnfv.org/ubuntu-builder + +.PHONY: test +test: + @hostname + @date diff --git a/fuel-build/docker/README b/fuel-build/docker/README new file mode 100644 index 0000000..5d22bc9 --- /dev/null +++ b/fuel-build/docker/README @@ -0,0 +1,26 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +The makefile on this level is used for *creating* the Docker image +used for building in Ubuntu 12.04 context. + +There are two requirements before running make on this level: + +1. You need to have Docker installed on your system, and make sure +to have a valid DNS config in your /etc/default/docker. +e.g: +DOCKER_OPTS=" --dns=8.8.8.8 --dns=8.8.8.4" + + +2. You must have installed the package "debootstrap". + +The top level makefile will refer to the "runcontext" file in order to +run the build process as the current user with the current working +directory available to the container. diff --git a/fuel-build/docker/mkimage/debootstrap b/fuel-build/docker/mkimage/debootstrap new file mode 100755 index 0000000..0862120 --- /dev/null +++ b/fuel-build/docker/mkimage/debootstrap @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# +set -e + +rootfsDir="$1" +shift + +# we have to do a little fancy footwork to make sure "rootfsDir" becomes the second non-option argument to debootstrap + +before=() +while [ $# -gt 0 ] && [[ "$1" == -* ]]; do + before+=( "$1" ) + shift +done + +suite="$1" +shift + +( + set -x + debootstrap "${before[@]}" "$suite" "$rootfsDir" "$@" +) + +# now for some Docker-specific tweaks + +# prevent init scripts from running during install/update +echo >&2 "+ cat > '$rootfsDir/usr/sbin/policy-rc.d'" +cat > "$rootfsDir/usr/sbin/policy-rc.d" <<'EOF' +#!/bin/sh +exit 101 +EOF +chmod +x "$rootfsDir/usr/sbin/policy-rc.d" + +# prevent upstart scripts from running during install/update +( + set -x + chroot "$rootfsDir" dpkg-divert --local --rename --add /sbin/initctl + ln -sf /bin/true "$rootfsDir/sbin/initctl" +) + +# shrink the image, since apt makes us fat (wheezy: ~157.5MB vs ~120MB) +( set -x; chroot "$rootfsDir" apt-get clean ) + +# Ubuntu 10.04 sucks... :) +if strings "$rootfsDir/usr/bin/dpkg" | grep -q unsafe-io; then + # force dpkg not to call sync() after package extraction (speeding up installs) + echo >&2 "+ echo force-unsafe-io > '$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup'" + echo 'force-unsafe-io' > "$rootfsDir/etc/dpkg/dpkg.cfg.d/docker-apt-speedup" +fi + +if [ -d "$rootfsDir/etc/apt/apt.conf.d" ]; then + # _keep_ us lean by effectively running "apt-get clean" after every install + aptGetClean='"rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";' + echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-clean'" + cat > "$rootfsDir/etc/apt/apt.conf.d/docker-clean" <<-EOF + DPkg::Post-Invoke { ${aptGetClean} }; + APT::Update::Post-Invoke { ${aptGetClean} }; + + Dir::Cache::pkgcache ""; + Dir::Cache::srcpkgcache ""; + EOF + + # remove apt-cache translations for fast "apt-get update" + echo >&2 "+ cat > '$rootfsDir/etc/apt/apt.conf.d/docker-no-languages'" + echo 'Acquire::Languages "none";' > "$rootfsDir/etc/apt/apt.conf.d/docker-no-languages" +fi + +if [ -z "$DONT_TOUCH_SOURCES_LIST" ]; then + # tweak sources.list, where appropriate + lsbDist= + if [ -z "$lsbDist" -a -r "$rootfsDir/etc/os-release" ]; then + lsbDist="$(. "$rootfsDir/etc/os-release" && echo "$ID")" + fi + if [ -z "$lsbDist" -a -r "$rootfsDir/etc/lsb-release" ]; then + lsbDist="$(. "$rootfsDir/etc/lsb-release" && echo "$DISTRIB_ID")" + fi + if [ -z "$lsbDist" -a -r "$rootfsDir/etc/debian_version" ]; then + lsbDist='Debian' + fi + case "$lsbDist" in + debian|Debian) + # updates and security! + if [ "$suite" != 'sid' -a "$suite" != 'unstable' ]; then + ( + set -x + sed -i "p; s/ $suite main$/ ${suite}-updates main/" "$rootfsDir/etc/apt/sources.list" + echo "deb http://security.debian.org $suite/updates main" >> "$rootfsDir/etc/apt/sources.list" + ) + fi + ;; + ubuntu|Ubuntu) + # add the universe, updates, and security repositories + ( + set -x + sed -i " + s/ $suite main$/ $suite main universe/; p; + s/ $suite main/ ${suite}-updates main/; p; + s/ $suite-updates main/ ${suite}-security main/ + " "$rootfsDir/etc/apt/sources.list" + ) + ;; + tanglu|Tanglu) + # add the updates repository + if [ "$suite" != 'devel' ]; then + ( + set -x + sed -i "p; s/ $suite main$/ ${suite}-updates main/" "$rootfsDir/etc/apt/sources.list" + ) + fi + ;; + steamos|SteamOS) + # add contrib and non-free + ( + set -x + sed -i "s/ $suite main$/ $suite main contrib non-free/" "$rootfsDir/etc/apt/sources.list" + ) + ;; + esac +fi + +# make sure we're fully up-to-date, too +( + set -x + chroot "$rootfsDir" apt-get update + chroot "$rootfsDir" apt-get dist-upgrade -y +) diff --git a/fuel-build/docker/mkimage/mkimage.sh b/fuel-build/docker/mkimage/mkimage.sh new file mode 100755 index 0000000..3424258 --- /dev/null +++ b/fuel-build/docker/mkimage/mkimage.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +set -e + +mkimg="$(basename "$0")" + +usage() { + echo >&2 "usage: $mkimg [-d dir] [-t tag] script [script-args]" + echo >&2 " ie: $mkimg -t someuser/debian debootstrap --variant=minbase jessie" + echo >&2 " $mkimg -t someuser/ubuntu debootstrap --include=ubuntu-minimal trusty" + echo >&2 " $mkimg -t someuser/busybox busybox-static" + echo >&2 " $mkimg -t someuser/centos:5 rinse --distribution centos-5" + exit 1 +} + +scriptDir="$(dirname "$(readlink -f "$BASH_SOURCE")")" + +optTemp=$(getopt --options '+d:t:h' --longoptions 'dir:,tag:,help' --name "$mkimg" -- "$@") +eval set -- "$optTemp" +unset optTemp + +dir= +tag= +while true; do + case "$1" in + -d|--dir) dir="$2" ; shift 2 ;; + -t|--tag) tag="$2" ; shift 2 ;; + -h|--help) usage ;; + --) shift ; break ;; + esac +done + +script="$1" +[ "$script" ] || usage +shift + +if [ ! -x "$scriptDir/$script" ]; then + echo >&2 "error: $script does not exist or is not executable" + echo >&2 " see $scriptDir for possible scripts" + exit 1 +fi + +# don't mistake common scripts like .febootstrap-minimize as image-creators +if [[ "$script" == .* ]]; then + echo >&2 "error: $script is a script helper, not a script" + echo >&2 " see $scriptDir for possible scripts" + exit 1 +fi + +delDir= +if [ -z "$dir" ]; then + dir="$(mktemp -d ${TMPDIR:-/tmp}/docker-mkimage.XXXXXXXXXX)" + delDir=1 +fi + +rootfsDir="$dir/rootfs" +( set -x; mkdir -p "$rootfsDir" ) + +# pass all remaining arguments to $script +"$scriptDir/$script" "$rootfsDir" "$@" + +# Docker mounts tmpfs at /dev and procfs at /proc so we can remove them +rm -rf "$rootfsDir/dev" "$rootfsDir/proc" +mkdir -p "$rootfsDir/dev" "$rootfsDir/proc" + +# make sure /etc/resolv.conf has something useful in it +mkdir -p "$rootfsDir/etc" +cat > "$rootfsDir/etc/resolv.conf" <<'EOF' +nameserver 8.8.8.8 +nameserver 8.8.4.4 +EOF + +tarFile="$dir/rootfs.tar.xz" +touch "$tarFile" + +( + set -x + tar --numeric-owner -caf "$tarFile" -C "$rootfsDir" --transform='s,^./,,' . +) + +echo >&2 "+ cat > '$dir/Dockerfile'" +cat > "$dir/Dockerfile" <<'EOF' +FROM scratch +ADD rootfs.tar.xz / +EOF + +# if our generated image has a decent shell, let's set a default command +for shell in /bin/bash /usr/bin/fish /usr/bin/zsh /bin/sh; do + if [ -x "$rootfsDir/$shell" ]; then + ( set -x; echo 'CMD ["'"$shell"'"]' >> "$dir/Dockerfile" ) + break + fi +done + +umount $rootfsDir/run/shm +( set -x; rm -rf "$rootfsDir" ) + +if [ "$tag" ]; then + ( set -x; docker build -t "$tag" "$dir" ) +elif [ "$delDir" ]; then + # if we didn't specify a tag and we're going to delete our dir, let's just build an untagged image so that we did _something_ + ( set -x; docker build "$dir" ) +fi + +if [ "$delDir" ]; then + ( set -x; rm -rf "$dir" ) +fi diff --git a/fuel-build/docker/runcontext b/fuel-build/docker/runcontext new file mode 100755 index 0000000..45a7645 --- /dev/null +++ b/fuel-build/docker/runcontext @@ -0,0 +1,30 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +# +context=$1 +shift +GID=`id -g` +USER=`whoami` +res=`docker build -q --rm - <<EOF +FROM $context +RUN echo "invalidate cache" && echo "done" +RUN /usr/sbin/groupadd --gid $GID $USER +RUN /usr/sbin/adduser --system --uid=$UID --gid=$GID --home $HOME --shell /bin/bash $USER +RUN /usr/sbin/usermod -a -G fuse $USER +RUN echo "export HOME=$HOME" >> /etc/bash.bashrc +RUN echo "$@" >> /etc/bash.bashrc +RUN echo 'exit \\$?' >> /etc/bash.bashrc +EOF` +CID=`echo $res | sed 's/.* //'` +docker run --privileged=true --rm -i -t -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $PWD:$PWD $CID bash +rc=$? +docker rmi $CID > /dev/null +exit $rc diff --git a/fuel-build/docker/ubuntu-builder/Dockerfile b/fuel-build/docker/ubuntu-builder/Dockerfile new file mode 100644 index 0000000..e91afbd --- /dev/null +++ b/fuel-build/docker/ubuntu-builder/Dockerfile @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +FROM opnfv.org/ubuntu:12.04 +ADD install.sh /root/install.sh +RUN /root/install.sh + +ADD ./enable_dockerx2 /root/enable_dockerx2 +RUN chmod +x /root/enable_dockerx2 +VOLUME /var/lib/docker +CMD ["/root/enable_dockerx2"] diff --git a/fuel-build/docker/ubuntu-builder/enable_dockerx2 b/fuel-build/docker/ubuntu-builder/enable_dockerx2 new file mode 100644 index 0000000..b6bccdf --- /dev/null +++ b/fuel-build/docker/ubuntu-builder/enable_dockerx2 @@ -0,0 +1,10 @@ +#!/bin/sh +# Needed to expose underlying cgroups to container + +mount -n -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup +mount -t securityfs none /sys/kernel/security + +for mnt in $(cut -d: -f2 /proc/1/cgroup); do + mkdir /sys/fs/cgroup/$mnt + mount -n -t cgroup -o $mnt cgroup /sys/fs/cgroup/$mnt +done diff --git a/fuel-build/docker/ubuntu-builder/install.sh b/fuel-build/docker/ubuntu-builder/install.sh new file mode 100755 index 0000000..667ab27 --- /dev/null +++ b/fuel-build/docker/ubuntu-builder/install.sh @@ -0,0 +1,22 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +BASE_PACKAGES="make python-setuptools python-all dpkg-dev debhelper +fuseiso git genisoimage bind9-host wget curl lintian tmux lxc iptables +ca-certificates" + +apt-get update || exit 1 +apt-get upgrade -y || exit 1 + +apt-get install -y $BASE_PACKAGES || exit 1 + +echo "ALL ALL=NOPASSWD: ALL" > /etc/sudoers.d/open-sudo +chmod 0440 /etc/sudoers.d/open-sudo diff --git a/fuel-build/f_example_control_bond/Makefile b/fuel-build/f_example_control_bond/Makefile new file mode 100644 index 0000000..295fd0e --- /dev/null +++ b/fuel-build/f_example_control_bond/Makefile @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + + +.PHONY: release +release: + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_example_control_bond/README b/fuel-build/f_example_control_bond/README new file mode 100644 index 0000000..4449b2f --- /dev/null +++ b/fuel-build/f_example_control_bond/README @@ -0,0 +1,56 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is an example of a modification of the bridge and bonding of interfaces. +Rationale: Fuel currently don't support bonding of the "Admin" network, which +becomes a problem if you want to co-locate the single "Admin" and the redundant +bonded "Management" network on one and the same physical network in order to minimize +number of NICs, switches and cables. +This example show how you can modify the bridge and bonding settings and scripts to +achieve co-location. Of course the FUEL GUI becomes shorted in this respect, I.e. +the "admin" and "management" network cant be dragged across the NICs in the GUI. + +The f_example_control_bond has the following structure: +. ++--------+----------+-----------+ + | | | + puppet/ Makefile README + | (this file) + | + | + modules/ + | + | + | + opnfv/ + | + +--------------+ + | | + files/ manifests/ + | | + | | + | | + control-bond control-bond.pp + +Makefile: +Invoked by the git root Makefile, copies the files up to the release build +directory. + +control-bond: +The control-bond file is the .init file orchestrating the interface-, bridge- +and bond actions required for enabling the control bond + +control-bond.pp: +The control-bond.pp is the pupet manifest orchestrating the placement and +configuration of the control-bond shell script file. + +To activate this example feature, add "SUBDIRS += f_example_control_bond" in the git root Makefile. + + diff --git a/fuel-build/f_example_control_bond/puppet/modules/opnfv/files/control-bond b/fuel-build/f_example_control_bond/puppet/modules/opnfv/files/control-bond new file mode 100644 index 0000000..bf2930d --- /dev/null +++ b/fuel-build/f_example_control_bond/puppet/modules/opnfv/files/control-bond @@ -0,0 +1,90 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +#!/bin/sh +### BEGIN INIT INFO +# Provides: control-bond +# Required-Start: $remote_fs $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Bonds eth0 and eth1 and changes bridge configuration. +### END INIT INFO + + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +VSCTL=/usr/bin/ovs-vsctl +APPCTL=/usr/bin/ovs-appctl + + +add_control_bond() { + logger "Starting addition of control-bond" + $VSCTL --may-exist br-fw-admin + $VSCTL --may-exist br-mgmt + $VSCTL add-bond br-fw-admin bond-control eth0 eth1 + + $VSCTL set port br-mgmt tag=66 + $APPCTL bond/set-active-slave bond-control eth0 + + $VSCTL add-port br-fw-admin admin-to-mgmt + $VSCTL add-port br-mgmt mgmt-to-admin + $VSCTL set interface admin-to-mgmt type=patch + $VSCTL set interface mgmt-to-admin type=patch + + $VSCTL set interface admin-to-mgmt options:peer=mgmt-to-admin + $VSCTL set interface mgmt-to-admin options:peer=admin-to-mgmt + + $VSCTL set port admin-to-mgmt trunk=66 + $VSCTL set port mgmt-to-admin trunk=66 + logger "Finished addition of control-bond" +} + +status_control_bond() { + if [ ! -f $VSCTL ]; then + return 1 + else + $VSCTL show | grep -q "admin-to-mgmt" + return $? + fi +} + +case "$1" in + start) + status_control_bond + if [ $? -eq 0 ]; then + exit 0 + else + add_control_bond + fi + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + status) + status_control_bond + if [ $? -eq 0 ]; then + echo "The control-bond is enabled" + exit 0 + else + echo "The control-bond is disabled" + exit 1 + fi + + ;; + stop) + echo "Stop is not supported" + exit 0 + ;; + *) + echo "Usage: $0 start|status" >&2 + exit 3 + ;; +esac diff --git a/fuel-build/f_example_control_bond/puppet/modules/opnfv/manifests/control-bond.pp b/fuel-build/f_example_control_bond/puppet/modules/opnfv/manifests/control-bond.pp new file mode 100644 index 0000000..22fe781 --- /dev/null +++ b/fuel-build/f_example_control_bond/puppet/modules/opnfv/manifests/control-bond.pp @@ -0,0 +1,56 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Class: opnfv::control-bond +# +# Bridge control and management networks together using OVS. +# +# + +class opnfv::control-bond { + notify { '*** In Opnfv::control-bond-start ***': } + + file { "/etc/init.d/control-bond": + source => "puppet:///modules/opnfv/control-bond", + owner => 'root', + group => 'root', + mode => '0755', + notify => Service["control-bond"] + } + + + service { "control-bond": + ensure => running, + require => [ File["/etc/init.d/control-bond"], Service["openvswitch-service"] ], + } + + # Only start scripts - we don't want to bring down + # bridge during shutdown + + file { "/etc/rc2.d/S18control-bond": + ensure => 'link', + target => '/etc/init.d/control-bond', + } + + file { "/etc/rc3.d/S18control-bond": + ensure => 'link', + target => '/etc/init.d/control-bond', + } + + file { "/etc/rc4.d/S18control-bond": + ensure => 'link', + target => '/etc/init.d/control-bond', + } + + file { "/etc/rc5.d/S18control-bond": + ensure => 'link', + target => '/etc/init.d/control-bond', + } +} diff --git a/fuel-build/f_example_packadd/Makefile b/fuel-build/f_example_packadd/Makefile new file mode 100644 index 0000000..3808884 --- /dev/null +++ b/fuel-build/f_example_packadd/Makefile @@ -0,0 +1,37 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) +PACKAGE := foobar +VERSION := 1.0-1 + +.PHONY: all +all: release/pool/main/$(PACKAGE)_$(VERSION).deb + +release/pool/main/$(PACKAGE)_$(VERSION).deb: + @mkdir -p tmp/src + @mkdir -p release/pool/main + @cp -r $(PACKAGE)_$(VERSION) tmp/src + @gzip -9 tmp/src/$(PACKAGE)_$(VERSION)/usr/share/doc/$(PACKAGE)/changelog.Debian + @fakeroot dpkg-deb --build tmp/src/$(PACKAGE)_$(VERSION) + @lintian tmp/src/$(PACKAGE)_$(VERSION).deb + @cp tmp/src/$(PACKAGE)_$(VERSION).deb release/pool/main + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + @rm -f ../release/packages/ubuntu/pool/main/$(PACKAGE)_$(VERSION).deb + + +.PHONY: release +release:release/pool/main/$(PACKAGE)_$(VERSION).deb + @cp release/pool/main/$(PACKAGE)_$(VERSION).deb ../release/packages/ubuntu/pool/main + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_example_packadd/README b/fuel-build/f_example_packadd/README new file mode 100644 index 0000000..55fa7c1 --- /dev/null +++ b/fuel-build/f_example_packadd/README @@ -0,0 +1,47 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is an example of a an addition of an arbitrary debian package: foobar +It adds the debian package foobar_1.0-1 to the fuel .iso image and deploys it +to the controllers and the computes. + +The f_example_packadd has the following structure: +. ++--------+----------+-----------+------------+ + | | | | + puppet/ Makefile README foobar_1.0-1/ + | (this file) (deb pack) + | + | + modules/ + | + | + | + opnfv/ + | + | + | + manifests/ + | + | + | + foobar.pp + +Makefile: +Invoked by the git root Makefile, based on the foobar_1.0-1 deb pack artifacts, and the pupet manifests, it builds a deb package +and adds it together with the manifest to a fuel build artifact directory, such that it eventually gets built into the new fuel .iso + +foobar_1.0-1: +Contains arbitrary debian package artifacts + +foobar.pp: +Controls the installation and configuration of foobar + +To activate this example feature, add "SUBDIRS += f_example_packadd" in the git root Makefile. diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/conffiles b/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/conffiles new file mode 100644 index 0000000..bad6a0e --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/foobar/foobar.conf diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/control b/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/control new file mode 100644 index 0000000..f3f0eb6 --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/control @@ -0,0 +1,10 @@ +Package: foobar +Version: 1.0-1 +Section: utils +Priority: optional +Architecture: amd64 +Depends: python2.7 +Maintainer: Main Tainer <maintainer@somwhere.org> +Description: foo bar daemon + This is a daemon for the Foobar service. + Foo is bar! diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/postinst b/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/postinst new file mode 100755 index 0000000..f48f260 --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/DEBIAN/postinst @@ -0,0 +1,2 @@ +#!/bin/bash -e +date diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/etc/foobar/foobar.conf b/fuel-build/f_example_packadd/foobar_1.0-1/etc/foobar/foobar.conf new file mode 100644 index 0000000..e0eee5c --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/etc/foobar/foobar.conf @@ -0,0 +1,2 @@ +# Foobar config file +foo=bar diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/usr/bin/foobar b/fuel-build/f_example_packadd/foobar_1.0-1/usr/bin/foobar new file mode 100755 index 0000000..c9651a4 --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/usr/bin/foobar @@ -0,0 +1,2 @@ +#!/bin/bash +echo Hello from the foobar package diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/usr/share/doc/foobar/changelog.Debian b/fuel-build/f_example_packadd/foobar_1.0-1/usr/share/doc/foobar/changelog.Debian new file mode 100644 index 0000000..fe776f3 --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/usr/share/doc/foobar/changelog.Debian @@ -0,0 +1,5 @@ +foobar (1.0-1) precise-proposed; urgency=low + + * Genesis + + -- Main Tainer <maintainer@somewhere.org> Tue, 23 Sep 2014 11:13:27 +0200 diff --git a/fuel-build/f_example_packadd/foobar_1.0-1/usr/share/doc/foobar/copyright b/fuel-build/f_example_packadd/foobar_1.0-1/usr/share/doc/foobar/copyright new file mode 100644 index 0000000..4279ce4 --- /dev/null +++ b/fuel-build/f_example_packadd/foobar_1.0-1/usr/share/doc/foobar/copyright @@ -0,0 +1,18 @@ +foobar - a test daemon +Copyright (C) 2014 Main Tainer + +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, either version 3 of the License, or +(at your option) any later version. + +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 with +your Debian GNU system, in /usr/share/common-licenses/GPL, or with the +Debian GNU gnupg source package as the file COPYING. If not, see +<http://www.gnu.org/licenses/> or write to the Free Software Foundation, +Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/fuel-build/f_example_packadd/puppet/modules/opnfv/manifests/foobar.pp b/fuel-build/f_example_packadd/puppet/modules/opnfv/manifests/foobar.pp new file mode 100644 index 0000000..c6219ba --- /dev/null +++ b/fuel-build/f_example_packadd/puppet/modules/opnfv/manifests/foobar.pp @@ -0,0 +1,7 @@ +class opnfv::foobar { + if $::osfamily == 'Debian' { + package { 'foobar': + ensure => installed, + } + } +} diff --git a/fuel-build/f_isoroot/Makefile b/fuel-build/f_isoroot/Makefile new file mode 100644 index 0000000..2fdbbae --- /dev/null +++ b/fuel-build/f_isoroot/Makefile @@ -0,0 +1,31 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +SUBDIRS = f_predeployment f_kscfg f_bootstrap +SUBCLEAN = $(addsuffix .clean,$(SUBDIRS)) + +.PHONY: all +all: $(SUBDIRS) + +.PHONY: $(SUBDIRS) +$(SUBDIRS): + @mkdir -p release + $(MAKE) -C $@ -f Makefile release + +.PHONY: clean $(SUBCLEAN) +clean: $(SUBCLEAN) + @rm -Rf release + +$(SUBCLEAN): %.clean: + $(MAKE) -C $* -f Makefile clean + +.PHONY: release +release:clean $(SUBDIRS) + @cp -Rvp release/* ../release/isoroot diff --git a/fuel-build/f_isoroot/README b/fuel-build/f_isoroot/README new file mode 100644 index 0000000..eb54c08 --- /dev/null +++ b/fuel-build/f_isoroot/README @@ -0,0 +1,16 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is to (a) replace/patch existing Fuel ISO files as well +as adding new information directly into the ISO structure + +Please separate changes into "patches" and new content into +"additions". Both directories will be anchored at the ISO file +root. diff --git a/fuel-build/f_isoroot/f_bootstrap/Makefile b/fuel-build/f_isoroot/f_bootstrap/Makefile new file mode 100644 index 0000000..7404319 --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/Makefile @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + @mkdir -p release/opnfv/bootstrap/pre.d + @mkdir -p release/opnfv/bootstrap/post.d + @mkdir -p release/usr/local/sbin + @cp pre-scripts/* release/opnfv/bootstrap/pre.d + @cp post-scripts/* release/opnfv/bootstrap/post.d + @cp bootstrap_admin_node.sh release + @cp bootstrap_admin_node.sh.orig release + +.PHONY: clean +clean: + @rm -rf release + +.PHONY: release +release:all + @cp -Rvp release/* ../release diff --git a/fuel-build/f_isoroot/f_bootstrap/README b/fuel-build/f_isoroot/f_bootstrap/README new file mode 100644 index 0000000..5da954c --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/README @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This function modifies the adds hooks to the beginning and end of +/usr/local/sbin/bootstrap_admin_nodes.sh, which is run as the +last post step from ks.cfg + +This enables other functions to place scripts into two directories +run either at the beginning or the end of the bootstrap procedure: + + /opt/opnfv/bootstrap/pre.d + /opt/opnfv/bootstrap/post.d + +These will be run in lexical order at pre or post. + +CI note: Using pre.d, it would be possible to "inject" a pre-defined +astute.yaml for Fuel. diff --git a/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh new file mode 100755 index 0000000..348ce3c --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +function countdown() { + local i + sleep 1 + for ((i=$1-1; i>=1; i--)); do + printf '\b\b%02d' "$i" + sleep 1 + done +} + +function fail() { + echo "ERROR: Fuel node deployment FAILED! Check /var/log/puppet/bootstrap_admin_node.log for details" 1>&2 + exit 1 +} +# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details +export LANG=en_US.UTF8 +showmenu="no" +if [ -f /root/.showfuelmenu ]; then + . /root/.showfuelmenu +fi + +echo -n "Applying default Fuel settings..." +fuelmenu --save-only --iface=eth0 +echo "Done!" + +### OPNFV addition BEGIN +shopt -s nullglob +for script in /opt/opnfv/bootstrap/pre.d/*.sh +do + echo "Pre script: $script" >> /root/pre.log 2>&1 + $script >> /root/pre.log 2>&1 +done +shopt -u nullglob +### OPNFV addition END + +if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then + fuelmenu + else + #Give user 15 seconds to enter fuelmenu or else continue + echo + echo -n "Press a key to enter Fuel Setup (or press ESC to skip)... 15" + countdown 15 & pid=$! + if ! read -s -n 1 -t 15 key; then + echo -e "\nSkipping Fuel Setup..." + else + { kill "$pid"; wait $!; } 2>/dev/null + case "$key" in + $'\e') echo "Skipping Fuel Setup.." + echo -n "Applying default Fuel setings..." + fuelmenu --save-only --iface=eth0 + echo "Done!" + ;; + *) echo -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +### docker stuff +images_dir="/var/www/nailgun/docker/images" + +# extract docker images +mkdir -p $images_dir $sources_dir +rm -f $images_dir/*tar +pushd $images_dir &>/dev/null + +echo "Extracting and loading docker images. (This may take a while)" +lrzip -d -o fuel-images.tar fuel-images.tar.lrz && tar -xf fuel-images.tar && rm -f fuel-images.tar +popd &>/dev/null +service docker start + +# load docker images +for image in $images_dir/*tar ; do + echo "Loading docker image ${image}..." + docker load -i "$image" + # clean up extracted image + rm -f "$image" +done + +# apply puppet +puppet apply --detailed-exitcodes -d -v /etc/puppet/modules/nailgun/examples/host-only.pp +if [ $? -ge 4 ];then + fail +fi +rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote + +dockerctl check || fail +bash /etc/rc.local + +### OPNFV addition BEGIN +shopt -s nullglob +for script in /opt/opnfv/bootstrap/post.d/*.sh +do + echo "Post script: $script" >> /root/post.log 2>&1 + $script >> /root/post.log 2>&1 +done +shopt -u nullglob +### OPNFV addition END + +echo "Fuel node deployment complete!" diff --git a/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig new file mode 100755 index 0000000..7b6e6bd --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig @@ -0,0 +1,84 @@ +#!/bin/bash + +function countdown() { + local i + sleep 1 + for ((i=$1-1; i>=1; i--)); do + printf '\b\b%02d' "$i" + sleep 1 + done +} + +function fail() { + echo "ERROR: Fuel node deployment FAILED! Check /var/log/puppet/bootstrap_admin_node.log for details" 1>&2 + exit 1 +} +# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details +export LANG=en_US.UTF8 +showmenu="no" +if [ -f /root/.showfuelmenu ]; then + . /root/.showfuelmenu +fi + +echo -n "Applying default Fuel settings..." +fuelmenu --save-only --iface=eth0 +echo "Done!" + +if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then + fuelmenu + else + #Give user 15 seconds to enter fuelmenu or else continue + echo + echo -n "Press a key to enter Fuel Setup (or press ESC to skip)... 15" + countdown 15 & pid=$! + if ! read -s -n 1 -t 15 key; then + echo -e "\nSkipping Fuel Setup..." + else + { kill "$pid"; wait $!; } 2>/dev/null + case "$key" in + $'\e') echo "Skipping Fuel Setup.." + echo -n "Applying default Fuel setings..." + fuelmenu --save-only --iface=eth0 + echo "Done!" + ;; + *) echo -e "\nEntering Fuel Setup..." + fuelmenu + ;; + esac + fi +fi +#Reread /etc/sysconfig/network to inform puppet of changes +. /etc/sysconfig/network +hostname "$HOSTNAME" + +### docker stuff +images_dir="/var/www/nailgun/docker/images" + +# extract docker images +mkdir -p $images_dir $sources_dir +rm -f $images_dir/*tar +pushd $images_dir &>/dev/null + +echo "Extracting and loading docker images. (This may take a while)" +lrzip -d -o fuel-images.tar fuel-images.tar.lrz && tar -xf fuel-images.tar && rm -f fuel-images.tar +popd &>/dev/null +service docker start + +# load docker images +for image in $images_dir/*tar ; do + echo "Loading docker image ${image}..." + docker load -i "$image" + # clean up extracted image + rm -f "$image" +done + +# apply puppet +puppet apply --detailed-exitcodes -d -v /etc/puppet/modules/nailgun/examples/host-only.pp +if [ $? -ge 4 ];then + fail +fi +rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote + +dockerctl check || fail +bash /etc/rc.local +echo "Fuel node deployment complete!" diff --git a/fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh b/fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh new file mode 100755 index 0000000..7ac8965 --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/post-scripts/00_post_example.sh @@ -0,0 +1,4 @@ +#/bin/sh +date +echo "This is an example file run at post-bootstrap." +exit 0 diff --git a/fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh b/fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh new file mode 100755 index 0000000..79aa31a --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/post-scripts/01_fix_iommubug.sh @@ -0,0 +1,9 @@ +#/bin/sh +echo "Setting intel_iommu=off in bootstrap profile - a fix for the Dell systems" +echo "Old settings" +dockerctl shell cobbler cobbler profile report --name bootstrap +echo "Modifying" +dockerctl shell cobbler cobbler profile edit --name bootstrap --kopts "intel_iommu=off" --in-place +echo "New settings" +dockerctl shell cobbler cobbler profile report --name bootstrap + diff --git a/fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh b/fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh new file mode 100755 index 0000000..bf7591b --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/post-scripts/02_fix_console_speed.sh @@ -0,0 +1,15 @@ +#/bin/sh +echo "Changing console speed to 115200 (std is 9600) on bootstrap" +echo "Old settings" +dockerctl shell cobbler cobbler profile report --name bootstrap +echo "Modifying" +dockerctl shell cobbler cobbler profile edit --name bootstrap --kopts "console=tty0 console=ttyS0,115200" --in-place +echo "New settings" +dockerctl shell cobbler cobbler profile report --name bootstrap +echo "Setting console speed to 115200 on ubuntu_1204_x86_64 (std is no serial console)" +echo "Old settings" +dockerctl shell cobbler cobbler profile report --name ubuntu_1204_x86_64 +echo "Modifying" +dockerctl shell cobbler cobbler profile edit --name ubuntu_1204_x86_64 --kopts "console=tty0 console=ttyS0,115200" --in-place +echo "New settings" +dockerctl shell cobbler cobbler profile report --name ubuntu_1204_x86_64 diff --git a/fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh b/fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh new file mode 100755 index 0000000..ac427bf --- /dev/null +++ b/fuel-build/f_isoroot/f_bootstrap/pre-scripts/00_pre_example.sh @@ -0,0 +1,4 @@ +#/bin/sh +date +echo "This is an example file run at pre-bootstrap." +exit 0 diff --git a/fuel-build/f_isoroot/f_kscfg/Makefile b/fuel-build/f_isoroot/f_kscfg/Makefile new file mode 100644 index 0000000..38305fd --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/Makefile @@ -0,0 +1,25 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + @mkdir -p release + @cp ks.cfg release + @cp ks.cfg.orig release + +.PHONY: clean +clean: + @rm -rf release + +.PHONY: release +release: all + @cp -Rvp release/* ../release diff --git a/fuel-build/f_isoroot/f_kscfg/README b/fuel-build/f_isoroot/f_kscfg/README new file mode 100644 index 0000000..c85efde --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/README @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This function modifies the ks.cfg of the Fuel master to +make copy whatever is in the top level opnfv directory +of the ISO (populated by, for example, f_configfrontend) to +/opt/opnfv. In the end this is where the installation +parts will evolve. + +This is also the place to force the installation to overwrite +the disk (set forceformat="yes" instead of "no"). diff --git a/fuel-build/f_isoroot/f_kscfg/ks.cfg b/fuel-build/f_isoroot/f_kscfg/ks.cfg new file mode 100755 index 0000000..8194e8d --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/ks.cfg @@ -0,0 +1,540 @@ +install +text +%include /tmp/source.ks +reboot --eject +lang en_US.UTF-8 +keyboard us +rootpw r00tme +timezone --utc Etc/UTC +firewall --disabled +selinux --disabled +# ignore unsupported hardware warning +unsupported_hardware +# SKIP CONFIGURING X +skipx +# NEVER ever place zerombr here, it breaks automated installation +%include /tmp/bootloader.ks +%include /tmp/partition.ks + +# PREINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE +# INSTALLATION PROCESS ITSELF +%pre +#!/bin/sh + +# hard drives +drives="" +removable_drives="" +for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do + if (grep -q 0 /sys/block/${drv}/removable); then + drives="${drives} ${drv}" + else + removable_drives="${removable_drives} ${drv}" + fi +done +default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'` + +installdrive="undefined" +forceformat="no" +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +set ${drives} ${removable_drives} +numdrives=`echo $#` + +tgtdrive="${installdrive}" + +function confirm_format { + check_drive="$1" + local confirm_format="no" + + if [[ "$forceformat" == "yes" ]] ; then + return 0 + fi + + if parted -s /dev/$check_drive print &>/dev/null ; then + echo + echo "$check_drive drive contains partition table:" + parted -s /dev/$check_drive print + echo + read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format + if [[ "$confirm_format" == "y" ]] || [[ "$forceformat" == "yes" ]]; then + return 0 + else + return 1 + fi + else + return 0 + fi +} + +format_confirmed="no" + +if [ $numdrives -lt 1 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* There is no suitable media available for installation. *' + echo '* Please attach a drive and try again. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to shut down the system: " _ + poweroff +fi + +if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + while [ "${tgtdrive}" = "undefined" ]; do + clear + echo + echo '********************************************************************************' + echo '* W A R N I N G *' + echo '* *' + echo '* Which of the detected hard drives do you want to be used as *' + echo '* the installation target? *' + echo '* *' + echo '********************************************************************************' + echo + echo "Possible choices" + echo "Persistent drives: ${drives}" + echo "Removable drives: ${removable_drives}" + echo + if [ `echo ${drives} | wc -w` -eq 1 ] ; then + read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive + else + read -p "Choose hard drive: " tgtdrive + fi + match="no" + for drive in ${drives[@]} ${removable_drives[@]}; do + if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then + if confirm_format $tgtdrive ; then + format_confirmed="yes" + break + else + tgtdrive="undefined" + read -p "You may select another disk. Press Enter to continue." _ + fi + fi + done + if [[ "$match" == "no" ]]; then + tgtdrive="undefined" + read -p "Invalid choice. Press Enter to continue." _ + fi + done + clear + chvt 1 +else + tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"` +fi + +if [ "$format_confirmed" != "yes" ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + if ! confirm_format $tgtdrive ; then + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Disk $tgtdrive contains active partition(s). *' + echo '* Installation cannot continue without confirmation. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot + fi + chvt 1 +fi + +# verify tgtdrive is at least 30GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 30720 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Your disk is under 30GB in size. Installation cannot continue. *' + echo '* Restart installation with a larger disk. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot +fi + +# paths in /dev have "/" instead of "!" for cciss devices +tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//') + +# source +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks +else + echo "cdrom" > /tmp/source.ks +fi + +vgremove -ff os +dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10 +sleep 3 +hdparm -z /dev/${tgtdrive} +parted -s /dev/${tgtdrive} mklabel gpt +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24 +parted -s /dev/${tgtdrive} set 1 bios_grub on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224 +parted -s /dev/${tgtdrive} set 2 boot on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424 +sleep 3 +hdparm -z /dev/${tgtdrive} + +# partition + +# This adds support for the p seperator required for cciss devices +if echo ${tgtdrive} | grep -q -e cciss ; then + bootdev=${tgtdrive}p +else + bootdev=${tgtdrive} +fi +echo > /tmp/partition.ks +echo "partition /boot --onpart=/dev/${bootdev}3" >> /tmp/partition.ks +echo "partition pv.001 --ondisk=${tgtdrive} --size=30000 --grow" >> /tmp/partition.ks +echo "volgroup os pv.001" >> /tmp/partition.ks +echo "logvol swap --vgname=os --recommended --name=swap" >> /tmp/partition.ks +echo "logvol / --vgname=os --size=10000 --name=root --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var --vgname=os --size=1 --grow --name=var --fstype=xfs" >> /tmp/partition.ks + +# bootloader +echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks + +# Anaconda can not install grub 0.97 on disks which are >4T. +# The reason is that grub does not support such large geometries +# and it simply thinks that the cylinder number has negative value. +# Here we just set geometry manually so that grub thinks that disk +# size is equal to 1G. +# 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G +echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks +echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks + +%end + +%packages --nobase --excludedocs +@Core +authconfig +bind-utils +cronie +crontabs +curl +daemonize +dhcp +docker-io +fuelmenu +gdisk +lrzip +lsof +man +mlocate +nmap-ncat +ntp +openssh-clients +policycoreutils +rsync +ruby21-puppet +ruby21-rubygem-netaddr +ruby21-rubygem-openstack +selinux-policy-targeted +strace +subscription-manager +sysstat +system-config-firewall-base +tcpdump +telnet +vim-enhanced +virt-what +wget +yum + +%include /tmp/post_partition.ks + +# POSTINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER +# INSTALLATION ITSELF COMPLETED +%post +echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules +chmod +x /etc/rc.modules +echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf +mkdir -p /var/log/coredump +echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf +chmod 777 /var/log/coredump +echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf + +# Mount installation media in chroot +%post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log +#!/bin/sh + +SOURCE="/mnt/sysimage/tmp/source" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +mkdir -p "${SOURCE}" + +case "${repo}" in + nfs:*) + nfs_url="${repo#nfs:}" + mount -t nfs "${nfs_url}" "${SOURCE}" + ;; + *) + if [ -d "/mnt/source" ]; then + mount -o bind "/mnt/source" "${SOURCE}" + fi + ;; +esac + +%post --log=/root/anaconda-post-after-chroot.log +#!/bin/bash + +set -x + +function save_cfg { + scrFile="/etc/sysconfig/network-scripts/ifcfg-$device" + search="domain $domain\nsearch $domain" + sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network + grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts + echo "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream + [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf + [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream + + echo DEVICE=$device > $scrFile + echo ONBOOT=yes >> $scrFile + echo NM_CONTROLLED=no >> $scrFile + echo HWADDR=$hwaddr >> $scrFile + echo USERCTL=no >> $scrFile + echo PEERDNS=no >> $scrFile + if [ $ip ]; then + echo BOOTPROTO=static >> $scrFile + echo IPADDR=$ip >> $scrFile + echo NETMASK=$netmask >> $scrFile + else + echo BOOTPROTO=dhcp >> $scrFile + fi + scrDHCPFile="/etc/sysconfig/network-scripts/ifcfg-$dhcp_interface" + #Ignore gateway and set up DHCP if it is used, otherwise apply it + if [ $dhcp_interface ] && [ "$dhcp_interface" != "$device" ]; then + echo "DEVICE=$dhcp_interface" > $scrDHCPFile + echo "BOOTPROTO=dhcp" >> $scrDHCPFile + echo "ONBOOT=yes" >> $scrDHCPFile + echo "USERCTL=no" >> $scrDHCPFile + else + echo GATEWAY=$gw >> /etc/sysconfig/network + fi +} + +# Default FQDN +hostname="nailgun.mirantis.com" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done +hostname=$hostname +domain=${hostname#*.} +ip=$ip +netmask=$netmask +gw=$gw +device="eth0" +hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` +dhcp_interface=$dhcp_interface +save_cfg + +# Mounting installation source +SOURCE=/tmp/source +FS=/tmp/fs + +echo +mkdir -p ${SOURCE} +mkdir -p ${FS} + +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS} + mount -o loop ${FS}/nailgun.iso ${SOURCE} +fi + +# Copying Repo to the nailgun /var/www directory +repodir="/var/www/nailgun" +mkdir -p ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/images ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/isolinux ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/repodata ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/Packages ${repodir}/centos/fuelweb/x86_64 +cp ${SOURCE}/.treeinfo ${repodir}/centos/fuelweb/x86_64 + +# Copying Ubuntu files +mkdir -p ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/conf ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/db ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/indices ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz ${repodir}/ubuntu/fuelweb/x86_64/images + +# Copying bootstrap image +mkdir -p ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/initramfs.img ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/linux ${repodir}/bootstrap + +mkdir -p /root/.ssh +chmod 700 /root/.ssh +cp ${SOURCE}/bootstrap/bootstrap.rsa /root/.ssh +chmod 600 /root/.ssh/bootstrap.rsa + +# Unpacking puppet manifests for master and slave +cp ${SOURCE}/puppet-slave.tgz ${repodir}/ +tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/modules +mkdir -p /etc/puppet/manifests/ +cp /etc/puppet/modules/osnailyfacter/examples/site.pp /etc/puppet/manifests/site.pp +cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/manifests/ +cp ${SOURCE}/send2syslog.py /bin/send2syslog.py +mkdir -p /var/lib/hiera +touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml + +# Deploy docker images and ctl tools if we built ISO with docker containers support +[ -d "${SOURCE}/docker" ] && cp -r ${SOURCE}/docker ${repodir}/docker + +# Prepare local repository specification +rm /etc/yum.repos.d/CentOS*.repo +cat > /etc/yum.repos.d/nailgun.repo << EOF +[nailgun] +name=Nailgun Local Repo +baseurl=file:/var/www/nailgun/centos/fuelweb/x86_64 +gpgcheck=0 +EOF + +# Disable subscription-manager plugins +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || : +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || : + +# Disable GSSAPI in ssh server config +sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config + +# Copying bootstrap_admin_node.sh, chmod it and +# adding /etc/init/bootstrap_admin_node.conf +cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh +chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh +cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf +echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node + +# Copying version.yaml file. It contains COMMIT_SHA of last commit. +RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml) +mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions +cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml +ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml + +# Generete Fuel UUID +uuidgen > /etc/fuel/fuel-uuid + +###Run fuel menu +[ -z "$showmenu" ] && showmenu="no" +cat > /root/.showfuelmenu << EOF +#Set to yes to run Fuel Setup +#Set to no to accept default settings +showmenu=$showmenu +EOF + +# Prepare custom /etc/issue logon banner and script for changing IP in it +cat > /etc/issue << EOF +######################################### +# Welcome to the Fuel server # +######################################### +Server is running on \m platform + +Fuel UI is available on: +http://:8000 + +Default administrator login: root +Default administrator password: r00tme + +Default Fuel UI login: admin +Default Fuel UI password: admin + +Please change root password on first login. + +EOF + + +cat >> '/etc/rc.local' << EOF +first=yes +for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do +if [ "\$first" = "yes" ]; then + ipstr="Fuel UI is available on: http://\$ip:8000" + first=no +else + ipstr=\$(printf "%s\n%51s" "\$ipstr" "http://\$ip:8000") +fi +done +tmpissue=\$(mktemp) +while read -r line; do + if [[ "\$line" =~ "Fuel UI is available on" ]]; then + echo -e "\$ipstr" >> \$tmpissue + elif [[ "\$line" =~ :8000$ ]]; then + : + else + echo -e "\$line" >> \$tmpissue + fi +done < /etc/issue +mv "\$tmpissue" /etc/issue + +EOF + +######### OPNFV addition BEGIN ############ +# Copy data into /opt/opnfv +# TODO: This ought to be a package instead! +mkdir -p /opt/opnfv +cp -r ${SOURCE}/opnfv /opt +######### OPNFV addition END ############ + +# Unmounting source +umount -f ${SOURCE} +rm -rf ${SOURCE} + +umount -f ${FS} || true +rm -rf ${FS} + +# Enabling/configuring NTPD and ntpdate services +echo "server 127.127.1.0" >> /etc/ntp.conf +echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf +echo "tos orphan 7" >> /etc/ntp.conf + +# Do not show error message on ntpdate failure. Customers should not be confused +# if admin node does not have access to the internet time servers. +sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/' + +# Disabling splash +sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf +sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf + +# Disabling console clearing +sed -i 's/getty/getty --noclear/' /etc/init/tty.conf + +# Disabling starting first console from start-ttys service +sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init + +# Copying default bash settings to the root directory +cp -f /etc/skel/.bash* /root/ + +# Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors +[[ $(virt-what) = "virtualbox" ]] && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf + +%end diff --git a/fuel-build/f_isoroot/f_kscfg/ks.cfg.orig b/fuel-build/f_isoroot/f_kscfg/ks.cfg.orig new file mode 100644 index 0000000..8d00dff --- /dev/null +++ b/fuel-build/f_isoroot/f_kscfg/ks.cfg.orig @@ -0,0 +1,534 @@ +install +text +%include /tmp/source.ks +reboot --eject +lang en_US.UTF-8 +keyboard us +rootpw r00tme +timezone --utc Etc/UTC +firewall --disabled +selinux --disabled +# ignore unsupported hardware warning +unsupported_hardware +# SKIP CONFIGURING X +skipx +# NEVER ever place zerombr here, it breaks automated installation +%include /tmp/bootloader.ks +%include /tmp/partition.ks + +# PREINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE +# INSTALLATION PROCESS ITSELF +%pre +#!/bin/sh + +# hard drives +drives="" +removable_drives="" +for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do + if (grep -q 0 /sys/block/${drv}/removable); then + drives="${drives} ${drv}" + else + removable_drives="${removable_drives} ${drv}" + fi +done +default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'` + +installdrive="undefined" +forceformat="no" +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +set ${drives} ${removable_drives} +numdrives=`echo $#` + +tgtdrive="${installdrive}" + +function confirm_format { + check_drive="$1" + local confirm_format="no" + + if [[ "$forceformat" == "yes" ]] ; then + return 0 + fi + + if parted -s /dev/$check_drive print &>/dev/null ; then + echo + echo "$check_drive drive contains partition table:" + parted -s /dev/$check_drive print + echo + read -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format + if [[ "$confirm_format" == "y" ]] || [[ "$forceformat" == "yes" ]]; then + return 0 + else + return 1 + fi + else + return 0 + fi +} + +format_confirmed="no" + +if [ $numdrives -lt 1 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* There is no suitable media available for installation. *' + echo '* Please attach a drive and try again. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to shut down the system: " _ + poweroff +fi + +if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + while [ "${tgtdrive}" = "undefined" ]; do + clear + echo + echo '********************************************************************************' + echo '* W A R N I N G *' + echo '* *' + echo '* Which of the detected hard drives do you want to be used as *' + echo '* the installation target? *' + echo '* *' + echo '********************************************************************************' + echo + echo "Possible choices" + echo "Persistent drives: ${drives}" + echo "Removable drives: ${removable_drives}" + echo + if [ `echo ${drives} | wc -w` -eq 1 ] ; then + read -t 30 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive + else + read -p "Choose hard drive: " tgtdrive + fi + match="no" + for drive in ${drives[@]} ${removable_drives[@]}; do + if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then + if confirm_format $tgtdrive ; then + format_confirmed="yes" + break + else + tgtdrive="undefined" + read -p "You may select another disk. Press Enter to continue." _ + fi + fi + done + if [[ "$match" == "no" ]]; then + tgtdrive="undefined" + read -p "Invalid choice. Press Enter to continue." _ + fi + done + clear + chvt 1 +else + tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"` +fi + +if [ "$format_confirmed" != "yes" ] ; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + if ! confirm_format $tgtdrive ; then + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Disk $tgtdrive contains active partition(s). *' + echo '* Installation cannot continue without confirmation. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot + fi + chvt 1 +fi + +# verify tgtdrive is at least 30GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 30720 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Your disk is under 30GB in size. Installation cannot continue. *' + echo '* Restart installation with a larger disk. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot +fi + +# paths in /dev have "/" instead of "!" for cciss devices +tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//') + +# source +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks +else + echo "cdrom" > /tmp/source.ks +fi + +vgremove -ff os +dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10 +sleep 3 +hdparm -z /dev/${tgtdrive} +parted -s /dev/${tgtdrive} mklabel gpt +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24 +parted -s /dev/${tgtdrive} set 1 bios_grub on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224 +parted -s /dev/${tgtdrive} set 2 boot on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424 +sleep 3 +hdparm -z /dev/${tgtdrive} + +# partition + +# This adds support for the p seperator required for cciss devices +if echo ${tgtdrive} | grep -q -e cciss ; then + bootdev=${tgtdrive}p +else + bootdev=${tgtdrive} +fi +echo > /tmp/partition.ks +echo "partition /boot --onpart=/dev/${bootdev}3" >> /tmp/partition.ks +echo "partition pv.001 --ondisk=${tgtdrive} --size=30000 --grow" >> /tmp/partition.ks +echo "volgroup os pv.001" >> /tmp/partition.ks +echo "logvol swap --vgname=os --recommended --name=swap" >> /tmp/partition.ks +echo "logvol / --vgname=os --size=10000 --name=root --fstype=ext4" >> /tmp/partition.ks +echo "logvol /var --vgname=os --size=1 --grow --name=var --fstype=xfs" >> /tmp/partition.ks + +# bootloader +echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks + +# Anaconda can not install grub 0.97 on disks which are >4T. +# The reason is that grub does not support such large geometries +# and it simply thinks that the cylinder number has negative value. +# Here we just set geometry manually so that grub thinks that disk +# size is equal to 1G. +# 130 cylinders * (16065 * 512 = 8225280 bytes) = 1G +echo "%post --nochroot --log=/mnt/sysimage/root/anaconda-post-partition.log" > /tmp/post_partition.ks +echo "echo \"device (hd0) /dev/${tgtdrive}\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"geometry (hd0) 130 255 63\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"root (hd0,2)\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo \"install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf\" >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "echo quit >> /tmp/grub.script" >> /tmp/post_partition.ks +echo "cat /tmp/grub.script | chroot /mnt/sysimage /sbin/grub --no-floppy --batch" >> /tmp/post_partition.ks + +%end + +%packages --nobase --excludedocs +@Core +authconfig +bind-utils +cronie +crontabs +curl +daemonize +dhcp +docker-io +fuelmenu +gdisk +lrzip +lsof +man +mlocate +nmap-ncat +ntp +openssh-clients +policycoreutils +rsync +ruby21-puppet +ruby21-rubygem-netaddr +ruby21-rubygem-openstack +selinux-policy-targeted +strace +subscription-manager +sysstat +system-config-firewall-base +tcpdump +telnet +vim-enhanced +virt-what +wget +yum + +%include /tmp/post_partition.ks + +# POSTINSTALL SECTION +# HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER +# INSTALLATION ITSELF COMPLETED +%post +echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules +chmod +x /etc/rc.modules +echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf +mkdir -p /var/log/coredump +echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf +chmod 777 /var/log/coredump +echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf + +# Mount installation media in chroot +%post --nochroot --log=/mnt/sysimage/root/anaconda-post-before-chroot.log +#!/bin/sh + +SOURCE="/mnt/sysimage/tmp/source" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +mkdir -p "${SOURCE}" + +case "${repo}" in + nfs:*) + nfs_url="${repo#nfs:}" + mount -t nfs "${nfs_url}" "${SOURCE}" + ;; + *) + if [ -d "/mnt/source" ]; then + mount -o bind "/mnt/source" "${SOURCE}" + fi + ;; +esac + +%post --log=/root/anaconda-post-after-chroot.log +#!/bin/bash + +set -x + +function save_cfg { + scrFile="/etc/sysconfig/network-scripts/ifcfg-$device" + search="domain $domain\nsearch $domain" + sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network + grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts + echo "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream + [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf + [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream + + echo DEVICE=$device > $scrFile + echo ONBOOT=yes >> $scrFile + echo NM_CONTROLLED=no >> $scrFile + echo HWADDR=$hwaddr >> $scrFile + echo USERCTL=no >> $scrFile + echo PEERDNS=no >> $scrFile + if [ $ip ]; then + echo BOOTPROTO=static >> $scrFile + echo IPADDR=$ip >> $scrFile + echo NETMASK=$netmask >> $scrFile + else + echo BOOTPROTO=dhcp >> $scrFile + fi + scrDHCPFile="/etc/sysconfig/network-scripts/ifcfg-$dhcp_interface" + #Ignore gateway and set up DHCP if it is used, otherwise apply it + if [ $dhcp_interface ] && [ "$dhcp_interface" != "$device" ]; then + echo "DEVICE=$dhcp_interface" > $scrDHCPFile + echo "BOOTPROTO=dhcp" >> $scrDHCPFile + echo "ONBOOT=yes" >> $scrDHCPFile + echo "USERCTL=no" >> $scrDHCPFile + else + echo GATEWAY=$gw >> /etc/sysconfig/network + fi +} + +# Default FQDN +hostname="nailgun.mirantis.com" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done +hostname=$hostname +domain=${hostname#*.} +ip=$ip +netmask=$netmask +gw=$gw +device="eth0" +hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` +dhcp_interface=$dhcp_interface +save_cfg + +# Mounting installation source +SOURCE=/tmp/source +FS=/tmp/fs + +echo +mkdir -p ${SOURCE} +mkdir -p ${FS} + +if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then + mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS} + mount -o loop ${FS}/nailgun.iso ${SOURCE} +fi + +# Copying Repo to the nailgun /var/www directory +repodir="/var/www/nailgun" +mkdir -p ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/images ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/isolinux ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/repodata ${repodir}/centos/fuelweb/x86_64 +cp -r ${SOURCE}/Packages ${repodir}/centos/fuelweb/x86_64 +cp ${SOURCE}/.treeinfo ${repodir}/centos/fuelweb/x86_64 + +# Copying Ubuntu files +mkdir -p ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/conf ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/db ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/dists ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/indices ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/pool ${repodir}/ubuntu/fuelweb/x86_64 +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/linux ${repodir}/ubuntu/fuelweb/x86_64/images +cp -r ${SOURCE}/ubuntu/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz ${repodir}/ubuntu/fuelweb/x86_64/images + +# Copying bootstrap image +mkdir -p ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/initramfs.img ${repodir}/bootstrap +cp -r ${SOURCE}/bootstrap/linux ${repodir}/bootstrap + +mkdir -p /root/.ssh +chmod 700 /root/.ssh +cp ${SOURCE}/bootstrap/bootstrap.rsa /root/.ssh +chmod 600 /root/.ssh/bootstrap.rsa + +# Unpacking puppet manifests for master and slave +cp ${SOURCE}/puppet-slave.tgz ${repodir}/ +tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/modules +mkdir -p /etc/puppet/manifests/ +cp /etc/puppet/modules/osnailyfacter/examples/site.pp /etc/puppet/manifests/site.pp +cp ${SOURCE}/centos-versions.yaml ${SOURCE}/ubuntu-versions.yaml /etc/puppet/manifests/ +cp ${SOURCE}/send2syslog.py /bin/send2syslog.py +mkdir -p /var/lib/hiera +touch /var/lib/hiera/common.yaml /etc/puppet/hiera.yaml + +# Deploy docker images and ctl tools if we built ISO with docker containers support +[ -d "${SOURCE}/docker" ] && cp -r ${SOURCE}/docker ${repodir}/docker + +# Prepare local repository specification +rm /etc/yum.repos.d/CentOS*.repo +cat > /etc/yum.repos.d/nailgun.repo << EOF +[nailgun] +name=Nailgun Local Repo +baseurl=file:/var/www/nailgun/centos/fuelweb/x86_64 +gpgcheck=0 +EOF + +# Disable subscription-manager plugins +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || : +sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || : + +# Disable GSSAPI in ssh server config +sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config + +# Copying bootstrap_admin_node.sh, chmod it and +# adding /etc/init/bootstrap_admin_node.conf +cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh +chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh +cp ${SOURCE}/bootstrap_admin_node.conf /etc/init/bootstrap_admin_node.conf +echo "ENABLED=1" > /etc/sysconfig/bootstrap_admin_node + +# Copying version.yaml file. It contains COMMIT_SHA of last commit. +RELEASE=$(awk '/release/{gsub(/"/, "");print $2}' ${SOURCE}/version.yaml) +mkdir -p /etc/nailgun /etc/fuel/${RELEASE} /etc/fuel/release_versions +cp ${SOURCE}/version.yaml /etc/nailgun/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/${RELEASE}/version.yaml +ln -s /etc/fuel/${RELEASE}/version.yaml /etc/fuel/version.yaml +cp ${SOURCE}/version.yaml /etc/fuel/release_versions/`cat ${SOURCE}/openstack_version`.yaml + +# Generete Fuel UUID +uuidgen > /etc/fuel/fuel-uuid + +###Run fuel menu +[ -z "$showmenu" ] && showmenu="no" +cat > /root/.showfuelmenu << EOF +#Set to yes to run Fuel Setup +#Set to no to accept default settings +showmenu=$showmenu +EOF + +# Prepare custom /etc/issue logon banner and script for changing IP in it +cat > /etc/issue << EOF +######################################### +# Welcome to the Fuel server # +######################################### +Server is running on \m platform + +Fuel UI is available on: +http://:8000 + +Default administrator login: root +Default administrator password: r00tme + +Default Fuel UI login: admin +Default Fuel UI password: admin + +Please change root password on first login. + +EOF + + +cat >> '/etc/rc.local' << EOF +first=yes +for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do +if [ "\$first" = "yes" ]; then + ipstr="Fuel UI is available on: http://\$ip:8000" + first=no +else + ipstr=\$(printf "%s\n%51s" "\$ipstr" "http://\$ip:8000") +fi +done +tmpissue=\$(mktemp) +while read -r line; do + if [[ "\$line" =~ "Fuel UI is available on" ]]; then + echo -e "\$ipstr" >> \$tmpissue + elif [[ "\$line" =~ :8000$ ]]; then + : + else + echo -e "\$line" >> \$tmpissue + fi +done < /etc/issue +mv "\$tmpissue" /etc/issue + +EOF + + +# Unmounting source +umount -f ${SOURCE} +rm -rf ${SOURCE} + +umount -f ${FS} || true +rm -rf ${FS} + +# Enabling/configuring NTPD and ntpdate services +echo "server 127.127.1.0" >> /etc/ntp.conf +echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf +echo "tos orphan 7" >> /etc/ntp.conf + +# Do not show error message on ntpdate failure. Customers should not be confused +# if admin node does not have access to the internet time servers. +sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/' + +# Disabling splash +sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf +sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf + +# Disabling console clearing +sed -i 's/getty/getty --noclear/' /etc/init/tty.conf + +# Disabling starting first console from start-ttys service +sed -i --follow-symlinks -e 's/ACTIVE_CONSOLES=.*/ACTIVE_CONSOLES=\/dev\/tty\[2-6\]/' /etc/sysconfig/init + +# Copying default bash settings to the root directory +cp -f /etc/skel/.bash* /root/ + +# Blacklist i2c_piix4 module for VirtualBox so it does not create kernel errors +[[ $(virt-what) = "virtualbox" ]] && echo "blacklist i2c_piix4" > /etc/modprobe.d/blacklist-i2c-piix4.conf + +%end
\ No newline at end of file diff --git a/fuel-build/f_isoroot/f_predeployment/Makefile b/fuel-build/f_isoroot/f_predeployment/Makefile new file mode 100644 index 0000000..a5252df --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/Makefile @@ -0,0 +1,28 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + @mkdir -p release/opnfv + @cp pre-deploy.sh release/opnfv + @cp sysinfo.sh release/opnfv + @cp transform_yaml.py release/opnfv + @chmod 755 release/opnfv/* + +.PHONY: clean +clean: + @rm -rf release + + +.PHONY: release +release:clean all + @cp -Rvp release/* ../release diff --git a/fuel-build/f_isoroot/f_predeployment/README b/fuel-build/f_isoroot/f_predeployment/README new file mode 100644 index 0000000..3eef9f2 --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/README @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is the start of the interactive frontend that will add OPNFV configuration into +the astute.yaml of the nodes. Currently just a test setup - prepare an installation +up to the point of "deploy changes", but run "./pre-deploy.sh <envid> fragment.yaml" +before actually hitting deploy, which will make sure to add the example fragment to +the nodes. + +Note that the only part of the fragment.yaml that actually is acted on is the hosts +part at this time. diff --git a/fuel-build/f_isoroot/f_predeployment/pre-deploy.sh b/fuel-build/f_isoroot/f_predeployment/pre-deploy.sh new file mode 100755 index 0000000..c5c6c42 --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/pre-deploy.sh @@ -0,0 +1,401 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +error_exit () { + echo "$@" >&2 + exit 1 +} + +get_env() { + local env_id=${1:-""} + + if [ -z $env_id ]; then + local n_envs=$(fuel env --list | grep -v -E "^id|^--|^ *$" | wc -l) + if [ $n_envs -ne 1 ]; then + echo "Usage: $0 [<env-id>]" >&2 + error_exit "If only a single environment is present it can be left" \ + "out. Otherwise the environment must be selected" + fi + env_id=$(fuel env --list | grep -v -E "^id|^--" | awk '{print $1}') + else + if ! fuel --env $env_id environment 2>/dev/null grep -v -E "^id|^--" | \ + grep -q ^$env_id; then + error_exit "No such environment ID: $env_id" + fi + fi + echo $env_id +} + +get_node_uid () { + cat $1 | grep "^uid: " | sed "s/^uid: '//" | sed "s/'$//" +} + +get_node_role () { + cat $1 | grep "^role: " | sed "s/^role: //" +} + +get_next_cic () { + file=$1 + + last=`cat $file | sed 's/.*://' | grep "cic-" | sed 's/cic\-.*sl//' | sort -n | tail -1` + if [ -z "$last" ]; then + next=1 + else + next=$[$last + 2] + fi + echo $next +} + +get_next_compute () { + file=$1 + + last=`cat $file | sed 's/.*://' | grep "cmp-" | sed 's/cmp\-.*sl//' | sort -n | tail -1` + if [ -z "$last" ]; then + next=7 + else + next=$[$last + 2] + fi + echo $next +} + +modify_hostnames () { + env=$1 + file=$2 + for line in `cat $file` + do + old=`echo $line | sed 's/:.*//'` + new=`echo $line | sed 's/.*://'` + echo "Applying: $old -> $new" + + for dfile in deployment_$env/*.yaml + do + sed -i "s/$old/$new/g" $dfile + done + + for pfile in provisioning_$env/*.yaml + do + sed -i "s/$old/$new/g" $pfile + done + done +} + +setup_hostnames () { + ENV=$1 + cd ${CONFIGDIR} + touch hostnames.$ENV + + for dfile in deployment_$ENV/*.yaml + do + uid=`get_node_uid $dfile` + hostname=`grep "^node-$uid:" hostnames.$ENV | sed 's/.*://'` + if [ -z $hostname ]; then + + pfile=provisioning_$ENV/node-$uid.yaml + role=`get_node_role $dfile` + + case $role in + primary-controller) + hostname="cic-pod0-sh0-sl`get_next_cic hostnames.$ENV`" + ;; + controller) + hostname="cic-pod0-sh0-sl`get_next_cic hostnames.$ENV`" + ;; + compute) + hostname="cmp-pod0-sh0-sl`get_next_compute hostnames.$ENV`" + ;; + *) + echo "Unknown node type for UID $uid" + exit 1 + ;; + esac + + echo "node-$uid:$hostname" >> hostnames.$ENV + else + echo "Already got hostname $hostname for node-$uid" + + fi + done + + rm -f hostnames.$ENV.old + mv hostnames.$ENV hostnames.$ENV.old + sort hostnames.$ENV.old | uniq > hostnames.$ENV + modify_hostnames $ENV hostnames.$ENV +} + + + +get_provisioning_info () { + ENV=$1 + mkdir -p ${CONFIGDIR} + cd ${CONFIGDIR} + rm -Rf provisioning_$ENV + echo "Getting provisioning info..." + fuel --env $ENV provisioning --default + if [ $? -ne 0 ]; then + echo "Error: Could not get provisioning info for env $ENV">&2 + exit 1 + fi +} + +get_deployment_info () { + ENV=$1 + mkdir -p ${CONFIGDIR} + cd ${CONFIGDIR} + rm -Rf deployment_$ENV + echo "Getting deployment info..." + fuel --env $ENV deployment --default + if [ $? -ne 0 ]; then + echo "Error: Could not get deployment info for env $ENV">&2 + exit 1 + fi +} + +transform_yaml () { + ENV=$1 + cd ${CONFIGDIR} + for dfile in deployment_$ENV/*.yaml + do + /opt/opnfv/transform_yaml.py $dfile + done +} + +commit_changes () { + ENV=$1 + cd ${CONFIGDIR} + + fuel --env $ENV deployment --upload + fuel --env $ENV provisioning --upload +} + +add_yaml_fragment () { + ENV=$1 + FRAGMENT=${CONFIGDIR}/fragment.yaml.$ENV + + cd ${CONFIGDIR} + for dfile in deployment_$ENV/*.yaml + do + cnt=`grep "^opnfv:" $dfile | wc -l ` + if [ $cnt -eq 0 ]; then + echo "Adding fragment to $dfile" + cat $FRAGMENT >> $dfile + else + echo "Already have fragment in $dfile" + fi + done +} + + +ip_valid() { + IP_ADDRESS="$1" + # Check if the format looks right_ + echo "$IP_ADDRESS" | egrep -qE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' || return 1 + #check that each octect is less than or equal to 255: + echo $IP_ADDRESS | awk -F'.' '$1 <=255 && $2 <= 255 && $3 <=255 && $4 <= 255 {print "Y" } ' | grep -q Y || return 1 + return 0 +} + + +generate_ntp_entry() { + FILE=$1 + read -p "NTP server:" NTP_SERVER + if [ -z "$NTP_SERVER" ]; then + return 1 + elif confirm_yes "Are you sure you want to add this entry (y/n): "; then + echo "Confirmed" + echo " server $NTP_SERVER" >> $FILE + fi +} + +generate_hostfile_entry() { + FILE=$1 + read -p "Name:" HOST_NAME + if [ -z "$HOST_NAME" ]; then + return 1 + else + read -p "FQDN:" HOST_FQDN + read -p "IP: " HOST_IP + while ! ip_valid "$HOST_IP" + do + echo "This is not a valid IP! Try again." + read -p "IP: " HOST_IP + done + fi + if confirm_yes "Are you sure you want to add this entry (y/n): "; then + echo "Confirmed" + echo " - name: $HOST_NAME" >> $FILE + echo " address: $HOST_IP" >> $FILE + echo " fqdn: $HOST_FQDN" >> $FILE + else + echo "Not confirmed" + fi + return 0 +} + +generate_dns_entry() { + FILE=$1 + PROMPT=$2 + read -p "${PROMPT}:" DNS_IP + if [ -z "$DNS_IP" ]; then + return 1 + else + while ! ip_valid "$DNS_IP" + do + echo "This is not a valid IP! Try again." + read -p "${PROMPT}: " DNS_IP + done + fi + if confirm_yes "Are you sure you want to add this entry (y/n): "; then + echo "Confirmed" + echo " - $DNS_IP" >> $FILE + else + echo "Not confirmed" + fi + return 0 +} + +confirm_yes() { + prompt=$1 + while true + do + read -p "$prompt" YESNO + case $YESNO in + [Yy]) + return 0 + ;; + [Nn]) + return 1 + ;; + esac + done +} + +generate_yaml_fragment() { + ENV=$1 + FRAGMENT=${CONFIGDIR}/fragment.yaml.$ENV + + if [ -f $FRAGMENT ]; then + echo "Manual configuration already performed, reusing previous data from $FRAGMENT." + echo "Press return to continue or ^C to stop." + read ans + return + fi + + echo "opnfv:" > ${FRAGMENT} + + clear + echo -e "\n\nPre-deployment configuration\n\n" + + echo -e "\n\nIPs for the DNS servers to go into /etc/resolv.conf. You will be" + echo -e "prompted for one IP at the time. Press return on an empty line" + echo -e "to complete your input. If no DNS server is specified, the IP of" + echo -e "the Fuel master will be used instead.\n" + + DNSCICYAML=${CONFIGDIR}/cicdns.yaml.$ENV + rm -f $DNSCICYAML + + echo -e "\n\n" + + while generate_dns_entry $DNSCICYAML "IP for CIC name servers" + do + : + done + + if [ -f $DNSCICYAML ]; then + echo " dns:" >> $FRAGMENT + echo " controller:" >> $FRAGMENT + cat $DNSCICYAML >> $FRAGMENT + fi + + + DNSCMPYAML=${CONFIGDIR}/cmpdns.yaml.$ENV + rm -f $DNSCMPYAML + + echo -e "\n\n" + + while generate_dns_entry $DNSCMPYAML "IP for compute node name servers" + do + : + done + + + if [ -f $DNSCMPYAML ]; then + if [ ! -f $DNSCICYAML ]; then + echo " dns:" >> $FRAGMENT + fi + echo " compute:" >> $FRAGMENT + cat $DNSCMPYAML >> $FRAGMENT + fi + + echo -e "\n\nHosts file additions for controllers and compute nodes. You will be" + echo -e "prompted for name, FQDN and IP for each entry. Press return when prompted" + echo -e "for a name when you have completed your input.\n" + + + HOSTYAML=${CONFIGDIR}/hosts.yaml.$ENV + rm -f $HOSTYAML + while generate_hostfile_entry $HOSTYAML + do + : + done + + if [ -f $HOSTYAML ]; then + echo " hosts:" >> $FRAGMENT + cat $HOSTYAML >> $FRAGMENT + fi + + echo -e "\n\nNTP upstream configuration for controllers.You will be" + echo -e "prompted for a NTP server each entry. Press return when prompted" + echo -e "for a NTP serverwhen you have completed your input.\n" + + + NTPYAML=${CONFIGDIR}/ntp.yaml.$ENV + rm -f $NTPYAML + while generate_ntp_entry $NTPYAML + do + : + done + + if [ -f $NTPYAML ]; then + echo " ntp:" >> $FRAGMENT + echo " controller: |" >> $FRAGMENT + cat $NTPYAML >> $FRAGMENT + + echo " compute: |" >> $FRAGMENT + for ctl in `find $CONFIGDIR/deployment_$ENV -name '*controller*.yaml'` + do + fqdn=`grep "^fqdn:" $ctl | sed 's/fqdn: *//'` + echo " server $fqdn" >> $FRAGMENT + done + fi + + # If nothing added make sure we get an empty opnfv hash + # instead of a NULL hash. + if [ $(wc -l $FRAGMENT | awk '{print $1}') -le 1 ]; then + echo "opnfv: {}" >$FRAGMENT + fi +} + +ENV=$(get_env "$@") + +CONFIGDIR="/var/lib/opnfv" +mkdir -p $CONFIGDIR + +get_deployment_info $ENV +# Uncomment the below to enable the control_bond example +#transform_yaml $ENV +get_provisioning_info $ENV +generate_yaml_fragment $ENV +# The feature to change hostnames from node-<n> to cmp- or cic- is disabled. +# To turn it on, uncomment the following line. +#setup_hostnames $ENV +add_yaml_fragment $ENV +commit_changes $ENV diff --git a/fuel-build/f_isoroot/f_predeployment/sysinfo.sh b/fuel-build/f_isoroot/f_predeployment/sysinfo.sh new file mode 100755 index 0000000..e99cac0 --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/sysinfo.sh @@ -0,0 +1,12 @@ +#!/bin/sh +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +dockerctl shell cobbler cobbler system list | grep -v default | xargs -n 1 host | sort | sed 's/\..* /\t/' diff --git a/fuel-build/f_isoroot/f_predeployment/transform_yaml.py b/fuel-build/f_isoroot/f_predeployment/transform_yaml.py new file mode 100755 index 0000000..14eec4c --- /dev/null +++ b/fuel-build/f_isoroot/f_predeployment/transform_yaml.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Remove control and management network transformations from file. +# Only to be used together with f_control_bond_example (enable in +# pre-deploy.sh) + +import yaml +import re +import sys +import os + +if len(sys.argv) != 2: + sys.stderr.write("Usage: "+sys.argv[0]+" <filename>\n") + sys.exit(1) + +filename = sys.argv[1] +if not os.path.exists(filename): + sys.stderr.write("ERROR: The file "+filename+" could not be opened\n") + sys.exit(1) + +ignore_values = [ "eth0", "eth1", "br-mgmt", "br-fw-admin" ] + +infile = open(filename, 'r') +doc = yaml.load(infile) +infile.close() + +out={} + +for scheme in doc: + if scheme == "network_scheme": + mytransformation = {} + for operation in doc[scheme]: + if operation == "transformations": + # We need the base bridges for l23network to be happy, + # remove everything else. + mytrans = [ { "action": "add-br", "name": "br-mgmt" }, + { "action": "add-br", "name": "br-fw-admin" } ] + for trans in doc[scheme][operation]: + delete = 0 + for ignore in ignore_values: + matchObj = re.search(ignore,str(trans)) + if matchObj: + delete = 1 + if delete == 0: + mytrans.append(trans) + else: + pass + #print "Deleted", trans + + mytransformation[operation] = mytrans + else: + mytransformation[operation] = doc[scheme][operation] + out[scheme] = mytransformation + else: + out[scheme] = doc[scheme] + +outfile = open(filename, 'w') +outfile.write(yaml.dump(out, default_flow_style=False)) +outfile.close() diff --git a/fuel-build/f_l23network/Makefile b/fuel-build/f_l23network/Makefile new file mode 100644 index 0000000..295fd0e --- /dev/null +++ b/fuel-build/f_l23network/Makefile @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + + +.PHONY: release +release: + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_l23network/README b/fuel-build/f_l23network/README new file mode 100644 index 0000000..9aa4718 --- /dev/null +++ b/fuel-build/f_l23network/README @@ -0,0 +1,35 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +Addition to add entries to /etc/hosts through Astute. + +The astute.yaml file should contain entries as those below to have them picked up during deployment: + +opnfv: + hosts: + - name: test1 + address: 192.168.100.100 + fqdn: test1.opnfv.org + - name: test2 + address: 192.168.100.101 + fqdn: test2.opnfv.org + - name: test3 + address: 192.168.100.102 + fqdn: test3.opnfv.org + +The suggested method for adding this information is to prepare for deployment with the Fuel GUI or CLI, +but before actually deploying: + +1. Download the current deployment for all hosts: fuel --env 1 deployment --default +2. Iterate through the hosts in "deployment_1" and add hosts configuration in the above format to their + respective yaml file. +3. Upload the modifed deployment information: fuel --env 1 deployment --upload + +After deploying, the additions will be included in /etc/astute.yaml of each host. diff --git a/fuel-build/f_l23network/puppet/modules/l23network/lib/puppet/parser/functions/extras_to_hosts.rb b/fuel-build/f_l23network/puppet/modules/l23network/lib/puppet/parser/functions/extras_to_hosts.rb new file mode 100644 index 0000000..33bfad8 --- /dev/null +++ b/fuel-build/f_l23network/puppet/modules/l23network/lib/puppet/parser/functions/extras_to_hosts.rb @@ -0,0 +1,21 @@ +# +# array_or_string_to_array.rb +# + +module Puppet::Parser::Functions + newfunction(:extras_to_hosts, :type => :rvalue, :doc => <<-EOS + convert extras array passed from Astute into + hash for puppet `host` create_resources call + EOS + ) do |args| + hosts=Hash.new + extras=args[0] + extras.each do |extras| + hosts[extras['name']]={:ip=>extras['address'],:host_aliases=>[extras['fqdn']]} + notice("Generating extras host entry #{extras['name']} #{extras['address']} #{extras['fqdn']}") + end + return hosts + end +end + +# vim: set ts=2 sw=2 et : diff --git a/fuel-build/f_l23network/puppet/modules/l23network/manifests/hosts_file.pp b/fuel-build/f_l23network/puppet/modules/l23network/manifests/hosts_file.pp new file mode 100644 index 0000000..05cff8d --- /dev/null +++ b/fuel-build/f_l23network/puppet/modules/l23network/manifests/hosts_file.pp @@ -0,0 +1,18 @@ +class l23network::hosts_file ( + $nodes, + $extras=[], + $hosts_file = "/etc/hosts" +) { + + # OPNFV addition: Add additional lines in /etc/hosts through Astute additions + + $host_resources = nodes_to_hosts($nodes) + $extras_host_resources = extras_to_hosts($extras) + Host { + ensure => present, + target => $hosts_file + } + + create_resources(host, $host_resources) + create_resources(host, $extras_host_resources) +} diff --git a/fuel-build/f_l23network/puppet/modules/l23network/manifests/hosts_file.pp.orig b/fuel-build/f_l23network/puppet/modules/l23network/manifests/hosts_file.pp.orig new file mode 100644 index 0000000..2295e3f --- /dev/null +++ b/fuel-build/f_l23network/puppet/modules/l23network/manifests/hosts_file.pp.orig @@ -0,0 +1,16 @@ +class l23network::hosts_file ( + $nodes, + $hosts_file = "/etc/hosts" +) { + + #Move original hosts file + + $host_resources = nodes_to_hosts($nodes) + + Host { + ensure => present, + target => $hosts_file + } + + create_resources(host, $host_resources) +} diff --git a/fuel-build/f_l23network/testing/README b/fuel-build/f_l23network/testing/README new file mode 100644 index 0000000..b68eddf --- /dev/null +++ b/fuel-build/f_l23network/testing/README @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +In order to test the functionality without performing a full deployment, run "puppet apply" on the fake_init.pp +which will call only the l23network::hosts_file class. diff --git a/fuel-build/f_l23network/testing/fake_init.pp b/fuel-build/f_l23network/testing/fake_init.pp new file mode 100644 index 0000000..bc6b163 --- /dev/null +++ b/fuel-build/f_l23network/testing/fake_init.pp @@ -0,0 +1,13 @@ +$fuel_settings = parseyaml($astute_settings_yaml) + +if $::fuel_settings['nodes'] { + $nodes_hash = $::fuel_settings['nodes'] + $extras_hash = $::fuel_settings['opnfv']['hosts'] + + class {'l23network::hosts_file': + nodes => $nodes_hash, + extras => $extras_hash + } + + include l23network::hosts_file +} diff --git a/fuel-build/f_ntp/Makefile b/fuel-build/f_ntp/Makefile new file mode 100644 index 0000000..295fd0e --- /dev/null +++ b/fuel-build/f_ntp/Makefile @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + + +.PHONY: release +release: + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_ntp/README b/fuel-build/f_ntp/README new file mode 100644 index 0000000..77fd1da --- /dev/null +++ b/fuel-build/f_ntp/README @@ -0,0 +1,32 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +Addition to add ntp.conf separately for compute hosts and controller hosts through Astute. + +The astute.yaml file should contain entries as those below to have them picked up during deployment: + +opnfv: + ntp: + controller: | + line 1 + line 2 + compute: | + line 1 + line 2 + +The suggested method for adding this information is to prepare for deployment with the Fuel GUI or CLI, +but before actually deploying: + +1. Download the current deployment for all hosts: fuel --env 1 deployment --default +2. Iterate through the hosts in "deployment_1" and add hosts configuration in the above format to their + respective yaml file. +3. Upload the modifed deployment information: fuel --env 1 deployment --upload + +After deploying, the additions will be included in /etc/astute.yaml of each host. diff --git a/fuel-build/f_ntp/puppet/modules/opnfv/manifests/ntp.pp b/fuel-build/f_ntp/puppet/modules/opnfv/manifests/ntp.pp new file mode 100644 index 0000000..8180e3d --- /dev/null +++ b/fuel-build/f_ntp/puppet/modules/opnfv/manifests/ntp.pp @@ -0,0 +1,71 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Class: Ntp +# +# Add Ntp content passed through astute.yaml into ntp.conf depending on the role +# +# Suitable yaml content: +# <begin> +# opnfv: +# ntp: +# controller: | +# line 1 +# line 2 +# compute: | +# line 1 +# line 2 +# <end> +# +# +# + +class opnfv::ntp( + $file='/etc/ntp.conf' +) { + + if $::fuel_settings['role'] { + if ($::fuel_settings['opnfv'] and + $::fuel_settings['opnfv']['ntp']) { + case $::fuel_settings['role'] { + /controller/: { + if $::fuel_settings['opnfv']['ntp']['controller'] { + $template = 'opnfv/ntp.conf.controller.erb' + $file_content = $::fuel_settings['opnfv']['ntp']['controller'] + } + } + /compute/: { + if $::fuel_settings['opnfv']['ntp']['compute'] { + $template = 'opnfv/ntp.conf.compute.erb' + $file_content = $::fuel_settings['opnfv']['ntp']['compute'] + } + } + } + } + } + + if $file_content { + package { 'ntp': + ensure => installed, + } + + file { $file: + content => template($template), + notify => Service['ntp'], + } + + service { 'ntp': + ensure => running, + enable => true, + require => [ Package['ntp'], File[$file]] + } + } +} + diff --git a/fuel-build/f_ntp/puppet/modules/opnfv/templates/ntp.conf.compute.erb b/fuel-build/f_ntp/puppet/modules/opnfv/templates/ntp.conf.compute.erb new file mode 100644 index 0000000..37ecfd7 --- /dev/null +++ b/fuel-build/f_ntp/puppet/modules/opnfv/templates/ntp.conf.compute.erb @@ -0,0 +1,21 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +tinker panic 0 +driftfile /var/lib/ntp/ntp.drift +statistics loopstats peerstats clockstats +filegen loopstats file loopstats type day enable +filegen peerstats file peerstats type day enable +filegen clockstats file clockstats type day enable +restrict -4 default kod notrap nomodify nopeer noquery +restrict -6 default kod notrap nomodify nopeer noquery +restrict 127.0.0.1 +restrict ::1 +<%= @file_content %> diff --git a/fuel-build/f_ntp/puppet/modules/opnfv/templates/ntp.conf.controller.erb b/fuel-build/f_ntp/puppet/modules/opnfv/templates/ntp.conf.controller.erb new file mode 100644 index 0000000..37ecfd7 --- /dev/null +++ b/fuel-build/f_ntp/puppet/modules/opnfv/templates/ntp.conf.controller.erb @@ -0,0 +1,21 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +tinker panic 0 +driftfile /var/lib/ntp/ntp.drift +statistics loopstats peerstats clockstats +filegen loopstats file loopstats type day enable +filegen peerstats file peerstats type day enable +filegen clockstats file clockstats type day enable +restrict -4 default kod notrap nomodify nopeer noquery +restrict -6 default kod notrap nomodify nopeer noquery +restrict 127.0.0.1 +restrict ::1 +<%= @file_content %> diff --git a/fuel-build/f_ntp/testing/README b/fuel-build/f_ntp/testing/README new file mode 100644 index 0000000..6d80b0a --- /dev/null +++ b/fuel-build/f_ntp/testing/README @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +In order to test the functionality without performing a full deployment, run "puppet apply" on the +fake_init.pp which will call only the opnfv::ntp class. diff --git a/fuel-build/f_ntp/testing/fake_init.pp b/fuel-build/f_ntp/testing/fake_init.pp new file mode 100644 index 0000000..b9af218 --- /dev/null +++ b/fuel-build/f_ntp/testing/fake_init.pp @@ -0,0 +1,13 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +$fuel_settings = parseyaml($astute_settings_yaml) + +include opnfv::ntp diff --git a/fuel-build/f_opnfv_puppet/Makefile b/fuel-build/f_opnfv_puppet/Makefile new file mode 100644 index 0000000..295fd0e --- /dev/null +++ b/fuel-build/f_opnfv_puppet/Makefile @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + + +.PHONY: release +release: + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_opnfv_puppet/README b/fuel-build/f_opnfv_puppet/README new file mode 100644 index 0000000..35bea5a --- /dev/null +++ b/fuel-build/f_opnfv_puppet/README @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +This is the top level "OPNFV" Puppet class which (hopefully) only will be used to include +an appropriate set of sub-classes which themselves will be self-contained. diff --git a/fuel-build/f_opnfv_puppet/puppet/modules/opnfv/manifests/init.pp b/fuel-build/f_opnfv_puppet/puppet/modules/opnfv/manifests/init.pp new file mode 100644 index 0000000..b06997b --- /dev/null +++ b/fuel-build/f_opnfv_puppet/puppet/modules/opnfv/manifests/init.pp @@ -0,0 +1,26 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# == Class: opnfv +# +# This class is used to perform OPNFV inclusions and settings on top of +# the vanilla Fuel installation. +# +# Currently all logic is self contained, i.e. it is sufficient to +# "include opnfv" from site.pp. + +class opnfv { + # Configure resolv.conf if parameters passed through astute + include opnfv::resolver + # Setup OPNFV style NTP config + include opnfv::ntp + # Make sure all added packages are installed + include opnfv::add_packages +} diff --git a/fuel-build/f_opnfv_puppet/puppet/modules/opnfv/manifests/opncheck.pp b/fuel-build/f_opnfv_puppet/puppet/modules/opnfv/manifests/opncheck.pp new file mode 100644 index 0000000..0822f02 --- /dev/null +++ b/fuel-build/f_opnfv_puppet/puppet/modules/opnfv/manifests/opncheck.pp @@ -0,0 +1,21 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Class: opnfv::opncheck +# +# Make sure that /opt/opnfv/pre-deploy.sh has been run by +# verifying there is an "opnfv:" level in the astute.yaml. + +class opnfv::opncheck() +{ + unless $::fuel_settings['opnfv'] { + fail("Error: You have not run /opt/opnfv/pre-deploy.sh on the Fuel master prior to deploying!") + } +} diff --git a/fuel-build/f_osnaily/Makefile b/fuel-build/f_osnaily/Makefile new file mode 100644 index 0000000..295fd0e --- /dev/null +++ b/fuel-build/f_osnaily/Makefile @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + + +.PHONY: release +release: + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_osnaily/puppet/modules/osnailyfacter/examples/site.pp b/fuel-build/f_osnaily/puppet/modules/osnailyfacter/examples/site.pp new file mode 100644 index 0000000..c32a92b --- /dev/null +++ b/fuel-build/f_osnaily/puppet/modules/osnailyfacter/examples/site.pp @@ -0,0 +1,325 @@ +$fuel_settings = parseyaml($astute_settings_yaml) + +$openstack_version = { + 'keystone' => 'installed', + 'glance' => 'installed', + 'horizon' => 'installed', + 'nova' => 'installed', + 'novncproxy' => 'installed', + 'cinder' => 'installed', +} + +tag("${::fuel_settings['deployment_id']}::${::fuel_settings['environment']}") + +#Stages configuration +stage {'zero': } -> +stage {'opncheck': } -> +stage {'first': } -> +stage {'openstack-custom-repo': } -> +stage {'netconfig': } -> +stage {'corosync_setup': } -> +stage {'openstack-firewall': } -> Stage['main'] + +class begin_deployment () +{ + $role = $::fuel_settings['role'] + notify { "***** Beginning deployment of node ${::hostname} with role $role *****": } +} + +class {'begin_deployment': stage => 'zero' } + +stage {'glance-image': + require => Stage['main'], +} + +if $::fuel_settings['nodes'] { + $nodes_hash = $::fuel_settings['nodes'] +# OPNFV addition to add to hosts file + if ($::fuel_settings['opnfv'] and + $::fuel_settings['opnfv']['hosts']) { + $extras_hash = $::fuel_settings['opnfv']['hosts'] + } else { + $extras_hash = undef + } + + $dns_nameservers=$::fuel_settings['dns_nameservers'] + $node = filter_nodes($nodes_hash,'name',$::hostname) + if empty($node) { + fail("Node $::hostname is not defined in the hash structure") + } + + $default_gateway = $node[0]['default_gateway'] + + $base_syslog_hash = $::fuel_settings['base_syslog'] + $syslog_hash = $::fuel_settings['syslog'] + + + $use_quantum = $::fuel_settings['quantum'] + if (!empty(filter_nodes($::fuel_settings['nodes'], 'role', 'ceph-osd')) or + $::fuel_settings['storage']['volumes_ceph'] or + $::fuel_settings['storage']['images_ceph'] or + $::fuel_settings['storage']['objects_ceph'] + ) { + $use_ceph = true + } else { + $use_ceph = false + } + + + if $use_quantum { + prepare_network_config($::fuel_settings['network_scheme']) + # + $internal_int = get_network_role_property('management', 'interface') + $internal_address = get_network_role_property('management', 'ipaddr') + $internal_netmask = get_network_role_property('management', 'netmask') + # + $public_int = get_network_role_property('ex', 'interface') + if $public_int { + $public_address = get_network_role_property('ex', 'ipaddr') + $public_netmask = get_network_role_property('ex', 'netmask') + } + # + $storage_address = get_network_role_property('storage', 'ipaddr') + $storage_netmask = get_network_role_property('storage', 'netmask') + } else { + $internal_address = $node[0]['internal_address'] + $internal_netmask = $node[0]['internal_netmask'] + $public_address = $node[0]['public_address'] + $public_netmask = $node[0]['public_netmask'] + $storage_address = $node[0]['storage_address'] + $storage_netmask = $node[0]['storage_netmask'] + $public_br = $node[0]['public_br'] + $internal_br = $node[0]['internal_br'] + $public_int = $::fuel_settings['public_interface'] + $internal_int = $::fuel_settings['management_interface'] + } +} + +if ($::fuel_settings['neutron_mellanox']) { + $mellanox_mode = $::fuel_settings['neutron_mellanox']['plugin'] +} else { + $mellanox_mode = 'disabled' +} + +# This parameter specifies the verbosity level of log messages +# in openstack components config. +# Debug would have set DEBUG level and ignore verbose settings, if any. +# Verbose would have set INFO level messages +# In case of non debug and non verbose - WARNING, default level would have set. +$verbose = true +$debug = $::fuel_settings['debug'] + +### Storage Settings ### +# Determine if any ceph parts have been asked for. +# This will ensure that monitors are set up on controllers, even if no +# ceph-osd roles during deployment + + +### Syslog ### +#TODO(bogdando) move logging options to astute.yaml +# Enable error messages reporting to rsyslog. Rsyslog must be installed in this case. +$use_syslog = $::fuel_settings['use_syslog'] ? { default=>true } +# Syslog facilities for main openstack services +# should vary (reserved usage) +# local1 is reserved for openstack-dashboard +$syslog_log_facility_glance = 'LOG_LOCAL2' +$syslog_log_facility_cinder = 'LOG_LOCAL3' +$syslog_log_facility_neutron = 'LOG_LOCAL4' +$syslog_log_facility_nova = 'LOG_LOCAL6' +$syslog_log_facility_keystone = 'LOG_LOCAL7' +# could be the same +# local0 is free for use +$syslog_log_facility_murano = 'LOG_LOCAL0' +$syslog_log_facility_heat = 'LOG_LOCAL0' +$syslog_log_facility_sahara = 'LOG_LOCAL0' +$syslog_log_facility_ceilometer = 'LOG_LOCAL0' + +$nova_rate_limits = { + 'POST' => 100000, + 'POST_SERVERS' => 100000, + 'PUT' => 1000, 'GET' => 100000, + 'DELETE' => 100000 +} +$cinder_rate_limits = { + 'POST' => 100000, + 'POST_SERVERS' => 100000, + 'PUT' => 100000, 'GET' => 100000, + 'DELETE' => 100000 +} + +### +class advanced_node_netconfig { + $sdn = generate_network_config() + notify {"SDN: ${sdn}": } +} + +case $::operatingsystem { + 'redhat' : { + $queue_provider = 'qpid' + $custom_mysql_setup_class = 'pacemaker_mysql' + } + default: { + $queue_provider='rabbitmq' + $custom_mysql_setup_class='galera' + } +} + +class os_common { + # OPNFV check if pre_deploy.sh has been run, otherwise fail + class {'opnfv::opncheck': stage => 'opncheck' } + if ($::fuel_settings['neutron_mellanox']) and ($::fuel_settings['storage']['iser']) { + class { 'mellanox_openstack::iser_rename': + stage => 'zero', + storage_parent => $::fuel_settings['neutron_mellanox']['storage_parent'], + iser_interface_name => $::fuel_settings['neutron_mellanox']['iser_interface_name'], + } + } + class {"l23network::hosts_file": stage => 'netconfig', nodes => $nodes_hash, extras => $extras_hash } + class {'l23network': use_ovs=>$use_quantum, stage=> 'netconfig'} + if $use_quantum { + class {'advanced_node_netconfig': stage => 'netconfig' } + } else { + class {'osnailyfacter::network_setup': stage => 'netconfig'} + } + + class { 'openstack::firewall': + stage => 'openstack-firewall', + nova_vnc_ip_range => $::fuel_settings['management_network_range'], + } + + $base_syslog_rserver = { + 'remote_type' => 'tcp', + 'server' => $base_syslog_hash['syslog_server'], + 'port' => $base_syslog_hash['syslog_port'] + } + +### TCP connections keepalives and failover related parameters ### + # configure TCP keepalive for host OS. + # Send 3 probes each 8 seconds, if the connection was idle + # for a 30 seconds. Consider it dead, if there was no responces + # during the check time frame, i.e. 30+3*8=54 seconds overall. + # (note: overall check time frame should be lower then + # nova_report_interval). + class { 'openstack::keepalive' : + stage => 'netconfig', + tcpka_time => '30', + tcpka_probes => '8', + tcpka_intvl => '3', + tcp_retries2 => '5', + } + + # setting kernel reserved ports + # defaults are 49000,35357,41055,58882 + class { 'openstack::reserved_ports': + stage => 'netconfig', + } + + # setting service down time and report interval + # to 60 and 180 for Nova respectively to allow kernel + # to kill dead connections + # (see zendesk #1158 as well) + $nova_report_interval = '60' + $nova_service_down_time = '180' + + $syslog_rserver = { + 'remote_type' => $syslog_hash['syslog_transport'], + 'server' => $syslog_hash['syslog_server'], + 'port' => $syslog_hash['syslog_port'], + } + if $syslog_hash['syslog_server'] != "" and $syslog_hash['syslog_port'] != "" and $syslog_hash['syslog_transport'] != "" { + $rservers = [$base_syslog_rserver, $syslog_rserver] + } else { + $rservers = [$base_syslog_rserver] + } + + if $use_syslog { + class { "::openstack::logging": + stage => 'first', + role => 'client', + show_timezone => true, + # log both locally include auth, and remote + log_remote => true, + log_local => true, + log_auth_local => true, + # keep four weekly log rotations, force rotate if 300M size have exceeded + rotation => 'weekly', + keep => '4', + # should be > 30M + limitsize => '300M', + # remote servers to send logs to + rservers => $rservers, + # should be true, if client is running at virtual node + virtual => str2bool($::is_virtual), + # Rabbit doesn't support syslog directly + rabbit_log_level => 'NOTICE', + debug => $debug, + } + } + + #case $role { + # /controller/: { $hostgroup = 'controller' } + # /swift-proxy/: { $hostgroup = 'swift-proxy' } + # /storage/:{ $hostgroup = 'swift-storage' } + # /compute/: { $hostgroup = 'compute' } + # /cinder/: { $hostgroup = 'cinder' } + # default: { $hostgroup = 'generic' } + #} + + # if $nagios != 'false' { + # class {'nagios': + # proj_name => $proj_name, + # services => [ + # 'host-alive','nova-novncproxy','keystone', 'nova-scheduler', + # 'nova-consoleauth', 'nova-cert', 'haproxy', 'nova-api', 'glance-api', + # 'glance-registry','horizon', 'rabbitmq', 'mysql', + # ], + # whitelist => ['127.0.0.1', $nagios_master], + # hostgroup => $hostgroup , + # } + # } + + # Workaround for fuel bug with firewall + firewall {'003 remote rabbitmq ': + sport => [ 4369, 5672, 15672, 41055, 55672, 61613 ], + source => $::fuel_settings['master_ip'], + proto => 'tcp', + action => 'accept', + require => Class['openstack::firewall'], + } + + firewall {'004 remote puppet ': + sport => [ 8140 ], + source => $master_ip, + proto => 'tcp', + action => 'accept', + require => Class['openstack::firewall'], + } + + class { 'puppet::pull' : + master_ip => $::fuel_settings['master_ip'], + } +} # OS_COMMON ENDS + + + +node default { + case $::fuel_settings['deployment_mode'] { + "singlenode": { + include "osnailyfacter::cluster_simple" + class {'os_common':} + class {'opnfv':} + } + "multinode": { + include "osnailyfacter::cluster_simple" + class {'os_common':} + class {'opnfv':} + } + /^(ha|ha_compact)$/: { + include "osnailyfacter::cluster_ha" + class {'os_common':} + class {'corosync::commitorder': stage=>'main'} + class {'opnfv':} + } + "rpmcache": { include osnailyfacter::rpmcache } + } +} diff --git a/fuel-build/f_osnaily/puppet/modules/osnailyfacter/examples/site.pp.orig b/fuel-build/f_osnaily/puppet/modules/osnailyfacter/examples/site.pp.orig new file mode 100644 index 0000000..330a699 --- /dev/null +++ b/fuel-build/f_osnaily/puppet/modules/osnailyfacter/examples/site.pp.orig @@ -0,0 +1,311 @@ +$fuel_settings = parseyaml($astute_settings_yaml) + +$openstack_version = { + 'keystone' => 'installed', + 'glance' => 'installed', + 'horizon' => 'installed', + 'nova' => 'installed', + 'novncproxy' => 'installed', + 'cinder' => 'installed', +} + +tag("${::fuel_settings['deployment_id']}::${::fuel_settings['environment']}") + +#Stages configuration +stage {'zero': } -> +stage {'first': } -> +stage {'openstack-custom-repo': } -> +stage {'netconfig': } -> +stage {'corosync_setup': } -> +stage {'openstack-firewall': } -> Stage['main'] + +class begin_deployment () +{ + $role = $::fuel_settings['role'] + notify { "***** Beginning deployment of node ${::hostname} with role $role *****": } +} + +class {'begin_deployment': stage => 'zero' } + +stage {'glance-image': + require => Stage['main'], +} + +if $::fuel_settings['nodes'] { + $nodes_hash = $::fuel_settings['nodes'] + $dns_nameservers=$::fuel_settings['dns_nameservers'] + $node = filter_nodes($nodes_hash,'name',$::hostname) + if empty($node) { + fail("Node $::hostname is not defined in the hash structure") + } + + $default_gateway = $node[0]['default_gateway'] + + $base_syslog_hash = $::fuel_settings['base_syslog'] + $syslog_hash = $::fuel_settings['syslog'] + + + $use_quantum = $::fuel_settings['quantum'] + if (!empty(filter_nodes($::fuel_settings['nodes'], 'role', 'ceph-osd')) or + $::fuel_settings['storage']['volumes_ceph'] or + $::fuel_settings['storage']['images_ceph'] or + $::fuel_settings['storage']['objects_ceph'] + ) { + $use_ceph = true + } else { + $use_ceph = false + } + + + if $use_quantum { + prepare_network_config($::fuel_settings['network_scheme']) + # + $internal_int = get_network_role_property('management', 'interface') + $internal_address = get_network_role_property('management', 'ipaddr') + $internal_netmask = get_network_role_property('management', 'netmask') + # + $public_int = get_network_role_property('ex', 'interface') + if $public_int { + $public_address = get_network_role_property('ex', 'ipaddr') + $public_netmask = get_network_role_property('ex', 'netmask') + } + # + $storage_address = get_network_role_property('storage', 'ipaddr') + $storage_netmask = get_network_role_property('storage', 'netmask') + } else { + $internal_address = $node[0]['internal_address'] + $internal_netmask = $node[0]['internal_netmask'] + $public_address = $node[0]['public_address'] + $public_netmask = $node[0]['public_netmask'] + $storage_address = $node[0]['storage_address'] + $storage_netmask = $node[0]['storage_netmask'] + $public_br = $node[0]['public_br'] + $internal_br = $node[0]['internal_br'] + $public_int = $::fuel_settings['public_interface'] + $internal_int = $::fuel_settings['management_interface'] + } +} + +if ($::fuel_settings['neutron_mellanox']) { + $mellanox_mode = $::fuel_settings['neutron_mellanox']['plugin'] +} else { + $mellanox_mode = 'disabled' +} + +# This parameter specifies the verbosity level of log messages +# in openstack components config. +# Debug would have set DEBUG level and ignore verbose settings, if any. +# Verbose would have set INFO level messages +# In case of non debug and non verbose - WARNING, default level would have set. +$verbose = true +$debug = $::fuel_settings['debug'] + +### Storage Settings ### +# Determine if any ceph parts have been asked for. +# This will ensure that monitors are set up on controllers, even if no +# ceph-osd roles during deployment + + +### Syslog ### +#TODO(bogdando) move logging options to astute.yaml +# Enable error messages reporting to rsyslog. Rsyslog must be installed in this case. +$use_syslog = $::fuel_settings['use_syslog'] ? { default=>true } +# Syslog facilities for main openstack services +# should vary (reserved usage) +# local1 is reserved for openstack-dashboard +$syslog_log_facility_glance = 'LOG_LOCAL2' +$syslog_log_facility_cinder = 'LOG_LOCAL3' +$syslog_log_facility_neutron = 'LOG_LOCAL4' +$syslog_log_facility_nova = 'LOG_LOCAL6' +$syslog_log_facility_keystone = 'LOG_LOCAL7' +# could be the same +# local0 is free for use +$syslog_log_facility_murano = 'LOG_LOCAL0' +$syslog_log_facility_heat = 'LOG_LOCAL0' +$syslog_log_facility_sahara = 'LOG_LOCAL0' +$syslog_log_facility_ceilometer = 'LOG_LOCAL0' + +$nova_rate_limits = { + 'POST' => 100000, + 'POST_SERVERS' => 100000, + 'PUT' => 1000, 'GET' => 100000, + 'DELETE' => 100000 +} +$cinder_rate_limits = { + 'POST' => 100000, + 'POST_SERVERS' => 100000, + 'PUT' => 100000, 'GET' => 100000, + 'DELETE' => 100000 +} + +### +class advanced_node_netconfig { + $sdn = generate_network_config() + notify {"SDN: ${sdn}": } +} + +case $::operatingsystem { + 'redhat' : { + $queue_provider = 'qpid' + $custom_mysql_setup_class = 'pacemaker_mysql' + } + default: { + $queue_provider='rabbitmq' + $custom_mysql_setup_class='galera' + } +} + +class os_common { + if ($::fuel_settings['neutron_mellanox']) and ($::fuel_settings['storage']['iser']) { + class { 'mellanox_openstack::iser_rename': + stage => 'zero', + storage_parent => $::fuel_settings['neutron_mellanox']['storage_parent'], + iser_interface_name => $::fuel_settings['neutron_mellanox']['iser_interface_name'], + } + } + class {"l23network::hosts_file": stage => 'netconfig', nodes => $nodes_hash } + class {'l23network': use_ovs=>$use_quantum, stage=> 'netconfig'} + if $use_quantum { + class {'advanced_node_netconfig': stage => 'netconfig' } + } else { + class {'osnailyfacter::network_setup': stage => 'netconfig'} + } + + class { 'openstack::firewall': + stage => 'openstack-firewall', + nova_vnc_ip_range => $::fuel_settings['management_network_range'], + } + + $base_syslog_rserver = { + 'remote_type' => 'tcp', + 'server' => $base_syslog_hash['syslog_server'], + 'port' => $base_syslog_hash['syslog_port'] + } + +### TCP connections keepalives and failover related parameters ### + # configure TCP keepalive for host OS. + # Send 3 probes each 8 seconds, if the connection was idle + # for a 30 seconds. Consider it dead, if there was no responces + # during the check time frame, i.e. 30+3*8=54 seconds overall. + # (note: overall check time frame should be lower then + # nova_report_interval). + class { 'openstack::keepalive' : + stage => 'netconfig', + tcpka_time => '30', + tcpka_probes => '8', + tcpka_intvl => '3', + tcp_retries2 => '5', + } + + # setting kernel reserved ports + # defaults are 49000,35357,41055,58882 + class { 'openstack::reserved_ports': + stage => 'netconfig', + } + + # setting service down time and report interval + # to 60 and 180 for Nova respectively to allow kernel + # to kill dead connections + # (see zendesk #1158 as well) + $nova_report_interval = '60' + $nova_service_down_time = '180' + + $syslog_rserver = { + 'remote_type' => $syslog_hash['syslog_transport'], + 'server' => $syslog_hash['syslog_server'], + 'port' => $syslog_hash['syslog_port'], + } + if $syslog_hash['syslog_server'] != "" and $syslog_hash['syslog_port'] != "" and $syslog_hash['syslog_transport'] != "" { + $rservers = [$base_syslog_rserver, $syslog_rserver] + } else { + $rservers = [$base_syslog_rserver] + } + + if $use_syslog { + class { "::openstack::logging": + stage => 'first', + role => 'client', + show_timezone => true, + # log both locally include auth, and remote + log_remote => true, + log_local => true, + log_auth_local => true, + # keep four weekly log rotations, force rotate if 300M size have exceeded + rotation => 'weekly', + keep => '4', + # should be > 30M + limitsize => '300M', + # remote servers to send logs to + rservers => $rservers, + # should be true, if client is running at virtual node + virtual => str2bool($::is_virtual), + # Rabbit doesn't support syslog directly + rabbit_log_level => 'NOTICE', + debug => $debug, + } + } + + #case $role { + # /controller/: { $hostgroup = 'controller' } + # /swift-proxy/: { $hostgroup = 'swift-proxy' } + # /storage/:{ $hostgroup = 'swift-storage' } + # /compute/: { $hostgroup = 'compute' } + # /cinder/: { $hostgroup = 'cinder' } + # default: { $hostgroup = 'generic' } + #} + + # if $nagios != 'false' { + # class {'nagios': + # proj_name => $proj_name, + # services => [ + # 'host-alive','nova-novncproxy','keystone', 'nova-scheduler', + # 'nova-consoleauth', 'nova-cert', 'haproxy', 'nova-api', 'glance-api', + # 'glance-registry','horizon', 'rabbitmq', 'mysql', + # ], + # whitelist => ['127.0.0.1', $nagios_master], + # hostgroup => $hostgroup , + # } + # } + + # Workaround for fuel bug with firewall + firewall {'003 remote rabbitmq ': + sport => [ 4369, 5672, 15672, 41055, 55672, 61613 ], + source => $::fuel_settings['master_ip'], + proto => 'tcp', + action => 'accept', + require => Class['openstack::firewall'], + } + + firewall {'004 remote puppet ': + sport => [ 8140 ], + source => $master_ip, + proto => 'tcp', + action => 'accept', + require => Class['openstack::firewall'], + } + + class { 'puppet::pull' : + master_ip => $::fuel_settings['master_ip'], + } +} # OS_COMMON ENDS + + + +node default { + case $::fuel_settings['deployment_mode'] { + "singlenode": { + include "osnailyfacter::cluster_simple" + class {'os_common':} + } + "multinode": { + include "osnailyfacter::cluster_simple" + class {'os_common':} + } + /^(ha|ha_compact)$/: { + include "osnailyfacter::cluster_ha" + class {'os_common':} + class {'corosync::commitorder': stage=>'main'} + } + "rpmcache": { include osnailyfacter::rpmcache } + } +} diff --git a/fuel-build/f_resolvconf/Makefile b/fuel-build/f_resolvconf/Makefile new file mode 100644 index 0000000..295fd0e --- /dev/null +++ b/fuel-build/f_resolvconf/Makefile @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf tmp + @rm -rf release + + +.PHONY: release +release: + @cp -Rvp puppet/modules/* ../release/puppet/modules diff --git a/fuel-build/f_resolvconf/README b/fuel-build/f_resolvconf/README new file mode 100644 index 0000000..77c6e6a --- /dev/null +++ b/fuel-build/f_resolvconf/README @@ -0,0 +1,35 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +Addition to generate resolv.conf separately for compute hosts and controller +hosts through Astute. + +The astute.yaml file should contain entries as those below to have them picked +up during deployment: + +opnfv: + dns: + compute: + - 100.100.100.2 + - 100.100.100.3 + controller: + - 100.100.100.102 + - 100.100.100.104 + +The suggested method for adding this information is to prepare for deployment +with the Fuel GUI or CLI, but before actually deploying: + +1. Download the current deployment for all hosts: fuel --env 1 deployment --default +2. Iterate through the hosts in "deployment_1" and add hosts configuration in + the above format to their respective yaml file. +3. Upload the modifed deployment information: fuel --env 1 deployment --upload + +After deploying, the additions will be included in /etc/astute.yaml of each +host. diff --git a/fuel-build/f_resolvconf/puppet/modules/opnfv/manifests/resolver.pp b/fuel-build/f_resolvconf/puppet/modules/opnfv/manifests/resolver.pp new file mode 100644 index 0000000..be4e67d --- /dev/null +++ b/fuel-build/f_resolvconf/puppet/modules/opnfv/manifests/resolver.pp @@ -0,0 +1,63 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Class: opnfv::resolver +# +# Add resolver content passed through astute.yaml into resolv.conf +# depending on the role +# +# Suitable yaml content: +# <begin> +# opnfv: +# dns: +# compute: +# - 100.100.100.2 +# - 100.100.100.3 +# controller: +# - 100.100.100.102 +# - 100.100.100.104 +# <end> +# +# +# + +class opnfv::resolver() +{ + if $::fuel_settings['role'] { + if $::fuel_settings['role'] == 'primary-controller' { + $role = 'controller' + } else { + $role = $::fuel_settings['role'] + } + + if ($::fuel_settings['opnfv'] + and $::fuel_settings['opnfv']['dns'] + and $::fuel_settings['opnfv']['dns'][$role]) { + $nameservers=$::fuel_settings['opnfv']['dns'][$role] + + file { '/etc/resolv.conf': + owner => root, + group => root, + mode => '0644', + content => template('opnfv/resolv.conf.erb'), + } +# /etc/resolv.conf is re-generated at each boot by resolvconf, so we +# need to store there as well. + file { '/etc/resolvconf/resolv.conf.d/head': + owner => root, + group => root, + mode => '0644', + content => template('opnfv/resolv.conf.erb'), + } + } + } +} + + diff --git a/fuel-build/f_resolvconf/puppet/modules/opnfv/templates/resolv.conf.erb b/fuel-build/f_resolvconf/puppet/modules/opnfv/templates/resolv.conf.erb new file mode 100644 index 0000000..7a29dca --- /dev/null +++ b/fuel-build/f_resolvconf/puppet/modules/opnfv/templates/resolv.conf.erb @@ -0,0 +1,15 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# Modified by OPNFV. +<% @nameservers.each do |ns| %>nameserver <%= ns %> +<% end -%> diff --git a/fuel-build/f_resolvconf/testing/README b/fuel-build/f_resolvconf/testing/README new file mode 100644 index 0000000..6846a8d --- /dev/null +++ b/fuel-build/f_resolvconf/testing/README @@ -0,0 +1,13 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +In order to test the functionality without performing a full deployment, +run "puppet apply" on the fake_init.pp which will call only the +opnfv::resolvconf class. diff --git a/fuel-build/f_resolvconf/testing/fake_init.pp b/fuel-build/f_resolvconf/testing/fake_init.pp new file mode 100644 index 0000000..496dcd2 --- /dev/null +++ b/fuel-build/f_resolvconf/testing/fake_init.pp @@ -0,0 +1,13 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +$fuel_settings = parseyaml($astute_settings_yaml) + +include opnfv::resolvconf diff --git a/fuel-build/fuel-main.patches b/fuel-build/fuel-main.patches new file mode 100644 index 0000000..a982e80 --- /dev/null +++ b/fuel-build/fuel-main.patches @@ -0,0 +1,104 @@ +diff --git a/docker/astute/Dockerfile b/docker/astute/Dockerfile +index 55f617a..cd05f19 100644 +--- a/docker/astute/Dockerfile ++++ b/docker/astute/Dockerfile +@@ -5,7 +5,7 @@ + FROM fuel/centos + MAINTAINER Matthew Mosesohn mmosesohn@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y ruby21-nailgun-mcagents sysstat ++RUN sleep 15; rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y ruby21-nailgun-mcagents sysstat + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/cobbler/Dockerfile b/docker/cobbler/Dockerfile +index 0c80abd..3a3d966 100644 +--- a/docker/cobbler/Dockerfile ++++ b/docker/cobbler/Dockerfile +@@ -5,7 +5,7 @@ + FROM fuel/centos + MAINTAINER Matthew Mosesohn mmosesohn@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*;echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y httpd cobbler dnsmasq xinetd tftp-server; ln -s /etc/dnsmasq.conf /etc/cobbler.dnsmasq.conf ++RUN sleep 15; rm -rf /etc/yum.repos.d/*;echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y httpd cobbler dnsmasq xinetd tftp-server; ln -s /etc/dnsmasq.conf /etc/cobbler.dnsmasq.conf + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/mcollective/Dockerfile b/docker/mcollective/Dockerfile +index e70e87d..d6554b7 100644 +--- a/docker/mcollective/Dockerfile ++++ b/docker/mcollective/Dockerfile +@@ -4,7 +4,7 @@ MAINTAINER Aleksandr Didenko adidenko@mirantis.com + + WORKDIR /root + +-RUN rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y sudo ruby21-mcollective ++RUN sleep 15; rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y sudo ruby21-mcollective + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/ostf/Dockerfile b/docker/ostf/Dockerfile +index 43f911e..8da9108 100644 +--- a/docker/ostf/Dockerfile ++++ b/docker/ostf/Dockerfile +@@ -5,7 +5,7 @@ + FROM fuel/centos + MAINTAINER Matthew Mosesohn mmosesohn@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*;echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo;yum clean all; yum --quiet install -y python-fuelclient supervisor postgresql-libs ++RUN sleep 15; rm -rf /etc/yum.repos.d/*;echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo;yum clean all; yum --quiet install -y python-fuelclient supervisor postgresql-libs + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile +index b2930db..63cc4c2 100644 +--- a/docker/postgres/Dockerfile ++++ b/docker/postgres/Dockerfile +@@ -3,7 +3,7 @@ FROM fuel/centos + + MAINTAINER Aleksandr Didenko adidenko@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo;yum clean all;yum --quiet install -y sudo ++RUN sleep 15; rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo;yum clean all;yum --quiet install -y sudo + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/rabbitmq/Dockerfile b/docker/rabbitmq/Dockerfile +index 201648f..4f3b67c 100644 +--- a/docker/rabbitmq/Dockerfile ++++ b/docker/rabbitmq/Dockerfile +@@ -3,7 +3,7 @@ + FROM fuel/centos + MAINTAINER Aleksandr Didenko adidenko@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y rabbitmq-server ++RUN sleep 15; rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all; yum --quiet install -y rabbitmq-server + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/rsync/Dockerfile b/docker/rsync/Dockerfile +index ef737bd..b6eefd1 100644 +--- a/docker/rsync/Dockerfile ++++ b/docker/rsync/Dockerfile +@@ -5,7 +5,7 @@ + FROM fuel/centos + MAINTAINER Matthew Mosesohn mmosesohn@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo;yum clean all;yum --quiet install -y ruby21-puppet xinetd rsync logrotate ++RUN sleep 15; rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo;yum clean all;yum --quiet install -y ruby21-puppet xinetd rsync logrotate + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh +diff --git a/docker/rsyslog/Dockerfile b/docker/rsyslog/Dockerfile +index 5efd623..8721b39 100644 +--- a/docker/rsyslog/Dockerfile ++++ b/docker/rsyslog/Dockerfile +@@ -2,7 +2,7 @@ FROM fuel/centos + + MAINTAINER Aleksandr Didenko adidenko@mirantis.com + +-RUN rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all;yum --quiet install -y anacron rsyslog ++RUN sleep 15; rm -rf /etc/yum.repos.d/*; echo -e "[nailgun]\nname=Nailgun Local Repo\nbaseurl=http://$(route -n | awk '/^0.0.0.0/ { print $2 }'):_PORT_/os/x86_64/\ngpgcheck=0" > /etc/yum.repos.d/nailgun.repo; yum clean all;yum --quiet install -y anacron rsyslog + + ADD etc /etc + ADD start.sh /usr/local/bin/start.sh diff --git a/fuel-build/install/apt-ftparchive-deb.conf b/fuel-build/install/apt-ftparchive-deb.conf new file mode 100644 index 0000000..1101ac9 --- /dev/null +++ b/fuel-build/install/apt-ftparchive-deb.conf @@ -0,0 +1,35 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +Dir { + ArchiveDir "."; +}; + +TreeDefault { + Directory "pool"; +}; + +BinDirectory "pool/main" { + Packages "dists/precise/main/binary-amd64/Packages"; + BinOverride "./indices/override.precise.main"; + ExtraOverride "./indices/override.precise.extra.main"; +}; + +Default { + Packages { + Extensions ".deb"; + Compress ". gzip"; + }; +}; + +Contents { + Compress "gzip"; +}; + diff --git a/fuel-build/install/apt-ftparchive-release.conf b/fuel-build/install/apt-ftparchive-release.conf new file mode 100644 index 0000000..0252882 --- /dev/null +++ b/fuel-build/install/apt-ftparchive-release.conf @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +APT::FTPArchive::Release::Origin "Ubuntu"; +APT::FTPArchive::Release::Label "Ubuntu"; +APT::FTPArchive::Release::Suite "precise"; +APT::FTPArchive::Release::Version "12.04"; +APT::FTPArchive::Release::Codename "precise"; +APT::FTPArchive::Release::Architectures "amd64"; +APT::FTPArchive::Release::Components "main"; +APT::FTPArchive::Release::Description "Ubuntu Precise 12.04 LTS"; diff --git a/fuel-build/install/install.sh b/fuel-build/install/install.sh new file mode 100755 index 0000000..823bcd9 --- /dev/null +++ b/fuel-build/install/install.sh @@ -0,0 +1,447 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +my_exit() { + rc=$? + + cd /tmp + + if [ -n "$TMP_HOSTMOUNT" ]; then + if [ -d "$TMP_HOSTMOUNT" ]; then + fusermount -u $TMP_HOSTMOUNT + rmdir $TMP_HOSTMOUNT + fi + fi + + if [ -d "$TMP_OLDISO" ]; then + fusermount -u $TMP_OLDISO + rmdir $TMP_OLDISO + fi + + if [ -f "$CONF" ]; then + rm $CONF + fi + + if [ -d "$TMP_ISOPUPPET" ]; then + rm -Rf $TMP_ISOPUPPET + fi +} + +get_deb_name() { + ar p $1 control.tar.gz | tar xzO ./control | grep "^Package:.* " | sed 's/.* //' + if [ $PIPESTATUS -ne 0 ]; then + echo "Error in get_deb_name($1)" + exit 1 + fi +} + +get_deb_rev() { + ar p $1 control.tar.gz | tar xzO ./control | grep "^Version:.* " | sed 's/.* //' + if [ $PIPESTATUS -ne 0 ]; then + echo "Error in get_deb_rev($1)" + exit 1 + fi +} + + +# Added logic for ".orig" files: +# 1. Is there an .orig file for the new file? +# 2. If the file is not present in base ISO -> Error! +# 3. If the file is changed i base ISO -> Error! (need manual rebase) +# 4. If there is no .orig file, but file is present in base ISO: Error! +verify_orig_files() { + OLDDIR=$1 + NEWDIR=$2 + + pushd $NEWDIR >/dev/null + for f in $(find * -type f -name '*.orig') + do + origfile=$NEWDIR/$f + oldfile=$OLDDIR/$(echo $f | sed 's/.orig$//') + newfile=$NEWDIR/$(echo $f | sed 's/.orig$//') + + origfile=${newfile}.orig + # If no corresponding base file, error + if [ ! -f $oldfile ]; then + printf "\n\n\n\n" + echo "Error: found ${newfile} but no" + echo "Error: ${oldfile}" + echo "Error: Manual rebase is needed!" + printf "\n\n\n\n" + exit 1 + fi + + # If orig file differs from base file, error + if ! diff -q $origfile $oldfile > /dev/null; then + printf "\n\n\n\n" + echo "Error: $origfile differs from" + echo "Error: $oldfile!" + echo "Error: Manual rebase is needed!" + printf "\n\n\n\n" + exit 1 + fi + + done + + + # Check that there we're not overwriting oldfiles without having a ".orig" copy + for f in $(find * -type f ! -name '*.orig') + do + newfile=$NEWDIR/$(echo $f | sed 's/.orig$//') + origfile=${newfile}.orig + oldfile=$OLDDIR/$f + if [ -f $oldfile ]; then + if [ ! -f $origfile ]; then + printf "\n\n\n\n" + echo "Error: Will overwrite $oldfile, but there is no" + echo "Error: $origfile!" + echo "Error: You need to create the `basename $origfile`!" + printf "\n\n\n\n" + exit 1 + fi + fi + done + + + popd >/dev/null +} + +prep_make_live() { + DEST=$TMP_HOSTMOUNT + REPO=$DEST/var/www/nailgun/ubuntu/fuelweb/x86_64 + echo "Live install" + ssh-copy-id root@$FUELHOST + sshfs root@1${FUELHOST}:/ $TMP_HOSTMOUNT + + if [ -f $REPO/dists/precise/main/binary-amd64/Packages.backup ]; then + echo "Error - found backup file for Packages!" + exit 1 + fi + + if [ -f $REPO/dists/precise/main/binary-amd64/Packages.gz.backup ]; then + echo "Error - found backup file for Packages.gz!" + exit 1 + fi + + if [ -f $REPO/dists/precise/Release.backup ]; then + echo "Error - found backup file for Release!" + exit 1 + fi + + if [ -d $DEST/etc/puppet.backup ]; then + echo "Error - found backup file for Puppet!" + exit 1 + fi + + cp $REPO/dists/precise/main/binary-amd64/Packages $REPO/dists/precise/main/binary-amd64/Packages.backup + cp $REPO/dists/precise/main/binary-amd64/Packages.gz $REPO/dists/precise/main/binary-amd64/Packages.gz.backup + cp $REPO/dists/precise/Release $REPO/dists/precise/Release.backup + cp -Rvp $DEST/etc/puppet $DEST/etc/puppet.backup +} + +post_make_live() { + echo "Installing into Puppet:" + cd $TOP/release/puppet/modules + for dir in * + do + echo " $dir" + cp -Rp $dir $DEST/etc/puppet/modules + done +} + +make_live() { + prep_make_live + copy_packages + post_make_live +} + + +prep_make_iso() { + DEST=$TOP/newiso + REPO=$DEST/ubuntu + echo "Making ISO..." + echo "Unpack of old ISO..." + if [ -d newiso ]; then + chmod -R 755 newiso + rm -rf newiso + fi + mkdir newiso + fusermount -u $TMP_OLDISO 2>/dev/null || cat /dev/null + fuseiso -p $ORIGISO $TMP_OLDISO + sleep 1 + cd $TMP_OLDISO + find . | cpio -pd $TOP/newiso + cd .. + fusermount -u $TMP_OLDISO + rm -Rf $TMP_OLDISO + chmod -R 755 $TOP/newiso +} + +make_iso_image() { + echo "Making ISO..." + cd $DEST + find . -name TRANS.TBL -exec rm {} \; + rm -rf rr_moved + + mkisofs --quiet -r -V "$VOLUMEID" -publisher "$PUBLISHER" \ + -p `git rev-parse --verify HEAD` -J -R -b isolinux/isolinux.bin \ + -no-emul-boot \ + -boot-load-size 4 -boot-info-table \ + --hide-rr-moved \ + -x "lost+found" -o $NEWISO . + + isoinfo -d -i $NEWISO +} + +# iso_copy_puppet: Create a new puppet-slave.tgz for the iso +iso_copy_puppet() { + echo "Installing into Puppet..." + mkdir -p $TMP_ISOPUPPET/release/puppet + cd $TMP_ISOPUPPET/release/puppet + tar xzf $DEST/puppet-slave.tgz + cd $TOP/release/puppet/modules + + verify_orig_files $TMP_ISOPUPPET/release/puppet $TOP/release/puppet/modules + # Remove all .orig files before copying as they now have been verfied + find $TOP/release/puppet/modules -type f -name '*.orig' -exec rm {} \; + + for dir in $TOP/release/puppet/modules/* + do + echo " $dir" + cp -Rp $dir $TMP_ISOPUPPET/release/puppet + done + cd $TMP_ISOPUPPET/release/puppet + + + tar czf $DEST/puppet-slave.tgz . + cd $TOP + rm -Rf $TMP_ISOPUPPET +} + +# iso_modify_image: Add/patch files in the ISO root +iso_modify_image () { + # TODO: Add logic for ".orig" files (hey! make a function!), which would look + # something like: + # 1. Is there an .orig file? + # 2. If the file is not present in origiso -> Error exit + # 3. If the file is changed in origiso -> Error exit (need manual rebase) + # 4. Otherwise continue, but don't copy orig file (or maybe we should?) + # ... and corresponding reverse logic: + # 1. If there is no .orig file, but file is present in origiso -> Error exit + echo "Modify ISO files (wild copy)..." + + verify_orig_files $DEST $TOP/release/isoroot + # Remove all .orig files before copying as they now have been verfied + find $TOP/release/isoroot -type f -name '*.orig' -exec rm {} \; + + cd $TOP/release/isoroot + cp -Rvp . $DEST +} + +make_iso() { + prep_make_iso + copy_packages + iso_copy_puppet + iso_modify_image + make_iso_image +} + +copy_packages() { + echo "Copying Debian packages..." + cd $TOP/release/packages/ubuntu/pool/main + for deb in `ls -1 | grep '\.deb$'` + do + echo " $deb" + cp $deb $REPO/pool/main + done + + echo "Running Fuel package patch file" + pushd $REPO/pool/main > /dev/null + + for line in `cat $TOP/apply_patches | grep -v "^#" | grep -v "^$"`; do + echo "Line is $line" + ref=`echo $line | cut -d '>' -f 1` + origpkg=`echo $line| cut -d '>' -f 2` + url=`echo $line | cut -d '>' -f 3` + + if [ -z "$origpkg" ]; then + echo "Error: No origpkg for patching" + exit 1 + fi + + if [ -z "$url" ]; then + echo "Error: No url for patching" + exit 1 + fi + + if [ -z "$ref" ]; then + echo "Error: No reference text for patching" + exit 1 + fi + + echo "CM: Patching Fuel package for $ref" | tee -a $REPORTFILE + echo "CM: Replacing package $origpkg with $url" | tee -a $REPORTFILE + oldrev=`get_deb_rev $origpkg` + rm $origpkg + wget --quiet $url + topkg=`basename $url` + echo "CM: MD5 of new package:" | tee -a $REPORTFILE + md5sum $topkg | tee -a $REPORTFILE + + patchname=`get_deb_name $topkg` + patchrev=`get_deb_rev $topkg` + echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE + $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE + if [ $PIPESTATUS -ne 0 ]; then + exit 1 + fi + done + + printf "Done running Fuel patch file\n\n" + + echo "Running add packages file" + for line in `cat $TOP/add_opnfv_packages | grep -v "^#" | grep -v "^$"`; do + echo "Line is $line" + ref=`echo $line | cut -d '>' -f 1` + origpkg=`echo $line| cut -d '>' -f 2` + url=`echo $line | cut -d '>' -f 3` + + if [ -z "$origpkg" ]; then + echo "Error: No origpkg for patching" + exit 1 + fi + + if [ -z "$url" ]; then + echo "Error: No url for patching" + exit 1 + fi + + if [ -z "$ref" ]; then + echo "Error: No reference text for patching" + exit 1 + fi + + if [ "$origpkg" != "NONE" ]; then + echo "CM: Patching added package for $ref" | tee -a $REPORTFILE + echo "CM: Replacing package $origpkg with $url" | tee -a $REPORTFILE + oldrev=`get_deb_rev $origpkg` + rm $origpkg + else + echo "CM: Adding previoulsy uninstalled package for $ref" tee -a $REPORTFILE + fi + wget --quiet $url + topkg=`basename $url` + echo "CM: MD5 of new package:" | tee -a $REPORTFILE + md5sum $topkg | tee -a $REPORTFILE + if [ "$origpkg" != "NONE" ]; then + patchname=`get_deb_name $topkg` + patchrev=`get_deb_rev $topkg` + echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE + $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE + if [ $PIPESTATUS -ne 0 ]; then + exit 1 + fi + fi + done + printf "Done running add packages file\n\n" + + popd > /dev/null + + if [ -f $TOP/patch-packages/release/patch-replacements ]; then + echo "Applying package patches" | tee -a $REPORTFILE + pushd $REPO/pool/main > /dev/null + printf "\n\n" | tee -a $REPORTFILE + for line in `cat $TOP/patch-packages/release/patch-replacements` + do + frompkg=`echo $line | cut -d ">" -f 1` + topkg=`echo $line | cut -d ">" -f 2` + echo "CM: Applying patch to $frompkg" | tee -a $REPORTFILE + echo "CM: New package rev after patch: $topkg" | tee -a $REPORTFILE + + if [ ! -f $frompkg ]; then + echo "Error: Can't find $frompkg in repo" + exit 1 + else + oldrev=`get_deb_rev $frompkg` + echo "Removing $frompkg from repo" + rm $frompkg + fi + + if [ ! -f $TOP/patch-packages/release/packages/$topkg ]; then + echo "Error: Can't find $topkg in patch release" + exit 1 + else + echo "Adding $topkg to repo" + cp $TOP/patch-packages/release/packages/$topkg . + fi + + patchname=`get_deb_name $topkg` + patchrev=`get_deb_rev $topkg` + echo "Correcting dependencies towards $patchname rev $patchrev - old rev $oldrev" | tee -a $REPORTFILE + $TOP/patch-packages/tools/correct_deps $patchname $oldrev $patchrev | tee -a $REPORTFILE + if [ $PIPESTATUS -ne 0 ]; then + exit 1 + fi + done + popd > /dev/null + fi + + echo "Generating metadata..." + pushd $REPO > /dev/null + + # The below methods are from 15B + APT_REL_CONF="$TOP/install/apt-ftparchive-release.conf" + APT_DEB_CONF="$TOP/install/apt-ftparchive-deb.conf" + + apt-ftparchive -c "${APT_REL_CONF}" generate "${APT_DEB_CONF}" + + # Fuel also needs this index file + cat dists/precise/main/binary-amd64/Packages | \ + awk '/^Package:/{pkg=$2} + /^Version:/{print pkg ": \"" $2 "\""}' > ubuntu-versions.yaml + cp ubuntu-versions.yaml $DEST + + apt-ftparchive -c "${APT_REL_CONF}" release dists/precise/ > dists/precise/Release + gzip -9cf dists/precise/Release > dists/precise/Release.gz + + popd > /dev/null + +} + + +############################################################################# + +trap my_exit EXIT + +CONF=`mktemp /tmp/XXXXXXX` +MODE=$1 +TOP=`pwd` + +if [ $MODE = "iso" ]; then + PUBLISHER="OPNFV" + TMP_OLDISO=`mktemp -d /tmp/XXXXXXX` + TMP_ISOPUPPET=`mktemp -d /tmp/XXXXXXX` + ORIGISO=$2 + NEWISO=$3 + VOLUMEID="$4 $5" + REPORTFILE="${NEWISO}.txt" + if [ ! -f $ORIGISO ]; then + echo "Can't find original MOS 5.1 iso at $ORIGISO" + rm $CONF + exit 1 + fi + + make_iso +else + echo "Unknown mode: $MODE" + exit 1 +fi diff --git a/fuel-build/install/uninstall.sh b/fuel-build/install/uninstall.sh new file mode 100755 index 0000000..36b8884 --- /dev/null +++ b/fuel-build/install/uninstall.sh @@ -0,0 +1,79 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +my_exit() { + cd /tmp + if [ -d "$MOUNT" ]; then + fusermount -u $MOUNT + rmdir $MOUNT + fi +} +trap my_exit EXIT + +echo "Live uninstall is currently disabled as it is not tested" +exit 1 + +TOP=`pwd` +MOUNT=`mktemp -d /tmp/XXXXXXX` +ssh-copy-id root@10.20.0.2 +sshfs root@10.20.0.2:/ $MOUNT + +DEST=$MOUNT +REPO=$DEST/var/www/nailgun/ubuntu/fuelweb/x86_64 + +cd $REPO +if [ ! -f $REPO/dists/precise/main/binary-amd64/Packages.backup ]; then + echo "Error - didn't find backup file for Packages!" + exit 1 +fi + +if [ ! -f $REPO/dists/precise/main/binary-amd64/Packages.gz.backup ]; then + echo "Error - didn't find backup file for Packages.gz!" + exit 1 +fi + +if [ ! -f $REPO/dists/precise/Release.backup ]; then + echo "Error - didn't find backup file for Release!" + exit 1 +fi + +if [ ! -f $DEST/etc/puppet/manifests/site.pp.backup ]; then + echo "Error - didn't find backup file for site.pp!" + exit 1 +fi + +echo "Removing Debian packages:" +cd $TOP/release/pool/main +for deb in *.deb +do + echo " $deb" + rm -Rf $REPO/pool/main/$deb +done +cd $REPO + +echo "Removing Puppet modules:" +cd $TOP/puppet/modules +for dir in * +do + echo " $dir" + rm -Rf $DEST/etc/puppet/modules/$dir +done +cd $REPO + +echo "Restoring backups of datafiles" + +rm -f $REPO/dists/precise/main/binary-amd64/Packages $REPO/dists/precise/main/binary-amd64/Packages.gz +rm -f $REPO/dists/precise/Release $DEST/etc/puppet/manifests/site.pp +mv $REPO/dists/precise/main/binary-amd64/Packages.backup $REPO/dists/precise/main/binary-amd64/Packages +mv $REPO/dists/precise/main/binary-amd64/Packages.gz.backup $REPO/dists/precise/main/binary-amd64/Packages.gz +mv $REPO/dists/precise/Release.backup $REPO/dists/precise/Release +mv $DEST/etc/puppet/manifests/site.pp.backup $DEST/etc/puppet/manifests/site.pp diff --git a/fuel-build/patch-packages/Makefile b/fuel-build/patch-packages/Makefile new file mode 100644 index 0000000..56bbc89 --- /dev/null +++ b/fuel-build/patch-packages/Makefile @@ -0,0 +1,26 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +SUBDIRS := python-nova +SUBCLEAN = $(addsuffix .clean,$(SUBDIRS)) + +.PHONY: $(SUBDIRS) $(SUBCLEAN) clean +$(SUBDIRS): + @mkdir -p release/packages + ORIGISO=$(ORIGISO) VERSION=$(VERSION) $(MAKE) -C $@ -f Makefile release + +release: $(SUBDIRS) + @echo $(ORIGISO) + +clean: $(SUBCLEAN) + @rm -Rf release + +$(SUBCLEAN): %.clean: + $(MAKE) -C $* -f Makefile clean diff --git a/fuel-build/patch-packages/python-nova/Makefile b/fuel-build/patch-packages/python-nova/Makefile new file mode 100644 index 0000000..9bcff70 --- /dev/null +++ b/fuel-build/patch-packages/python-nova/Makefile @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf package + @rm -rf *.deb + @rm -rf patch-replacements + @rm -rf .package + +.PHONY: release +release: + ../tools/deb_unpack python-nova_2014.1.3-fuel5.1.1~mira3_all.deb $(ORIGISO) + patch -s -p0 < nova-console.patch + ../tools/deb_pack $(VERSION) + @cp *.deb ../release/packages + @cat patch-replacements >> ../release/patch-replacements diff --git a/fuel-build/patch-packages/python-nova/nova-console.patch b/fuel-build/patch-packages/python-nova/nova-console.patch new file mode 100644 index 0000000..a05af3b --- /dev/null +++ b/fuel-build/patch-packages/python-nova/nova-console.patch @@ -0,0 +1,17 @@ +--- package/usr/share/pyshared/nova/virt/libvirt/driver.py.org ++++ package/usr/share/pyshared/nova/virt/libvirt/driver.py +@@ -3280,10 +3280,10 @@ + # client app is connected. Thus we can't get away + # with a single type=pty console. Instead we have + # to configure two separate consoles. +- consolelog = vconfig.LibvirtConfigGuestSerial() +- consolelog.type = "file" +- consolelog.source_path = self._get_console_log_path(instance) +- guest.add_device(consolelog) ++ #consolelog = vconfig.LibvirtConfigGuestSerial() ++ #consolelog.type = "file" ++ #consolelog.source_path = self._get_console_log_path(instance) ++ #guest.add_device(consolelog) + + consolepty = vconfig.LibvirtConfigGuestSerial() + consolepty.type = "pty" diff --git a/fuel-build/patch-packages/tools/correct_deps b/fuel-build/patch-packages/tools/correct_deps new file mode 100755 index 0000000..cfb7d53 --- /dev/null +++ b/fuel-build/patch-packages/tools/correct_deps @@ -0,0 +1,78 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +patch_package () { + deb=$1 + pkgdep=$2 + newrev=$3 + + + tmpdir=`mktemp -d /tmp/patchXXXXX` + + cp $deb $tmpdir + pushd $tmpdir > /dev/null + + mkdir -p repack + dpkg -x $deb repack + + mkdir -p repack/DEBIAN + dpkg -e $deb repack/DEBIAN + + + pushd repack/DEBIAN > /dev/null + + echo "Before: `cat control | grep '^Depends:'`" + sed -i "s/$pkgdep (\([^ ]*\) [^)]*)/$pkgdep (\1 $newrev)/" control + echo "After: `cat control | grep '^Depends:'`" + popd > /dev/null + + fakeroot dpkg-deb --build repack + + popd > /dev/null + + cp $tmpdir/repack.deb $deb + rm -Rf $tmpdir +} + +# Name of package for which to check dependencies to +PKGDEP=$1 +# The old revision of the package in question +OLDREV=$2 +# The new revision of the package in question +NEWREV=$3 + +if [ -z "$PKGDEP" ]; then + echo "No package dependency name" + exit 1 +fi + +if [ -z "$OLDREV" ]; then + echo "No old rev" + exit 1 +fi + +if [ -z "$NEWREV" ]; then + echo "No new rev" + exit 1 +fi + + +for deb in *.deb +do + ar p $deb control.tar.gz | tar xzO ./control | grep -q "^Depends:.* ${PKGDEP} ([^ ]* ${OLDREV})" + if [ $? -eq 0 ]; then + name=`ar p $deb control.tar.gz | tar xzO ./control | grep "^Package:.* " | sed 's/.* //'` + echo "**** Changing dependencies line in $deb ($name) ****" + patch_package $deb $PKGDEP $NEWREV + fi +done + diff --git a/fuel-build/patch-packages/tools/deb_pack b/fuel-build/patch-packages/tools/deb_pack new file mode 100755 index 0000000..f07a15d --- /dev/null +++ b/fuel-build/patch-packages/tools/deb_pack @@ -0,0 +1,63 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +my_exit() { + + if [ -d "$ISOROOT" ]; then + fusermount -u $ISOROOT + fi +} + +ME=$(basename $0) + +trap my_exit EXIT + +REV=$1 +if [ -z "$REV" ]; then + echo "$ME: Error - no revision info provided" + exit 1 +fi + +if [ ! -d package ]; then + echo "$ME: Error - package directory does not exist" + exit 1 +fi + +echo "Stepping revision number to $REV" + + +revision_step () +{ + REV=$1 + + sed -i "s/^\(Version:.*$\)/\1-eri$REV/" package/DEBIAN/control +} + +md5sum_gen () +{ + pushd package + find * -type f | grep -v "^DEBIAN/" | xargs md5sum | sort > DEBIAN/md5sums + popd +} + +revision_step $REV +md5sum_gen +fakeroot dpkg-deb --build package +PKGNAME=`grep "^Package: " package/DEBIAN/control | awk '{ print $2 }'` +PKGREV=`grep "^Version: " package/DEBIAN/control | awk '{ print $2 }'` +mv package.deb ${PKGNAME}_${PKGREV}.deb + +ORIGPKG=`cat .package` + +# Add patch into file read by install.sh +echo "$ORIGPKG>${PKGNAME}_${PKGREV}.deb" > patch-replacements + diff --git a/fuel-build/patch-packages/tools/deb_unpack b/fuel-build/patch-packages/tools/deb_unpack new file mode 100755 index 0000000..aaa60b7 --- /dev/null +++ b/fuel-build/patch-packages/tools/deb_unpack @@ -0,0 +1,58 @@ +#!/bin/bash -e +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +my_exit() { + + if [ -d "$ISOROOT" ]; then + fusermount -u $ISOROOT + fi +} + +ME=$(basename $0) + +trap my_exit EXIT + + +if [ -z "$1" ]; then + echo "$ME: Error - No package specified" + exit 1 +fi + +if [ -z "$2" ]; then + echo "$ME: Error - No ISO path specified" + exit 1 +fi + +DEB=$1 +ORIGISO=$2 +DEST=package + +if [ -e $DEST -o -d $DEST ]; then + echo "$ME: Error - $DEST already exists" + exit 1 +fi + +ISOROOT=`mktemp -d /tmp/XXXXXXX` +fuseiso -p $ORIGISO $ISOROOT +sleep 1 + +if [ ! -f $ISOROOT/ubuntu/pool/main/$DEB ];then + echo "Could not find package $DEB in source ISO!" +fi + +mkdir -p $DEST +dpkg -x $ISOROOT/ubuntu/pool/main/$DEB $DEST + +mkdir -p $DEST/DEBIAN +dpkg -e $ISOROOT/ubuntu/pool/main/$DEB $DEST/DEBIAN + +echo $DEB > .package
\ No newline at end of file diff --git a/fuel-build/patch-packages/tr_example/Makefile b/fuel-build/patch-packages/tr_example/Makefile new file mode 100644 index 0000000..07ce28a --- /dev/null +++ b/fuel-build/patch-packages/tr_example/Makefile @@ -0,0 +1,30 @@ +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +TOP := $(shell pwd) + +.PHONY: all +all: + +.PHONY: clean +clean: + @rm -rf package + @rm -rf *.deb + @rm -rf patch-replacements + @rm -rf .package + +.PHONY: release +release: + ../tools/deb_unpack python-oslo.messaging_1.3.0-fuel5.1~mira4_all.deb $(ORIGISO) + @mkdir -p package/etc + @echo "Hello, world" > package/etc/hello.txt + ../tools/deb_pack $(VERSION) + @cp *.deb ../release/packages + @cat patch-replacements >> ../release/patch-replacements |