-
-
Save fuzzygroup/b8e9bb1bfdd6c8986c613d8e07f10ec2 to your computer and use it in GitHub Desktop.
ansible playbook to add memory metrics for cloudwatch - RedHat family only
This file contains 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: all | |
vars: | |
ec2_access_key: "AKIA-----------A" | |
ec2_secret_key: "i-------------/--------A" | |
remote_user: ec2-user | |
sudo: yes | |
tasks: | |
- name: "make sure package perl-switch is installed for the monitoring scripts" | |
yum: name=perl-Switch state=present | |
when: ansible_os_family == "RedHat" | |
- name: "make sure package perl-Sys-Syslog is installed for the monitoring scripts" | |
yum: name=perl-Sys-Syslog state=present | |
when: ansible_os_family == "RedHat" | |
- name: "make sure package perl-LWP-Protocol-https is installed for the monitoring scripts" | |
yum: name=perl-LWP-Protocol-https state=present | |
when: ansible_os_family == "RedHat" | |
- name: download scripts | |
get_url: url=http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip dest=/tmp/CloudWatchMonitoringScripts.zip | |
- name: unzip the scripts | |
unarchive: src=/tmp/CloudWatchMonitoringScripts.zip dest=/tmp/ | |
- name: delete archive | |
file: path=/tmp/CloudWatchMonitoringScripts.zip state=absent | |
- name: set Access key in credentials file | |
replace: dest=/tmp/aws-scripts-mon/awscreds.template regexp='AWSAccessKeyId=' replace='AWSAccessKeyId={{ ec2_access_key }}' backup=yes | |
- name: set Secret key in credentials file | |
replace: dest=/tmp/aws-scripts-mon/awscreds.template regexp='AWSSecretKey=' replace='AWSSecretKey={{ ec2_secret_key }}' backup=yes | |
- name: move directory out of /tmp | |
command: mv /tmp/aws-scripts-mon/ /root/ creates=/root/aws-scripts-mon/ | |
- name: add command to cron | |
lineinfile: dest=/etc/crontab insertafter=EOF line="* * * * * root /root/aws-scripts-mon/mon-put-instance-data.pl --mem-util --mem-used --mem-avail --aws-credential-file=/root/aws-scripts-mon/awscreds.template" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment