Helm charts for supporting clustering in ODL
[integration/packaging.git] / packer / provision / config_ansible_fedora.sh
1 #!/usr/bin/env bash
2 # Install Ansible, as required for Packer's ansible-local provisioner.
3 # Also installs EPEL (dependency).
4
5 # Echo commands as they are run
6 set -x
7
8 # Install Ansible, required for Packer's ansible-local provisioner
9 # Git is required by the ansible-galaxy tool when installing roles
10 # Ansible will fail if selinux is enabled but bindings not installed
11 sudo dnf install -y ansible git python-dnf libselinux-python
12
13 # Install the latest release of ODL's Ansible role from Ansible Galaxy
14 # The `ansible-galaxy` tool was installed by Ansible's RPM
15 # NB: This could also be done by locally installing ODL's role, then
16 #     giving Packer it's local path via the role_paths argument to the
17 #     ansible-local provisioner. However, that approach requires a
18 #     step not managed by Packer (installing the role, which shouldn't
19 #     be checked into VCS, locally). Not only does that break the
20 #     model of being able to build directly from what's in VCS, it
21 #     breaks pushes to do automated remote builds. We can/should only
22 #     push what's version controlled, and we can't install the role
23 #     pre-build manually on the remote host, so we have to let Packer
24 #     own the ODL role install.
25 # NB: The simple `ansible-galaxy install <role>[,version]` syntax doesn't
26 #     support versions other than those on Ansible Galaxy, so tags. The
27 #     `ansible-galaxy` command will accept more complex versions via a
28 #     requirements.yml file, however. Using that to support branches,
29 #     commits, and tags. See: http://stackoverflow.com/a/30176625/1011749
30 # TODO: Pass this version var from packer_vars.json
31 ansible_version="origin/master"
32 cat > /tmp/requirements.yml << EOM
33 - name: opendaylight
34   src: git+https://git.opendaylight.org/gerrit/p/integration/packaging/ansible-opendaylight.git
35   version: $ansible_version
36 EOM
37 cat /tmp/requirements.yml
38 # Ansible runs as non-root, so don't install as root or role will not be found
39 ansible-galaxy install -r /tmp/requirements.yml
40
41 # Clean up to save space
42 # NB: The point of this script is to leave Ansible and ODL's role installed
43 #     and ready for use by the Packer Ansible provisioner, so we can't clean
44 #     up that space here. Need to clean it up in a post-install cleanup script.
45 sudo dnf remove -y git
46 sudo dnf clean all -y
47 sudo rm -rf /tmp/*