0

earlier I have these condition on my ansible task.yml which I verified working, basically when the parameter is dev then the ASG is set to "awseb-e-xxxxxxxxxxxxxxx-stack-AWSEBAutoScalingGroup-DEV", if not then ASG will be set to the uat ASG which is "awseb-e-xxxxxxxxxxxxxxx-stack-AWSEBAutoScalingGroup-UAT"

 - set_fact:
  ASG: "{{ (env == 'dev') | ternary('awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-DEV', 'awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-UAT') }}"

My question is what if I add more choice on the logic, say when the parameter used on the playbook is prod then use the ASG "awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-PROD"? I have this idea but not sure if it will work, let me know your expert advices

 - set_fact:
  ASG: "{{ (env == 'dev') | ternary('awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-DEV'}}"
 - set_fact:
  ASG: "{{ (env == 'uat') | ternary('awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-UAT'}}"
 - set_fact:
  ASG: "{{ (env == 'prod') | ternary('awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-PROD'}}"    
Ersan Poguita
  • 119
  • 1
  • 2
  • 8
  • "*I have this idea but not sure if it will work*" ー how about trying? – techraf May 28 '18 at 03:40
  • didnt worked, gave me an error = ternary() takes exactly 3 arguments (2 given) – Ersan Poguita May 28 '18 at 04:20
  • Create a data structure and use [the most voted answer](https://stackoverflow.com/a/31896249/2947502) under the dup-target to get the corresponding value for the one you are searching. – techraf May 28 '18 at 04:33

0 Answers0