From 3803b27f6cca3295c5b791bdcb59224c0b46f46f Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Mon, 30 Apr 2012 14:24:58 -0700 Subject: [PATCH] Add playbook and template to set up ansible-pull Playbook will install ansible, create directory where git checkout goes, and set up a cron job to run ansible-pull. --- examples/playbooks/ansible_pull.yml | 19 +++++++++++++++++++ examples/playbooks/templates/ansible-pull.j2 | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 examples/playbooks/ansible_pull.yml create mode 100644 examples/playbooks/templates/ansible-pull.j2 diff --git a/examples/playbooks/ansible_pull.yml b/examples/playbooks/ansible_pull.yml new file mode 100644 index 0000000000..96b82735e7 --- /dev/null +++ b/examples/playbooks/ansible_pull.yml @@ -0,0 +1,19 @@ +--- +- hosts: all + user: root + vars: + # schdule is fed directly to cron + schedule: '*/15 * * * *' + # User to run ansible-pull as from cron + cron_user: root + # Directory to where repository will be cloned + workdir: /var/lib/ansible/local + # Repository to check out + repo_url: git://github.com/sfromm/ansible-playbooks.git + tasks: + - name: Install ansible + action: yum pkg=ansible state=installed + - name: Create local directory to work from + action: file path=$workdir state=directory owner=root group=root mode=0751 + - 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 diff --git a/examples/playbooks/templates/ansible-pull.j2 b/examples/playbooks/templates/ansible-pull.j2 new file mode 100644 index 0000000000..bab3f3f73d --- /dev/null +++ b/examples/playbooks/templates/ansible-pull.j2 @@ -0,0 +1,2 @@ +# Cron job to git clone/pull a repo and then run locally +{{ schedule }} {{ cron_user }} ansible-pull -d {{ workdir }} -U {{ repo_url }}