From 0f5a4e2112c90d6167bae97c5b10d94f8e977b31 Mon Sep 17 00:00:00 2001
From: Matthew Johnson <mjjohnson33@gmail.com>
Date: Fri, 14 Sep 2012 14:01:44 -0400
Subject: [PATCH] add logrotate config

---
 examples/playbooks/ansible_pull.yml                      | 9 +++++++--
 .../{ansible-pull.j2 => etc_cron.d_ansible-pull.j2}      | 2 +-
 .../playbooks/templates/etc_logrotate.d_ansible-pull.j2  | 7 +++++++
 3 files changed, 15 insertions(+), 3 deletions(-)
 rename examples/playbooks/templates/{ansible-pull.j2 => etc_cron.d_ansible-pull.j2} (72%)
 create mode 100644 examples/playbooks/templates/etc_logrotate.d_ansible-pull.j2

diff --git a/examples/playbooks/ansible_pull.yml b/examples/playbooks/ansible_pull.yml
index fbd66cdb206..c2d37d83225 100644
--- a/examples/playbooks/ansible_pull.yml
+++ b/examples/playbooks/ansible_pull.yml
@@ -20,12 +20,15 @@
 
   vars:
 
-    # schdule is fed directly to cron
+    # schedule is fed directly to cron
     schedule: '*/15 * * * *'
 
     # User to run ansible-pull as from cron
     cron_user: root
 
+    # File that ansible will use for logs
+    logfile: /var/log/ansible-pull.log
+
     # Directory to where repository will be cloned
     workdir: /var/lib/ansible/local
 
@@ -47,5 +50,7 @@
               owner=root group=root mode=0644
 
     - name: Create crontab entry to clone/pull git repository
-      action: template src=templates/ansible-pull.j2 dest=/etc/cron.d/ansible-pull owner=root group=root mode=0644
+      action: template src=templates/etc_cron.d_ansible-pull.j2 dest=/etc/cron.d/ansible-pull owner=root group=root mode=0644
 
+    - name: Create logrotate entry for ansible-pull.log
+      action: template src=templates/etc_logrotate.d_ansible-pull.j2 dest=/etc/logrorate.d/ansible-pull owner=root group=root mode=0644
diff --git a/examples/playbooks/templates/ansible-pull.j2 b/examples/playbooks/templates/etc_cron.d_ansible-pull.j2
similarity index 72%
rename from examples/playbooks/templates/ansible-pull.j2
rename to examples/playbooks/templates/etc_cron.d_ansible-pull.j2
index c6f1759cca8..99f7339120c 100644
--- a/examples/playbooks/templates/ansible-pull.j2
+++ b/examples/playbooks/templates/etc_cron.d_ansible-pull.j2
@@ -1,2 +1,2 @@
 # Cron job to git clone/pull a repo and then run locally
-{{ schedule }} {{ cron_user }} ansible-pull -d {{ workdir }} -U {{ repo_url }} >/var/log/ansible-pull.log 2>&1
+{{ schedule }} {{ cron_user }} ansible-pull -d {{ workdir }} -U {{ repo_url }} >>{{ logfile }} 2>&1
diff --git a/examples/playbooks/templates/etc_logrotate.d_ansible-pull.j2 b/examples/playbooks/templates/etc_logrotate.d_ansible-pull.j2
new file mode 100644
index 00000000000..e396f31a4e5
--- /dev/null
+++ b/examples/playbooks/templates/etc_logrotate.d_ansible-pull.j2
@@ -0,0 +1,7 @@
+{{ logfile }} {
+  rotate 7
+  daily
+  compress
+  missingok
+  notifempty
+}