generated from genaumann/salt-formula-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{% from 'acme_sh/map.jinja' import acme_sh with context %} | ||
{%- for user, config in acme_sh.items() %} | ||
{%- if config.get('certs') is mapping %} | ||
{%- for domain, cert_config in config['certs'].items() %} | ||
acme_sh_cert_{{ user }}_{{ domain }}: | ||
acme_sh.cert: | ||
- name: {{ domain }} | ||
- acme_mode: {{ cert_config['acme_mode'] }} | ||
{%- if cert_config.get('aliases') %} | ||
- aliases: {{ cert_config['aliases'] }} | ||
{%- endif %} | ||
- server: {{ cert_config.get('server', 'letsencrypt') }} | ||
- keysize: {{ cert_config.get('keysize', '4096') }} | ||
{%- if cert_config.get('dns_plugin') %} | ||
- dns_plugin: {{ cert_config['dns_plugin'] }} | ||
{%- endif %} | ||
{%- if cert_config.get('webroot') %} | ||
- webroot: {{ cert_config['webroot'] }} | ||
{%- endif %} | ||
{%- if cert_config.get('http_port') %} | ||
- http_port: {{ cert_config['http_port'] }} | ||
{%- endif %} | ||
- user: {{ user }} | ||
{%- if cert_config.get('cert_path') %} | ||
- cert_path: {{ cert_config['cert_path'] }} | ||
{%- endif %} | ||
{%- if cert_config.get('dns_credentials') %} | ||
- dns_credentials: {{ cert_config['dns_credentials'] }} | ||
{%- endif %} | ||
- force: {{ cert_config.get('force', False) }} | ||
{%- if cert_config.get('valid_to') %} | ||
- valid_to: {{ cert_config['valid_to'] }} | ||
{%- endif %} | ||
{%- if cert_config.get('valid_from') %} | ||
- valid_from: {{ cert_config['valid_from'] }} | ||
{%- endif %} | ||
{%- endfor %} | ||
{%- endif %} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include: | ||
- acme_sh.install | ||
- acme_sh.cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{%- from 'acme_sh/map.jinja' import acme_sh with context %} | ||
{%- for user, config in acme_sh.items() %} | ||
acme_sh_install_{{ user }}: | ||
acme_sh.installed: | ||
- email: {{ config['email'] }} | ||
- user: {{ user }} | ||
{%- if config.get('upgrade') %} | ||
- upgrade: {{ config['upgrade'] }} | ||
{%- endif %} | ||
{%- if config.get('force') %} | ||
- force: {{ config['force'] }} | ||
{%- endif %} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% set acme_sh = salt['pillar.get']('acme_sh', {}) %} | ||
|
||
{# get credentials from env #} | ||
{%- set envs = salt['environ.items']() %} | ||
{%- for key, value in envs.items() %} | ||
{%- if key.startswith('ACMESH_') %} | ||
{%- set parts = key.split('_') %} | ||
{%- set user = parts[1] %} | ||
{%- set domain = parts[2] | regex_replace('(?<!^)(?=[A-Z])', '.') | lower %} | ||
{%- set var = '_'.join(parts[3:]) %} | ||
{#- if acme_sh.get(user) and acme_sh[user].get(domain) and acme_sh[user][domain].get(acme_mode) == 'dns' #} | ||
{%- set acme_sh = acme_sh | update_dict_key_value(user ~ ':certs:' ~ domain ~ ':dns_credentials', {var:value}) %} | ||
{#- endif #} | ||
{%- endif %} | ||
{%- endfor %} |