forked from gaby/devops-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.yml
42 lines (37 loc) · 1.29 KB
/
deploy.yml
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
- name: Apply Kubernetes YAMLs
hosts: kubernetes
tasks:
- name: Ensure SSL related directories exist
file:
path: "{{ item }}"
state: directory
loop:
- "/etc/ssl/crt"
- "/etc/ssl/csr"
- "/etc/ssl/private"
- name: Generate an OpenSSL private key.
openssl_privatekey:
path: /etc/ssl/private/privkey.pem
- name: generate openssl certficate signing requests
openssl_csr:
path: /etc/ssl/csr/hello-world.app.csr
privatekey_path: /etc/ssl/private/privkey.pem
common_name: hello-world.app
- name: Generate a Self Signed OpenSSL certificate
openssl_certificate:
path: /etc/ssl/crt/hello-world.app.crt
privatekey_path: /etc/ssl/private/privkey.pem
csr_path: /etc/ssl/csr/hello-world.app.csr
provider: selfsigned
- name: Create k8s secret
command: "kubectl create secret tls tls-secret --cert=/etc/ssl/crt/hello-world.app.crt --key=/etc/ssl/private/privkey.pem"
register: result
failed_when:
- result.rc == 2
- name: Deploy web app
k8s:
state: present
definition: "{{ lookup('file', './helloworld.yml') }}"
kubeconfig: '/home/abregman/.kube/config'
namespace: 'default'
wait: true