At the moment I don't think there's anything in the windows modules that 
will help with this.  If anyone knows better please say but I think today 
--check and --diff aren't implemented for windows modules.

However, it might be possible to make use of the --check and --diff 
playbook command line arguments if you first fetch the files that you care 
about back to the controller and then use copy tasks (which won't actually 
copy in --check mode).

There's a thread here describing this

https://groups.google.com/forum/#!topic/ansible-project/6xkSE1nxIOU

That said, as you've pointed out comparing files in powershell is pretty 
straightforward so there's no reason why win_copy couldn't be changed to 
implement --check and --diff modes.

Hope this helps,

Jon

On Tuesday, 23 February 2016 11:29:48 UTC, Mark Matthews wrote:
>
> Hi
>
> I am trying to find an way Ansible can not only alert me of a change in a 
> file but exactly what was changed in that file.
>
> I am currently using win_stat play bookk to check the host file of a 
> server and let me know if anything has changed. This works great, cut it 
> only tells me if something has changed, it doesn;t tell me what has changed 
> in the file.
>
> ---
> - name: Check Host file
>   hosts: all
>   tasks:
>      - name: stat the hosts file
>        win_stat:
>          path: C:\windows\system32\drivers\etc\hosts
>        register: hosts_fileinfo
>      - name: show hosts file stats for debugging purposes
>        debug:
>          var: hosts_fileinfo
>      - name: Fail if Host File Missing
>        fail:
>          msg: "WEB.CONFIG file is missing"
>        when: hosts_fileinfo.stat.exists != true
>      - name: Fail if Host File Modified
>        fail:
>          msg: "HOSTS file has been modified"
>        when: hosts_fileinfo.stat.checksum != 
> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
>
>
> I am looking for something that the following Powershell script does.
> As you can see it has picked up that there is a difference between the two 
> files and it then shows me where the difference is.
>
>
> PS H:\> *Compare-Object -ReferenceObject (Get-Content 
> C:\Temp\applicationHost.config) -DifferenceObject (Get-Content 
>  C:\Temp\applicationHost_2.config)*
>
> InputObject                                                               
>                            SideIndicator                                   
>                                                     
> -----------                                                               
>                            -------------                                   
>                                                     
>             <section name="applicationPool" allowDefinition="AppHostOnly" 
> overrideModeDefault="De... =>                                               
>                                                    
>             <section name="applicationPools" allowDefinition="AppHostOnly" 
> overrideModeDefault="D... <=              
>
>
> Any help with this would be really appreciated.
>
> Cheers
> Mark
>                                                                            
>                                                                             
>                           
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8d6ff81c-f115-4e2d-a2e5-5065e3d86810%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to