Hi,
Looks like I am not able to find a solution to a not-so-complex problem :
I have a application server, let's say web server to which client are connecting through a reverse proxy (nginx). So for each app server I must add a small block to my nginx/conf.d/app.proxy config file.
In this block I mainly needs a location and a proxy_pass, this proxy_pass IS the internal name of the app server and the location should be computed from this app server name (with some exception, but I am not even that far).
I am provisioning app server through salt-cloud on our private proxmox, using reactor I am able to configure each and every details from the app server.
I firts thought it would be easy to add the corresponding block to the nginx config file, but finally I am not able to do this :(
The master plan is to simply add a state to the already existing orchestration; this state would just push the block to the nginx by using the data that are already available in this orchestrate state ... For this I tried to use the followong but could not make it works :
{% set vm_name = salt.pillar.get('vm_name') %}
...
[ many others states before, already validated ]
...
# Add vm_name config to proxy(ies)
orchestrate_add_client_to_proxy:
salt.state:
- tgt: 'nginx-slave.tld'
- sls:
- role.proxy.add_client_proxy
- pillar:
tgt_client_name: {{ vm_name }}
In the above example I am trying to pass the client name (the sever newly created, in this very orchestration actually) by using the
vm_namewhich I got from the reactor state as :
acd_orch:
runner.state.orchestrate:
- mods: orch.acd
- pillar:
vm_name: {{ data.name }}
This allow me to dynamically get the
vm name that is being created and use that name as a target (very usual I guess) inside the orchestration state as shown above.
Then "fort de tout cela" I tried to use that vm_name again when calling the state responsible to add the required block to nginx config, but that was unfortunate.
Has anyone a solution for this ? How can I pass an arg / kwarg / pillar data to a state and then how to use it inside this target state ?
I am sure it is not complex but I couldn't find the solution by my own, please ;)
PierB