The user account is a local admin account with perm to the c:\temp folder. 
Error is:

fatal: [winserver1.foo.com]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "win_lineinfile"
    }, 
    "msg": "Destination c:\\temp\\ansible-windows_base.log does not exist !"
}


If the file exists it works:

changed: [winserver1.foo.com] => {
    "backup": "", 
    "changed": true, 
    "encoding": "utf-8", 
    "invocation": {
        "module_name": "win_lineinfile"
    }, 
    "msg": "line added"
}


And if i create a task to create the file ahead of time all is OK

*- hosts: all*
*  tasks:*
  
*  - name: create file*
*    win_file:*
*      path: 'c:\temp\ansible-windows_base.log'*
*      state: touch*

*  - name:  win_lineinfile test*
*    win_lineinfile:*
*      dest: 'c:\temp\ansible-windows_base.log'*
*      create: true *
*      line: 'test-{{ ansible_hostname }}-{{ ansible_date_time.iso8601 }}'*
*      regexp: 'test-{{ ansible_hostname }}-'*
*      state: present*



And re-run:
TASK [create file] ******
changed: [winserver1.foo.com] => { "changed": true, "invocation": { 
"module_name": "win_file" } } 

TASK [win_lineinfile test] ******
changed: [winserver1.foo.com] => { "backup": "", "changed": true, 
"encoding": "utf-16", "invocation": { "module_name": "win_lineinfile" }, 
"msg": "line added" }


I've also upgrade to 2.2.1.0 and getting the same. Since the linux module 
will create a new file I'm assuming something is funky with the windows one.


On Tuesday, February 28, 2017 at 9:00:30 AM UTC-5, J Hawkesworth wrote:
>
> If you run with -vvvvv what error message do you see?
>
> Does your ansible user have permission to write to 
> c:\temp\ansible-windows.log ?
>
> Hope this helps,
>
> Jon
> On Thursday, February 16, 2017 at 6:52:24 PM UTC, cupcake wrote:
>>
>> ansible core 2.1
>>
>> When using win_lineinfile module and the `create: yes` option it seems it 
>> should create a new file. it fails the same as if create:yes is not 
>> specified.
>>
>> - hosts: all
>>   tasks:
>>
>>   - name:  win_lineinfile test
>>     win_lineinfile:
>>       dest: 'c:\temp\ansible-windows.log'
>>       create: yes
>>       line: '{{ ansible_hostname }}-{{ ansible_date_time.iso8601 }}'
>>       regexp: '{{ ansible_hostname }}-'
>>       state: present
>>
>> If dest doesn't exist it fails. Guessing I am doing something wrong?
>>
>>
>>
>>

-- 
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/b3a59569-c5c7-45db-a49e-2d3a04c04e27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to