Commit 0ef427cb authored by Christopher Huhn's avatar Christopher Huhn 🥚
Browse files

Add data bag support

parent 684352bf
......@@ -39,6 +39,7 @@ suites:
- recipe[debmirror]
attributes:
debmirror:
data_bag: debmirror_repos
mirrors:
cvmfs:
server: cvmrepo.web.cern.ch
......@@ -47,3 +48,5 @@ suites:
- buster-prod
key: "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQGiBEuGP6YRBADV89cbF4uoEX89Q8uxOklIDVJhOJAFKZ33LSdzHv3iObnjo5w4\nwbb8FiSir4oWgarAco4u0kR1yKjHJ33oVB2xmPOzW3NWoHI7aPF7tCgo7FY9hNoC\n4NEkNycvbfSoCScsv2yY5qz2q2sY1LWGZGbUXjBvKbmASe9sJFKJV7NsmwCg76W/\naMazleHyDtooD8tk3ZWvpKcD/Rg51Oad+ZLc7h45wDMHpaDvOBeGoyp+k7JgQd87\nHfXiJtg/Q6zyTwrV3vCQvMpw3GRjRkZBcPgRWb6rUk68dL8fa2cTxhISX5/DIQzc\nmmuDa0EgCGGAKUZ4bHqaexFFnp/B+VKBPvJuxLa0cBDd6eewxNwtHJ90EaMeBzGd\n6zU2BADO9YbXiEMqRkfVLnuvD5G31/WJZvffXCxspnSfg923DbILWa4vNW9MLMsK\nIVHvyVr0mZF8xdyQNVPUX3/4uahKM4hwuFqdbyjuLGEIF3U73aIJ0+YDep/+I6yU\nJGHnxy8Ex+a1XIhJ1hSI7+oalSdt+w/pE3+2MQyUfSDPSXVA3LQ+Q2VyblZNIEFk\nbWluaXN0cmF0b3IgKGN2bWFkbWluKSA8Y2VybnZtLmFkbWluaXN0cmF0b3JAY2Vy\nbi5jaD6IXgQTEQIAHgIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAUCVwOYkgAKCRAj\nDTidiuRc50E1AJ9AYvH/cydD7029jxGcs8K87lo3jACdEhbCj3cjPsp2U/WfpgK1\nBQOMiwe5Ag0ES4Y/qBAIAL3sWKXQKpbIOpwX+mNX2IV2XxNBM3KYjYOEii66i9ap\nPo3BA39a9Wm9vh1kYIHTkh9Qqb8w53hc4ANkVT+cYzxXythGBjWoLtwCzKCPrIb7\nRQJRc956Ot0q4qmlcUEGi5zefSIoJZR5jyR7rZS+1PNJYI05xY2+Eah1u9UxrlzB\nH5DCsvUqTNK12WrPIibmLo8u+yIDJjwgh9O5YITC+et/g47NLfZdiAGPLEjvJFRi\n7Ju+8ywO32dSVBPJQDktr5BC950DKZHA9n+sJ63iF3lP/aCTECpxxUqXVVqioobw\ng5ytl60hw9I9sfwBP6z9PR90RcyT1l4giiBz9LV+KpcAAwUIAKeAxArGaJxzWziK\ns7D8TTuE50Nw+S3RGhVzwSKy7183Z11iOEMqbm2/zwp65wFkntCKmLKDnGsTgFNp\nstIyFwJmj34Axp7N3KGqXnTI+SIQd6VmzQ1phxfCOw8IGueOR6YI7S1GYWt7Dose\nZKz4EWdvXCOkQAhbxq/HT2c3ihxsuxrErxz7QtNaYOFXiuLj3mYH9XaMeEe8Pkl+\nyyRTvyUNlMIu/i79qf+QUlsi10nCUm88cSXQiKWOJ4GiUoT+jD7pN4ohdALRVl0t\nl/EyPTw+asG3lQhPZ+solvJXp+i7KF7nwnyXDB63WNH15S1pQLMnqCuGCFyegf6j\nnOJU0AqISQQYEQIACQIbDAUCVwOYgwAKCRAjDTidiuRc534jAKDu/9BZU3rirEMr\nDuGbmN3ulUM+UgCfe7lg5qrGXUzZlJFTnTaTgS3Z0Rg=\n=fspm\n-----END PGP PUBLIC KEY BLOCK-----\n"
rsync_extra: none
databag: no_databag
x2go: {} # read everything from the data bag
# defaulf basedir for mirrored repositories
default_unless['debmirror']['base_dir'] = '/srv/debmirror'
# do not use data bags by default
default_unless['debmirror']['data_bag'] = nil
# keyring where debmirror looks for repository keys
default_unless['debmirror']['keyring'] =
node['debmirror']['base_dir'] + '/.gnupg/trustedkeys.gpg'
......
......@@ -4,7 +4,7 @@ maintainer_email 'hpc@gsi.de'
license 'GNU Public License 3.0'
description 'Installs/Configures debmirror'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
version '0.2.0'
source_url 'https://git.gsi.de/chef/cookbooks/debmirror'
issues_url 'https://git.gsi.de/chef/cookbooks/debmirror/issues'
......@@ -32,6 +32,17 @@ directory node['debmirror']['base_dir']
# Configure all mirrors defined by attributes
node['debmirror']['mirrors'].each do |name, conf|
databag = conf['databag'] || node['debmirror']['data_bag']
begin
if data_bag(databag).include?(name)
conf = conf.merge(data_bag_item(databag, name))
end
rescue Net::HTTPServerException => e
# ignore 404 "Not Found"
next unless e.response.code == '404'
end
debmirror_repository name do
server conf['server']
proto conf['method'] if conf['method']
......
......@@ -36,12 +36,12 @@ property :script_dir, String, default: node['debmirror']['script_dir']
property :rsync_extra, [Array, String, nil],
# turn strings into an array, default to ['trace']
coerce: proc { |x|
if x.is_a?(String)
Array[x]
else
x.nil? ? %w[trace] : x
end
}
if x.is_a?(String)
Array[x]
else
x.nil? ? %w[trace] : x
end
}
default_action :add
......
{
"id": "x2go",
"arch": [
"i386",
"armhf"
],
"section": [
"main",
"heuler"
],
"server": "packages.x2go.org",
"options": [
"--source",
"--diff=none",
"--rsync-extra=none",
"--getcontents",
"--ignore-small-errors",
"--proxy=http://proxy.gsi.de:3128"
],
"release": [
"buster",
"sid"
],
"path": "/debian",
"key": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1\n\nmQENBE15RZ4BCADGlna23kyfn96REJA7A+md74rAAsdvq3a2U1M9ghlta+6yOPGi\nXTSHykAYaJXrYXM8PlbVsb+ub4VyDpQHbr7U1L0hicSPd+h14yXLm5T+PyZpKvLV\n5OWP0dU4LkOvDIWN/EyMnUd6eHQrDo2FW8dPsJ95Pq6Ido264wHMz1LhnjOAb8s7\nqB8cn8t/+8lg28f6R+BcE926WJyEyZ/akvvo09MliNCshZyyW8/l76nSLGF/GzqY\nB0bNJi7LjMuOyrN+yhKhGXvmfXx5bwRXwBlWHxYfe3KWuTD/6KtHCjTgkEQMaBi3\nrRM8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
#
# Authors:
# Christopher Huhn <c.huhn@gsi.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
require 'spec_helper'
context 'x2go' do
@repo_name = 'x2go'
let(:key_id) { 'X2go Debian/Ubuntu Packaging' }
describe file "/etc/debmirror.d/#{@repo_name}.sh" do
it { should exist }
end
describe command 'gpg --no-default-keyring --list-keys '\
'--keyring /srv/debmirror/.gnupg/trustedkeys.gpg' do
its(:exit_status) { should be_zero }
its(:stdout) { should contain key_id }
end
describe command "sudo -u nobody LC_ALL=C /etc/debmirror.d/#{@repo_name}.sh"\
' --dry-run' do
its(:exit_status) { should be_zero }
its(:stdout) { should be_empty }
its(:stderr) { should be_empty }
end
describe command "sudo -u nobody LC_ALL=C /etc/debmirror.d/#{@repo_name}.sh"\
' --verbose --dry-run' do
its(:exit_status) { should be_zero }
its(:stdout) { should match(/gpgv: Good signature from ".*#{key_id}/) }
its(:stdout) { should contain 'All done.' }
end
describe file "/srv/debmirror/#{@repo_name}" do
it { should exist }
it { should be_directory }
end
end
describe command 'crontab -u nobody -l' do
its(:exit_status) { should be_zero }
its(:stdout) do
should match '^((\d+|\*) ){5}run-parts --regex=\.sh\$ /etc/debmirror\.d$'
end
its(:stderr) { should be_empty }
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment