-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovisioning.sh
More file actions
143 lines (116 loc) · 5.54 KB
/
Copy pathprovisioning.sh
File metadata and controls
143 lines (116 loc) · 5.54 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# ===================================================================
# provisioning.sh
# DESCRIPTION =======================================================
# Provisioning file for a Centos7 Vagrant host.
# config.vm.box = "geerlingguy/centos7" # https://app.vagrantup.com/geerlingguy/boxes/centos7
# config.vm.box_version = "1.2.7" #
#
# AUTHOR ============================================================
# Daniel Alejandro Macuare Tombolini
# 2>&1 > /dev/null # Redirects stderr to stdout to only see errors and then redirects stdout to /dev/null to show nothing else.
# =================================================================== # Variables # ===================================================================
green_bold="\033[1;32;49m"
red_bold="\033[1;31;49m"
normal="\033[0m"
VENV_NAME="py3_ansible3"
#ANSIBLE_TAG="v2.5.4"
ANSIBLE_TAG="v2.6.0"
ANS_REPO="/vagrant_data/ansible/" # Point to this location on your Vagrantfile.
USER_DIR="/home/vagrant/"
APT_PACKS=(
epel-release
vim
yamllint
git
yum-utils #https://janikarhunen.fi/how-to-install-python-3-6-1-on-centos-7.html
https://centos7.iuscommunity.org/ius-release.rpm
python36u
python36u-pip
python36u-devel
dh-autoreconf # Requirement to install libyaml
http://rpms.remirepo.net/enterprise/remi-release-7.rpm # Requirement to install PHP7.2 via YUM
)
# =================================================================== # Functions # ===================================================================
INST_PACK(){
for PCKGS in "$@"; do
printf "$green_bold[INSTALLING]$normal - Packet: $red_bold$PCKGS$normal\n"
sudo yum --quiet -y install $PCKGS > /dev/null 2>&1
# printf "\n\n"
done
}
# =================================================================== # Initial setup for Ansible # ===================================================================
printf "$normal\n\n############################################################################$normal\n"
printf "$normal\t\tINSTALLING YUM PACKAGES TO RUN ANSIBLE$normal\n"
printf "$normal############################################################################$normal\n"
INST_PACK "${APT_PACKS[@]}"
printf "\n\n"
#Pre task to install PHP72 with Ansible
printf "$green_bold[ENABLING]\t$normal - Repo: $red_bold Remi repo for php-72 $normal"
sudo yum-config-manager --enable remi-php72
# First Update after yum packets
printf "$green_bold[UPDATING]\t\t$normal - $red_bold YUM (This may take some minutes) $normal"
# sudo yum --quiet -y update
sudo yum -y update > /dev/null 2>&1
printf "\n"
# LibYaml - https://github.com/yaml/libyaml
printf "$green_bold[GIT CLONING]$normal\t - Packet: $red_bold Libyaml $normal"
git clone https://github.com/yaml/libyaml.git > /dev/null 2>&1
printf "$green_bold[INSTALLING]$normal\t - Packet: $red_bold Libyaml $normal"
cd libyaml/
./bootstrap > /dev/null 2>&1
./configure > /dev/null 2>&1
make > /dev/null 2>&1
make install > /dev/null 2>&1
printf "$green_bold[REMOVING]$normal\t\t - Packet: $red_bold Libyaml Repository$normal"
cd ..
rm -rf libyaml/
printf "\n\n"
# PIP 3.6
printf "$green_bold[UPGRADING]$normal\t - Packet: $red_bold Pip3.6 $normal"
sudo pip3.6 install --upgrade pip 2>&1 > /dev/null
printf "\n\n"
# VENV
printf "$green_bold[INSTALLING]$normal\t - Packet: $red_bold Virtualenv $normal"
pip3 install virtualenv > /dev/null 2>&1
printf "$green_bold[CREATING]$normal\t\t - Packet: $red_bold Virtualenv Name: $VENV_NAME$normal"
virtualenv -p python3.6 $USER_DIR$VENV_NAME/ > /dev/null 2>&1
cd $USER_DIR$VENV_NAME/
source bin/activate > /dev/null 2>&1
printf "\n\n"
# ANSIBLE - Through GIT - Requires Python >= 3.5
printf "$green_bold[GIT CLONING]$normal\t - Packet: $red_bold Ansible $ANSIBLE_TAG$normal"
git clone https://github.com/ansible/ansible.git > /dev/null 2>&1
cd ansible/
git checkout $ANSIBLE_TAG > /dev/null 2>&1
printf "$green_bold[INSTALLING]$normal\t - Packet: $red_bold Ansible $ANSIBLE_TAG$normal"
python3.6 setup.py install > /dev/null 2>&1
# ANSIBLE - Through PIP
# printf "$green_bold[PIP INSTALLING]$normal - Packet: $red_bold Ansible $ANSIBLE_TAG$normal"
# pip3.6 install ansible
# printf "\n\n"
printf "$green_bold[REMOVING]\t$normal\t - Packet: $red_bold Ansible Repository $ANSIBLE_TAG$normal"
cd ..
rm -rf ansible/
printf "\n\n"
printf "$green_bold[PERMISSIONS]$normal\t - chown -R: $red_bold$VENV_NAME is now owned by vagrant:vagrant$normal"
cd ..
chown -R vagrant:vagrant $VENV_NAME/ 2>&1 > /dev/null
printf "\n\n"
printf "$normal############################################################################$normal\n"
printf "$normal\t\tANSIBLE - Centos7 PROVISIONING$normal\n"
printf "$normal############################################################################$normal\n"
cp -R $ANS_REPO $USER_DIR$VENV_NAME/ansible/
cd $USER_DIR$VENV_NAME/ansible
ansible-playbook main.yaml
printf "\n\n"
# ===================================================================
# YUM UPGRADE/UPDATE
# ===================================================================
printf "$green_bold[UPDATING]$normal\t - $red_bold YUM $normal"
sudo yum -y update > /dev/null 2>&1
printf "$green_bold[UPGRADING]$normal - $red_bold YUM $normal"
sudo yum --quiet -y upgrade > /dev/null 2>&1
printf "$normal\n\n############################################################################$normal\n"
printf "$normal\t\tINITIAL SETUP IS FINISHED$normal\n"
printf "$normal############################################################################$normal"