Filippo Giunchedi has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/254411

Change subject: swift: add swift replication support via swiftrepl
......................................................................

swift: add swift replication support via swiftrepl

Change-Id: I6e598ead6f1f42324f46da4661760453c008e9b8
---
A modules/swift/manifests/swiftrepl.pp
A modules/swift/templates/swiftrepl.conf.erb
2 files changed, 118 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/11/254411/1

diff --git a/modules/swift/manifests/swiftrepl.pp 
b/modules/swift/manifests/swiftrepl.pp
new file mode 100644
index 0000000..ea4c69e
--- /dev/null
+++ b/modules/swift/manifests/swiftrepl.pp
@@ -0,0 +1,96 @@
+# instantiate a swift replication job with swiftrepl
+#
+# === Parameters
+# [*source_user*]
+#   swift user for source
+#
+# [*source_api_key*]
+#   swift password/api key for source
+#
+# [*source_auth_url*]
+#   authorization URL for source
+#
+# [*dest_user*]
+#   swift user for destination
+#
+# [*dest_api_key*]
+#   swift password/api key for destination
+#
+# [*dest_auth_url*]
+#   authorization URL for destination
+#
+# [*container_set*]
+#   which container set to replicate
+#
+# [*cron_hour*]
+#   hour specification for cron entry
+#
+# [*cron_minute*]
+#   minute specification for cron entry
+
+define swift::swiftrepl (
+    $source_user,
+    $source_api_key,
+    $source_auth_url,
+    $dest_user,
+    $dest_api_key,
+    $dest_auth_url,
+    $container_set,
+    $cron_hour,
+    $cron_minute,
+    ) {
+
+    $config_file = "/etc/swiftrepl/${title}.conf"
+
+    group { 'swiftrepl':
+        ensure => present,
+        system => true,
+    }
+
+    user { 'swiftrepl':
+        ensure => present,
+        gid  => 'swiftrepl',
+        home   => '/nonexistent',
+        shell  => '/bin/false',
+        system => true,
+    }
+
+    file { '/etc/swiftrepl':
+        ensure => directory,
+        mode   => 0500,
+        owner  => 'swiftrepl',
+        group  => 'swiftrepl',
+    }
+
+    file { '/var/log/swiftrepl':
+        ensure => directory,
+        mode   => 0700,
+        owner  => 'swiftrepl',
+        group  => 'swiftrepl',
+    }
+
+    file { $config_file:
+        content => template("${module_name}/swiftrepl.conf.erb"),
+        mode    => 0400,
+        owner   => 'swiftrepl',
+        group   => 'swiftrepl',
+    }
+
+    cron { "swiftrepl-${title}":
+        ensure  => present,
+        command => "/usr/bin/flock --timeout 120 
/var/tmp/swiftrepl-${title}.lock /usr/bin/script --flush --return --command 
'/usr/bin/swiftrepl --config ${config_file} --container-set ${container_set}' 
/var/log/swiftrepl/${title}-$(date +\\%s).log >/dev/null 2>&1",
+        user    => 'swiftrepl',
+        hour    => $cron_hour,
+        minute  => $cron_minute,
+    }
+
+    cron { "swiftrepl-cleanup-${title}":
+        ensure  => present,
+        command => "/usr/bin/find /var/log/swiftrepl/ -iname '${title}*.log' 
-type f -mtime +30 -delete",
+        user    => 'swiftrepl',
+        hour    => '1',
+        minute  => '17',
+    }
+
+    require_package('swiftrepl')
+}
diff --git a/modules/swift/templates/swiftrepl.conf.erb 
b/modules/swift/templates/swiftrepl.conf.erb
new file mode 100644
index 0000000..30ee084
--- /dev/null
+++ b/modules/swift/templates/swiftrepl.conf.erb
@@ -0,0 +1,22 @@
+[src]
+username = <%= @source_user %>
+api_key = <%= @source_api_key %>
+auth_url = <%= @source_auth_url %>
+
+[dst]
+username = <%= @dest_user %>
+api_key = <%= @dest_api_key %>
+auth_url = <%= @dest_auth_url %>
+
+[container_sets]
+all=^.*$
+thumb=-thumb(\.[a-z0-9][a-z][0-9])?$
+originals=-public(\.[a-z0-9][a-z0-9])?$
+temp=-temp(\.[a-z0-9][a-z0-9])?$
+deleted=-deleted(\.[a-z0-9][a-z0-9])?$
+transcoded=-transcoded(\.[a-z0-9][a-z0-9])?$
+render=-render(\.[a-z0-9][a-z0-9])?$
+commons=^wikipedia-commons-local-public.[0-9a-f]{2}$
+notcommons=^wikipedia-..-local-public.[0-9a-f]{2}$
+unsharded=^wik[a-z]+-.*-local-public$
+global=^global-.*$

-- 
To view, visit https://gerrit.wikimedia.org/r/254411
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e598ead6f1f42324f46da4661760453c008e9b8
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Filippo Giunchedi <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to