forked from holdennguyen/cicd-pipeline-java-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallDocker.sh
More file actions
34 lines (24 loc) · 994 Bytes
/
InstallDocker.sh
File metadata and controls
34 lines (24 loc) · 994 Bytes
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
#!/bin/bash
# Add user ansible admin
useradd ansibleadmin
# Set password: the below command will avoid re-entering the password
echo "ansibleadmin" | passwd --stdin ansibleadmin
# Modify the sudoers file at /etc/sudoers and add entry
echo 'ansibleadmin ALL=(ALL) NOPASSWD: ALL' | tee -a /etc/sudoers
echo 'ec2-user ALL=(ALL) NOPASSWD: ALL' | tee -a /etc/sudoers
# Enable Password Authentication
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd
# Update the installed packages and package cache
yum update -y
# Install the most recent Docker Engine package
amazon-linux-extras install docker -y
# Start the Docker service
systemctl start docker
# Auto start Docker service after booting
systemctl enable docker
# Install docker module for Python2 (require for ansible)
yum install python-pip -y
pip install docker-py
# Add user ansible admin to docker group (execute without using sudo)
usermod -a -G docker ansibleadmin