From a555901dfec992bbc71165ddb1d2b7e908cc1b8c Mon Sep 17 00:00:00 2001
From: sborenst <shachar.borenstein@gmail.com>
Date: Mon, 03 Sep 2018 03:11:15 +0200
Subject: [PATCH] added debug messages for Autoscalling groups

---
 ansible/configs/rhte-ocp-workshop/post_infra.yml       |   15 ++++++++++++---
 ansible/roles/infra-ec2-template-create/tasks/main.yml |    5 ++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ansible/configs/rhte-ocp-workshop/post_infra.yml b/ansible/configs/rhte-ocp-workshop/post_infra.yml
index c4acf90..f84e0ba 100644
--- a/ansible/configs/rhte-ocp-workshop/post_infra.yml
+++ b/ansible/configs/rhte-ocp-workshop/post_infra.yml
@@ -14,21 +14,30 @@
         AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}"
         AWS_DEFAULT_REGION: "{{aws_region_final|d(aws_region)}}"
       block:
+      - name: test cloudformation_out_final
+        debug:
+          var: cloudformation_out_final
+          verbosity: 2
       - name: Deactivate autoscaling
         command: >-
           aws autoscaling suspend-processes --auto-scaling-group-name
-          {{cloudformation_out_final.stack_outputs.AutoScalingGroupClientVM}} 
-
+          {{cloudformation_out_final.stack_outputs.AutoScalingGroupClientVM}}
+        when:
+          - cloudformation_out_final.stack_outputs.AutoScalingGroupClientVM is defined
       - name: Write down autoscaling name
         copy:
           dest: "{{ANSIBLE_REPO_PATH}}/workdir/{{ env_type }}.{{ guid }}.AutoScalingGroupClientVM"
           content: "{{cloudformation_out_final.stack_outputs.AutoScalingGroupClientVM}}"
+        when:
+          - cloudformation_out_final.stack_outputs.AutoScalingGroupClientVM is defined
 
       - name: Allocate and associate an EIP to the clientVMs
         ec2_eip:
           device_id: "{{hostvars[item].instance_id}}"
         with_items: "{{groups['clientvms']}}"
         register: eips
+        when:
+          - cloudformation_out_final.stack_outputs.AutoScalingGroupClientVM is defined
 
       # reimport roles to update inventory, and regenerate ssh config, since
       # we're using public ip to connect to clientVMs
@@ -121,7 +130,7 @@
           ** Route53User secret key: {{ route53user_secret_access_key }}
       when: route53user_access_key is defined
 
-  
+
 - name: Detect and map data disks (support) for Azure
   hosts: support
   become: true
diff --git a/ansible/roles/infra-ec2-template-create/tasks/main.yml b/ansible/roles/infra-ec2-template-create/tasks/main.yml
index 0019031..982fe98 100644
--- a/ansible/roles/infra-ec2-template-create/tasks/main.yml
+++ b/ansible/roles/infra-ec2-template-create/tasks/main.yml
@@ -159,6 +159,10 @@
 
     - name: Output region
       debug:
+        var: cloudformation_out_final
+        verbosity: 2
+    - name: Output region
+      debug:
         msg: "FALLBACK REGION = {{aws_region_final}}"
       when:
         - cloudformation_out is succeeded
@@ -171,4 +175,3 @@
     - set_fact:
         stack_deployed: false
       when: cloudformation_out is failed
-

--
Gitblit v1.9.3