solar/bootstrap/README.md
Bogdan Dobrelya 467d84c620 Add centos7 docker support
* Separate OSTYPE specific tasks/files.
* Keep only common tasks and files in the
playbooks dir.

TODO pxe case to be working for centos as well
note, the cmtools.sh installs ansible 2.0.1.0
  in centos7, while we have 2.0.0.2 for ubuntu trusty
note, the base.yaml installs python-keystoneclient
  1:1.3.0-1.el7 from kilo-2 (no juno for centos7),
  while for ubuntu we have one from juno
note, there is no pygraphviz for centos7, see also
  https://bugs.launchpad.net/fuel/+bug/1510884

Closes-bug: #1548851

Change-Id: Icec5637f9242104322d1104725f9f132d1ca16f0
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
2016-03-02 11:16:23 +01:00

4.3 KiB

Solar image building

Atlas Vagrant Boxes (Ubuntu 14.04) | Docker Image (Ubuntu 14.04)

Building on the host OS

To build for a Virtualbox, install Packer (https://www.packer.io/):

$ cp vagrant-settings.yaml_defaults vagrant-settings.yaml
$ sed -i 's/master_image:.*$/master_image: solar-master/g' ./vagrant-settings.yaml
$ sed -i 's/slaves_image:.*$/slaves_image: solar-master/g' ./vagrant-settings.yaml
$ cd bootstrap
$ packer build -only=virtualbox-iso solar-master.json
$ mv solar-master-virtualbox.box ../solar-master.box
$ cd ..
$ vagrant box add solar-master solar-master.box --provider virtualbox
$ vagrant up --provider virtualbox

To build for a libvirt, replace the following commands:

$ packer build -only=qemu solar-master.json
$ mv solar-master-libvirt.box ../solar-master.box
$ cd ..
$ vagrant box add solar-master solar-master.box --provider libvirt
$ vagrant up --provider libvirt

Note, this requires a vagrant-libvirt plugin.

To build for a docker (Ubuntu based), use:

# docker pull ubuntu:trusty
$ packer build -only=docker solar-master-docker.json

And for the Centos based:

# docker pull centos:centos7
$ packer build -only=docker solar-master-centos-docker.json
$ cd ..
$ vagrant up --provider docker

Note, this requires a vagrant-triggers plugin. The minimal docker 1.10.0 version is required.

Building in the docker container

Here is an example builder docker image how-to guide for the Fedora:latest. Note, that you will need the docker >=1.10.0 and we assume the current user to be included into the docker group to skip sudoing.

First, get a builder container up and ruinning:

$ docker pull fedora
$ docker run -v /sys/fs/cgroup:/sys/fs/cgroup \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v <your_path_to_clonned_solar_repo>:/solar \
  -v /tmp:/tmp --privileged -h builder -it fedora bash

Adjust the your_path_to_clonned_solar_repo as apropriate. You can access build artifacts by that path later as well. These mountpoints pass the host OS docker services to nested containers and also resolve packer tmp dir mount issues for nested dockers. Note, for the packer >=0.9.0, use -v /tmp:/root/.packer.d/tmp instead.

Second, setup Docker and misc build requirements:

# yum install sudo autoconf gcc-c++ curl wget unzip libvirt qemu
# curl -sSL https://get.docker.com/ | sh

Next, install Packer to the builder container:

# PACKER_VERSION=0.8.6
# mkdir -p /opt/packer && cd /opt/packer
# wget --no-verbose https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip
# unzip packer_${PACKER_VERSION}_linux_amd64.zip -d /opt/packer && rm -f packer_${PACKER_VERSION}_linux_amd64.zip
# cd /usr/bin && ln -s /opt/packer/* . && cd /root

You may want to commit and tag here to get a clean state for the builder container.

At last, you can build images with packer. For example:

# cd /solar/bootstrap
# export PATH=/usr/bin:$PATH
# PACKER_LOG=1 headless=true packer build -only=docker -color=false solar-master-ubuntu-docker.json
# PACKER_LOG=1 headless=true packer build -only=docker -color=false solar-master-centos-docker.json

Note, the custom path workarounds conflicting Fedora's /usr/sbin/packer and the packer binary we want to use here.

You may as well reuse the pre-built builder container, for example: TODO(bogdando) replace to the solar-project

$ docker pull bogdando/solar-packer-builder
$ docker run -v /sys/fs/cgroup:/sys/fs/cgroup \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v <your_path_to_clonned_solar_repo>:/solar \
  -v /tmp:/tmp --privileged -h builder -it bogdando/solar-packer-builder bash
# cd /solar/bootstrap
# export PATH=/usr/bin:$PATH
# PACKER_LOG=1 headless=true packer build -only=qemu -color=false solar-master.json

Troubleshooting

If Vagrant throws error about vboxsf try this:

$ vagrant plugin install vagrant-vbguest

(see https://github.com/shiguredo/packer-templates/issues/16).

If you're rebuilding the same box, make sure Vagrant reimports it:

$ vagrant box remove solar-master

Note that you can also set PACKER_LOG=debug and/or VAGRANT_LOG=debug the shell environment variables to get more information.