mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
registering node services in consul
This commit is contained in:
parent
61c8e70735
commit
710fedcf23
4 changed files with 39 additions and 1 deletions
9
ansible/roles/node/handlers/main.yml
Normal file
9
ansible/roles/node/handlers/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
# File: main.yml - Handlers for Consul
|
||||
|
||||
- name: reload consul configuration
|
||||
become: yes
|
||||
service:
|
||||
name: consul
|
||||
state: reloaded
|
||||
listen: reload consul
|
|
@ -32,3 +32,23 @@
|
|||
command: 'node favicons.js'
|
||||
target_host: 'node-favicons'
|
||||
when: "'{{item.target_host}}' in ansible_hostname"
|
||||
|
||||
|
||||
- name: Register nodes in consul
|
||||
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'
|
||||
notify:
|
||||
- reload consul
|
||||
when: "'{{item.target_host}}' in ansible_hostname"
|
||||
|
|
9
ansible/roles/node/templates/consul_service.json
Normal file
9
ansible/roles/node/templates/consul_service.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"service": {
|
||||
"name": "{{ item.target_host }}",
|
||||
"tags": [
|
||||
"node"
|
||||
],
|
||||
"port": {{ item.port }}
|
||||
}
|
||||
}
|
|
@ -15,5 +15,5 @@
|
|||
- repo
|
||||
- {role: 'consul', tags: 'consul'}
|
||||
- {role: 'consul-client', tags: 'consul'}
|
||||
- node
|
||||
- {role: 'node', tags: 'node'}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue