chown failed in file module

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

You are SSHing as root, is permitremoterootlogin enabled?

“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?

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?

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:
REMOTE_MODULE file path=/tmp/test11 state=directory mode=0700 owner=root
EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070 && echo $HOME/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070’]
PUT /tmp/tmptdYxcv TO /home/olga/.ansible/tmp/ansible-tmp-1412246841.03-7250721660070/file
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