Can't set ownership to system user

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?

Please, help.

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>

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.

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

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

Алексей,

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.

There are no any nfs shares.

So.
Can someone help me?

Try mode=0775

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

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