Copy Foreman deploy logic from bgs_vagrant repo
[genesis.git] / foreman / ci / bootstrap.sh
1 #!/usr/bin/env bash
2
3 #bootstrap script for installing/running Khaleesi in Foreman/QuickStack VM
4 #author: Tim Rozet (trozet@redhat.com)
5 #
6 #Uses Vagrant and VirtualBox
7 #VagrantFile uses bootsrap.sh which Installs Khaleesi
8 #Khaleesi will install and configure Foreman/QuickStack
9 #
10 #Pre-requisties:
11 #Target system should be Centos7
12 #Ensure the host's kernel is up to date (yum update)
13
14 ##VARS
15 reset=`tput sgr0`
16 blue=`tput setaf 4`
17 red=`tput setaf 1`
18 green=`tput setaf 2`
19
20 ##END VARS
21
22
23 ##install EPEL
24 if ! yum repolist | grep "epel/"; then
25   if ! rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm; then
26     printf '%s\n' 'bootstrap.sh: Unable to configure EPEL repo' >&2
27     exit 1
28   fi
29 else
30   printf '%s\n' 'bootstrap.sh: Skipping EPEL repo as it is already configured.'
31 fi
32
33 ##install python,gcc,git
34 if ! yum -y install python-pip python-virtualenv gcc git; then
35   printf '%s\n' 'bootstrap.sh: Unable to install python,gcc,git packages' >&2
36   exit 1
37 fi
38
39 ##Install sshpass
40 if ! yum -y install sshpass; then
41   printf '%s\n' 'bootstrap.sh: Unable to install sshpass' >&2
42   exit 1
43 fi
44
45 cd /opt
46
47 echo "Cloning khaleesi to /opt"
48
49 if [ ! -d khaleesi ]; then
50   if ! git clone -b opnfv https://github.com/trozet/khaleesi.git; then
51     printf '%s\n' 'bootstrap.sh: Unable to git clone khaleesi' >&2
52     exit 1
53   fi
54 fi
55
56 if ! pip install ansible; then
57   printf '%s\n' 'bootstrap.sh: Unable to install ansible' >&2
58   exit 1
59 fi
60
61 if ! pip install requests; then
62   printf '%s\n' 'bootstrap.sh: Unable to install requests python package' >&2
63   exit 1
64 fi
65
66
67 cd khaleesi
68
69 cp ansible.cfg.example ansible.cfg
70
71 echo "Completed Installing Khaleesi"
72
73 cd /opt/khaleesi/
74
75 ansible localhost -m setup -i local_hosts
76
77 ./run.sh --no-logs --use /vagrant/opnfv_ksgen_settings.yml playbooks/opnfv.yml