itamae/cookbooks/base/packages.rb

79 lines
2.0 KiB
Ruby
Raw Normal View History

2019-03-03 08:50:49 +00:00
# Execute `apt update`:
execute 'apt update'
# Install the necessary packages:
2024-04-06 08:12:49 +00:00
%w[build-essential zsh vim-nox debian-keyring curl direnv jq avahi-daemon wget gpg coreutils].each do |pkg|
2019-03-03 08:50:49 +00:00
package pkg
end
# Install the extra kernel:
unless node['is_ec2']
case run_command('grep VERSION_ID /etc/os-release | awk -F\" \'{print $2}\'').stdout.chomp
when "16.04"
2019-03-03 08:50:49 +00:00
KERNEL = run_command("uname -r").stdout.chomp
package "linux-image-extra-#{KERNEL}"
when "18.04"
package 'linux-image-extra-virtual'
2019-03-03 08:50:49 +00:00
end
end
### Here we are going to install git.
# Constants:
case run_command('grep VERSION_ID /etc/os-release | awk -F\" \'{print $2}\'').stdout.chomp
when "24.04"
execute 'add-apt-repository -y ppa:git-core/ppa' do
not_if 'test -e /etc/apt/sources.list.d/git-core-ubuntu-ppa-noble.sources'
end
else
KEYSRV = 'hkp://keyserver.ubuntu.com:80'
ID = 'E1DF1F24'
2019-03-03 08:50:49 +00:00
# Retrieve the Ubuntu code:
DIST = run_command('lsb_release -cs').stdout.chomp
2019-03-03 08:50:49 +00:00
# Add the public key file to install `git`
execute "apt-key adv --keyserver #{KEYSRV} --recv-keys #{ID}" do
not_if 'apt-key list | grep "E1DF 1F24"'
end
2019-03-03 08:50:49 +00:00
# Deploy the `apt` sources:
template '/etc/apt/sources.list.d/git.list' do
action :create
variables(distribution: DIST)
end
2019-03-03 08:50:49 +00:00
end
execute 'apt update' do
not_if 'LANG=C apt-cache policy git | grep Installed | grep ppa'
end
execute 'apt install git -y' do
not_if 'LANG=C apt-cache policy git | grep Installed | grep ppa'
end
GIT_PREPUSH = '/usr/share/git-core/templates/hooks/pre-push'
PREPUSH = 'https://gist.github.com/kazu634/8267388/raw/e9202cd4c29a66723c88d2be05f3cd19413d2137/pre-push'
2019-03-03 08:50:49 +00:00
execute "wget #{PREPUSH} -O #{GIT_PREPUSH}" do
not_if "test -e #{GIT_PREPUSH}"
end
[
'/usr/share/git-core/templates/hooks/pre-commit',
].each do |conf|
remote_file conf do
user 'root'
owner 'root'
group 'root'
2022-08-07 11:49:33 +00:00
mode '755'
2019-03-03 08:50:49 +00:00
end
end
2023-12-09 05:56:03 +00:00
execute 'ufw allow 5353/udp' do
user 'root'
not_if 'LANG=c ufw status | grep 5353'
notifies :run, 'execute[ufw reload-or-enable]'
end