Can't set ownership to system user

162 views
Skip to first unread message

Алексей Гуносов

unread,
Sep 15, 2016, 11:11:02 AM9/15/16
to Ansible Project
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?

Алексей Гуносов

unread,
Sep 16, 2016, 4:06:14 AM9/16/16
to Ansible Project
Please, help.

Kai Stian Olstad

unread,
Sep 16, 2016, 12:41:04 PM9/16/16
to ansible...@googlegroups.com
On 15. sep. 2016 14:10, Алексей Гуносов wrote:
> 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>

--
Kai Stian Olstad

Alexander H. Laughlin

unread,
Sep 19, 2016, 1:18:00 PM9/19/16
to Ansible Project, ansible-pr...@olstad.com
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. 

Алексей Гуносов

unread,
Oct 3, 2016, 3:00:45 AM10/3/16
to Ansible Project
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.


Brian Coca

unread,
Oct 3, 2016, 10:34:32 AM10/3/16
to ansible...@googlegroups.com
Алексей,

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.


----------
Brian Coca

Алексей Гуносов

unread,
Oct 3, 2016, 3:47:41 PM10/3/16
to Ansible Project
There are no any nfs shares.


четверг, 15 сентября 2016 г., 18:11:02 UTC+3 пользователь Алексей Гуносов написал:

Алексей Гуносов

unread,
Oct 6, 2016, 12:39:22 PM10/6/16
to Ansible Project
So.
Can someone help me?

четверг, 15 сентября 2016 г., 18:11:02 UTC+3 пользователь Алексей Гуносов написал:
Hello.

Phonthip Namkaew

unread,
Oct 6, 2016, 3:10:40 PM10/6/16
to Ansible Project
Try mode=0775

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

Алексей Гуносов

unread,
Oct 7, 2016, 2:53:11 AM10/7/16
to Ansible Project
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


четверг, 15 сентября 2016 г., 18:11:02 UTC+3 пользователь Алексей Гуносов написал:
Hello.
Reply all
Reply to author
Forward
0 new messages