-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-ansible.sh
executable file
·97 lines (83 loc) · 2.12 KB
/
run-ansible.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
set -e
usage="Ansible Script for Setting Up RACE VM
$(basename "$0") [-h] [-i INSTALL_FILES] -f FLOW_NAME
where:
-h Show this help text
-f Flow name (default: opensource) [open-source | isi]
-i Install files folder
-c Set Cadence License File
-s Set Synopsys License File
-t Set Synopsys ID
"
if [ $# -le 1 ]; then
echo "$usage"
exit 1
fi
# default variable values
ANSIBLE_DIR=/tmp/race-ansible
FLOW_FILE=open-source.yml
TOP_DIR=/race/install-files
CADENCE_LICENSE_FILE="[email protected]"
SYNOPSYS_LICENSE_FILE="[email protected]"
SYNOPSYS_ID=0
# parsing options
while getopts ':h:f:i:c:t:s:' option; do
case "$option" in
h) echo "$usage"
exit
;;
f) FLOW_FILE=$OPTARG.yml
;;
i) TOP_DIR=$OPTARG
;;
c) CADENCE_LICENSE_FILE=$OPTARG
;;
s) SYNOPSYS_LICENSE_FILE=$OPTARG
;;
t) SYNOPSYS_ID=$OPTARG
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ ! -f $FLOW_FILE ]; then
echo -e "Unsupported flow. File $FLOW_FILE does not exist"
exit 1
fi
# install ansible
mkdir -p $ANSIBLE_DIR/
cd $ANSIBLE_DIR/
tar xzf $TOP_DIR/ansible.tar.gz
cd $ANSIBLE_DIR/
yum config-manager --set-enabled PowerTools
if ! (which ansible-playbook) >/dev/null 2>&1; then
# prereqs
# yum -y install \
# PyYAML \
# python-jinja2 \
# python-paramiko \
# python-setuptools \
# python-six \
# python2-crytography \
# sshpass \
# git
yum -y install python3 python3-virtualenv python3-pip
# install ansible
# rpm -Uvh packages/rpm/ansible-2.7.1-1.el7.ans.noarch.rpm
pip3 install ansible
fi
# exporting environment variables
export ANSIBLE_INSTALL_SOURCE_DIR=$TOP_DIR
export CADENCE_LICENSE_FILE=$CADENCE_LICENSE_FILE
export SYNOPSYS_LICENSE_FILE=$SYNOPSYS_LICENSE_FILE
export SYNOPSYS_ID=$SYNOPSYS_ID
# running ansible
ansible-playbook --verbose --connection=local ${FLOW_FILE}