apt_repository 'openvpn' do
uri 'http://build.openvpn.net/debian/openvpn'
distribution node['lsb']['codename']
components ['main', 'stable']
keyserver 'https://swupdate.openvpn.net/repos/repo-public.gpg'
end
apt_package 'openvpn' do
version '2.4.2'
end
This code generates /etc/apt/sources.list.d/openvpn.list deb "http://build.openvpn.net/debian/openvpn" xenial main stable
And apt-get update command fails.
If I modify file in the way specified here deb http://build.openvpn.net/debian/openvpn/stable xenial main
I get public key verification failure. After adding it manually, apt-get update is successful.
What is wrong in my code?
Err:7 http://build.openvpn.net/debian/openvpn xenial/main amd64 Packages
404 Not Found
Ign:8 http://build.openvpn.net/debian/openvpn xenial/main i386 Packages
Ign:9 http://build.openvpn.net/debian/openvpn xenial/main all Packages
Ign:10 http://build.openvpn.net/debian/openvpn xenial/main Translation-en
Fetched 306 kB in 5s (54.5 kB/s)
Reading package lists...
STDERR: W: The repository 'http://build.openvpn.net/debian/openvpn xenial Release' does not have a Release file.
E: Failed to fetch http://build.openvpn.net/debian/openvpn/dists/xenial/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
---- End output of apt-get -q update ----
Ran apt-get -q update returned 100
Right, so look at the URI you’re expecting: http://build.openvpn.net/debian/openvpn/stable and the URI you’re passing to the resource: http://build.openvpn.net/debian/openvpn, and make the two the same.
If you just have the URL for a key and not the key signature you can simply specify the URL in the key attribute
So this code works
apt_repository 'openvpn' do
uri 'http://build.openvpn.net/debian/openvpn/stable'
distribution node['lsb']['codename']
components ['main']
key 'http://build.openvpn.net/debian/openvpn/stable/pubkey.gpg'
end
apt_package 'openvpn' do
version '2.4.2-xenial0'
end