From 4aaecfdcfdd006758f0224d6e870603bf70104f3 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 5 Feb 2023 11:00:25 +0900 Subject: [PATCH] Add `everun` recipe. --- cookbooks/everun/attributes.rb | 9 ++++++ cookbooks/everun/default.rb | 5 ++++ cookbooks/everun/files/etc/cron.d/everun | 1 + cookbooks/everun/nginx.rb | 38 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 cookbooks/everun/attributes.rb create mode 100644 cookbooks/everun/default.rb create mode 100644 cookbooks/everun/files/etc/cron.d/everun create mode 100644 cookbooks/everun/nginx.rb diff --git a/cookbooks/everun/attributes.rb b/cookbooks/everun/attributes.rb new file mode 100644 index 0000000..994debb --- /dev/null +++ b/cookbooks/everun/attributes.rb @@ -0,0 +1,9 @@ +# ------------------------------------------- +# Specifying the default settings: +# ------------------------------------------- +node.reverse_merge!({ + 'everun' => { + 'FQDN' => 'everun.club', + 'production' => true + } +}) diff --git a/cookbooks/everun/default.rb b/cookbooks/everun/default.rb new file mode 100644 index 0000000..dd3cbd2 --- /dev/null +++ b/cookbooks/everun/default.rb @@ -0,0 +1,5 @@ +include_recipe './attributes.rb' + +if node['everun']['production'] + include_recipe './nginx.rb' +end diff --git a/cookbooks/everun/files/etc/cron.d/everun b/cookbooks/everun/files/etc/cron.d/everun new file mode 100644 index 0000000..e62f6cb --- /dev/null +++ b/cookbooks/everun/files/etc/cron.d/everun @@ -0,0 +1 @@ +@reboot webadm cp -pr /home/webadm/works/everun/* /var/www/everun/ diff --git a/cookbooks/everun/nginx.rb b/cookbooks/everun/nginx.rb new file mode 100644 index 0000000..777d3c1 --- /dev/null +++ b/cookbooks/everun/nginx.rb @@ -0,0 +1,38 @@ +# Create the nginx directory: +%w( everun test-everun ).each do |d| + directory "/var/www/#{d}" do + owner 'www-data' + group 'webadm' + mode '770' + end +end + +# Add the fstab entry: +file '/etc/fstab' do + action :edit + + block do |content| + content << "tmpfs /var/www/everun tmpfs size=250m,noatime 0 0\n" + end + + not_if 'grep /var/www/everun /etc/fstab' + + notifies :run, 'execute[mount -a]' +end + +execute 'mount -a' do + action :nothing +end + +remote_file '/etc/cron.d/everun' do + owner 'root' + group 'root' + mode '644' +end + +# Create storage directory for blog data +directory '/home/webadm/works/everun' do + owner 'webadm' + group 'webadm' + mode '775' +end