Skip to content

Commit f22d3c4

Browse files
Merge pull request #224 from jpaulovic/ssl_cert_from_remote_src
Allow keytab and SSL certs to be sourced from a remote host
2 parents 52c1ee8 + 7e10cbe commit f22d3c4

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

cinch/roles/nginx/defaults/main.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ nginx_send_timeout: 120s
1515
## variables unset by default
1616
httpd_no_error_pages: false
1717
https_enabled: false
18+
# If httpd_keytab_file, httpd_ssl_key_file and httpd_ssl_crt_file
19+
# are already present on the remote Jenkins master being configured by cinch,
20+
# set the following variable to true to copy the files from the filesystem
21+
# of the remote host rather than from the system running Ansible
22+
httpd_ssl_keytab_files_remote_src: false
1823
# local path to use as source for keytab
19-
httpd_keytab_file: "/THIS/FILE/PROBABLY/DOESNT/EXIST"
24+
#httpd_keytab_file: "/THIS/FILE/PROBABLY/DOESNT/EXIST"
2025
# Local path to the SSL certificate to use in configuring HTTPS. Can be full or relative
2126
# to the path from where the main playbook is run. This can be overriden if you want
2227
# secure access to Jenkins using your own SSL certificate. By default, a self signed
2328
# certificate will be created and used.
24-
httpd_ssl_key_file: "{{ ssl_key_file | default('/THIS/FILE/PROBABLY/DOESNT/EXIST') }}"
25-
# Local path to the SSL private key in crt format. For more details see comment above.
26-
# When using own SSL certificates, you need to override either this variable or
27-
# httpd_ssl_pem_file along with httpd_ssl_key_file.
28-
httpd_ssl_crt_file: "{{ ssl_crt_file | default('/THIS/FILE/PROBABLY/DOESNT/EXIST') }}"
29+
#httpd_ssl_key_file: "/THIS/FILE/PROBABLY/DOESNT/EXIST"
30+
# Local path to the SSL private key in crt or pem format. For more details see comment above.
31+
# When using own SSL certificates, you need to override either this variable
32+
#httpd_ssl_crt_file: "/THIS/FILE/PROBABLY/DOESNT/EXIST"
2933
# Local path to the SSL private key in PEM format. For more details see comment above.
30-
httpd_ssl_pem_file: "{{ ssl_pem_file | default('/THIS/FILE/PROBABLY/DOESNT/EXIST') }}"
34+
#httpd_ssl_pem_file: "/THIS/FILE/PROBABLY/DOESNT/EXIST"
3135
# location and CN settings for the self signed certificate
3236
ssl_self_signed_string: "/C=US/ST=New York/L=New York City/O=My Department/CN={{ service_name }}"
3337
# whether to use a speedy method to generate Diffie Hellman parameters
+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
- name: copy over keytab
22
copy:
3-
src: "{{ item }}"
3+
src: "{{ httpd_keytab_file }}"
44
dest: "/etc/nginx/conf.d/httpd.keytab"
5-
with_first_found:
6-
- files:
7-
- "{{ httpd_keytab_file }}"
8-
skip: true
5+
remote_src: "{{ httpd_ssl_keytab_files_remote_src }}"
6+
when: httpd_keytab_file is defined
97
no_log: true

cinch/roles/nginx/tasks/ssl-setup.yml

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
- name: copy over ssl key
22
copy:
3-
src: "{{ item }}"
3+
src: "{{ httpd_ssl_key_file }}"
44
dest: "/etc/nginx/conf.d/ssl.key"
5+
remote_src: "{{ httpd_ssl_keytab_files_remote_src }}"
56
owner: nginx
67
group: nginx
78
mode: 0600
8-
with_first_found:
9-
- files:
10-
- "{{ httpd_ssl_key_file }}"
11-
skip: true
129
register: setup_ssl_key
13-
notify: restart nginx service
10+
when: httpd_ssl_key_file is defined
1411
no_log: true
1512
tags:
1613
- update_ssl_certs
1714

18-
- name: copy over ssl pem file
15+
- name: copy over ssl crt file
1916
copy:
20-
src: "{{ item }}"
17+
src: "{{ httpd_ssl_crt_file }}"
2118
dest: "/etc/nginx/conf.d/ssl.pem"
19+
remote_src: "{{ httpd_ssl_keytab_files_remote_src }}"
2220
owner: nginx
2321
group: nginx
2422
mode: 0644
25-
with_first_found:
26-
- files:
27-
- "{{ httpd_ssl_pem_file }}"
28-
- "{{ httpd_ssl_crt_file }}"
29-
skip: true
3023
register: setup_ssl_pem
3124
when: setup_ssl_key|success
25+
notify: restart nginx service
3226
tags:
3327
- update_ssl_certs
3428

0 commit comments

Comments
 (0)