Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from jdeathe/develop
Browse files Browse the repository at this point in the history
Release changes for 1.0.0 release.
  • Loading branch information
jdeathe authored Sep 28, 2016
2 parents 76fffa4 + 579d1ca commit da23d4e
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CentOS-7-Minimal-Cloud-Init-virtualbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,12 @@
"SSH_USER_SUDO={{user `ssh_user_sudo`}}"
],
"scripts": [
"scripts/install/nfs-utils.sh",
"scripts/install/tuned-virtual-guest.sh",
"scripts/install/cloud-init.sh",
"scripts/cloud-init/disable-locale-module.sh",
"scripts/cloud-init/add-datasource-list.sh",
"scripts/cloud-init/add-preserve-hostname.sh",
"scripts/common/ifcfg-name-to-device.sh",
"scripts/common/sshd-config-non-root-key-auth.sh",
"scripts/common/sudoers-default-not-requiretty.sh",
Expand Down
1 change: 1 addition & 0 deletions CentOS-7-Minimal-virtualbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"SSH_USER_SUDO={{user `ssh_user_sudo`}}"
],
"scripts": [
"scripts/install/nfs-utils.sh",
"scripts/install/tuned-virtual-guest.sh",
"scripts/common/ifcfg-name-to-device.sh",
"scripts/common/sshd-config-non-root-key-auth.sh",
Expand Down
Empty file modified CentOS-7.Vagrantfile
100644 → 100755
Empty file.
152 changes: 97 additions & 55 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
export SHELL := /usr/bin/env bash
export PATH := ${PATH}

define USAGE
Usage: make [options] [target] ...
Usage: VARIABLE="VALUE" make [options] -- [target] ...

This Makefile allows you to build a Vagrant box file from a template and
with Packer.

Targets:
all Combines targets build and install.
build Runs the packer build job. This is the
default target.
download-iso Download the source ISO image - required to
build the Virtual Machine. Packer should
be capable of downloading the source however
this feature can fail.
help Show this help.
install Used to install the Vagrant box with a
unique name based on the sha1 sum of
the box file. It will output a minimal
Vagrantfile source that can be used for
testing the build before release.

Variables (default value):
- BOX_DEBUG (false) Set to true to build in packer debug mode.
- BOX_LANG (en_US) The locale code, used to build a box with
an additonal locale to en_US. e.g. en_GB
- BOX_OUTPUT_PATH Ouput directory path - where the final build
(./builds) artifacts are placed.
- BOX_VARIANT (Minimal) Used to specify box build variants. i.e.
- Minimal
- Minimal-Cloud-Init
- BOX_VERSION_RELEASE The CentOS-7 Minor Release number. Note: A
(7.2.1511) corresponding template is required.

endef

BOX_NAMESPACE := jdeathe
BOX_PROVIDOR := virtualbox
BOX_ARCH_PATTERN := ^(x86_64|i386)$
BOX_ARCH := x86_64

BOX_ARCH ?= x86_64
BOX_DEBUG ?= false
BOX_LANG ?= en_US
BOX_OUTPUT_PATH ?= ./builds
Expand All @@ -19,35 +55,35 @@ COLOUR_RESET := \033[0m
CHARACTER_STEP := ==>
PREFIX_STEP := $(shell \
printf -- '%s ' \
"$(CHARACTER_STEP)"; \
"$(CHARACTER_STEP)"; \
)
PREFIX_SUB_STEP := $(shell \
printf -- ' %s ' \
"$(CHARACTER_STEP)"; \
"$(CHARACTER_STEP)"; \
)
PREFIX_STEP_NEGATIVE := $(shell \
printf -- '%b%s%b' \
"$(COLOUR_NEGATIVE)" \
"$(PREFIX_STEP)" \
"$(COLOUR_RESET)"; \
"$(COLOUR_NEGATIVE)" \
"$(PREFIX_STEP)" \
"$(COLOUR_RESET)"; \
)
PREFIX_STEP_POSITIVE := $(shell \
printf -- '%b%s%b' \
"$(COLOUR_POSITIVE)" \
"$(PREFIX_STEP)" \
"$(COLOUR_RESET)"; \
"$(COLOUR_POSITIVE)" \
"$(PREFIX_STEP)" \
"$(COLOUR_RESET)"; \
)
PREFIX_SUB_STEP_NEGATIVE := $(shell \
printf -- '%b%s%b' \
"$(COLOUR_NEGATIVE)" \
"$(PREFIX_SUB_STEP)" \
"$(COLOUR_RESET)"; \
"$(COLOUR_NEGATIVE)" \
"$(PREFIX_SUB_STEP)" \
"$(COLOUR_RESET)"; \
)
PREFIX_SUB_STEP_POSITIVE := $(shell \
printf -- '%b%s%b' \
"$(COLOUR_POSITIVE)" \
"$(PREFIX_SUB_STEP)" \
"$(COLOUR_RESET)"; \
"$(COLOUR_POSITIVE)" \
"$(PREFIX_SUB_STEP)" \
"$(COLOUR_RESET)"; \
)

.DEFAULT_GOAL := build
Expand Down Expand Up @@ -91,15 +127,52 @@ vagrant := $(shell type -p vagrant)
vboxmanage := $(shell type -p vboxmanage)

.PHONY: \
_prerequisites \
_require-supported-architecture \
_usage \
all \
build \
install \
prerequisites \
require-supported-architecture
help \
install

_prerequisites:
ifeq ($(vboxmanage),)
$(error "Please install VirtualBox. (https://www.virtualbox.org/)")
endif

ifeq ($(vagrant),)
$(error "Please install Vagrant. (https://www.vagrantup.com)")
endif

ifeq ($(packer),)
$(error "Please install Packer. (https://www.packer.io)")
endif

ifeq ($(curl),)
$(error "Please install the curl package.")
endif

ifeq ($(gzip),)
$(error "Please install the gzip package.")
endif

ifeq ($(openssl),)
$(error "Please install the openssl package.")
endif

_require-supported-architecture:
@ if [[ ! $(BOX_ARCH) =~ $(BOX_ARCH_PATTERN) ]]; then \
echo "$(PREFIX_STEP_NEGATIVE)Unsupported architecture ($(BOX_ARCH))" >&2; \
echo "$(PREFIX_SUB_STEP)Supported values: x86_64|i386." >&2; \
exit 1; \
fi

_usage:
@: $(info $(USAGE))

all: prerequisites | build
all: _prerequisites | build

build: prerequisites require-supported-architecture download-iso
build: _prerequisites _require-supported-architecture | download-iso
@ echo "$(PREFIX_STEP)Building $(PACKER_BUILD_NAME)"
@ if [[ ! -f $(PACKER_VAR_FILE) ]]; then \
echo "$(PREFIX_SUB_STEP_NEGATIVE)Missing var-file: $(PACKER_VAR_FILE)" >&2; \
Expand Down Expand Up @@ -133,7 +206,7 @@ build: prerequisites require-supported-architecture download-iso
fi; \
fi

download-iso: prerequisites require-supported-architecture
download-iso: _prerequisites _require-supported-architecture
@ if [[ ! -f isos/$(BOX_ARCH)/$(SOURCE_ISO_NAME) ]]; then \
if [[ ! -d ./isos/$(BOX_ARCH) ]]; then \
mkdir -p ./isos/$(BOX_ARCH); \
Expand All @@ -154,7 +227,9 @@ download-iso: prerequisites require-supported-architecture
fi; \
fi

install: prerequisites require-supported-architecture
help: _usage

install: _prerequisites _require-supported-architecture
$(eval $@_box_name := $(shell \
echo "$(PACKER_BUILD_NAME)" \
| awk '{ print tolower($$1); }' \
Expand All @@ -179,36 +254,3 @@ install: prerequisites require-supported-architecture
echo "$(PREFIX_STEP_NEGATIVE)No box file."; \
echo "$(PREFIX_SUB_STEP)Try running: make build"; \
fi

prerequisites:
ifeq ($(vboxmanage),)
$(error "Please install VirtualBox. (https://www.virtualbox.org/)")
endif

ifeq ($(vagrant),)
$(error "Please install Vagrant. (https://www.vagrantup.com)")
endif

ifeq ($(packer),)
$(error "Please install Packer. (https://www.packer.io)")
endif

ifeq ($(curl),)
$(error "Please install the curl package.")
endif

ifeq ($(gzip),)
$(error "Please install the gzip package.")
endif

ifeq ($(openssl),)
$(error "Please install the openssl package.")
endif

require-supported-architecture:
@ if [[ ! $(BOX_ARCH) =~ $(BOX_ARCH_PATTERN) ]]; then \
echo "$(PREFIX_STEP_NEGATIVE)Unsupported architecture ($(BOX_ARCH))" >&2; \
echo "$(PREFIX_SUB_STEP)Supported values: x86_64|i386." >&2; \
exit 1; \
fi

24 changes: 24 additions & 0 deletions scripts/cloud-init/add-datasource-list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -e

/bin/echo '--> Adding cloud-init datasources_list.'
/usr/bin/tee \
/etc/cloud/cloud.cfg.d/10_datasource_list.cfg \
1> /dev/null \
<<-EOF
datasource_list: [
NoCloud,
ConfigDrive,
OpenNebula,
Azure,
AltCloud,
OVF,
MAAS,
GCE,
CloudStack,
OpenStack,
Ec2,
CloudSigma,
SmartOS,
None,
]
EOF
15 changes: 15 additions & 0 deletions scripts/cloud-init/add-datasource-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

/bin/echo '--> Adding cloud-init datasource settings.'
/usr/bin/tee \
/etc/cloud/cloud.cfg.d/10_datasource.cfg \
1> /dev/null \
<<-EOF
datasource:
CloudStack:
timeout: 15
max_wait: 30
Ec2:
timeout: 15
max_wait: 30
EOF
10 changes: 10 additions & 0 deletions scripts/cloud-init/add-preserve-hostname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -e

/bin/echo '--> Adding cloud-init preserve_hostname settings.'
/usr/bin/tee \
/etc/cloud/cloud.cfg.d/10_preserve_hostname.cfg \
1> /dev/null \
<<-EOF
preserve_hostname: true
EOF

6 changes: 6 additions & 0 deletions scripts/cloud-init/disable-locale-module.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

/bin/echo '--> Disabling cloud-init locale module.'
/bin/sed -i \
-e 's~^\([ ]*\)\(- locale\)$~\1#\2~' \
/etc/cloud/cloud.cfg
5 changes: 5 additions & 0 deletions scripts/install/nfs-utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

/bin/echo '--> Install nfs-utils.'
/usr/bin/yum -y install \
nfs-utils

0 comments on commit da23d4e

Please sign in to comment.