-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-ansibleawx.sh
121 lines (104 loc) · 3.7 KB
/
install-ansibleawx.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
## Author: Bezaleel Silva(bezarsnba)
## E-mail: [email protected]
## Date: 06/02/2019
## Reference: https://github.com/ansible/awx/blob/devel/INSTALL.md#docker-or-docker-compose
## Reference: http://blog.onxsolutions.net/como-instalar-o-ansible-awx-no-ubuntu-bionic/
## Objective: shellscript to install ansible Awx, with dependence docker,npn,gnu make,git
## On Ubuntu Bionic (18.04) x86_64
## Generic functions
paramValue() {
echo $( message $1 | awk -F'=' '{print $2}' );
}
function infoOk() {
echo -e "\e[36m==>\e[32m $1 \e[39m";
}
function infoError() {
echo -e "\e[31m==>\e[91m $1 \e[39m";
}
function message() {
echo -e "\e[36m==>\e[37m $1 \e[39m";
}
## variables ###
dirSrcAwx=/opt/ansible-awx
fileDockerCompose=/var/lib/awx/docker-compose.yml
binGit=/usr/bin/git
binGcc=/usr/bin/gcc
binAnsible=/usr/bin/ansible
binDocker=/usr/bin/docker
binNpm=/usr/local/bin/npm
## verify git
if [ -f $binGit ]
then
infoOk "Git Installed: $(sudo git --version | head -n1)";
else
message "Git not Installed, Installing git...";
sudo apt -y install git
message "Finished installation of Git: $(sudo git --version | head -n1)";
fi
## verify gcc
if [ -f $binGcc ]
then
infoOk "Gcc Installed: $(sudo gcc --version | head -n1) " ;
else
infoError "GNU Make not Installed, Installing GNU Make...";
sudo apt install build-essential -y &>/dev/null
message "Finished installation of GNU Make: $(sudo gcc --version | head -n1)";
fi
## Install Ansible
if [ -f $binAnsible ]
then
infoOk "Ansible Installed: $( sudo ansible --version | head -n1) ";
else
infoError "Ansible not Installed, Installing Ansible...";
sudo apt-get install software-properties-common -y &>/dev/null
sudo apt-add-repository --yes --update ppa:ansible/ansible &>/dev/null
sudo apt update &>/dev/null
sudo apt install ansible -y &>/dev/null
infoOk "Finished installation Ansible:$( sudo ansible --version | head -n1)";
fi
## Install docker
if [ -f $binDocker ]
then
infoOk "Docker Installed: $(sudo docker --version | head -n1) ";
else
infoError "Docker not Installed, Installing Docker";
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y &>/dev/null
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &>/dev/null
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" &>/dev/null
sudo apt update &>/dev/null
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose -y &>/dev/null
sudo apt install python-pip -y &>/dev/null
sudo pip install docker &>/dev/null
infoOk "Finished installation of Docker: $(sudo docker --version | head -n1) ";
fi
## Install node NPM
if [ -f $binNpm ]
then
infoOk "NPN installed: $(sudo npm --version | head -n1) ";
else
infoError "Npm not installed, Installing NpM";
sudo apt install nodejs npm -y &>/dev/null
sudo npm install npm --global &>/dev/null
infoOk "Finished installation of NpM: $(sudo npm --version | head -n1)";
fi
## get awx git
message "Created $dirSrcAwx and Executing git clone ";
sudo mkdir $dirSrcAwx;cd $dirSrcAwx &>/dev/null
#sudo cp -r /vagrant/awx /opt/ansible-awx/
sudo git clone https://github.com/ansible/awx.git &>/dev/null
infoOk "Finished execute git clone"
## run ansible-plabook
message "Running ansible-playbook...";
cd $dirSrcAwx/awx/installer
sudo ansible-playbook -e use_docker_compose=true -i inventory install.yml &>/dev/null
infoOk "Finished ansible-playbook";
#check Dockercompose
if [ -f $fileDockerCompose ]
then
infoOk "Docker-compose exists";
else
message "Docker-compose not exists";
fi
message "Containers created"
sudo docker container ps