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.
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.
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.
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
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.
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