added ansible roles for swarming dynomite

This commit is contained in:
dcore94 2020-10-27 13:07:57 +01:00
parent 198a14fc59
commit cb033e7163
8 changed files with 60 additions and 26 deletions

5
ansible/playbook.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: localhost
roles:
- common
- dynomite

View File

@ -1,7 +1,9 @@
---
target_path: /tmp/conductor_setup_test
conductor_network: conductor-network
dynomite_shards: 2
dynomite_shards: 3
dynomite_replicas: 3
elasticsearch_replicas: 1

View File

@ -0,0 +1,4 @@
- name: Create target directory
file:
path: "{{ target_path }}"
state: directory

View File

@ -1,3 +1,18 @@
---
- name: Hello world dynomite
command: echo "Hello world"
- name: Generate seedlist
template:
src: templates/seeds.list.j2
dest: "{{ target_path }}/seeds.list"
- name: Prepare seeds
debug: msg="{{item}}"
loop: "{{ lookup('file', '{{ target_path}}/seeds.list').splitlines() }}"
register: seeds
- name: Generate dynomite-swarm
template:
src: templates/dynomite-swarm.yaml.j2
dest: "{{ target_path }}/dynomite-swarm.yaml"

View File

@ -1 +0,0 @@
{{ service }}:8101:{{ rack }}:{{ datacenter }}:{{ token }}

View File

@ -1,22 +1,25 @@
dynomite1:
environment:
- DYNO_NODE={{ node_seed }}
image: nubisware/autodynomite:latest
networks:
{{ conductor-network }}:
logging:
driver: "journald"
deploy:
mode: replicated
replicas: 1
endpoint_mode: dnsrr
placement:
constraints: [node.role == worker]
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
configs:
- source: seeds.list
target: /dynomite/seeds.list
{% for seed in seeds.results %}
{{ seed.msg.split(':')[0] }}:
environment:
- DYNO_NODE={{ seed.msg }}
image: nubisware/autodynomite:latest
networks:
{{ conductor_network }}:
logging:
driver: "journald"
deploy:
mode: replicated
replicas: 1
endpoint_mode: dnsrr
placement:
constraints: [node.role == worker]
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
configs:
- source: seeds.list
target: /dynomite/seeds.list
{%endfor%}

View File

@ -1,11 +1,11 @@
version: '3.6'
services:
{{ dynomyte_services }}
{% include 'dynomite-service.yaml.j2' %}
networks:
{{ conductor_network }}:
configs:
seeds.list:
file: {{ seeds_list_path }}
file: seeds.list

View File

@ -0,0 +1,6 @@
{% for replica in range(1,dynomite_replicas+1) %}
{% set replicaloop = loop %}
{% for shard in range(1,dynomite_shards+1) %}
dynomite{{ (replicaloop.index - 1) * dynomite_shards + shard}}:8101:rack{{ replicaloop.index }}:datacenter1:{{ (shard - 1) * (4294967295 // dynomite_shards) }}
{% endfor %}
{% endfor %}