1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 {%- set orig_cert_dir = salt['pillar.get']('extra_custom_certs_dir', '/srv/salt/certs') %}
6 {%- set dest_cert_dir = '/etc/nginx/ssl' %}
7 {%- set certs = salt['pillar.get']('extra_custom_certs', []) %}
10 extra_custom_certs_file_directory_certs_dir:
12 - name: /etc/nginx/ssl
16 {%- for cert in certs %}
17 {%- set cert_file = 'arvados-' ~ cert ~ '.pem' %}
18 {%- set key_file = 'arvados-' ~ cert ~ '.key' %}
19 extra_custom_certs_{{ cert }}_cert_file_copy:
21 - name: {{ dest_cert_dir }}/{{ cert_file }}
22 - source: {{ orig_cert_dir }}/{{ cert_file }}
27 - unless: cmp {{ dest_cert_dir }}/{{ cert_file }} {{ orig_cert_dir }}/{{ cert_file }}
29 - file: extra_custom_certs_file_directory_certs_dir
31 extra_custom_certs_{{ cert }}_key_file_copy:
33 - name: {{ dest_cert_dir }}/{{ key_file }}
34 - source: {{ orig_cert_dir }}/{{ key_file }}
39 - unless: cmp {{ dest_cert_dir }}/{{ key_file }} {{ orig_cert_dir }}/{{ key_file }}
41 - file: extra_custom_certs_file_directory_certs_dir
43 extra_nginx_service_reload_on_{{ cert }}_certs_changes:
45 - name: systemctl reload nginx
47 - file: extra_custom_certs_{{ cert }}_cert_file_copy
48 - file: extra_custom_certs_{{ cert }}_key_file_copy
50 - file: extra_custom_certs_{{ cert }}_cert_file_copy
51 - file: extra_custom_certs_{{ cert }}_key_file_copy
53 - test $(openssl rsa -modulus -noout -in {{ dest_cert_dir }}/{{ key_file }}) == $(openssl x509 -modulus -noout -in {{ dest_cert_dir }}/{{ cert_file }})