Hi

Sorry, probably didn't explain myself very well and what I was proposing 
was probably pretty fragile.

You'd have to set up a directory of reference files that you want to 
compare to, and another of candidate files.
Then you'd need a playbook to use fetch to pull the candidate files back 
from the windows hosts, and then use the copy module (running with --check 
--diff) to ''copy'' between the candidate and reference files.  It wouldn't 
actually copy but would show the difference between the reference and 
candidate files I think.

You can see the output from command if you run ansible with -v switch or if 
you store results from commands using register, and then use the debug 
module to display the contents of the registered variable.

Hope this helps,

Jon

On Wednesday, 24 February 2016 15:32:47 UTC, Mark Matthews wrote:
>
> Hi Jon
>
> I tried creating the following playbook below, and running the following 
> command:  ansible-playbook test_win.yml --check --diff 
> But I just got errors Not sure if this is what you were trying to explain 
> what I should do?
>
> ---
> - name: Check host file diff
>   hosts: all
>   tasks:
>     - name: Check host file diff
>       win_copy:
>         src: /srv/hosts
>         dest: C:\Windows\System32\drivers\etc\hosts
>
> I am able to run the below powershell script through a playbook, and it 
> works, but it really doesn't help me as the Ansible does not give the 
> output of of any changes that the powershell script may have picked up.
> Is there a way to get Ansible to show the powershell output of a script 
> that it runs?
>
> Cheers
> Mark
>
>
> On Tuesday, February 23, 2016 at 11:29:48 AM 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/bd6159a9-83b3-42e3-a58f-6e39aefecd8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to