Better evaluating of the seeds variable

This commit is contained in:
Mauro Mugnaini 2020-10-29 14:09:57 +01:00
parent 31710af6d5
commit 90400ce8c3
4 changed files with 9 additions and 15 deletions

View File

@ -4,12 +4,9 @@
src: templates/conductor-swarm.yaml.j2 src: templates/conductor-swarm.yaml.j2
dest: "{{ target_path }}/conductor-swarm.yaml" dest: "{{ target_path }}/conductor-swarm.yaml"
- name: Prepare seeds variable reading generated file lines
debug: msg="{{item}}"
loop: "{{ lookup('file', '{{ target_path}}/seeds.list').splitlines() }}"
register: seeds
- name: Generate conductor config from seeds - name: Generate conductor config from seeds
vars:
seeds: "{{ lookup('file', '{{ target_path}}/seeds.list').splitlines() }}"
template: template:
src: "templates/{{ conductor_config_template }}" src: "templates/{{ conductor_config_template }}"
dest: "{{ target_path }}/{{ conductor_config }}" dest: "{{ target_path }}/{{ conductor_config }}"

View File

@ -17,8 +17,8 @@ workflow.dynomite.cluster.hosts={% set ns = namespace() %}
{% set ns.datacenter = "us-east-" %} {% set ns.datacenter = "us-east-" %}
{% set ns.current_rack = "" %} {% set ns.current_rack = "" %}
{% set ns.current_suffix = 0 %} {% set ns.current_suffix = 0 %}
{% for seed in seeds.results %} {% for seed in seeds %}
{% set ns.seed_tokens = seed.msg.split(':') %} {% set ns.seed_tokens = seed.split(':') %}
{% if ns.seed_tokens[2] != ns.current_rack %} {% if ns.seed_tokens[2] != ns.current_rack %}
{% set ns.current_rack = ns.seed_tokens[2] %} {% set ns.current_rack = ns.seed_tokens[2] %}
{% set ns.current_suffix = ns.current_suffix + 1 %} {% set ns.current_suffix = ns.current_suffix + 1 %}

View File

@ -4,12 +4,9 @@
src: templates/seeds.list.j2 src: templates/seeds.list.j2
dest: "{{ target_path }}/seeds.list" dest: "{{ target_path }}/seeds.list"
- name: Prepare seeds variable reading generated file lines
debug: msg="{{item}}"
loop: "{{ lookup('file', '{{ target_path}}/seeds.list').splitlines() }}"
register: seeds
- name: Generate dynomite-swarm - name: Generate dynomite-swarm
vars:
seeds: "{{ lookup('file', '{{ target_path}}/seeds.list').splitlines() }}"
template: template:
src: templates/dynomite-swarm.yaml.j2 src: templates/dynomite-swarm.yaml.j2
dest: "{{ target_path }}/dynomite-swarm.yaml" dest: "{{ target_path }}/dynomite-swarm.yaml"

View File

@ -1,8 +1,8 @@
{% for seed in seeds.results %} {% for seed in seeds %}
{{ seed.msg.split(':')[0] }}: {{ seed.split(':')[0] }}:
environment: environment:
- DYNO_NODE={{ seed.msg }} - DYNO_NODE={{ seed }}
image: nubisware/autodynomite:latest image: nubisware/autodynomite:latest
networks: networks:
{{ conductor_network }}: {{ conductor_network }}: