Match regular expressions in the salt stack

I am rewriting some modules from a puppet to a salt one.

In the puppet we can use nodefor this particular part for this machine, for example:

node /william\d+.aws.dev/ {
  # some codes here.. 
}

But in a salt sink, it's not so elegant:

{% if grains['fqdn'] == 'william.aws.dev' %}
  # some codes here..
{% endif %}

and regex is not supported.

Is there a way to rewrite it in salt dishes using less code?


Note I do not want to use top.slsto determine which node is used with sls. because it will make the top.sls file too big to support.

I just want to define a simple two lines in top.sls:

'*':
  - node.*

every time I add a few salts of node, I just need to create a new file in the directory node.

+4
1

- SLSes topfile, , , , node SLS node/, SLS. , , top.sls.

, node, node.

, , top.sls, . , , node SLS SLS, fqdn. , top.sls,

{% set grain_fqdn = salt['grains.get']('fqdn', '') %}

base:
  'fqdn:{{ grain_fqdn }}':
      - match: grain  
      - node.{{ grain_fqdn }}

, node fqdn = williams.aws.dev node.williams.aws.dev.sls.

+1

All Articles