Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use snapd to install certbot #7

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/certbot_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module CertbotCmd
def initialize(*args)
@post_hook = []
@extra_args = []
super *args
super(*args)
end

def certbot
Expand Down
4 changes: 2 additions & 2 deletions libraries/certbot_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def certbot_exec_setup
post_hook []
extra_args []
notifies :install, 'certbot_pkg[certbot]', :before
notifies :create, 'ohai_plugin[certbot]', :immediate
notifies :reload, 'ohai[certbot]', :immediate
notifies :create, 'ohai_plugin[certbot]', :immediately
notifies :reload, 'ohai[certbot]', :immediately
action :exec
end
end
Expand Down
6 changes: 2 additions & 4 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
maintainer_email 'qubitrenegade@protonmail.com'
license 'MIT'
description 'Installs/Configures certbot-exec'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.2'
chef_version '>= 13.0'

Expand All @@ -13,6 +12,5 @@
issues_url 'https://github.com/qubitrenegade/certbot-exec/issues'
source_url 'https://github.com/qubitrenegade/certbot-exec'

%w(centos ubuntu).each do |platform|
supports platform
end
supports 'centos'
supports 'ubuntu'
4 changes: 3 additions & 1 deletion resources/certbot_cmd.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
unified_mode true

provides :certbot_cmd
resource_name :certbot_cmd

property :domains, [String, Array], name_property: true, coerce: proc { |x| [x].flatten }
property :post_hook, [String, Array], default: [], coerce: proc { |x| [x].flatten }
property :extra_args, [String, Array], coerce: proc { |x| [x].flatten }
property :force, [TrueClass, FalseClass], default: false
property :force, [true, false], default: false

action :exec do
if new_resource.force
Expand Down
4 changes: 3 additions & 1 deletion resources/certbot_exec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
unified_mode true

provides :certbot_exec
resource_name :certbot_exec

property :domains, [String, Array], name_property: true, coerce: proc { |x| [x].flatten }
property :post_hook, [String, Array], default: [], coerce: proc { |x| [x].flatten }
property :extra_args, [String, Array], default: [], coerce: proc { |x| [x].flatten }
property :packages, [String, Array], default: [], coerce: proc { |x| [x].flatten }
property :force, [TrueClass, FalseClass], default: false
property :force, [true, false], default: false

action :run do
initial_setup
Expand Down
2 changes: 2 additions & 0 deletions resources/certbot_pkg.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
unified_mode true

provides :certbot_pkg
resource_name :certbot_pkg

Expand Down
15 changes: 12 additions & 3 deletions resources/certbot_repo.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
unified_mode true

provides :certbot_repo
resource_name :certbot_repo

action :create do
case node['platform']
when 'centos', 'redhat', 'scientific', 'oracle'
Chef::Log.warn "Untested on #{platform}" if %w(redhat scientific oracle).include? node['platform']
Chef::Log.warn "Untested on #{platform}" if platform?('redhat', 'scientific', 'oracle')
include_recipe 'yum-epel'
when 'ubuntu', 'debian'
apt_repository 'certbot' do
uri 'ppa:certbot/certbot'
# Multiple people report problems with this resource, even on the slack chanel. https://chefcommunity.slack.com/archives/C0M1NGZE3/p1652383770807739
# snap_package 'certbot' do
# package_name ['certbot']
# end

execute 'install_certbot' do
command 'snap install --classic certbot'
action :run
not_if 'snap list certbot'
end
end
end
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ def default_attrs_from_file
)
default
end

at_exit { ChefSpec::Coverage.report! }
2 changes: 1 addition & 1 deletion spec/unit/libraries/certbot_cmd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

new_resource = Struct.new(:domains, :post_hook, :extra_args)
.new(
['domain-foo1', 'domain-bar2'],
%w(domain-foo1 domain-bar2),
['post-hook foo 1', 'post-hook foo 2'],
['--extra-args1', '--extra-args2']
)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
let(:chef_run) do
# for a complete list of available platforms and versions see:
# https://github.com/customink/fauxhai/blob/master/PLATFORMS.md
runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '7.4.1708')
runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '7')
runner.converge(described_recipe)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
certbot_exec 'foo.example.com' do
case node[:platform]
case node['platform']
when 'redhat', 'centos'
packages 'python2-certbot-dns-cloudflare'
when 'ubuntu', 'debian'
Expand Down