Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
Ansible role for setting cloudwatch reporting script on ubuntu servers
hostfile = hosts
[app_servers] ansible_ssh_user=ubuntu ansible_ssh_user=ubuntu
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
mkdir automation && cd automation
touch ansible.cfg && hosts
mkdir -pv roles/aws_monitoring/tasks/main.yml
- name: Updating apt-cache
sudo: yes
apt: update_cache=yes cache_valid_time=3600
- name: Installing perl pre requirements and unzip
sudo: yes
apt: pkg={{item}} state=installed
- libwww-perl
- libdatetime-perl
- libswitch-perl
- unzip
- name: Checking if cloudwatch already Downloaded to this machine
stat: path=~/aws-scripts-mon
register: cloudwatch_folder
- name: Downloading aws cloudwatch reporting script
get_url: url= dest=~/
when: not cloudwatch_folder.stat.exists
- name: Unzipping cloudwatch
unarchive: src=/home/ubuntu/ dest=/home/ubuntu/ copy=no
when: not cloudwatch_folder.stat.exists
- name: removing zip
file: path=/home/ubuntu/CloudWatchMonitoringScripts-v1.1.0 state=absent
- name: setup crontab reporting to aws cloud
cron: name="report aws" minute="1" job="~/aws-scripts-mon/ --mem-util --mem-used --mem-avail --disk-path=/ --disk-path=/home --disk-space-avail --disk-space-used --disk-space-util --aws-credential-file=/home/ubuntu/aws-scripts-mon/awscreds.template >/dev/null 2>&1"
- hosts: app_servers
remote_user: ubuntu
- role: aws_monitoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment