mirror of
https://github.com/viq/NewsBlur.git
synced 2025-04-13 09:38:09 +00:00
New forum server.
This commit is contained in:
parent
cdaec2487f
commit
b444523a02
10 changed files with 102 additions and 30 deletions
|
@ -2,7 +2,6 @@ plugin: constructed
|
||||||
strict: False
|
strict: False
|
||||||
|
|
||||||
groups:
|
groups:
|
||||||
|
|
||||||
haproxy: inventory_hostname.startswith('www')
|
haproxy: inventory_hostname.startswith('www')
|
||||||
|
|
||||||
web: inventory_hostname.startswith('app')
|
web: inventory_hostname.startswith('app')
|
||||||
|
@ -12,6 +11,7 @@ groups:
|
||||||
counts: inventory_hostname.startswith('app-counts')
|
counts: inventory_hostname.startswith('app-counts')
|
||||||
push: inventory_hostname.startswith('app-push')
|
push: inventory_hostname.startswith('app-push')
|
||||||
blogs: inventory_hostname.startswith('blog')
|
blogs: inventory_hostname.startswith('blog')
|
||||||
|
forum: inventory_hostname.startswith('forum')
|
||||||
|
|
||||||
node: inventory_hostname.startswith('node')
|
node: inventory_hostname.startswith('node')
|
||||||
node_socket: inventory_hostname.startswith('node-socket')
|
node_socket: inventory_hostname.startswith('node-socket')
|
||||||
|
|
|
@ -2,7 +2,6 @@ plugin: constructed
|
||||||
strict: False
|
strict: False
|
||||||
|
|
||||||
groups:
|
groups:
|
||||||
|
|
||||||
hall: inventory_hostname.startswith('h')
|
hall: inventory_hostname.startswith('h')
|
||||||
|
|
||||||
haproxy: inventory_hostname.startswith('hwww')
|
haproxy: inventory_hostname.startswith('hwww')
|
||||||
|
@ -20,6 +19,7 @@ groups:
|
||||||
push: inventory_hostname.startswith('happ-push')
|
push: inventory_hostname.startswith('happ-push')
|
||||||
hpush: inventory_hostname.startswith('happ-push')
|
hpush: inventory_hostname.startswith('happ-push')
|
||||||
blogs: inventory_hostname.startswith('blog')
|
blogs: inventory_hostname.startswith('blog')
|
||||||
|
forum: inventory_hostname.startswith('hforum')
|
||||||
|
|
||||||
node: inventory_hostname.startswith('hnode')
|
node: inventory_hostname.startswith('hnode')
|
||||||
hnode: inventory_hostname.startswith('hnode')
|
hnode: inventory_hostname.startswith('hnode')
|
||||||
|
|
|
@ -9,14 +9,14 @@
|
||||||
- motd_role: app
|
- motd_role: app
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- {role: 'base', tags: 'base'}
|
- { role: "base", tags: "base" }
|
||||||
- {role: 'ufw', tags: 'ufw'}
|
- { role: "ufw", tags: "ufw" }
|
||||||
- {role: 'docker', tags: 'docker'}
|
- { role: "docker", tags: "docker" }
|
||||||
- {role: 'repo', tags: ['repo', 'pull']}
|
- { role: "repo", tags: ["repo", "pull"] }
|
||||||
- {role: 'dnsmasq', tags: 'dnsmasq'}
|
- { role: "dnsmasq", tags: "dnsmasq" }
|
||||||
- {role: 'consul', tags: 'consul'}
|
- { role: "consul", tags: "consul" }
|
||||||
- {role: 'consul-client', tags: 'consul'}
|
- { role: "consul-client", tags: "consul" }
|
||||||
|
|
||||||
- {role: 'web', tags: 'web'}
|
- { role: "web", tags: "web" }
|
||||||
- {role: 'nginx', tags: 'nginx'}
|
- { role: "nginx", tags: "nginx" }
|
||||||
- {role: 'node-exporter', tags: ['node-exporter', 'metrics']}
|
- { role: "node-exporter", tags: ["node-exporter", "metrics"] }
|
||||||
|
|
20
ansible/playbooks/setup_forum.yml
Normal file
20
ansible/playbooks/setup_forum.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: SETUP -> forum containers
|
||||||
|
hosts: forum
|
||||||
|
vars_files:
|
||||||
|
- ../env_vars/base.yml
|
||||||
|
vars:
|
||||||
|
- update_apt_cache: yes
|
||||||
|
- motd_role: app
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- { role: "base", tags: "base" }
|
||||||
|
- { role: "ufw", tags: "ufw" }
|
||||||
|
- { role: "docker", tags: "docker" }
|
||||||
|
- { role: "repo", tags: ["repo", "pull"] }
|
||||||
|
- { role: "dnsmasq", tags: "dnsmasq" }
|
||||||
|
- { role: "consul", tags: "consul" }
|
||||||
|
- { role: "consul-client", tags: "consul" }
|
||||||
|
|
||||||
|
- { role: "forum", tags: "forum" }
|
||||||
|
- { role: "node-exporter", tags: ["node-exporter", "metrics"] }
|
11
ansible/roles/forum/handlers/main.yml
Normal file
11
ansible/roles/forum/handlers/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
- name: restart discourse
|
||||||
|
become: yes
|
||||||
|
docker_container:
|
||||||
|
name: discourse
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: reload ufw
|
||||||
|
become: yes
|
||||||
|
service:
|
||||||
|
name: ufw
|
||||||
|
state: reloaded
|
20
ansible/roles/forum/tasks/main.yml
Normal file
20
ansible/roles/forum/tasks/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
- name: Register forum in consul
|
||||||
|
tags: consul
|
||||||
|
become: yes
|
||||||
|
template:
|
||||||
|
src: consul_service.json
|
||||||
|
dest: /etc/consul.d/forum.json
|
||||||
|
when: disable_consul_services_ie_staging is not defined
|
||||||
|
notify:
|
||||||
|
- reload consul
|
||||||
|
|
||||||
|
- name: Allow http
|
||||||
|
become: yes
|
||||||
|
ufw: rule=allow port=80
|
||||||
|
tags: ufw
|
||||||
|
|
||||||
|
- name: Allow https
|
||||||
|
become: yes
|
||||||
|
ufw: rule=allow port=443
|
||||||
|
tags: ufw
|
10
ansible/roles/forum/templates/consul_service.json
Normal file
10
ansible/roles/forum/templates/consul_service.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"service": {
|
||||||
|
"name": "{{ inventory_hostname|regex_replace('\d+', '') }}",
|
||||||
|
"id": "{{ inventory_hostname }}",
|
||||||
|
"tags": [
|
||||||
|
"forum"
|
||||||
|
],
|
||||||
|
"port": 80
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: Set hosts
|
- name: Set hosts
|
||||||
set_fact:
|
set_fact:
|
||||||
hetzner_hosts: "{{ groups['hall'] | map('extract', hostvars, ['ansible_host']) }}"
|
hetzner_hosts: "{{ groups['hall'] | map('extract', hostvars, ['ansible_host']) }}"
|
||||||
|
@ -10,7 +9,7 @@
|
||||||
template:
|
template:
|
||||||
src: ufw_rules.sh.j2
|
src: ufw_rules.sh.j2
|
||||||
dest: /tmp/ufw_rules.sh
|
dest: /tmp/ufw_rules.sh
|
||||||
mode: '0755'
|
mode: "0755"
|
||||||
|
|
||||||
# - name: Stop ufw and delete all rules
|
# - name: Stop ufw and delete all rules
|
||||||
# become: yes
|
# become: yes
|
||||||
|
@ -145,7 +144,7 @@
|
||||||
|
|
||||||
COMMIT
|
COMMIT
|
||||||
# END UFW AND DOCKER
|
# END UFW AND DOCKER
|
||||||
tags: docker
|
tags: docker ufw
|
||||||
notify: restart ufw
|
notify: restart ufw
|
||||||
|
|
||||||
- name: Start ufw
|
- name: Start ufw
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
when: "'app' in group_names"
|
when: "'app' in group_names"
|
||||||
- import_playbook: playbooks/setup_blog.yml
|
- import_playbook: playbooks/setup_blog.yml
|
||||||
when: "'blogs' in group_names"
|
when: "'blogs' in group_names"
|
||||||
|
- import_playbook: playbooks/setup_forum.yml
|
||||||
|
when: "'forum' in group_names"
|
||||||
- import_playbook: playbooks/setup_www.yml
|
- import_playbook: playbooks/setup_www.yml
|
||||||
when: "'haproxy' in group_names"
|
when: "'haproxy' in group_names"
|
||||||
- import_playbook: playbooks/setup_node.yml
|
- import_playbook: playbooks/setup_node.yml
|
||||||
|
|
|
@ -71,6 +71,9 @@ frontend public
|
||||||
use_backend node_page if { path_beg /original_page/ }
|
use_backend node_page if { path_beg /original_page/ }
|
||||||
use_backend blog if { hdr_end(host) -i blog.newsblur.com }
|
use_backend blog if { hdr_end(host) -i blog.newsblur.com }
|
||||||
use_backend sentry if { hdr_end(host) -i sentry.newsblur.com }
|
use_backend sentry if { hdr_end(host) -i sentry.newsblur.com }
|
||||||
|
use_backend forum if { hdr_end(host) -i forum.newsblur.com }
|
||||||
|
use_backend forum if { hdr_end(host) -i forum2.newsblur.com }
|
||||||
|
use_backend forum if { hdr_end(host) -i forum3.newsblur.com }
|
||||||
use_backend nginx if { path_beg /media/ }
|
use_backend nginx if { path_beg /media/ }
|
||||||
use_backend nginx if { path_beg /static/ }
|
use_backend nginx if { path_beg /static/ }
|
||||||
use_backend nginx if { path_beg /favicon }
|
use_backend nginx if { path_beg /favicon }
|
||||||
|
@ -196,6 +199,13 @@ backend sentry
|
||||||
server {{host}} {{host}}.node.nyc1.consul:9000
|
server {{host}} {{host}}.node.nyc1.consul:9000
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
backend forum
|
||||||
|
balance roundrobin
|
||||||
|
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
|
||||||
|
{% for host in groups.forum %}
|
||||||
|
server {{host}} {{host}}.node.nyc1.consul:80
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
backend db_metrics
|
backend db_metrics
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
# option httpchk GET /_haproxychk
|
# option httpchk GET /_haproxychk
|
||||||
|
|
Loading…
Add table
Reference in a new issue