aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/certificates/tasks/generate.yml
blob: b0014e13aab9056e2281153b173019d2ad74ceb4 (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
---
- name: Ensuring config directories exist
  file:
    path: "{{ node_config_directory }}/{{ item }}"
    state: "directory"
    recurse: yes
  with_items:
    - "certificates/private"

- name: Creating SSL configuration file
  template:
    src: "{{ item }}.j2"
    dest: "{{ node_config_directory }}/certificates/{{ item }}"
  with_items:
    - "openssl-kolla.cnf"

- name: Creating Key
  command: creates="{{ item }}" openssl genrsa -out {{ item }}
  with_items:
    - "{{ node_config_directory }}/certificates/private/haproxy.key"

- name: Creating Server Certificate
  command: creates="{{ item }}" openssl req -new -nodes -sha256 -x509 \
    -subj "/C=US/ST=NC/L=RTP/O=kolla/CN={{ kolla_external_fqdn }}" \
    -config {{ node_config_directory }}/certificates/openssl-kolla.cnf \
    -days 3650 \
    -extensions v3_req \
    -key {{ node_config_directory }}/certificates/private/haproxy.key \
    -out {{ item }}
  with_items:
    - "{{ node_config_directory }}/certificates/private/haproxy.crt"

- name: Creating CA Certificate File
  copy:
    src: "{{ node_config_directory }}/certificates/private/haproxy.crt"
    dest: "{{ node_config_directory }}/certificates/haproxy-ca.crt"

- name: Creating Server PEM File
  assemble:
    src: "{{ node_config_directory }}/certificates/private"
    dest: "{{ node_config_directory }}/certificates/haproxy.pem"