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 conductor_network: conductor-network
dynomite_shards: 2 dynomite_shards: 3
dynomite_replicas: 3 dynomite_replicas: 3
elasticsearch_replicas: 1 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 - name: Hello world dynomite
command: echo "Hello world" 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: {% for seed in seeds.results %}
- DYNO_NODE={{ node_seed }} {{ seed.msg.split(':')[0] }}:
image: nubisware/autodynomite:latest environment:
networks: - DYNO_NODE={{ seed.msg }}
{{ conductor-network }}: image: nubisware/autodynomite:latest
logging: networks:
driver: "journald" {{ conductor_network }}:
deploy: logging:
mode: replicated driver: "journald"
replicas: 1 deploy:
endpoint_mode: dnsrr mode: replicated
placement: replicas: 1
constraints: [node.role == worker] endpoint_mode: dnsrr
restart_policy: placement:
condition: on-failure constraints: [node.role == worker]
delay: 5s restart_policy:
max_attempts: 3 condition: on-failure
window: 120s delay: 5s
configs: max_attempts: 3
- source: seeds.list window: 120s
target: /dynomite/seeds.list configs:
- source: seeds.list
target: /dynomite/seeds.list
{%endfor%}

View File

@ -1,11 +1,11 @@
version: '3.6' version: '3.6'
services: services:
{{ dynomyte_services }} {% include 'dynomite-service.yaml.j2' %}
networks: networks:
{{ conductor_network }}: {{ conductor_network }}:
configs: configs:
seeds.list: 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 %}