We recently integrated Ansible deployment with Jenkins. All looks good and the next step is to find a way to store all playbook variables. What is the best practice for that? We want to have different set of variables for each environment (Dev, QA, UAT, Prod). Many thanks.
Asked
Active
Viewed 531 times
0
-
Could you give a bit more details about your config? But for example, inventories can be used to have different variables for different stages. – user140547 Apr 26 '17 at 15:25
-
I don't think you need to store any Ansible variables in Jenkins to accomplish this well. – Matthew Schuchard Apr 26 '17 at 17:04
1 Answers
0
Use a shell/batch script and set them as environment variables. Like
#!/bin/bash
export var1=value1
export var2=value2
Then execute the script just before running playbook.
source <script>.sh
bash <script>.sh
You can also parameterize the values which can be passed through jenkins during runtime.i.e
export var1=$1 and so on.....

MMA
- 408
- 3
- 7
- 19