diff options
Diffstat (limited to 'roles')
4 files changed, 49 insertions, 0 deletions
diff --git a/roles/ansible-pull/tasks/main.yml b/roles/ansible-pull/tasks/main.yml new file mode 100644 index 0000000..1f36000 --- /dev/null +++ b/roles/ansible-pull/tasks/main.yml @@ -0,0 +1,27 @@ +--- +- name: install ansible + apt: name=ansible state=latest + +- name: install gnupg + apt: name=gpg state=latest + +- name: install git + apt: name=git state=latest + +- name: create ansible pull script + template: + src=templates/usr_local_bin_metamorphose.j2 + dest=/usr/local/bin/metamorphose + owner=root group=root mode=0755 + +- name: create crontab entry to clone/pull git repository + template: + src=templates/etc_cron.d_metamorphosis.j2 + dest=/etc/cron.d/metamorphosis + owner=root group=root mode=0644 + +- name: create logrotate entry for metamorphose.log + template: + src=templates/etc_logrotate.d_metamorphosis.j2 + dest=/etc/logrotate.d/metamorphosis + owner=root group=root mode=0644 diff --git a/roles/ansible-pull/templates/etc_cron.d_metamorphosis.j2 b/roles/ansible-pull/templates/etc_cron.d_metamorphosis.j2 new file mode 100644 index 0000000..a4c9541 --- /dev/null +++ b/roles/ansible-pull/templates/etc_cron.d_metamorphosis.j2 @@ -0,0 +1,2 @@ +# Cron job to git clone/pull a repo and then run locally +*/15 * * * * root /usr/local/bin/pull >>/var/log/pull.log 2>&1
\ No newline at end of file diff --git a/roles/ansible-pull/templates/etc_logrotate.d_metamorphosis.j2 b/roles/ansible-pull/templates/etc_logrotate.d_metamorphosis.j2 new file mode 100644 index 0000000..b81abbf --- /dev/null +++ b/roles/ansible-pull/templates/etc_logrotate.d_metamorphosis.j2 @@ -0,0 +1,7 @@ +/var/log/pull.log { + rotate 7 + daily + compress + missingok + notifempty +}
\ No newline at end of file diff --git a/roles/ansible-pull/templates/usr_local_bin_metamorphose.j2 b/roles/ansible-pull/templates/usr_local_bin_metamorphose.j2 new file mode 100644 index 0000000..d416526 --- /dev/null +++ b/roles/ansible-pull/templates/usr_local_bin_metamorphose.j2 @@ -0,0 +1,13 @@ +#!/bin/sh +# Pull ansible configuration and upgrade system +set -e + +workdir=/var/lib/ansible/local + +mkdir --parents "$workdir" +/usr/bin/ansible-pull \ + --verify-commit \ + --checkout master \ + --sleep 10 \ + --directory "$workdir" \ + --url "https://github.com/jodersky/metamorphic.git" |