This repository has been archived by the owner on Aug 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
69 lines (58 loc) · 1.87 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'date'
sh '/bin/bash lib/init.sh' if !File.exist?('Gemfile.lock') || (Date.today - File.mtime('Gemfile.lock').to_date).to_i > 20
require 'bundler/setup'
require_relative 'lib/helpers'
require_relative 'lib/git'
require_relative 'lib/certbot'
require_relative 'lib/chef_vault'
Rake.application.options.suppress_backtrace_pattern = %r{/} # Suppress trace when running. Using --trace still works
desc 'Initialize project'
task :init do
Helpers.log Certbot.init
Helpers.log ChefVault.init if Helpers.config['steps'].include?('chef_vault')
# HashicorpVault.init if Helpers.config['steps'].key?('hashicorp_vault')
end
desc 'Displays Help'
task :help do
puts 'How to use these rake taks:
Check the available tasks with rake23 -T.'
end
namespace :git do
desc 'Commit and push repository'
task :push do
Git.push
end
end
namespace :certbot do
desc 'Register Certbot account'
task :register do
Helpers.log Certbot.register
end
desc 'Run arbitrary certbot command passed as parameter'
task :run, [:cmd] do |_t, args|
Helpers.log Certbot.run(args[:cmd])
end
desc 'Run certbot to obtain or renew certificates'
task :renew do
Helpers.config['certificates'].each do |name, props|
Helpers.log Certbot.renew(name, props['domains'])
end
end
desc 'Run certbot to revoke a certificate'
task :revoke, [:cert] do |_t, args|
Helpers.log Certbot.revoke(args[:cert])
end
end
namespace :chef_vault do
desc 'Upload all changed certificates as chef vaults'
task :upload do
Helpers.config['certificates'].each do |name, props|
Helpers.log ChefVault.upload(name, props['chef_vault'] || {})
end
end
end if Helpers.config['steps'].include?('chef_vault')
desc 'Cleanup all temporary files, docker containers etc'
task :cleanup do
Helpers.log Certbot.cleanup
Helpers.log ChefVault.cleanup if Helpers.config['steps'].include?('chef_vault')
end