Role Detail


RedHat/CentOS configuration for Packer.
Type Ansible
Minimum Ansible Version 1.8
Installation $ ansible-galaxy install geerlingguy.packer-rhel
Last Commit 2017-02-28 15:33:03 PM UTC
Last Imported 2017-02-28 16:39:04 PM UTC
Version History
Version Release Date
1.3.0 2017-02-28 15:33:03 PM
1.2.2 2017-01-12 15:44:03 PM
1.2.1 2016-11-16 18:29:06 PM
1.2.0 2016-10-30 18:49:06 PM
1.1.3 2016-03-25 19:31:07 PM
1.1.2 2016-03-04 05:11:05 AM
1.1.1 2015-08-02 04:33:04 AM
1.1.0 2015-06-24 15:11:03 PM
1.0.7 2015-06-23 04:44:04 AM
1.0.6 2015-04-28 19:02:07 PM
1.0.5 2015-03-24 20:57:08 PM
1.0.4 2014-10-31 21:50:09 PM
1.0.3 2014-10-31 17:34:05 PM
1.0.2 2014-10-31 16:50:04 PM
1.0.1 2014-10-30 22:33:10 PM
1.0.0 2014-03-28 18:08:06 PM
Supported Platforms
Platform Version
EL 6
EL 7
Last 10 Imports
Completed Status
2017-02-28 16:39:04 PM UTC SUCCESS
2017-02-28 15:35:03 PM UTC SUCCESS
2017-01-22 03:38:03 AM UTC SUCCESS
2017-01-12 15:51:03 PM UTC SUCCESS
2017-01-12 15:47:03 PM UTC SUCCESS
2017-01-12 10:45:10 AM UTC SUCCESS
2016-11-16 18:30:06 PM UTC SUCCESS
2016-11-02 20:21:08 PM UTC SUCCESS
2016-09-14 03:49:03 AM UTC SUCCESS
2016-03-25 19:33:07 PM UTC SUCCESS

Ansible Role: Packer RHEL/CentOS Configuration for Vagrant VirtualBox

Build Status

This role configures RHEL/CentOS (either minimal or full install) in preparation for it to be packaged as part of a .box file for Vagrant/VirtualBox deployment using Packer.

The role may be made more flexible in the future, so it could work with other Linux flavors and/or other Packer builders besides VirtualBox, but I'm currently only focused on VirtualBox, since the main use case right now is developer VMs.


Prior to running this role via Packer, you need to make sure Ansible is installed via a shell provisioner, and that preliminary VM configuration (like adding a vagrant user to the appropriate group and the sudoers file) is complete, generally by using a Kickstart installation file (e.g. ks.cfg) with Packer. An example array of provisioners for your Packer .json template would be something like:

"provisioners": [
    "type": "shell",
    "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
    "script": "scripts/"
    "type": "ansible-local",
    "playbook_file": "ansible/main.yml",
    "role_paths": [

The files should contain, at a minimum:


#!/bin/bash -eux
# Add the EPEL repository, and install Ansible.
rpm -ivh
yum -y install ansible python-setuptools


- hosts: all
  sudo: yes
  gather_facts: yes
    - geerlingguy.packer-rhel

You might also want to add another shell provisioner to run cleanup, erasing free space using dd, but this is not required (it will just save a little disk space in the Packer-produced .box file).

If you'd like to add additional roles, make sure you add them to the role_paths array in the template .json file, and then you can include them in main.yml as you normally would. The Ansible configuration will be run over a local connection from within the Linux environment, so all relevant files need to be copied over to the VM; configuratin for this is in the template .json file. Read more: Ansible Local Provisioner.

Role Variables




Example Playbook

- hosts: all
    - { role: geerlingguy.packer-rhel }



Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.