summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-08-05 21:09:07 +0200
committerTharre <tharre3@gmail.com>2018-11-17 16:41:40 +0100
commitbe9e20c2d2d8f9bb677056ca08e3f41e2b733333 (patch)
treeed27956aaf1a951973e591ff47b1ce3866808e01 /roles
parent09ea09c02ea1f9b58d9966de848635c5d3c34800 (diff)
downloadinfrastructure-be9e20c2d2d8f9bb677056ca08e3f41e2b733333.tar.gz
infrastructure-be9e20c2d2d8f9bb677056ca08e3f41e2b733333.tar.xz
infrastructure-be9e20c2d2d8f9bb677056ca08e3f41e2b733333.zip
Add grokmirror role
Diffstat (limited to 'roles')
-rw-r--r--roles/grokmirror/defaults/main.yml6
-rw-r--r--roles/grokmirror/files/grokmirror.timer8
-rw-r--r--roles/grokmirror/tasks/main.yml38
-rw-r--r--roles/grokmirror/templates/grokmirror.service10
-rw-r--r--roles/grokmirror/templates/grokmirror.timer8
-rw-r--r--roles/grokmirror/templates/repos.conf.j2107
6 files changed, 177 insertions, 0 deletions
diff --git a/roles/grokmirror/defaults/main.yml b/roles/grokmirror/defaults/main.yml
new file mode 100644
index 0000000..085b834
--- /dev/null
+++ b/roles/grokmirror/defaults/main.yml
@@ -0,0 +1,6 @@
+---
+
+grokmirror_toplevel: "/var/lib/git/mirror"
+grokmirror_include: "*"
+git_user: "git"
+git_group: "git"
diff --git a/roles/grokmirror/files/grokmirror.timer b/roles/grokmirror/files/grokmirror.timer
new file mode 100644
index 0000000..1f69818
--- /dev/null
+++ b/roles/grokmirror/files/grokmirror.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Run grok-pull every 5 min for mirroring
+
+[Timer]
+OnCalendar=*:0/5
+
+[Install]
+WantedBy=timers.target
diff --git a/roles/grokmirror/tasks/main.yml b/roles/grokmirror/tasks/main.yml
new file mode 100644
index 0000000..618f2c6
--- /dev/null
+++ b/roles/grokmirror/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+
+- name: Ensure /etc/grokmirror exists
+ file:
+ path: /etc/grokmirror
+ state: directory
+ owner: root
+ group: root
+ mode: 0755
+
+- name: Ensure {{ grokmirror_toplevel }} exists
+ file:
+ path: "{{ grokmirror_toplevel }}"
+ state: directory
+ owner: "{{ git_user }}"
+ group: "{{ git_group }}"
+ mode: 0755
+
+- name: Install /etc/grokmirror/repos.conf
+ template:
+ src: repos.conf.j2
+ dest: /etc/grokmirror/repos.conf
+ owner: root
+ group: root
+ mode: 0644
+
+- name: Install grokmirror service+timer
+ template: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
+ with_items:
+ - grokmirror.service
+ - grokmirror.timer
+
+- name: Enable grokmirror timer
+ systemd:
+ name: grokmirror.timer
+ daemon-reload: yes
+ state: started
+ enabled: True
diff --git a/roles/grokmirror/templates/grokmirror.service b/roles/grokmirror/templates/grokmirror.service
new file mode 100644
index 0000000..88f6819
--- /dev/null
+++ b/roles/grokmirror/templates/grokmirror.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Run grok-pull for mirroring
+
+[Service]
+Type=oneshot
+User={{ git_user }}
+Group={{ git_group }}
+# 127 = contents modified
+SuccessExitStatus=127
+ExecStart=/usr/bin/grok-pull -p -c /etc/grokmirror/repos.conf
diff --git a/roles/grokmirror/templates/grokmirror.timer b/roles/grokmirror/templates/grokmirror.timer
new file mode 100644
index 0000000..1f69818
--- /dev/null
+++ b/roles/grokmirror/templates/grokmirror.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Run grok-pull every 5 min for mirroring
+
+[Timer]
+OnCalendar=*:0/5
+
+[Install]
+WantedBy=timers.target
diff --git a/roles/grokmirror/templates/repos.conf.j2 b/roles/grokmirror/templates/repos.conf.j2
new file mode 100644
index 0000000..b2b6462
--- /dev/null
+++ b/roles/grokmirror/templates/repos.conf.j2
@@ -0,0 +1,107 @@
+# You can pull from multiple grok mirrors, just create
+# a separate section for each mirror. The name can be anything.
+[kernel.org]
+# The host part of the mirror you're pulling from.
+#site = git://git.kernel.org
+site = git://git.kernel.org
+#
+# Where the grok manifest is published. The following protocols
+# are supported at this time:
+# http:// or https:// using If-Modified-Since http header
+# file:// (when manifest file is on NFS, for example)
+#manifest = http://git.kernel.org/manifest.js.gz
+manifest = http://git.kernel.org/manifest.js.gz
+#
+# Where are we going to put the mirror on our disk?
+#toplevel = /var/lib/git/mirror
+toplevel = {{ grokmirror_toplevel }}
+#
+# Where do we store our own manifest? Usually in the toplevel.
+#mymanifest = /var/lib/git/mirror/manifest.js.gz
+mymanifest = {{ grokmirror_toplevel }}/manifest.js.gz
+#
+# Write out projects.list that can be used by gitweb or cgit.
+# Leave blank if you don't want a projects.list.
+#projectslist = /var/lib/git/mirror/projects.list
+projectslist = {{ grokmirror_toplevel }}/projects.list
+#
+# When generating projects.list, start at this subpath instead
+# of at the toplevel. Useful when mirroring kernel or when generating
+# multiple gitweb/cgit configurations for the same tree.
+#projectslist_trimtop = /pub/scm/
+projectslist_trimtop = /pub/scm/
+#
+# The default behaviour is to use cross-repository references (if present)
+# to set git alternates between projects. This helps both significantly
+# reduce the bandwidth during cloning and dramatically reduce the mirror size
+# on disk. If for some reason you always want to create non-shared repositories,
+# set ignore_repo_references to "yes"
+# NOTE: this will NOT remove alternates for repositories already mirrored. You
+# will need to run "git repack -a" and then manually remove the
+# objects/info/alternates file for each repository.
+#ignore_repo_references = no
+#
+# When generating projects.list, also create entries for symlinks.
+# Otherwise we assume they are just legacy and keep them out of
+# web interfaces.
+#projectslist_symlinks = yes
+projectslist_symlinks = no
+#
+# A simple hook to execute whenever a repository is modified.
+# It passes the full path to the git repository modified as the only
+# argument.
+#post_update_hook = /usr/local/bin/make-git-fairies-appear
+post_update_hook =
+#
+# This prevents catastrophic mirror purges when our upstream master gives us
+# a manifest that is dramatically smaller than ours. The default is to refuse
+# the purge if the remote manifest has over 10% fewer repositories than what we
+# have, or in other words, if we have 100 repos and the remote manifest has
+# shrunk to 95 repos or less, we refuse to purge, suspecting that something has
+# gone wrong. You can set purgeprotect to a higher percentage, or override
+# it entirely with --force-purge commandline flag.
+#purgeprotect = 5
+purgeprotect = 5
+#
+# If owner is not specified in the manifest, who should be listed
+# as the default owner in tools like gitweb or cgit?
+#default_owner = Grokmirror User
+default_owner = Grokmirror User
+#
+# Where do we put the logs?
+#log = /var/log/mirror/kernelorg.log
+log = /var/log/kernelorg.log
+#
+# Log level can be "info" or "debug"
+#loglevel = info
+loglevel = info
+#
+# To speed up updates, grok-pull will use multiple threads. Please be
+# considerate to the mirror you're pulling from and don't set this very
+# high. You may also run into per-ip multiple session limits, so leave this
+# number at a nice low setting.
+#pull_threads = 5
+pull_threads = 5
+#
+# Use shell-globbing to list the repositories you would like to mirror.
+# If you want to mirror everything, just say "*". Separate multiple entries
+# with newline plus tab. Examples:
+#
+# mirror everything:
+#include = *
+#
+# mirror just the main kernel sources:
+#include = /pub/scm/linux/kernel/git/torvalds/linux.git
+# /pub/scm/linux/kernel/git/stable/linux-stable.git
+# /pub/scm/linux/kernel/git/next/linux-next.git
+#
+# mirror just git:
+#include = /pub/scm/git/*
+include = {{ grokmirror_include | join('\n\t') }}
+
+#
+# This is processed after the include. If you want to exclude some specific
+# entries from an all-inclusive globbing above. E.g., to exclude all linux-2.4
+# git sources:
+#exclude = */linux-2.4*
+exclude =