lineinfile module gives error: "chown failed: [Errno 1] Operation not permitted:

38 views
Skip to first unread message

arnab sen

unread,
Apr 30, 2018, 10:03:48 PM4/30/18
to Ansible Project
Playbook
I am trying to chnage some test in a property file using "lineinfile" module.  I am getting the below exception. 
On my host, there is a sudo user (testuser). sudo method is "sudo su - testuser"


--- 
  hosts: Test
  
  tasks: 
    
   - name: change files
     become: yes
     become_method: sudo su
     become_user: testuser
     lineinfile:
       path: /path/test.properties
       regexp: '^test1234'
       line: '1234test1234'
       owner: root
       group: root
       mode: 01777
       backup: yes
       
Error Output:

{"changed": false, "gid": 63243, "group": "testuser", "mode": "0777", "msg": "chown failed: [Errno 1] Operation not permitted: '/path/test.properties'", "owner": "testuser", "path": "/path/test.properties", "secontext": "unconfined_u:object_r:unlabeled_t:s0", "size": 2222, "state": "file", "uid": 29604}

Malcolm Hussain-Gambles

unread,
May 1, 2018, 2:30:43 PM5/1/18
to Ansible Project
You're trying to change the ownership of a file to root, you need to be root to do that

Cheers

Malcolm

Reply all
Reply to author
Forward
0 new messages