Skip to content

timmackinnon/virt-image-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This repository contains instructions and code to configure a Packer based image builder machine which can be used to build qemu images for KVM or Xen virtual machines or Vagrant box files for VirtualBox.

This code is geared towards Linux and the RedHat family of operating systems - CentOS, Oracle Linux or RedHat Enterprise Linux (e.g. a system using the yum package manager). The code uses Ansible to configure the image builder machine.

Once configured, this image builder machine can then be used to build virtualization images.

Does your machine support virtualization?

First things first ... we need to check if your system supports virtualization:

$ egrep "(svm|vmx)" /proc/cpuinfo

If your system supports virtualization, you will get either vmx (Intel-VT technology) or svm (AMD-V support) in the output.

Setting up Ansible

Ansible can be installed with your favourite package manager or you can install it in a Python Virtual Environment using the requirements.txt file in this repository.

Set up Ansible in a Python virtualenv (requires Python3)

If Python3 is the default Python version on the machine where this code will run:

virtualenv venv
venv/bin/pip install -r requirements.txt

If Python3 is not the default Python version on the machine where this code will run:

virtualenv --python=<path to Python3> venv
venv/bin/pip install -r requirements.txt

Check that ansible has been installed correctly:

venv/bin/ansible --version

Configuring your hosts file

Uncomment the host entry and modify it to reflect the IP address or hostname of the target host. For example:

[builders]
#builder0 ansible_host=a.b.c.d

could be changed to:

[builders]
builder0 ansible_host=1.1.1.1

Modify the ansible_ssh_user to reflect the user that will be used to connect to the target host. For example:

[builders:vars]
ansible_ssh_user=FIXME

could be changed to:

[builders:vars]
ansible_ssh_user=builder

NOTE - ansible_ssh_user is assumed to be a privileged user that can install packages, etc. - either root or a user with passwordless sudo to root.

Modify the ansible_ssh_private_key_file entry, if not using your default RSA key, to point to the key that will be used to connect to the target host.

Run the setup.yml playbook

venv/bin/ansible-playbook setup.yml

This playbook will perform the following set of granular operations:

  • install the @Base group
  • install the @Core group
  • install the @Platform Development group
  • install the @Additional Development group
  • install the @Virtualization Hypervisor group
  • install the @^Server with GUI environment
  • install a set of miscellaneous packages outlined in the group_vars/all.yml file
    • included in this miscellaneous set of packages is screen and tigervnc
  • install VirtualBox
    • version defined in group_vars/all.yml file
  • install Vagrant
    • version defined in group_vars/all.yml file
  • install Packer and set up packer in the PATH of the ansible_ssh_user via the ~/.bash_profile file
    • version defined in group_vars/all.yml file

About

Set up a Packer based virtualization image builder machine

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors