Last active
August 29, 2015 14:25
-
-
Save alonisser/23d3c9d0d5f7fb46840b to your computer and use it in GitHub Desktop.
Ansible role for setting cloudwatch reporting script on ubuntu servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[defaults] | |
hostfile = hosts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--roles | |
--aws_monitoring | |
--tasks | |
--main.yml | |
ansible.cfg | |
hosts | |
setup_aws_reporting.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[app_servers] | |
app1.example.com ansible_ssh_user=ubuntu | |
app2.example.com ansible_ssh_user=ubuntu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 | |
with_items: | |
- 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=http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip dest=~/CloudWatchMonitoringScripts-v1.1.0.zip | |
when: not cloudwatch_folder.stat.exists | |
- name: Unzipping cloudwatch | |
unarchive: src=/home/ubuntu/CloudWatchMonitoringScripts-v1.1.0.zip 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/mon-put-instance-data.pl --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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: app_servers | |
remote_user: ubuntu | |
roles: | |
- role: aws_monitoring |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment