我怎样才能触发ansible多个AWS cloudformation任务? [英] How can i trigger multiple aws cloudformation tasks in ansible?
问题描述
我试图找到一种方式来触发通过ansible多个并行cloudformation API调用。
I am trying to find a way to trigger multiple cloudformation api calls via ansible in parallel.
由于堆栈已经成长了很多单独触发每个任务是吃了大量的时间。我看着async选项与民意调查设置为0(发射后不管)。但是,这并不触发cloudformation任务都没有。
As the stack has grown a lot triggering each task seperately is eating up a lot of time. I looked at async option with poll set to 0 ( fire and forget ). But this doesn't trigger the cloudformation task at all.
有什么建议?
推荐答案
解决方案1: 裹在ansible模块的cloudformation电话(轻松地创建),并用内螺纹模块。
Solution 1: Wrap your cloudformation calls in ansible module (easy to create) and use threading module inside.
例如:
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: 编写一个脚本,将封装所有functuanality和ansible TRIGER一个脚本 例如:
Solution 2: Write a script that will encapsulate all the functuanality and triger single script in ansible Example:
#!/bin/bash
aws cloudformation list-stacks > foo &
aws cloudformation describe-stack --stack-name aaa > bar &
,然后在ansible剧本只使用壳
模块TRIGER它
and then in your ansible playbook just use shell
module to triger it
这篇关于我怎样才能触发ansible多个AWS cloudformation任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!