Skip to content

Commit

Permalink
Merge pull request #73 from netmanagers/master
Browse files Browse the repository at this point in the history
update to good-citizen defaults
  • Loading branch information
javierbertoli authored Jul 23, 2020
2 parents e59bf3f + 926c779 commit d39113a
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 19 deletions.
5 changes: 4 additions & 1 deletion letsencrypt/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ letsencrypt-config-directory:
letsencrypt-config:
file.managed:
- name: {{ letsencrypt.config_dir.path }}/cli.ini
- template: jinja
- source: salt://letsencrypt/files/cli.ini.jinja
- user: {{ letsencrypt.config_dir.user }}
- group: {{ letsencrypt.config_dir.group }}
- makedirs: true
- contents_pillar: letsencrypt:config
- context:
config: {{ letsencrypt.config | json }}
8 changes: 7 additions & 1 deletion letsencrypt/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
letsencrypt:
use_package: true
pkgs:
- python-certbot-apache
- python3-certbot-apache
service: certbot.timer
# Only used for the git install method (use_package: false)
cli_install_dir: /opt/letsencrypt
Expand All @@ -17,6 +17,12 @@ letsencrypt:
user: root
group: root
mode: 755
config:
server: https://acme-v02.api.letsencrypt.org/directory
agree-tos: true
keep-until-expiring: true
expand: true
max-log-backups: 0
# The post_renew cmds are executed via renew_letsencrypt_cert.sh after every
# run. For more fine grain control, consider placing scripts in the pre,
# post, and/or deploy directories within /etc/letsencrypt/renewal-hooks/. For
Expand Down
11 changes: 11 additions & 0 deletions letsencrypt/files/cli.ini.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
########################################################################
# File managed by Salt at <{{ source }}>.
# Your changes will be overwritten.
########################################################################
{%- if config is string %}
{{ config }}
{%- else %}
{%- for k, v in config.items() %}
{{ k }} = {{ v }}
{%- endfor %}
{%- endif %}
7 changes: 6 additions & 1 deletion letsencrypt/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
{#- Start with defaults from defaults.sls #}
{% import_yaml 'letsencrypt/defaults.yaml' as defaults %}
{% import_yaml 'letsencrypt/osfamilymap.yaml' as osfamilymap %}
{% import_yaml 'letsencrypt/osmap.yaml' as osmap %}

{% set letsencrypt = salt['grains.filter_by'](
defaults,
merge = salt['grains.filter_by'](
osfamilymap,
grain='os_family',
merge = salt['pillar.get']('letsencrypt', {}),
merge=salt['grains.filter_by'](
osmap,
grain='os',
merge = salt['pillar.get']('letsencrypt', {}),
),
),
base='letsencrypt')
%}
2 changes: 0 additions & 2 deletions letsencrypt/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
# vim: ft=yaml
---
RedHat:
pkgs:
- python2-certbot-apache
service: certbot-renew.timer
16 changes: 16 additions & 0 deletions letsencrypt/osmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['os'] based logic.
# You just need to add the key:values for an `os` that differ
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`.
# Only add an `os` which is/will be supported by the formula.
#
# If you do not need to provide defaults via the `os` grain,
# you will need to provide at least an empty dict in this file, e.g.
# osmap: {}
---
# os_family: RedHat
Amazon:
pkgs:
- python2-certbot-apache
28 changes: 21 additions & 7 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@ letsencrypt:
# have specific version of certbot you can enable it. The version value
# should match a certbot/certbot branch.
version: 0.30.x
config: |
server = https://acme-v01.api.letsencrypt.org/directory
email = [email protected]
authenticator = webroot
webroot-path = /var/lib/www
agree-tos = True
renew-by-default = True
# Any parameter from the cli can be specified in the config file
# check https://certbot.eff.org/docs/using.html#configuration-file
config:
server: https://acme-v02.api.letsencrypt.org/directory
email: [email protected]
authenticator: webroot
webroot-path: /var/lib/www
agree-tos: true
keep-until-expiring: true
expand: true
# For backward compatibility, config can be passed as a string
# (although it's discouraged, as this format might be dropped in a future
# release)
# config: |
# server = https://acme-v01.api.letsencrypt.org/directory
# email = [email protected]
# authenticator = webroot
# webroot-path = /var/lib/www
# agree-tos = True
# keep-until-expiring = True
# expand = True
config_dir:
path: /etc/letsencrypt
user: root
Expand Down
1 change: 1 addition & 0 deletions test/integration/deb/controls/letsencrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
should match 'server = https://acme-staging.api.letsencrypt.org/directory'
end
its('content') { should match 'authenticator = webroot' }
its('content') { should match 'File managed by Salt' }
end

describe file('/usr/bin/letsencrypt') do
Expand Down
1 change: 1 addition & 0 deletions test/integration/git/controls/letsencrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
should match 'server = https://acme-staging.api.letsencrypt.org/directory'
end
its('content') { should match 'authenticator = standalone' }
its('content') { should match 'File managed by Salt' }
end
1 change: 1 addition & 0 deletions test/integration/rpm/controls/letsencrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
should match 'server = https://acme-staging.api.letsencrypt.org/directory'
end
its('content') { should match 'authenticator = webroot' }
its('content') { should match 'File managed by Salt' }
end

describe file('/usr/bin/letsencrypt') do
Expand Down
14 changes: 7 additions & 7 deletions test/salt/pillar/rpm.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
---
letsencrypt:
use_package: true
config: |
server = https://acme-staging.api.letsencrypt.org/directory
email = [email protected]
authenticator = webroot
webroot-path = /var/www/html
agree-tos = true
renew-by-default = true
config:
server: https://acme-staging.api.letsencrypt.org/directory
email: [email protected]
authenticator: webroot
webroot-path: /var/www/html
agree-tos: true
renew-by-default: true
domainsets:
www:
- letsencrypt-formula.example.com

0 comments on commit d39113a

Please sign in to comment.