Anyone have any ideas?

On Wednesday, July 29, 2015 at 2:58:06 PM UTC-4, Craig Moynes wrote:
>
> Hi,
>   Just getting started with Ansible (1.9.2) and trying to get a playbook 
> configured to deploy the latest version of our developers code.
>
> What I wanted to do was loop through the property files from the source, 
> and if there was a difference (by md5 comparison) prompt the user that they 
> should manually verify and confirm. The reason for this is that different 
> environments (lower test environments, production environments) may have 
> had optimizations that I don't want to overwrite blindly - or skip and miss 
> a change that should be deployed.
>
> Even logging it at the end of the run would work from my perspective.
>
> The following runs against a list of hosts (2 currently):
> - hosts: webservice
>   vars:
>     local_path: /tmp/webservice-latest
>     tomcat_dest_path: /opt/tomcat/webapps
>     shared_classes_path: /opt/tomcat/shared/classes
>
>     webservice_files: [
>      {
>       sample_name: wrapper.properties.sample,
>       name: wrapper.properties,
>       src: "{{local_path}}/conf",
>       dest: "{{shared_classes_path}}"
>      }
>     ]
>
>  tasks:
>
>     - name: Get local stat of all webapp files
>       become: no
>       local_action: stat path="{{item.src}}/{{item.sample_name}}"
>       with_items:
>         - "{{webservice_files}}"
>       register: local
>
>     - name: Get remote stat of all the webapp files
>       action: stat path="{{item.dest}}/{{item.name}}"
>       with_items:
>         - "{{webservice_files}}"
>       register: remote
>
>    - name: "Debug file stat for both local and remote - True"
>       debug: msg="Stat should be True 
> {{item.1.stat.path}}:{{item.1.stat.md5}} 
> {{item.2.stat.path}}:{{item.2.stat.md5}}"
>       when: '"{{item.2.stat.exists}}" == "True" and "{{item.1.stat.md5}}" 
> != "{{item.2.stat.md5|default}}"'
>       with_together:
>         - "{{webservice_files}}"
>         - "{{local.results}}"
>         - "{{remote.results}}"
>
>     # if the property files do exist, then we need to tell the user
>     # and let them sort it out
>     - name: Compare md5 of webservice files that do exist, prompt if 
> different
>       pause: prompt="Files are different - manually review (enter to 
> continue)"
>       when: '"{{item.2.stat.exists}}" == "True" and "{{item.1.stat.md5}}" 
> != "{{item.2.stat.md5|default}}"'
>       with_together:
>         - "{{webservice_files}}"
>         - "{{local.results}}"
>         - "{{remote.results}}"
>
> Test Scenario:
> For my test the remote file on server1 is different than the local file, 
> the remote file on server2 is identical.
>
> Results:
> I can see the debug line skipped for server2, and displayed for server1 
> which is correct.
>
> The issue is that I only see the action skipped for server2, for server1 I 
> don't get a prompt or a notification that it was skipped.  It just silently 
> skips it.
>
> Any suggestions?
>
> I am thinking that pause does not work when used within a loop (although 
> not documented here - http://docs.ansible.com/ansible/pause_module.html).
>
> Even if I template the different environments property files, if someone 
> has made a change I would prefer to at least notify the person deploying 
> that there is an unexpected change in one of the files.
>
>
> Cheers,
>   Craig
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5186da61-ad25-4b72-b033-5d543c908567%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to