-
Notifications
You must be signed in to change notification settings - Fork 22
/
automation.sh
69 lines (53 loc) · 1.99 KB
/
automation.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
#!/bin/bash
# Variaveis
LOGSTASH_VERSION="7.13.1"
LOGSTASH_URL="https://artifacts.elastic.co/downloads/logstash/logstash-${LOGSTASH_VERSION}-amd64.deb"
DEPS_PACKAGES="apt-transport-https ca-certificates curl gnupg-agent software-properties-common python3 python3-pip vim openjdk-11-jre wget tree"
PACKAGES="docker-ce docker-compose"
PIP_PACKAGES="ComplexHTTPServer"
# Registrando dia do Provision
sudo date >> /var/log/vagrant_provision.log
validateCommand() {
if [ $? -eq 0 ]; then
echo "[OK] $1"
else
echo "[ERROR] $1"
exit 1
fi
}
# Inserindo chave SSH
sudo test -f /root/.ssh/id_rsa
if [ $? -eq 1 ]; then
sudo mkdir -p /root/.ssh/ && \
sudo cp /tmp/devsecops.pem /root/.ssh/id_rsa && \
sudo cp /tmp/devsecops.pub /root/.ssh/authorized_keys && \
sudo chmod 600 /root/.ssh/id_rsa
validateCommand "Preparando SSH KEY"
else
echo "[OK] SSH KEY"
fi
# Instalando Pacotes
export DEBIAN_FRONTEND=noninteractive
sudo apt-get --allow-releaseinfo-change update -qq >/dev/null 2>>/var/log/vagrant_provision.log && \
sudo apt-get install -qq -y ${DEPS_PACKAGES} ${PACKAGES} >/dev/null 2>>/var/log/vagrant_provision.log
validateCommand "Instalação de Pacotes"
# Instalando Pacotes do Python
pip3 install -q ${PIP_PACKAGES} >/dev/null 2>>/var/log/vagrant_provision.log && \
pip3 uninstall -y docker-py >/dev/null 2>>/var/log/vagrant_provision.log
validateCommand "Pacotes Python"
#Ativando Servido do Docker
systemctl enable docker &>/dev/null && \
systemctl start docker
validateCommand "Ativando Docker"
# Incluindo Usuário Jenkins no grupo do Docker
usermod -a -G docker jenkins
validateCommand "Configurando Usuario Jenkins"
# Baixando Instalador do Logstash
sudo test -e /root/logstash-${LOGSTASH_VERSION}.deb
if [ $? -eq 1 ]; then
sudo wget -q -c ${LOGSTASH_URL} -O /root/logstash-${LOGSTASH_VERSION}.deb && \
sudo chmod 644 /root/logstash-${LOGSTASH_VERSION}.deb
validateCommand "Preparando Instalador do Logstash"
else
echo "[OK] Instalador do Logstash"
fi