chown failed in file module

1,483 views
Skip to first unread message

olga

unread,
Oct 1, 2014, 7:36:16 AM10/1/14
to ansible...@googlegroups.com
Hi,

I am using ansible 1.7.2 and see the chown is not working

olga@ubuntu:~/ansible/try/02$ ansible localhost -u root -k -m file -a 'path=/tmp/test6 state=directory mode=0700 owner=root'
SSH password: 
localhost | FAILED >> {
    "failed": true, 
    "gid": 1001, 
    "group": "olga", 
    "mode": "0775", 
    "msg": "chown failed", 
    "owner": "olga", 
    "path": "//tmp/test6", 
    "size": 4096, 
    "state": "directory", 
    "uid": 1001
}

What is the right command option to create dir owned by the sudo user ?

Thanks,
olga

Mark

unread,
Oct 1, 2014, 7:40:51 AM10/1/14
to ansible...@googlegroups.com

You are SSHing as root, is permitremoterootlogin enabled?
Op woensdag 1 oktober 2014 13:36:16 UTC+2 schreef olga:

Michael DeHaan

unread,
Oct 1, 2014, 8:21:12 AM10/1/14
to ansible...@googlegroups.com
"You are SSHing as root, is permitremoterootlogin enabled?"

If that were the case the error would appear further up.

Also sudo isn't being used because of the "-u root"

Is there anything unusual about /tmp we might need to know?



--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9c489288-8085-47b4-844a-14712fb51ac2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mark

unread,
Oct 2, 2014, 3:16:30 AM10/2/14
to ansible...@googlegroups.com
So doing this on a bare install of ubuntu 14.04 LTS makes it work.

mark@ans:~$ ansible localhost -u root -k -m file -a 'path=/tmp/test6 state=directory mode=0700 owner=root'
SSH password: 
sudo password [defaults to SSH password]: 
localhost | success >> {
    "changed": false, 
    "gid": 0, 
    "group": "root", 
    "mode": "0700", 
    "owner": "root", 
    "path": "/tmp/test6", 
    "size": 4096, 
    "state": "directory", 
    "uid": 0
}




Doing this on my CentOS will fail in the same way you see it fail. 
[markh@sen-ansible-int ~]$ ansible localhost -u root -k -m file -a 'path=/tmp/test6 state=direct                                                                                                           SSH password:
sudo password [defaults to SSH password]:
localhost | FAILED >> {
    "failed": true,
    "gid": 60007,
    "group": "senuser",
    "mode": "0755",
    "msg": "chown failed",
    "owner": "markh",
    "path": "//tmp/test6",
    "size": 4096,
    "state": "directory",
    "uid": 60018



Ofcourse there are a lot of settings that diff between these 2 systems, but one is not, and those are the filerights on /tmp which are exactly the same...
does running it in -vvvv gives you any more details?



Op woensdag 1 oktober 2014 14:21:12 UTC+2 schreef Michael DeHaan:

Subramanian Olagappan

unread,
Oct 2, 2014, 7:13:53 AM10/2/14
to ansible...@googlegroups.com
Hi Mark,

I'm using ubuntu 12.04 LTS and I can ssh as "root" in localhost and enabled PermitRootLogin in ssh_config file

olga@ubuntu:~/ansible/try/02$ ansible localhost -u root -k -m file -a 'path=/tmp/test11 state=directory mode=0700 owner=root' -vvv
SSH password: 
<localhost> REMOTE_MODULE file path=/tmp/test11 state=directory mode=0700 owner=root
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070 && echo $HOME/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070']
<localhost> PUT /tmp/tmptdYxcv TO /home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/file
<localhost> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/file; rm -rf /home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/ >/dev/null 2>&1']
localhost | FAILED >> {
    "failed": true, 
    "gid": 1001, 
    "group": "olga", 
    "mode": "0775", 
    "msg": "chown failed", 
    "owner": "olga", 
    "path": "/tmp/test11", 
    "size": 4096, 
    "state": "directory", 
    "uid": 1001
}

root@ubuntu:/tmp# ls -ld /tmp
drwxrwxrwt 12 root root 4096 Oct  2 16:23 /tmp
root@ubuntu:/tmp# 

I tried with a wrong "ssh" password for root ( -k option ) , it created the dir in /tmp and the error was same. I was not expecting this and the command should not have created the dir.

Regards,
Olga

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/tNgiPM1Tt0E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages