summaryrefslogtreecommitdiff
path: root/playbooks/ssl.yaml
blob: 6b5e53da755ee419891534e341224b8eb934cf88 (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
---
- name: "Create self-signed SSL cert"
  shell:
    cmd: |
      ssl_hostname="{{ ansible_nodename }}.{{ fqdn }}"
      if [ ! -f "/etc/ssl/certs/${ssl_hostname}.crt" ] && [ ! -f "/etc/ssl/private/${ssl_hostname}.key" ]; then
          openssl req -x509 -nodes -sha256 -days 3650 -newkey rsa:4096 -keyout "/tmp/${ssl_hostname}.key" -out "/tmp/${ssl_hostname}.crt" <<EOF
      US
      New Jersey
      Basking Ridge
      Verizon Wireless
      Verizon Cloud Platform
      ${ssl_hostname}
      carlos.konstanski@verizonwireless.com
      EOF
          cp -f "/tmp/${ssl_hostname}.crt" "/etc/ssl/certs/"
          cp -f "/tmp/${ssl_hostname}.key" "/etc/ssl/private/"
          chmod 644 "/etc/ssl/certs/${ssl_hostname}.crt"
          chown root: "/etc/ssl/certs/${ssl_hostname}.crt"
          chmod 640 "/etc/ssl/private/${ssl_hostname}.key"
          chown root:ssl-cert "/etc/ssl/private/${ssl_hostname}.key"
      fi
  args:
    executable: /bin/bash