summaryrefslogtreecommitdiff
path: root/salt/openbook/ansible/files/ssl.yaml
blob: cb61c448cd4dff9f22530525f27072e0e925709a (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
---
- name: "SSL cert"
  hosts: target
  tasks:
    - name: "Install ca-certificates"
      apt:
        pkg: "{{ item }}"
        state: present
      with_items:
        - ca-certificates
      when: ansible_distribution == "Ubuntu"

    - name: "Install ca-certificates"
      portage:
        package: "{{ item }}"
        update: yes
        changed_use: yes
      with_items:
        - app-misc/ca-certificates
      when: ansible_distribution == "Gentoo"

    - name: "Create self-signed SSL cert"
      shell:
        cmd: |
          if [ ! -f "/etc/ssl/certs/{{ item }}.crt" ] && [ ! -f "/etc/ssl/private/{{ item }}.key" ]; then
              openssl req -x509 -nodes -sha256 -days 3650 -newkey rsa:4096 -keyout "/tmp/{{ item }}.key" -out "/tmp/{{ item }}.crt" <<EOF
          US
          New Jersey
          Basking Ridge
          Verizon Wireless
          Verizon Cloud Platform
          {{ item }}
          carlos.konstanski@verizonwireless.com
          EOF
              cp -f "/tmp/{{ item }}.crt" "/etc/ssl/certs/"
              cp -f "/tmp/{{ item }}.key" "/etc/ssl/private/"
              chmod 644 "/etc/ssl/certs/{{ item }}.crt"
              chown root: "/etc/ssl/certs/{{ item }}.crt"
              chmod 640 "/etc/ssl/private/{{ item }}.key"
              chown root: "/etc/ssl/private/{{ item }}.key"
          fi
        executable: /bin/bash
      with_items:
        - "{{ inventory_hostname }}"