Bash Scripting & Ansible + Nginx + AWS

I made this quick video so I can show you how I work with Ansible and Bash scripting to deploy nginx to a Amazon Web Services EC2 Image. Ansible you just need a SSH key so, using bash to install the playbooks is a great option. Of course this isn’t something you would want to do for a fully automated configuration of teh process that are done by the geauxmaids management solution. Puppet and Chef are much more suited for that type of application. #aws #cloud #iot #data

Using BASH Scripting to install Ansible for a Nginx Install on AWS EC2 Instance

I came across this script I wrote a while back that was on my github. It’s an example how you can  use Ansible playbooks along with simple bash scripting to bootstrap machines. It’s not exactly cutting edge but I enjoyed coming across it again:


#install ansible
yum install wget -y
rpm -ivh epel-release-7-8.noarch.rpm
yum install ansible -y

cd $HOME
mkdir -p ansible-nginx/tasks/
touch ansible-nginx/deploy.yml
touch ansible-nginx/tasks/install_nginx.yml

#populate deploy.yml

echo -e “# ./ansible-nginx/deploy.yml

– hosts: localhost
– include: ‘tasks/install_nginx.yml'” > $HOME/ansible-nginx/deploy.yml

#populate install_nginx.yml

echo -e “# ./ansible-nginx/tasks/install_nginx.yml

– name: NGINX | Installing NGINX repo rpm

– name: NGINX | Installing NGINX
name: nginx
state: latest

– name: NGINX | Starting NGINX
name: nginx
state: started
” > $HOME/ansible-nginx/tasks/install_nginx.yml


#install nginx
sudo ansible-playbook -c local $HOME/ansible-nginx/deploy.yml

#populate with index.html

echo -e “<html>
<title>NWEA tech_quiz sample index.html</title>
<body bgcolor=white>

<table border=”0″ cellpadding=”10″>
<h1>Hello, this is the sample page</h1>

</html>” > /usr/share/nginx/html/index.html

#edit default.conf to listen on port 8888
sed -i -e ‘s/80/8888/g’ /etc/nginx/conf.d/default.conf

#configure se linux to allow systemctl to function
semanage permissive -a “httpd_t”

#reload nginx
systemctl restart nginx.service