diff --git a/examples/playbooks/ansible_pull.yml b/examples/playbooks/ansible_pull.yml index fbd66cdb20..c2d37d8322 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 c6f1759cca..99f7339120 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 0000000000..e396f31a4e --- /dev/null +++ b/examples/playbooks/templates/etc_logrotate.d_ansible-pull.j2 @@ -0,0 +1,7 @@ +{{ logfile }} { + rotate 7 + daily + compress + missingok + notifempty +}