-1

I am using salt 2015.8.1 (Beryllium) and using SaltStacks documenation, have enable haproxy.cfg autogenertion. However I would like to have a side A and side B type layout in my config file. I have tried to accomplish this using the following:

    # Side A
{% for server, addrs in salt['mine.get']('roles:docker', 'network.ip_addrs', expr_form='grain').items() %}
    {% if '*web1*' in server %}
    server {{ server }} {{ addrs[0] }}:443 check inter 2000 rise 2 fall 5
    {% endif %}
{% endfor %}

    # Side B
{% for server, addrs in salt['mine.get']('roles:docker', 'network.ip_addrs', expr_form='grain').items() %}
    {% if '*web2*' in server %}
    server {{ server }} {{ addrs[0] }}:443 check inter 2000 rise 2 fall 5
    {% endif %}
{% endfor %}

The problem is, while this does run AND complete it does not actually generate anything. I have looked around and asked in IRC but have been able to find a solid solution. If anyone could point me in the right direction I would be eternally grateful. The full haproxy.cfg can be found in this gist:

https://gist.github.com/beardedeagle/8b19a34f332ed26ac859

The documenation where this has been pulled from can be found here:

https://docs.saltstack.com/en/latest/topics/mine/

Again, thanks in advance.

* EDIT * I would like to state that I have the following working without issue so mine data is pulling the way it should:

{% for server, addrs in salt['mine.get']('roles:docker', 'network.ip_addrs', expr_form='grain').items() %}
    server {{ server }} {{ addrs[0] }}:443 check inter 2000 rise 2 fall 5
{% endfor %}
Adam Michalik
  • 9,678
  • 13
  • 71
  • 102
beardedeagle
  • 762
  • 1
  • 11
  • 24
  • Did you setup the mining? Use the following command to see if the IP adresses are collected by the mine in the first place: `salt-call mine.get '*' 'network.ip_addrs'` – ahus1 Nov 23 '15 at 22:42
  • @ahus1: Indeed I have, and if I just do one simple for loop for all servers in `roles:docker` then it works fine. I am just trying to figure out how to split it out in a nicely formatted way like what I have above should produce. – beardedeagle Nov 28 '15 at 04:11

1 Answers1

1

You can use compound matching in your loop, so if you don't have another specific grain to separate web1/web2, you can try

{% for server, addrs in salt['mine.get']('G@roles:docker' and L@web1*.domain.com', 'network.ip_addrs', expr_form='compound').items() %}
server {{ server }} {{ addrs[0] }}:443 check inter 2000 rise 2 fall 5
{% endfor %}

Same for web2.

savamane
  • 148
  • 1
  • 7