NewsBlur-viq/ansible/roles/node/tasks/main.yml

108 lines
No EOL
2.7 KiB
YAML

---
- name: Copy node secrets
copy:
src: /srv/secrets-newsblur/settings/dotenv.env
dest: /srv/newsblur/node/.env
register: app_changed
notify: restart node
with_items:
- node-socket
- node-page
- node-text
- node-favicons
- staging
when: item in inventory_hostname
- name: Add SERVER_NAME to app secrets
lineinfile:
path: /srv/newsblur/node/.env
line: 'SERVER_NAME = "{{ inventory_hostname }}"'
- name: Make docker network for newsblurnet
become: yes
docker_network:
name: newsblurnet
notify: restart docker
- name: Start node docker containers
become: yes
docker_container:
name: node
image: newsblur/newsblur_node
state: started
command: node /srv/node/newsblur.js
container_default_behavior: no_defaults
pull: true
networks_cli_compatible: yes
network_mode: default
networks:
- name: newsblurnet
ports:
- "8008:8008"
env:
NODE_ENV: "production"
restart_policy: unless-stopped
volumes:
- /srv/newsblur/node:/srv/node
with_items:
- node-socket
- node-page
- node-text
- node-favicons
- staging
when: item in inventory_hostname
- name: Start non-newsblur node docker containers
become: yes
docker_container:
name: "{{ item.container_name }}"
image: "{{ item.image }}"
state: started
container_default_behavior: no_defaults
pull: true
ports:
- "{{ item.ports }}"
env:
NODE_ENV: "production"
restart_policy: unless-stopped
volumes:
- /srv/newsblur/node:/srv/node
with_items:
- container_name: imageproxy
image: willnorris/imageproxy
ports: 8088:8080
target_host: node-images
when: item.target_host in inventory_hostname
- name: Register nodes in consul
tags: consul
become: yes
template:
src: consul_service.json
dest: /etc/consul.d/{{item.target_host}}.json
with_items:
- target_host: node-socket
port: 8008
- target_host: node-page
port: 8008
- target_host: node-text
port: 8008
- target_host: node-favicons
port: 8008
- target_host: node-images
port: 8088
notify:
- reload consul
when: item.target_host in inventory_hostname and disable_consul_services_ie_staging is not defined
- name: Add sanity checkers cronjob for disk usage
become: yes
cron:
name: disk_usage_sanity_checker
special_time: daily
job: docker pull newsblur/newsblur_python3:latest;
docker run --rm
output=$(eval sudo df / | head -n 2 | tail -1);
-v /srv/newsblur:/srv/newsblur
--network=newsblurnet --hostname {{ ansible_hostname }}
newsblur/newsblur_python3 /srv/newsblur/utils/monitor_disk_usage.py $output