Pārlūkot izejas kodu

Use forward dependency for ca_file instead of reverse one

We can have this failing because of bad mine data:
salt['mine.get'](cert.host, 'x509.get_pem_entries')

Without this change, dependency between salt_minion_cert_*_all and
ca_file is just ignored and salt_minion_cert_*_all state fails because
it can't find appropriate file.

Change-Id: I2a5dd12e08159bf110ff0d9879ebf0ad5d9d97c1
pr/fix/minion_dependencis
Yuriy Taraday pirms 7 gadiem
vecāks
revīzija
19054adce5
1 mainītis faili ar 8 papildinājumiem un 8 dzēšanām
  1. +8
    -8
      salt/minion/cert.sls

+ 8
- 8
salt/minion/cert.sls Parādīt failu



{%- if minion.cert is defined %} {%- if minion.cert is defined %}


{%- set created_ca_files = [] %}

{%- for cert_name,cert in minion.get('cert', {}).iteritems() %} {%- for cert_name,cert in minion.get('cert', {}).iteritems() %}
{%- set rowloop = loop %} {%- set rowloop = loop %}


- watch: - watch:
- x509: {{ cert_file }} - x509: {{ cert_file }}


{%- if cert.host is defined %}
{%- if cert.host is defined and ca_file not in created_ca_files %}
{%- for ca_path,ca_cert in salt['mine.get'](cert.host, 'x509.get_pem_entries').get(cert.host, {}).iteritems() %} {%- for ca_path,ca_cert in salt['mine.get'](cert.host, 'x509.get_pem_entries').get(cert.host, {}).iteritems() %}


{%- if '/etc/pki/ca/'+cert.authority in ca_path %} {%- if '/etc/pki/ca/'+cert.authority in ca_path %}


{{ ca_file }}_{{ rowloop.index }}:
{{ ca_file }}:
x509.pem_managed: x509.pem_managed:
- name: {{ ca_file }} - name: {{ ca_file }}
- text: {{ ca_cert|replace('\n', '') }} - text: {{ ca_cert|replace('\n', '') }}
- watch: - watch:
- x509: {{ cert_file }} - x509: {{ cert_file }}
{%- if cert.all_file is defined %}
- watch_in:
- cmd: salt_minion_cert_{{ cert_name }}_all
{%- endif %}


{{ ca_file }}_cert_permissions_{{ rowloop.index }}:
{{ ca_file }}_cert_permissions:
file.managed: file.managed:
- name: {{ ca_file }} - name: {{ ca_file }}
- mode: 0644 - mode: 0644
- watch: - watch:
- x509: {{ ca_file }} - x509: {{ ca_file }}


{{ ca_file }}_{{ rowloop.index }}_local_trusted_symlink:
{{ ca_file }}_local_trusted_symlink:
file.symlink: file.symlink:
- name: "{{ cacerts_dir }}/ca-{{ cert.authority }}.crt" - name: "{{ cacerts_dir }}/ca-{{ cert.authority }}.crt"
- target: {{ ca_file }} - target: {{ ca_file }}
{%- endif %} {%- endif %}


{%- endfor %} {%- endfor %}
{%- do created_ca_files.append(ca_file) %}
{%- endif %} {%- endif %}


{%- if cert.all_file is defined %} {%- if cert.all_file is defined %}
- watch: - watch:
- x509: {{ key_file }} - x509: {{ key_file }}
- x509: {{ cert_file }} - x509: {{ cert_file }}
- x509: {{ ca_file }}


{{ cert.all_file }}_cert_permissions: {{ cert.all_file }}_cert_permissions:
file.managed: file.managed:

Notiek ielāde…
Atcelt
Saglabāt