-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from louim/add-snake-oil-certs
Allow auto-generation of self signed SSL certificate.
- Loading branch information
Showing
5 changed files
with
40 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
- include: database.yml | ||
- include: self-signed-certificate.yml | ||
- include: nginx.yml | ||
|
||
- name: Create web root | ||
|
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,28 @@ | ||
--- | ||
- name: Get existing self-signed certificates | ||
shell: find . -name "*_self_signed.pem" | ||
args: | ||
chdir: /etc/nginx/ssl/ | ||
register: self_signed_certs | ||
changed_when: false | ||
|
||
- name: Get self-signed certificates domains | ||
shell: openssl x509 -noout -subject -in {{ item | quote }} | sed -n "/^subject/s/^.*CN=//p" | ||
register: self_signed_domains | ||
args: | ||
chdir: /etc/nginx/ssl/ | ||
with_items: self_signed_certs.stdout_lines | ||
changed_when: false | ||
|
||
- name: Generate self-signed certificates | ||
shell: > | ||
openssl req -subj "/CN={{ item.value.site_hosts | first }}" -new | ||
-newkey rsa:2048 -days 3650 -nodes -x509 -sha256 | ||
-keyout {{ item.key }}_self_signed.key -out {{ item.key }}_self_signed.pem | ||
args: | ||
chdir: /etc/nginx/ssl/ | ||
with_dict: wordpress_sites | ||
when: > | ||
item.value.ssl.enabled and item.value.site_hosts | first | ||
not in self_signed_domains.results | default([]) | map(attribute='stdout') | list | ||
notify: reload nginx |
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