2021-02-02 23:40:09 -05:00
|
|
|
---
|
|
|
|
- name: Start node docker containers
|
|
|
|
become: yes
|
2021-02-10 17:11:28 -05:00
|
|
|
docker_container:
|
|
|
|
name: "{{ item.container_name }}"
|
|
|
|
image: newsblur/newsblur_node
|
|
|
|
state: started
|
|
|
|
command: "{{ item.command }}"
|
2021-02-24 17:17:06 -05:00
|
|
|
container_default_behavior: no_defaults
|
2021-02-10 17:11:28 -05:00
|
|
|
pull: true
|
2021-02-24 18:13:26 -05:00
|
|
|
network_mode: host
|
2021-02-10 17:11:28 -05:00
|
|
|
env:
|
2021-02-24 17:17:06 -05:00
|
|
|
NODE_ENV: "production"
|
2021-02-10 17:11:28 -05:00
|
|
|
restart_policy: unless-stopped
|
2021-02-24 20:02:37 -05:00
|
|
|
volumes:
|
|
|
|
- /srv/newsblur/node:/srv/node
|
2021-02-02 23:40:09 -05:00
|
|
|
with_items:
|
2021-02-24 17:17:06 -05:00
|
|
|
- container_name: node_socket
|
2021-02-03 17:56:21 -05:00
|
|
|
ports: 8888:8888
|
2021-02-24 20:02:37 -05:00
|
|
|
command: node /srv/node/unread_counts.js
|
2021-02-10 16:59:48 -05:00
|
|
|
target_host: 'node-socket'
|
2021-02-03 17:56:21 -05:00
|
|
|
- container_name: 'original_pages'
|
|
|
|
ports: '3060:3060'
|
2021-02-24 20:02:37 -05:00
|
|
|
command: 'node /srv/node/original_page.js'
|
2021-02-24 17:17:06 -05:00
|
|
|
target_host: 'node-page'
|
2021-02-03 17:56:21 -05:00
|
|
|
- container_name: 'original_text'
|
|
|
|
ports: '4040:4040'
|
2021-02-24 20:02:37 -05:00
|
|
|
command: 'node /srv/node/original_text.js'
|
2021-02-24 17:17:06 -05:00
|
|
|
target_host: 'node-text'
|
2021-02-03 17:56:21 -05:00
|
|
|
- container_name: 'favicons'
|
|
|
|
ports: '3030:3030'
|
2021-02-24 20:02:37 -05:00
|
|
|
command: 'node /srv/node/favicons.js'
|
2021-02-10 16:59:48 -05:00
|
|
|
target_host: 'node-favicons'
|
2021-02-24 17:17:06 -05:00
|
|
|
when: item.target_host in inventory_hostname
|
2021-02-15 19:16:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
- name: Register nodes in consul
|
2021-02-23 19:30:28 -05:00
|
|
|
tags: consul
|
2021-02-15 19:16:08 -05:00
|
|
|
become: yes
|
|
|
|
template:
|
|
|
|
src: consul_service.json
|
|
|
|
dest: /etc/consul.d/{{item.target_host}}.json
|
|
|
|
with_items:
|
|
|
|
- port: 8888
|
|
|
|
target_host: 'node-socket'
|
|
|
|
- port: 3060
|
|
|
|
target_host: 'node-page'
|
|
|
|
- port: 4040
|
|
|
|
target_host: 'node-text'
|
|
|
|
- port: 3030
|
|
|
|
target_host: 'node-favicons'
|
2021-02-18 18:03:36 -05:00
|
|
|
- port: 80
|
|
|
|
target_host: 'node-images'
|
2021-02-15 19:16:08 -05:00
|
|
|
notify:
|
|
|
|
- reload consul
|
2021-02-24 17:17:06 -05:00
|
|
|
when: item.target_host in inventory_hostname
|