sudo su -
yum install python
python --version
yum install python-pip
pip install ansible
ansible --version
mkdir /etc/ansible
useradd ansadmin
passwd ansadmin
echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
yum install docker
service docker start
service docker status
usermod -aG docker ansadmin
vi /etc/ssh/sshd_config [search for /password. Change the PasswordAuthentication yes]
EC2 uses keys for remote access
PasswordAuthentication yes
service sshd reload
su - ansadmin
ssh-keygen [No need to pass anything, keep hitting “Enter”]
ls -la
cd .ssh
cat id_rsa.pub
exit
sudo su -
adduser ansadmin
echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
sudo usermod -aG docker ansadmin
id ansadmin
su – ansadmin
cd /etc/ansible
sudo vi hosts (Add the target host IP & localhost)
ssh-copy-id ansadmin@targethostipaddress
ssh-copy-id ansadmin@localhost
ansible -m ping all
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
su - ansadmin
cd /opt
sudo mkdir docker
sudo chown -R ansadmin:ansadmin /opt/docker
ls -l /opt
cd docker
ls –l
docker login -u dockerid
wget https://raw.githubusercontent.com/duorg/Scripts/master/Dockerfile (Refer script folder)
wget https://raw.githubusercontent.com/duorg/Scripts/master/docker-create-push-webapp.yml (Refer script folder)
wget https://raw.githubusercontent.com/duorg/Scripts/master/docker-pull-run-webapp.yml (Refer script folder)
vi hosts (Add the target host IP & localhost)
ansible-playbook -i /opt/docker/hosts /opt/docker/docker-create-push-webapp.yml --limit localhost
ansible-playbook -i /opt/docker/hosts /opt/docker/docker-pull-run-webapp.yml --limit targethostipaddress