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
|
||||
|
||||
groups:
|
||||
|
||||
haproxy: inventory_hostname.startswith('www')
|
||||
|
||||
web: inventory_hostname.startswith('app')
|
||||
|
@ -12,6 +11,7 @@ groups:
|
|||
counts: inventory_hostname.startswith('app-counts')
|
||||
push: inventory_hostname.startswith('app-push')
|
||||
blogs: inventory_hostname.startswith('blog')
|
||||
forum: inventory_hostname.startswith('forum')
|
||||
|
||||
node: inventory_hostname.startswith('node')
|
||||
node_socket: inventory_hostname.startswith('node-socket')
|
||||
|
|
|
@ -2,7 +2,6 @@ plugin: constructed
|
|||
strict: False
|
||||
|
||||
groups:
|
||||
|
||||
hall: inventory_hostname.startswith('h')
|
||||
|
||||
haproxy: inventory_hostname.startswith('hwww')
|
||||
|
@ -20,6 +19,7 @@ groups:
|
|||
push: inventory_hostname.startswith('happ-push')
|
||||
hpush: inventory_hostname.startswith('happ-push')
|
||||
blogs: inventory_hostname.startswith('blog')
|
||||
forum: inventory_hostname.startswith('hforum')
|
||||
|
||||
node: inventory_hostname.startswith('hnode')
|
||||
hnode: inventory_hostname.startswith('hnode')
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
- 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: "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: 'web', tags: 'web'}
|
||||
- {role: 'nginx', tags: 'nginx'}
|
||||
- {role: 'node-exporter', tags: ['node-exporter', 'metrics']}
|
||||
- { role: "web", tags: "web" }
|
||||
- { role: "nginx", tags: "nginx" }
|
||||
- { 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
|
||||
set_fact:
|
||||
hetzner_hosts: "{{ groups['hall'] | map('extract', hostvars, ['ansible_host']) }}"
|
||||
|
@ -10,7 +9,7 @@
|
|||
template:
|
||||
src: ufw_rules.sh.j2
|
||||
dest: /tmp/ufw_rules.sh
|
||||
mode: '0755'
|
||||
mode: "0755"
|
||||
|
||||
# - name: Stop ufw and delete all rules
|
||||
# become: yes
|
||||
|
@ -145,7 +144,7 @@
|
|||
|
||||
COMMIT
|
||||
# END UFW AND DOCKER
|
||||
tags: docker
|
||||
tags: docker ufw
|
||||
notify: restart ufw
|
||||
|
||||
- name: Start ufw
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
when: "'app' in group_names"
|
||||
- import_playbook: playbooks/setup_blog.yml
|
||||
when: "'blogs' in group_names"
|
||||
- import_playbook: playbooks/setup_forum.yml
|
||||
when: "'forum' in group_names"
|
||||
- import_playbook: playbooks/setup_www.yml
|
||||
when: "'haproxy' in group_names"
|
||||
- import_playbook: playbooks/setup_node.yml
|
||||
|
|
|
@ -71,6 +71,9 @@ frontend public
|
|||
use_backend node_page if { path_beg /original_page/ }
|
||||
use_backend blog if { hdr_end(host) -i blog.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 /static/ }
|
||||
use_backend nginx if { path_beg /favicon }
|
||||
|
@ -196,6 +199,13 @@ backend sentry
|
|||
server {{host}} {{host}}.node.nyc1.consul:9000
|
||||
{% 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
|
||||
balance roundrobin
|
||||
# option httpchk GET /_haproxychk
|
||||
|
|
Loading…
Add table
Reference in a new issue