Make syncproxy mirror basedir configurable in hiera, and use it in all templates...
[mirror/dsa-puppet.git] / modules / roles / templates / syncproxy / rsyncd.conf.erb
index 14a6d07..37c8f7f 100644 (file)
@@ -12,44 +12,43 @@ read only = true
 ignore nonreadable = true
 strict modes = false
 
-[debian]
-  path = /srv/mirrors/debian/
-<%- unless has_variable?("has_srv_mirrors_debian") && @has_srv_mirrors_debian -%>
-  list = no
-<%- end -%>
-  comment = Debian archive (contact mirrors@debian.org for access; see https://www.debian.org/mirror/size for size)
-  auth users = *
-  secrets file = /home/archvsync/rsyncd/debian.secrets
+<%=
+ repositories = [
+  { name: 'debian',
+    comment: 'Debian archive (contact mirrors@debian.org for access; see https://www.debian.org/mirror/size for size)'
+  },
+  { name: 'debian-debug',
+    comment: 'Debug packages for Debian archive (contact mirrors@debian.org for access)'
+  },
+  { name: 'debian-ports',
+    comment: 'Debian ports archive (contact mirrors@debian.org for access)'
+  },
+  { name: 'debian-security',
+    comment: 'Debian security archive'
+  },
+  { name: 'debian-security-buildd-pool',
+    list: false
+  },
+  ]
 
-[debian-debug]
-  path = /srv/mirrors/debian-debug/
-<%- unless has_variable?("has_srv_mirrors_debian_debug") && @has_srv_mirrors_debian_debug -%>
-  list = no
-<%- end -%>
-  comment = Debug packages for Debian archive (contact mirrors@debian.org for access)
-  auth users = *
-  secrets file = /home/archvsync/rsyncd/debian-debug.secrets
+  lines = []
 
-[debian-ports]
-  path = /srv/mirrors/debian-ports/
-<%- unless has_variable?("has_srv_mirrors_debian_debug") && @has_srv_mirrors_debian_debug -%>
-  list = no
-<%- end -%>
-  comment = Debian ports archive (contact mirrors@debian.org for access)
-  auth users = *
-  secrets file = /home/archvsync/rsyncd/debian-ports.secrets
+  repositories.each do |repo|
+    varname = ('has' + @mirror_basedir_prefix + repo[:name]).gsub(/[\/-]/,'_')
+    next unless has_variable?(varname) and (eval("@"+varname))
 
-[debian-security]
-  path = /srv/mirrors/debian-security/
-<%- unless has_variable?("has_srv_mirrors_debian_security") && @has_srv_mirrors_debian_security -%>
-  list = no
-<%- end -%>
-  comment = Debian security archive (contact mirrors@debian.org for access)
-  auth users = *
-  secrets file = /home/archvsync/rsyncd/debian-security.secrets
+    lines << "[#{ repo[:name] }]"
+    lines << "  path = #{ @mirror_basedir_prefix }#{ repo[:name] }/"
+    if (repo.include?(:list) and not repo[:list])
+      lines << "  list = no"
+    end
+    if repo.include?(:comment)
+      lines << "  comment = #{ repo[:comment] }"
+    end
+    lines << "  auth users = *"
+    lines << "  secrets file = /home/archvsync/rsyncd/#{ repo[:name] }.secrets"
+    lines << ""
+  end
 
-[debian-security-buildd-pool]
-  path = /srv/mirrors/debian-security-buildd/pool/
-  list = no
-  auth users = *
-  secrets file = /home/archvsync/rsyncd/debian-security-buildd-pool.secrets
+  lines.join("\n")
+%>