summaryrefslogtreecommitdiffstats
path: root/roles/etcd_ca/tasks/main.yml
blob: e1bb9baed48e1e0cc569671bc64f7a44f7dfb553 (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
---
- name: Install openssl
  action: "{{ ansible_pkg_mgr }} name=openssl state=present"
  when: not etcd_is_atomic | bool

- file:
    path: "{{ item }}"
    state: directory
    mode: 0700
    owner: root
    group: root
  with_items:
  - "{{ etcd_ca_new_certs_dir }}"
  - "{{ etcd_ca_crl_dir }}"
  - "{{ etcd_ca_dir }}/fragments"

- command: cp /etc/pki/tls/openssl.cnf ./
  args:
    chdir: "{{ etcd_ca_dir }}/fragments"
    creates: "{{ etcd_ca_dir }}/fragments/openssl.cnf"

- template:
    dest: "{{ etcd_ca_dir }}/fragments/openssl_append.cnf"
    src: openssl_append.j2
    backup: true

- assemble:
    src: "{{ etcd_ca_dir }}/fragments"
    dest: "{{ etcd_openssl_conf }}"

- command: touch {{ etcd_ca_db }}
  args:
    creates: "{{ etcd_ca_db }}"

- copy:
    dest: "{{ etcd_ca_serial }}"
    content: "01"
    force: no

- command: >
    openssl req -config {{ etcd_openssl_conf }} -newkey rsa:4096
    -keyout {{ etcd_ca_key }} -new -out {{ etcd_ca_cert }}
    -x509 -extensions {{ etcd_ca_exts_self }} -batch -nodes
    -days {{ etcd_ca_default_days }}
    -subj /CN=etcd-signer@{{ ansible_date_time.epoch }}
  args:
    chdir: "{{ etcd_ca_dir }}"
    creates: "{{ etcd_ca_cert }}"
  environment:
    SAN: 'etcd-signer'