-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for installing an existing ACME account
- Loading branch information
1 parent
dec334d
commit b9b001b
Showing
7 changed files
with
114 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
|
||
- name: Install provided Let's Encrypt ACME account | ||
block: | ||
|
||
- name: Create ACME v02 account directory | ||
ansible.builtin.file: | ||
path: "{{ letsencrypt_directory }}/{{ item }}" | ||
owner: root | ||
group: root | ||
mode: 0700 | ||
state: directory | ||
with_items: | ||
- accounts | ||
- accounts/acme-v02.api.letsencrypt.org | ||
- accounts/acme-v02.api.letsencrypt.org/directory | ||
- accounts/acme-v02.api.letsencrypt.org/directory/{{ letsencrypt_account.hash }} | ||
|
||
- name: Copy Let's Encrypt account data files | ||
ansible.builtin.template: | ||
src: "account/{{ item }}.j2" | ||
dest: "{{ letsencrypt_directory }}/accounts/acme-v02.api.letsencrypt.org/directory/{{ letsencrypt_account.hash }}/{{ item }}" | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
with_items: | ||
- meta.json | ||
- regr.json | ||
|
||
- name: Copy Let's Encrypt account key file | ||
ansible.builtin.template: | ||
src: account/private_key.json.j2 | ||
dest: "{{ letsencrypt_directory }}/accounts/acme-v02.api.letsencrypt.org/directory/{{ letsencrypt_account.hash }}/private_key.json" | ||
owner: root | ||
group: root | ||
mode: 0400 | ||
|
||
when: letsencrypt_account | ||
|
||
- name: Create new Let's Encrypt ACME account | ||
block: | ||
|
||
- name: Check if a Let's Encrypt account exists | ||
ansible.builtin.stat: | ||
path: "{{ letsencrypt_directory }}/accounts" | ||
register: letsencrypt_reg_accounts_dir | ||
|
||
- name: Prepare optional account email option | ||
ansible.builtin.set_fact: | ||
letsencrypt_opt_email: "{{ letsencrypt_account_email | ternary('--email ' + letsencrypt_account_email, '') }}" | ||
|
||
- name: Create new Let's Encrypt account | ||
ansible.builtin.command: > | ||
certbot register | ||
{{ letsencrypt_opt_test_cert }} | ||
{{ letsencrypt_opt_email }} | ||
{{ letsencrypt_opts_extra }} | ||
--non-interactive --agree-tos --quiet | ||
register: letsencrypt_reg_account | ||
changed_when: letsencrypt_reg_account.rc != 0 | ||
when: not letsencrypt_reg_accounts_dir.stat.exists | ||
|
||
when: not letsencrypt_account | ||
tags: | ||
- molecule-notest |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{"creation_dt": "{{ letsencrypt_account.creation_dt }}","creation_host": "{{ letsencrypt_account.creation_host }}"} |
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,11 @@ | ||
{ | ||
"n": "{{ letsencrypt_account.private_key.n }}", | ||
"e": "{{ letsencrypt_account.private_key.e }}", | ||
"d": "{{ letsencrypt_account.private_key.d }}", | ||
"p": "{{ letsencrypt_account.private_key.p }}", | ||
"q": "{{ letsencrypt_account.private_key.q }}", | ||
"dp": "{{ letsencrypt_account.private_key.dp }}", | ||
"dq": "{{ letsencrypt_account.private_key.dq }}", | ||
"qi": "{{ letsencrypt_account.private_key.qi }}", | ||
"kty": "{{ letsencrypt_account.private_key.kty }}" | ||
} |
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 @@ | ||
{"body": {}, "uri": "https://acme-v02.api.letsencrypt.org/acme/acct/{{ letsencrypt_account.id }}"} |