-
Notifications
You must be signed in to change notification settings - Fork 0
add consul services playbook #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| - hosts: rabbitmq | ||
| - hosts: redis | ||
|
|
||
| - hosts: vault | ||
| roles: | ||
| - { role: consul-services } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --- | ||
| - name: make /etc/consul.d folder | ||
| sudo: yes | ||
| file: | ||
| path=/etc/consul.d | ||
| state=directory | ||
|
|
||
| - name: remove all current configs | ||
| sudo: yes | ||
| shell: rm -f /etc/consul.d/*.json | ||
|
|
||
| - name: put service files in place | ||
| sudo: yes | ||
| template: | ||
| dest=/etc/consul.d/{{ item.name }}.json | ||
| src=service.json | ||
| with_items: | ||
| - name: 'datadog' | ||
| host_address: '{{ datadog_host_address }}' | ||
| tags: ['master'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if tags are not dynamic why not just set them in the template?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they could be. I don't want to tie down the template up front. you could just leave these out, I believe... |
||
| port: '{{ datadog_port }}' | ||
| - name: 'rabbitmq' | ||
| host_address: '{{ rabbit_host_address }}' | ||
| tags: ['master'] | ||
| port: '{{ rabbit_port }}' | ||
| - name: 'redis' | ||
| host_address: '{{ redis_host_address }}' | ||
| tags: ['master'] | ||
| port: '{{ redis_port }}' | ||
| - name: 'registry' | ||
| host_address: '{{ registry_host }}' | ||
| tags: ['master'] | ||
| port: '{{ registry_port }}' | ||
|
|
||
| - name: send consul SIGUP to reload services | ||
| sudo: yes | ||
| shell: pkill --signal SIGHUP consul | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "service": { | ||
| "name": "{{ item.name }}", | ||
| "tags": [ "{{ item.tags | join('","') }}" ], | ||
| "address": "{{ item.host_address }}", | ||
| "port": {{ item.port }} | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to do this? the template below should update the configs, if you do this then you always update the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you remove a service; it's really annoying to add a 'soft-delete' to each of the items below that you want to remove, so I'm figuring just clean it out every time (also prevents me from adding something manually hehe)