diff options
author | Jakob Odersky <jakob@odersky.com> | 2017-12-04 00:24:53 -0800 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2017-12-04 01:09:28 -0800 |
commit | dc984f4d05889a240e6a81b442b4cfd249bcf22f (patch) | |
tree | 4a020a98192f13b2a2ceab85aaf6b93e6a7b70da /roles | |
parent | c780b908f539b8042881a87007859797e0d6bdc4 (diff) | |
download | metamorphic-dc984f4d05889a240e6a81b442b4cfd249bcf22f.tar.gz metamorphic-dc984f4d05889a240e6a81b442b4cfd249bcf22f.tar.bz2 metamorphic-dc984f4d05889a240e6a81b442b4cfd249bcf22f.zip |
Use ansible-pull to propagate changespull-based
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" |