main.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. - name: Install openssl
  3. action: "{{ ansible_pkg_mgr }} name=openssl state=present"
  4. when: not etcd_is_atomic | bool
  5. - file:
  6. path: "{{ item }}"
  7. state: directory
  8. mode: 0700
  9. owner: root
  10. group: root
  11. with_items:
  12. - "{{ etcd_ca_new_certs_dir }}"
  13. - "{{ etcd_ca_crl_dir }}"
  14. - "{{ etcd_ca_dir }}/fragments"
  15. - command: cp /etc/pki/tls/openssl.cnf ./
  16. args:
  17. chdir: "{{ etcd_ca_dir }}/fragments"
  18. creates: "{{ etcd_ca_dir }}/fragments/openssl.cnf"
  19. - template:
  20. dest: "{{ etcd_ca_dir }}/fragments/openssl_append.cnf"
  21. src: openssl_append.j2
  22. backup: true
  23. - assemble:
  24. src: "{{ etcd_ca_dir }}/fragments"
  25. dest: "{{ etcd_openssl_conf }}"
  26. - command: touch {{ etcd_ca_db }}
  27. args:
  28. creates: "{{ etcd_ca_db }}"
  29. - copy:
  30. dest: "{{ etcd_ca_serial }}"
  31. content: "01"
  32. force: no
  33. - command: >
  34. openssl req -config {{ etcd_openssl_conf }} -newkey rsa:4096
  35. -keyout {{ etcd_ca_key }} -new -out {{ etcd_ca_cert }}
  36. -x509 -extensions {{ etcd_ca_exts_self }} -batch -nodes
  37. -days {{ etcd_ca_default_days }}
  38. -subj /CN=etcd-signer@{{ ansible_date_time.epoch }}
  39. args:
  40. chdir: "{{ etcd_ca_dir }}"
  41. creates: "{{ etcd_ca_cert }}"
  42. environment:
  43. SAN: 'etcd-signer'