# Can't set ownership to system user

**URL:** <https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [September 15, 2016, 12:10pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555 "2016-09-15T12:10:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![user74](https://avatars.discourse-cdn.com/v4/letter/u/ce73a5/32.png) [@user74](https://forum.ansible.com/u/user74)\
**Post date:** [September 15, 2016, 12:10pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/1 "2016-09-15T12:10:14Z")

</div>

Hello.  
I have a server with Ubuntu Server 16.04.1. I test some ansible features on it from my desktop with Ubuntu 16.04.1.  
So I have system user “www-data” for Apache with uid=33(www-data) gid=33(www-data) groups=33(www-data).  
I have directory /var/www/html/wordpress that I want to set permissions to the system user/group “www-data”.  
I write that in playbook:  
file: path=/var/www/html/wordpress owner=www-data group=www-data mode=775 state=directory recurse=yes

So when I check the permissions of directory /var/www/html/wordpress I see that the owner is “1001” and group is “1001”. But I haven’t the user and group with uid and gid 1001. And this is the problem.  
What can I do?

---

<div class="post-metadata">

**Author:** ![user74](https://avatars.discourse-cdn.com/v4/letter/u/ce73a5/32.png) [@user74](https://forum.ansible.com/u/user74)\
**Post date:** [September 16, 2016, 8:06am UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/2 "2016-09-16T08:06:14Z")

</div>

Please, help.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 16, 2016, 4:40pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/3 "2016-09-16T16:40:48Z")

</div>

> Hello.  
> I have a server with Ubuntu Server 16.04.1. I test some ansible features on  
> it from my desktop with Ubuntu 16.04.1.  
> So I have system user "www-data" for Apache with uid=33(www-data)  
> gid=33(www-data) groups=33(www-data).  
> I have directory /var/www/html/wordpress that I want to set permissions to  
> the system user/group "www-data".  
> I write that in playbook:  
> file: path=/var/www/html/wordpress owner=www-data group=www-data mode=775  
> state=directory recurse=yes

Mode should always start with a 0 since it's a octal.

To change the owner and group you need to be root to allow that.

> So when I check the permissions of directory /var/www/html/wordpress I see  
> that the owner is "1001" and group is "1001". But I haven't the user and  
> group with uid and gid 1001. And this is the problem.  
> What can I do?

Since you have provided little information about how you run this it's hard for people to help. Which user are you using, are you using become, what is the output of ansible-playbook -vvvv \<your playbook\>

---

<div class="post-metadata">

**Author:** ![Alexander\_H\_Laughlin](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@Alexander\_H\_Laughlin](https://forum.ansible.com/u/Alexander_H_Laughlin)\
**Post date:** [September 17, 2016, 6:56am UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/4 "2016-09-17T06:56:42Z")

</div>

Also, since a version prior to 2.0 it’s been possible to specify the mode using non-octal notation. That is:  
`mode=ug+rw,o-rwx`

Or, in a playbook:

`

- name: Update permissions on a file.  
file:  
dest: /path/to/file  
owner: user  
group: group  
mode: ug+rw,o-rwx  
state: file

`

Personally I prefer this method and recall being quite happy when it was implemented mostly because I just don’t like octal notation.

---

<div class="post-metadata">

**Author:** ![user74](https://avatars.discourse-cdn.com/v4/letter/u/ce73a5/32.png) [@user74](https://forum.ansible.com/u/user74)\
**Post date:** [October 3, 2016, 7:00am UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/5 "2016-10-03T07:00:45Z")

</div>

Friends, you are talking not about my issue ☹  
There are no answers for my question.

Please, help me with my question about how to set ownership to system user.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 3, 2016, 2:34pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/6 "2016-10-03T14:34:25Z")

</div>

Алексей,

Is the directory mounted from another system (nfs)? That can cause the disparity you see if the nfs exporter does not have same UID-\>user mappings as the nfs client system.

---

<div class="post-metadata">

**Author:** ![user74](https://avatars.discourse-cdn.com/v4/letter/u/ce73a5/32.png) [@user74](https://forum.ansible.com/u/user74)\
**Post date:** [October 3, 2016, 7:47pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/7 "2016-10-03T19:47:40Z")

</div>

There are no any nfs shares.

---

<div class="post-metadata">

**Author:** ![user74](https://avatars.discourse-cdn.com/v4/letter/u/ce73a5/32.png) [@user74](https://forum.ansible.com/u/user74)\
**Post date:** [October 6, 2016, 4:39pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/8 "2016-10-06T16:39:21Z")

</div>

So.  
Can someone help me?

---

<div class="post-metadata">

**Author:** ![Phonthip\_Namkaew](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@Phonthip\_Namkaew](https://forum.ansible.com/u/Phonthip_Namkaew)\
**Post date:** [October 6, 2016, 7:10pm UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/9 "2016-10-06T19:10:39Z")

</div>

Try mode=0775

What is the output of \< getent passwd \> on that server ?

---

<div class="post-metadata">

**Author:** ![user74](https://avatars.discourse-cdn.com/v4/letter/u/ce73a5/32.png) [@user74](https://forum.ansible.com/u/user74)\
**Post date:** [October 7, 2016, 6:53am UTC](https://forum.ansible.com/t/cant-set-ownership-to-system-user/22555/10 "2016-10-07T06:53:11Z")

</div>

In my first message I said that I have already used mode=775.

Output of getent passwd:

root:x:0:0:root:/root:/bin/bash  
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin  
bin:x:2:2:bin:/bin:/usr/sbin/nologin  
sys:x:3:3:sys:/dev:/usr/sbin/nologin  
sync:x:4:65534:sync:/bin:/bin/sync  
games:x:5:60:games:/usr/games:/usr/sbin/nologin  
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin  
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin  
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin  
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin  
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin  
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin  
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin  
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin  
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin  
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin  
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin  
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin  
systemd-timesync:x:100:102:systemd Time Synchronization,:/run/systemd:/bin/false  
systemd-network:x:101:103:systemd Network Management,:/run/systemd/netif:/bin/false  
systemd-resolve:x:102:104:systemd Resolver,:/run/systemd/resolve:/bin/false  
systemd-bus-proxy:x:103:105:systemd Bus Proxy,:/run/systemd:/bin/false  
syslog:x:104:108::/home/syslog:/bin/false  
\_apt:x:105:65534::/nonexistent:/bin/false  
messagebus:x:106:110::/var/run/dbus:/bin/false  
uuidd:x:107:111::/run/uuidd:/bin/false  
sshd:x:108:65534::/var/run/sshd:/usr/sbin/nologin  
statd:x:109:65534::/var/lib/nfs:/bin/false  
mysql:x:110:114:MySQL Server,:/nonexistent:/bin/false
