]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/management-component-pack.rb
apt: workaround chef 18.8.11 apt_repository key bug
[chef.git] / cookbooks / apt / recipes / management-component-pack.rb
1 #
2 # Cookbook:: apt
3 # Recipe:: management-component-pack
4 #
5 # Copyright:: 2022, Tom Hughes
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 include_recipe "apt"
21
22 apt_repository "management-component-pack" do
23   action :remove
24 end
25
26 if platform?("debian")
27   apt_repository "mcp" do
28     uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
29     distribution "#{node[:lsb][:codename]}/current"
30     components ["non-free"]
31     key ["https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key1.pub", "https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key2.pub"]
32   end
33
34   # Workaround v18.8.11 bug: https://github.com/chef/chef/issues/15214
35   if Chef::VERSION == "18.8.11"
36     edit_resource(:file, "/etc/apt/keyrings/mcp.gpg") do
37       action :create_if_missing
38     end
39   end
40
41   if node[:dmi][:system][:product_name].end_with?("Gen9")
42     apt_repository "mcp-gen9" do
43       uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
44       distribution "stretch/current-gen9"
45       components ["non-free"]
46       key ["https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key1.pub", "https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key2.pub"]
47     end
48
49     # Workaround v18.8.11 bug: https://github.com/chef/chef/issues/15214
50     if Chef::VERSION == "18.8.11"
51       edit_resource(:file, "/etc/apt/keyrings/mcp-gen9.gpg") do
52         action :create_if_missing
53       end
54     end
55
56   end
57 elsif platform?("ubuntu")
58   if node[:dmi][:system][:product_name].end_with?("Gen10")
59     apt_repository "mcp-jammy" do
60       uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
61       distribution "jammy/current"
62       components ["non-free"]
63       key ["https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key1.pub", "https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key2.pub"]
64     end
65
66     # Workaround v18.8.11 bug: https://github.com/chef/chef/issues/15214
67     if Chef::VERSION == "18.8.11"
68       edit_resource(:file, "/etc/apt/keyrings/mcp-jammy.gpg") do
69         action :create_if_missing
70       end
71     end
72
73     apt_repository "mcp-focal-gen10" do
74       uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
75       distribution "focal/current-gen10"
76       components ["non-free"]
77       key ["https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key1.pub", "https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key2.pub"]
78     end
79
80     # Workaround v18.8.11 bug: https://github.com/chef/chef/issues/15214
81     if Chef::VERSION == "18.8.11"
82       edit_resource(:file, "/etc/apt/keyrings/mcp-focal-gen10.gpg") do
83         action :create_if_missing
84       end
85     end
86   else
87     apt_repository "mcp-bionic-gen9" do
88       uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
89       distribution "bionic/current-gen9"
90       components ["non-free"]
91       key ["https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key1.pub", "https://downloads.linux.hpe.com/SDR/hpePublicKey2048_key2.pub"]
92     end
93
94     # Workaround v18.8.11 bug: https://github.com/chef/chef/issues/15214
95     if Chef::VERSION == "18.8.11"
96       edit_resource(:file, "/etc/apt/keyrings/mcp-bionic-gen9.gpg") do
97         action :create_if_missing
98       end
99     end
100   end
101 end