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 management solution. Puppet and Chef are much more suited for that type of application. #aws #cloud #iot #data
automation
Controlling AWS with Python SDK and Boto3 for Automation
Here is a quick video I made on how you can use python and boto3 to interact with AWS in the same way you would use awscl! #data #iot #aws #cloud
AWS has really made it easy to interact with their services via the Python SDK. This is very well documented and, for those shops who code mostly in Python I’m sure you already are using this sort of thing
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:
#!/bin/bash
#install ansible
yum install wget -y
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
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
tasks:
– 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
yum:
name: http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
– name: NGINX | Installing NGINX
yum:
name: nginx
state: latest
– name: NGINX | Starting NGINX
service:
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>
<head>
<title>NWEA tech_quiz sample index.html</title>
</head>
<body bgcolor=white>
<table border=”0″ cellpadding=”10″>
<tr>
<td>
<h1>Hello, this is the sample page</h1>
</td>
</tr>
</table>
</body>
</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