之前我在我的ansible task.yml上有这些条件,我验证了它的工作,基本上当参数为dev
时,ASG
设置为" awseb-e-xxxxxxxxxxxxxxx-stack-AWSEBAutoScalingGroup-DEV
&# 34;如果没有,那么ASG将被设置为uat
ASG
,这是" awseb-e-xxxxxxxxxxxxxxx-stack-AWSEBAutoScalingGroup-UAT
"
- set_fact:
ASG: "{{ (env == 'dev') | ternary('awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-DEV', 'awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-UAT') }}"
我的问题是,如果我在逻辑上添加更多选项,比如当剧本中使用的参数为prod
时,请使用ASG
" awseb-e-xxxxxxxxxxxxxxj-stack-AWSEBAutoScalingGroup-PROD
&#34 ;?我有这个想法,但不确定它是否有用,让我知道你的专家意见
- 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'}}"