-
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
10 changed files
with
86 additions
and
30 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
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
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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
--- | ||
- include_tasks: deps.yml | ||
when: installed_acme_deps is not defined | ||
|
||
- include_tasks: acme.yml | ||
|
||
- include_role: | ||
name: noobient.setfcontext | ||
- include_tasks: main2.yml | ||
vars: | ||
path: "{{ acme_deploy_dir }}" | ||
type: 'cert_t' | ||
pattern: "{{ acme_deploy_dir }}(/.*)?" | ||
when: ansible_os_family == 'RedHat' | ||
domain: "{{ item.domain }}" | ||
provider: "{{ item.provider }}" | ||
credential: "{{ item.credential }}" | ||
wildcard: "{{ item.wildcard | default('') }}" | ||
cronjob: "{{ item.cronjob | default('') }}" | ||
staging: "{{ item.staging | default('') }}" | ||
sleep: "{{ item.sleep | default('') }}" | ||
min_days: "{{ item.min_days | default('') }}" | ||
reload_cmd: "{{ item.reload_cmd | default('') }}" | ||
loop: "{{ acme_batch }}" | ||
loop_control: | ||
# make sure we don't leak credentials to stdout lol | ||
label: "{{ item.domain }}" | ||
when: (acme_batch is defined) and (acme_batch.__class__.__name__ == 'list') | ||
|
||
- include_tasks: cron.yml | ||
when: eff_cronjob | ||
- include_tasks: main2.yml | ||
when: (acme_batch is not defined) or (acme_batch.__class__.__name__ != 'list') |
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,16 @@ | ||
--- | ||
- include_tasks: deps.yml | ||
when: installed_acme_deps is not defined | ||
|
||
- include_tasks: acme.yml | ||
|
||
- include_role: | ||
name: noobient.setfcontext | ||
vars: | ||
path: "{{ acme_deploy_dir }}" | ||
type: 'cert_t' | ||
pattern: "{{ acme_deploy_dir }}(/.*)?" | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- include_tasks: cron.yml | ||
when: eff_cronjob | bool |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Minutes are pseudo-random, to ensure idempotency, but still don't flood ACME with all certs at once. | ||
{{ domain.split('.')[0] | length % 6 }}{{ domain | length % 10 }} 07 1 * * root {{ acme_install_dir }}/acme.sh {% if eff_staging %}--staging{% else %}--server letsencrypt{% endif %} --ecc --renew --dns dns_{{ provider }} --dnssleep {{ eff_sleep }} --force --domain {{ domain }}{% if eff_wildcard %} --domain *.{{ domain }}{% endif %} >> /var/log/letsencrypt 2>&1 | ||
{{ domain.split('.')[0] | length % 6 }}{{ domain | length % 10 }} 07 1 * * root {{ acme_install_dir }}/acme.sh {% if eff_staging | bool %}--staging{% else %}--server letsencrypt{% endif %} --ecc --renew --dns dns_{{ provider }} --dnssleep {{ eff_sleep | int }} --force --domain {{ domain }}{% if eff_wildcard | bool %} --domain *.{{ domain }}{% endif %} >> /var/log/letsencrypt 2>&1 | ||
|
||
{% if reload_cmd is defined and reload_cmd | length %} | ||
{{ domain.split('.')[0] | length % 6 }}{{ domain | length % 10 }} 08 1 * * root {{ reload_cmd }} | ||
{% if eff_reload_cmd | length %} | ||
{{ domain.split('.')[0] | length % 6 }}{{ domain | length % 10 }} 08 1 * * root {{ eff_reload_cmd }} | ||
{% endif %} |
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,8 @@ | ||
--- | ||
# Idempotency and batch | ||
- include_role: | ||
name: "{{ playbook_dir.split('/')[:-1] | last }}" | ||
vars: | ||
acme_batch: | ||
- { domain: "{{ noobient_acme_test_domain_2 }}", provider: 'cf', credential: { CF_Token: "{{ lookup('ansible.builtin.env', 'CF_Token') }}", CF_Account_ID: "{{ lookup('ansible.builtin.env', 'CF_Account_ID') }}", CF_Zone_ID: "{{ lookup('ansible.builtin.env', 'CF_Zone_ID') }}" }, cronjob: 'true', staging: 1 } | ||
- { domain: "{{ noobient_acme_test_domain }}", provider: 'cf', credential: { CF_Token: "{{ lookup('ansible.builtin.env', 'CF_Token') }}", CF_Account_ID: "{{ lookup('ansible.builtin.env', 'CF_Account_ID') }}", CF_Zone_ID: "{{ lookup('ansible.builtin.env', 'CF_Zone_ID') }}" }, wildcard: yes, staging: 'true' } |
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,22 @@ | ||
--- | ||
# set_fact appears to be async, so acme_new may be undefined without individual calls | ||
- set_fact: | ||
acme_new: "{ '{{ item.domain }}.cert_file': '{{ item.domain }}.cer' }" | ||
|
||
# the closes thing to add() | ||
- set_fact: | ||
acme: "{{ acme | combine( acme_new ) }}" | ||
|
||
# TODO still won't work. The combine part adds the previous stuff to the new keys. | ||
- set_fact: | ||
acme_new: "{ '{{ item.domain }}.key_file': '{{ item.domain }}.key' }" | ||
|
||
# the closes thing to add() | ||
- set_fact: | ||
acme: "{{ acme | combine( acme_new ) }}" | ||
|
||
# the closes thing to unset_fact | ||
- set_fact: | ||
acme_new: | ||
|
||
- include_tasks: print.yml |
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
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
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
--- | ||
noobient_acme_test_domain: "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second }}.vault-tec.info" | ||
noobient_acme_test_prefix: "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second }}" | ||
noobient_acme_test_domain: "{{ noobient_acme_test_prefix }}a.vault-tec.info" | ||
noobient_acme_test_domain_2: "{{ noobient_acme_test_prefix }}b.vault-tec.info" |