Эх сурвалжийг харах

feat(apt): Add defautl debian repository

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 3 жил өмнө
parent
commit
2e126e7c1d

+ 70 - 0
cookbooks/workstation/recipes/_apt.rb

@@ -0,0 +1,70 @@
+#
+# Cookbook:: workstation
+# Recipe:: _apt
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+
+file '/etc/apt/sources.list' do
+  action :delete
+end
+
+components_ = %w[main contrib non-free]
+
+# Main distribution
+apt_repository 'debian_testing' do
+  arch 'amd64'
+  uri 'http://deb.debian.org/debian/'
+  distribution 'testing'
+  components components_
+  deb_src true
+  action :add
+end
+
+apt_repository 'debian_testing_updates' do
+  arch 'amd64'
+  uri 'http://deb.debian.org/debian/'
+  distribution 'testing-updates'
+  components components_
+  deb_src true
+  action :add
+end
+
+apt_repository 'debian_testing_security' do
+  arch 'amd64'
+  uri 'http://deb.debian.org/debian-security'
+  distribution 'testing-security'
+  components components_
+  deb_src true
+  action :add
+end
+
+apt_repository 'debian_testing_proposed_updates' do
+  arch 'amd64'
+  uri 'http://deb.debian.org/debian/'
+  distribution 'testing-proposed-updates'
+  components components_
+  deb_src true
+  action :add
+end
+
+# Stable in case package not found in testing
+apt_repository 'debian_stable' do
+  arch 'amd64'
+  uri 'http://deb.debian.org/debian/'
+  distribution 'stable'
+  components components_
+  deb_src true
+  action :add
+end
+
+# Apt configuration
+file '/etc/apt/apt.conf.d/01norecommend' do
+  owner 'root'
+  group 'root'
+  mode '0644'
+  content <<-_EOF.gsub(/^\s+/, '')
+    APT::Install-Recommends "0";
+    APT::Install-Suggests "0";
+  _EOF
+end
+

+ 3 - 0
cookbooks/workstation/recipes/default.rb

@@ -11,6 +11,9 @@ chef_handler 'Chef::Handler::JsonFile' do
   action :enable
 end
 
+# Configure repo
+include_recipe 'workstation::_apt'
+# Setup podman
 include_recipe 'workstation::_podman'
 
 # Setup etckeeper

+ 29 - 0
cookbooks/workstation/spec/unit/recipes/_apt_spec.rb

@@ -0,0 +1,29 @@
+#
+# Cookbook:: workstation
+# Spec:: _apt
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+
+require 'spec_helper'
+
+describe 'workstation::_apt' do
+  context 'When all attributes are default, on Ubuntu 20.04' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'ubuntu', '20.04'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+
+  context 'When all attributes are default, on CentOS 8' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'centos', '8'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+end

+ 16 - 0
cookbooks/workstation/test/integration/default/_apt_test.rb

@@ -0,0 +1,16 @@
+# Chef InSpec test for recipe workstation::_apt
+
+# The Chef InSpec reference, with examples and extensive documentation, can be
+# found at https://docs.chef.io/inspec/resources/
+
+unless os.windows?
+  # This is an example test, replace with your own test.
+  describe user('root'), :skip do
+    it { should exist }
+  end
+end
+
+# This is an example test, replace it with your own test.
+describe port(80), :skip do
+  it { should_not be_listening }
+end