Add ghost deploy
authorLorin Hochstein <lhochstein@netflix.com>
Tue, 7 Feb 2017 03:59:20 +0000 (19:59 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Tue, 7 Feb 2017 03:59:52 +0000 (19:59 -0800)
ch13/deploy.yml

index 67f1efe..a1d7358 100644 (file)
@@ -38,7 +38,7 @@
         state: directory
     - name: start postgres container
       docker_container:
-        name: ghost_postgres
+        name: postgres_ghost
         image: postgres:9.6
         ports:
           - "0.0.0.0:5432:5432"
   hosts: ghost
   become: True
   gather_facts: False
+  vars:
+    url: "https://{{ ansible_host }}"
+    database_host: "{{ groups[postgres][0] }}"
+    data_dir: /data/ghostdata
+    certs_dir: /data/certs
   tasks:
+    - name: create ghostdata directory
+      file:
+        path: "{{ data_dir }}"
+        state: directory
     - name: copy the config file
-      template: 
+      template: src=templates/config.js.j2 dest={{ datadir}}/config.js
+    - name: start ghost container
+      docker_container:
+        name: ghost
+        image: ghost
+        volumes:
+          - "{{ data_dir }}:/var/lib/ghost"
+    - name: create certs directory
+      file:
+        path: "{{ certs_dir }}"
+        state: directory
+    - name: generate tls certs
+      command: >
+        openssl req -new -x509 -nodes
+        -out "{{ certs_dir }}/nginx.crt" -keyout "{{ certs_dir }}/nginx.key"
+        -subj "/CN={{ ansible_host}}" -days 3650
+        creates=certs/nginx.crt
+    - name: start nginx container
+      docker_container:
+        name: nginx_ghost
+        image: ansiblebook/nginx-ghost
+        command: npm start --production
+        links:
+          - ghost
+        ports:
+          - "0.0.0.0:80:80"
+          - "0.0.0.0:443:443"
+        volumes:
+          - "{{ certs_dir }}:/certs"