[英]How can i trigger multiple aws cloudformation tasks in ansible?
我正在嘗試找到一種通過ansible並行觸發多個cloudformation api調用的方法。
隨着堆棧的增長,觸發每個任務單獨消耗大量時間。 我查看了將poll設置為0(即起即忘)的異步選項。 但這根本不會觸發cloudformation任務。
有什么建議么 ?
解決方案1:將您的cloudformation調用包裝在ansible模塊(易於創建)中,並在其中使用線程模塊。
例:
import threading
def main():
module=AnsibleModule(
argument_spec=dict(
region=dict(choices=AWS_REGIONS, default='us-east-1'),
aws_secret_key=dict(no_log=True),
aws_access_key=dict(no_log=True)
...
)
)
t = threading.Thread(target=cfn_command)
threads.append(t)
t.start()
解決方案2:編寫一個腳本,將所有功能和觸發單個腳本封裝在ansible示例中:
#!/bin/bash
aws cloudformation list-stacks > foo &
aws cloudformation describe-stack --stack-name aaa > bar &
然后在您的ansible劇本中使用shell
模塊進行觸發
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.