From a392d817352de0ea6c84ca0c2023ad1506830486 Mon Sep 17 00:00:00 2001 From: Carlos Konstanski Date: Tue, 16 Jan 2018 11:57:33 -0700 Subject: Openbook CI: make new self-signed cert for CI/CD stack Issue: IS-56 --- salt/openbook/ansible/files/docker_registry.yaml | 6 +++--- .../ansible/files/env.yaml.docker_registry.example | 1 - .../ansible/files/install_docker_registry.yaml | 1 + salt/openbook/ansible/files/registry.conf | 6 +++--- salt/openbook/ansible/files/ssl.yaml | 24 ++++++++++++++++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 salt/openbook/ansible/files/ssl.yaml (limited to 'salt') diff --git a/salt/openbook/ansible/files/docker_registry.yaml b/salt/openbook/ansible/files/docker_registry.yaml index 20dfb73..3666deb 100644 --- a/salt/openbook/ansible/files/docker_registry.yaml +++ b/salt/openbook/ansible/files/docker_registry.yaml @@ -33,9 +33,9 @@ - name: "Copy SSL certs into nginx directory" shell: | - cp "/etc/ssl/certs/{{ cn }}.crt" /root/docker-registry/nginx/ - cp "/etc/ssl/certs/{{ cn }}.ca" /root/docker-registry/nginx/ - cp "/etc/ssl/private/{{ cn }}.key" /root/docker-registry/nginx/ + cp "/etc/ssl/certs/{{ inventory_hostname }}.crt" /root/docker-registry/nginx/ + cp "/etc/ssl/certs/{{ inventory_hostname }}.ca" /root/docker-registry/nginx/ + cp "/etc/ssl/private/{{ inventory_hostname }}.key" /root/docker-registry/nginx/ when: ansible_distribution == "Ubuntu" or ansible_distribution == "Gentoo" - name: "Create password file" diff --git a/salt/openbook/ansible/files/env.yaml.docker_registry.example b/salt/openbook/ansible/files/env.yaml.docker_registry.example index f00e29c..f027328 100644 --- a/salt/openbook/ansible/files/env.yaml.docker_registry.example +++ b/salt/openbook/ansible/files/env.yaml.docker_registry.example @@ -7,6 +7,5 @@ globals: environments: - master: - host1: - cn: ~ username: ~ password: ~ diff --git a/salt/openbook/ansible/files/install_docker_registry.yaml b/salt/openbook/ansible/files/install_docker_registry.yaml index f22e643..0a0ad8b 100644 --- a/salt/openbook/ansible/files/install_docker_registry.yaml +++ b/salt/openbook/ansible/files/install_docker_registry.yaml @@ -1,4 +1,5 @@ --- +- include: ssl.yaml - include: docker.yaml - include: docker_compose.yaml - include: docker_registry.yaml diff --git a/salt/openbook/ansible/files/registry.conf b/salt/openbook/ansible/files/registry.conf index e97729a..70ebf7e 100644 --- a/salt/openbook/ansible/files/registry.conf +++ b/salt/openbook/ansible/files/registry.conf @@ -4,12 +4,12 @@ upstream docker-registry { server { listen 443; - server_name {% raw %}{{ cn }}{% endraw %}; + server_name {% raw %}{{ inventory_hostsname }}{% endraw %}; # SSL ssl on; - ssl_certificate /etc/nginx/conf.d/{% raw %}{{ cn }}{% endraw %}.crt; - ssl_certificate_key /etc/nginx/conf.d/{% raw %}{{ cn }}{% endraw %}.key; + ssl_certificate /etc/nginx/conf.d/{% raw %}{{ inventory_hostsname }}{% endraw %}.crt; + ssl_certificate_key /etc/nginx/conf.d/{% raw %}{{ inventory_hostsname }}{% endraw %}.key; # disable any limits to avoid HTTP 413 for large image uploads client_max_body_size 0; diff --git a/salt/openbook/ansible/files/ssl.yaml b/salt/openbook/ansible/files/ssl.yaml new file mode 100644 index 0000000..6330e87 --- /dev/null +++ b/salt/openbook/ansible/files/ssl.yaml @@ -0,0 +1,24 @@ +--- +- 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" <