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 # Git is required by the ansible-galaxy tool when installing roles
14 sudo yum install -y ansible git
16 # Install the latest release of ODL's Ansible role from Ansible Galaxy
17 # The `ansible-galaxy` tool was installed by Ansible's RPM
18 # NB: This could also be done by locally installing ODL's role, then
19 # giving Packer it's local path via the role_paths argument to the
20 # ansible-local provisioner. However, that approach requires a
21 # step not managed by Packer (installing the role, which shouldn't
22 # be checked into VCS, locally). Not only does that break the
23 # model of being able to build directly from what's in VCS, it
24 # breaks pushes to do automated remote builds. We can/should only
25 # push what's version controlled, and we can't install the role
26 # pre-build manually on the remote host, so we have to let Packer
27 # own the ODL role install.
28 # NB: The simple `ansible-galaxy install <role>[,version]` syntax doesn't
29 # support versions other than those on Ansible Galaxy, so tags. The
30 # `ansible-galaxy` command will accept more complex versions via a
31 # requirements.yml file, however. Using that to support branches,
32 # commits, and tags. See: http://stackoverflow.com/a/30176625/1011749
33 # TODO: Pass this version var from packer_vars.json
34 ansible_version="origin/master"
35 cat > /tmp/requirements.yml << EOM
37 src: git+https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git
38 version: $ansible_version
40 sudo ansible-galaxy install -r /tmp/requirements.yml
42 # Clean up to save space
43 # NB: The point of this script is to leave Ansible and ODL's role installed
44 # and ready for use by the Packer Ansible provisioner, so we can't clean
45 # up that space here. Need to clean it up in a post-install cleanup script.
46 sudo yum remove -y git