I would like to know if there is a way to print information while a module is executing – primarily as a means to demonstrate that the process is working and has not hung. Specifically, I am trying to get feedback during the execution of the cloudformation module. I tried modifying the source code to include the following:
`
def debug(msg):
print json.dumps({
“DEBUG” : msg
})
…
debug(“The stack operation is still working…”)
`
What this did, of course, was store all this output and only print it all after the module had finished executing. So for particularly large cloudformation templates, this means that I wait around for 5 minutes or so, and then suddenly see a large amount of text appear on the screen at the end. What I was expecting was to see “The stack operation is still working…” printed every x seconds.
It would seem that the Asynchronous Actions and Polling are what I’m looking for… but this didn’t work, either. The entire task, “Launch CloudFormation for {{ stackname }}”, was skipped entirely. See below for the relevant snippet from my playbook:
`
- name: Launch CloudFormation for {{ stackname }}
cloudformation: >
stack_name=“{{ stackname }}” state=present
region=“{{ region }}” disable_rollback=true
template=“{{ template }}”
register: cloud
args:
template_parameters:
KeyName: “{{ keyName }}”
Region: “{{ region }}”
SecurityGroup: “{{ securityGroup }}”
BootStrapper: “{{ bootStrapper }}”
BootStrapCommand: “powershell.exe -executionpolicy unrestricted -File C:\{{ bootStrapper }} {{ region }}”
S3Bucket: “{{ s3Bucket }}”
async: 3600
poll: 30
`
This tells me that async is meant for typical shell commands, and not complex modules such as cloudformation. OR – I may have done something wrong.
Could anyone shed some light on this situation? Again, for large cloudformation tasks that take a while, I would like some periodic indication that the task is still running, and not hanging. I appreciate the help!