Initial ci-management upload
[ci-management.git] / packer / provision / basebuild.sh
1 #!/bin/bash
2
3 # vim: ts=4 sw=4 sts=4 et tw=72 :
4
5 rh_systems() {
6     # Install python dependencies
7     yum install -y python-{devel,virtualenv,setuptools,pip}
8
9     # Build dependencies for Python packages
10     yum install -y openssl-devel mysql-devel gcc
11
12     # Autorelease support packages
13     yum install -y xmlstarlet
14
15     # Additional libraries for Python ncclient
16     yum install -y libxml2 libxslt libxslt-devel libffi libffi-devel
17
18     # Packer builds happen from the centos flavor images
19     PACKERDIR=$(mktemp -d)
20     # disable double quote checking
21     # shellcheck disable=SC2086
22     cd $PACKERDIR
23     wget https://releases.hashicorp.com/packer/0.12.2/packer_0.12.2_linux_amd64.zip
24     unzip packer_0.12.2_linux_amd64.zip -d /usr/local/bin/
25     # rename packer to avoid conflicts with cracklib
26     mv /usr/local/bin/packer /usr/local/bin/packer.io
27
28     # cleanup from the installation
29     # disable double quote checking
30     # shellcheck disable=SC2086
31     rm -rf $PACKERDIR
32     # cleanup from previous install process
33     if [ -d /tmp/packer ]
34     then
35         rm -rf /tmp/packer
36     fi
37 }
38
39 ubuntu_systems() {
40     # Install python dependencies
41     apt-get install -y python-{dev,virtualenv,setuptools,pip}
42
43     # Build dependencies for Python packages
44     apt-get install -y libssl-dev libmysqlclient-dev gcc
45
46     # Additional libraries for Python ncclient
47     apt-get install -y wget unzip python-ncclient
48 }
49
50 all_systems() {
51     echo 'No common distribution configuration to perform'
52 }
53
54 echo "---> Detecting OS"
55 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
56
57 case "${ORIGIN}" in
58     fedora|centos|redhat)
59         echo "---> RH type system detected"
60         rh_systems
61     ;;
62     ubuntu)
63         echo "---> Ubuntu system detected"
64         ubuntu_systems
65     ;;
66     *)
67         echo "---> Unknown operating system"
68     ;;
69 esac
70
71 # execute steps for all systems
72 all_systems