aboutsummaryrefslogtreecommitdiff
path: root/roles/ldap_certs/tasks/main.yml
blob: a088b382c302e5fd019e156335aee8029c83f811 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- name: ldap_certs get vars
  include_vars: default.yml

- name: ldap_certs get OS vars
  include_vars: '{{ item }}'
  with_first_found:
    - '{{ ansible_distribution }}.yml'
    - default.yml

- name: ldap_certs get host-specific vars
  include_vars: '{{ item }}'
  with_first_found:
    - files:
      - 'roles/ldap_certs/hosts/{{ ansible_fqdn }}.yml'
      skip: true

- name: ldap_certs deploy files that exist
  template: src='{{ item.file }}' dest='{{ ldap_certs_cert_dir }}/{{ item.file | regex_replace('.*/','') }}' owner='{{ ldap_certs_owner }}' group='{{ ldap_certs_group }}' mode=0644 #'
  with_items:
    - '{{ ldap_certs }}'
  when:
    - ( not '{{ item.exists | lower }}' == 'false' )
    - ldap_certs is defined

- name: ldap_certs remove files that should not exist
  file: path='{{ ldap_certs_cert_dir }}/{{ item.file | regex_replace('.*/','') }}' state='absent'
  with_items:
    - '{{ ldap_certs }}'
  when:
    - ( not '{{ item.exists }}' ) or ( '{{ item.exists | lower }}' == 'false' )
    - ldap_certs is defined

- name: ldap_certs get hash values
  command: openssl x509 -in "{{ ldap_certs_cert_dir }}/{{ item.file | regex_replace('.*/','') }}" -hash -noout
  register: hashes
  with_items:
    - '{{ ldap_certs }}'
  when:
    - '{{ item.exists }}'
    - ( not '{{ item.gets_hashlink | lower }}' == 'false' )
    - ldap_certs is defined

- name: ldap_certs deploy hashlink files
  file:
    path: "{{ ldap_certs_hashlink_dir }}/{{ item.stdout | quote }}.0"
    src: "{{ ldap_certs_cert_dir}}/{{ item.item.file | regex_replace('.*/','') }}"
    state: 'link'
  with_items:
    - '{{ hashes.results }}'
  when:
    - hashes is defined
    - item.stdout is defined
    - ldap_certs is defined
bgstack15