下面是我用于创建rd的有趣的剧本。
- name: provision stack
hosts: localhost
connection: local
gather_facts: false
# Launch the cloudformation-example.yml template. Register the output.
tasks:
- name: launch ansible cloudformation example
cloudformation: >
stack_name="ansible-cloudformation" state=present
region=us-east-1 disable_rollback=true
template=files/simple-rds.yml
args:
template_parameters:
vpcid: vpc-0123456
application: abc
appSubnetCidr1: 201.0.0.0/20
appSubnetCidr2: 201.0.0.0/22
dbCreateNewParamsGroup: true
dbInstanceType: db.t2.micro
dbName: testdb
dbSubnetId1: subnet-87654321
dbSubnetId2: subnet-12345678
dbUsername: master_user
environment: development
product: ""
dbPassword: ""
techContact: ""
register: stack
- name: show stack events
debug: msg="My stack events are {{stack.events}}"
当我运行剧本时,我得到了这样的堆栈事件。它以失真的形式出现:
ok: [localhost] => {
"msg": "My stack outputs are [u'StackEvent AWS::CloudFormation::Stack dev-beanstalk-ansible UPDATE_COMPLETE', u'StackEvent AWS::CloudFormation::Stack BeanstalkTemplateStack UPDATE_COMPLETE', u'StackEvent AWS::CloudFormation::Stack BeanstalkTemplateStack UPDATE_IN_PROGRESS'...
如何以正确的格式获取输出,如下所述。我也尝试过{{stack.stack_resources}},{{stack.stack_outputs}}。所有人都有相同的问题。
events": [
"StackEvent AWS::CloudFormation::Stack dev-beanstalk-ansible UPDATE_COMPLETE",
"StackEvent AWS::CloudFormation::Stack BeanstalkTemplateStack UPDATE_COMPLETE",
"StackEvent AWS::CloudFormation::Stack BeanstalkTemplateStack UPDATE_IN_PROGRESS",
答案 0 :(得分:0)
您尝试过内置filters吗?
您可以尝试
- name: debug events
debug: msg="My stack events are {{stack.events | to_nice_json }}"