Browse Source

feat(gateway): First 'default' recipe

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 2 years ago
parent
commit
adb7556e35

+ 30 - 0
cookbooks/gateway/attributes/_git.rb

@@ -0,0 +1,30 @@
+default['workstation']['_git']['system'] = {
+  'color.ui': true,
+  'color.diff': 'auto',
+  'color.status': 'auto',
+  'color.branch': 'auto',
+  'color.interactive': 'auto',
+  'status.submodulesummary': true,
+  'fetch.recursesubmodules': true,
+  'rebase.stat': true,
+  'help.autocorrect': '10',
+  'commit.verbose': true,
+  'alias.gol': %Q{log --graph --pretty=format:'%C(yellow)%h%C(green)%d%Creset %s %C(white) %an, %ar%Creset'},
+  'alias.commit': '--signoff',
+  'alias.com': 'commit --signoff',
+  'alias.coma': 'commit --signoff --amend',
+  'alias.push': '--verbose --tags',
+  'alias.pull': '--verbose',
+  'alias.co': 'checkout',
+  'alias.br': 'branch --all --verbose',
+  'alias.s': 'status --short --branch',
+  'include.path': '~/.gitconfig',
+  'user.email': "jeremy@#{node['hostname']}",
+  'user.name': 'Jeremy from Gateway',
+}
+
+default['workstation']['_git']['global'] = {
+  'user.email': 'jeremy.mauro@gmail.com',
+  'user.name': 'Jeremy MAURO',
+  'url.git@github.com': '.insteadof=https://github.com/',
+}

+ 5 - 0
cookbooks/gateway/metadata.rb

@@ -17,3 +17,8 @@ chef_version '>= 16.0'
 # a Supermarket.
 #
 # source_url 'https://github.com/<insert_org_here>/gateway'
+
+depends 'etckeeper'
+depends 'git'
+depends 'apt_repositories'
+depends 'resolver_config'

+ 22 - 0
cookbooks/gateway/recipes/_git.rb

@@ -0,0 +1,22 @@
+#
+# Cookbook:: workstation
+# Recipe:: _git
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+
+include_recipe 'git'
+
+node['gateway']['_git'].each do |scope_git, git_options|
+  if scope_git.match(/^file_/)
+    gitconfig_file = $' # String after the match (ref: https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Special+global+variables)
+    scope_git = 'file'
+  end
+  git_options.each do |k, v|
+    git_config k do
+      value v.to_s
+      scope scope_git
+      user username if %w{global file}.include?(scope_git)
+      config_file gitconfig_file if scope_git == 'file'
+    end
+  end
+end

+ 39 - 0
cookbooks/gateway/recipes/_packages.rb

@@ -0,0 +1,39 @@
+#
+# Cookbook:: workstation
+# Recipe:: _packages
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+#
+
+package %w{
+  moreutils
+  debian-goodies
+  bash-completion
+  vim
+  dnsutils
+  whois
+  iproute2
+  apt-file
+  mc
+  curl
+  wget
+  grc
+  jq
+  lftp
+  lsof
+  openssh-client
+  plocate
+  smem
+  sudo
+} do
+  notifies :run, 'execute[/usr/bin/apt-file update]', :immediately
+  notifies :run, 'execute[/usr/bin/updatedb]', :immediately
+end
+
+execute '/usr/bin/apt-file update' do
+  action :nothing
+end
+
+execute '/usr/bin/updatedb' do
+  action :nothing
+end

+ 23 - 0
cookbooks/gateway/recipes/default.rb

@@ -3,3 +3,26 @@
 # Recipe:: default
 #
 # Copyright:: 2022, The Authors, All Rights Reserved.
+
+# Enable json file reports
+chef_handler 'Chef::Handler::JsonFile' do
+  source 'chef/handler/json_file'
+  arguments path: '/var/chef/reports'
+  action :enable
+end
+
+# Configure repo
+include_recipe 'apt_repositories::_official'
+
+# Setup podman
+include_recipe 'apt_repositories::_podman'
+
+# Setup 'git'
+include_recipe 'gateway::_git'
+
+# Add defaut packages
+include_recipe 'gateway::_packages'
+
+# END: Setup etckeeper
+include_recipe 'etckeeper'
+include_recipe 'etckeeper::commit'