2 # Install Ansible, as required for Packer's ansible-local provisioner.
3 # Also installs EPEL (dependency).
5 # Echo commands as they are run
8 # Install EPEL for access to Ansible repo
9 # EPEL is okay to bake in, good minimization vs functionality trade-off
10 sudo yum install -y epel-release
12 # Install Ansible, required for Packer's ansible-local provisioner
13 # Recent versions of Ansible require ansible-playbook
14 # Git is required by the ansible-galaxy tool when installing roles
15 sudo yum install -y ansible ansible-playbook git
17 # Install the latest release of ODL's Ansible role from Ansible Galaxy
18 # The `ansible-galaxy` tool was installed by Ansible's RPM
19 # NB: This could also be done by locally installing ODL's role, then
20 # giving Packer it's local path via the role_paths argument to the
21 # ansible-local provisioner. However, that approach requires a
22 # step not managed by Packer (installing the role, which shouldn't
23 # be checked into VCS, locally). Not only does that break the
24 # model of being able to build directly from what's in VCS, it
25 # breaks pushes to do automated remote builds. We can/should only
26 # push what's version controlled, and we can't install the role
27 # pre-build manually on the remote host, so we have to let Packer
28 # own the ODL role install.
29 # NB: The simple `ansible-galaxy install <role>[,version]` syntax doesn't
30 # support versions other than those on Ansible Galaxy, so tags. The
31 # `ansible-galaxy` command will accept more complex versions via a
32 # requirements.yml file, however. Using that to support branches,
33 # commits, and tags. See: http://stackoverflow.com/a/30176625/1011749
34 # TODO: Pass this version var from packer_vars.json
35 ansible_version="origin/master"
36 cat > /tmp/requirements.yml << EOM
38 src: https://github.com/dfarrell07/ansible-opendaylight
39 version: $ansible_version
41 sudo ansible-galaxy install -r /tmp/requirements.yml
43 # Clean up to save space
44 # NB: The point of this script is to leave Ansible and ODL's role installed
45 # and ready for use by the Packer Ansible provisioner, so we can't clean
46 # up that space here. Need to clean it up in a post-install cleanup script.
47 sudo yum remove -y git