Have a look at salt pillar. But before you do that check out my awful hack below, all in a single init.sls:
{% for environment in 'test','production','development' %}
/etc/nginx/sites-available/{{ environment }}:
file:
- managed
- source: salt://templates/nginx.conf.template
- template: jinja
- defaults:
environment: {{ environment }}
/etc/ssl/private/{{ environment }}.key.pem:
file:
- managed
- source: salt://certs/{{ environment }}.key.pem
/etc/ssl/certs/{{ environment }}.cert.pem:
file:
- managed
- source: salt://certs/{{ environment }}.cert.pem
{% endfor %}
Mine is configuring the ssl key for nginx but you would just put in Replica4 in there, it will get expanded as environment. I just add environments as necessary and it sync it all up for me.
Yours might look something like:
{% for environment in 'Replica4','Replica5', %}
mongo {{ environment }}:27000 /usr/lib/mongo/init_addshard.js:
cmd:
- run
- user: present
{% endfor %}