provision_docker icon indicating copy to clipboard operation
provision_docker copied to clipboard

Role execution fails if not running under root user

Open KKoukiou opened this issue 8 years ago • 4 comments

TASK [provision_docker : Install libselinux-python package for 'copy' task] ****************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "This command has to be run under the root user."}

I have the libselinux package already installed on my machine, but even for checking if the package is installed it requires root, which is not expected behavior.

I tried to replace the package module with yum module which works on my system and it succeeds as expected, so I guess we can replace it here as well.

Affects only system where ansible_os_family== "Redhat"

KKoukiou avatar Aug 01 '17 09:08 KKoukiou

@orpiske this PR introduced the issue https://github.com/chrismeyersfsu/provision_docker/pull/54 I will open also issue in ansible for the package module.

KKoukiou avatar Aug 01 '17 10:08 KKoukiou

The error actually comes from dnf_module, so it might be better to open issue there . https://github.com/ansible/ansible/issues/27844

lukas-bednar avatar Aug 07 '17 13:08 lukas-bednar

@lukas-bednar I am getting this issue as well, is there a way to tell it to run as sudo?

Trying to use this role https://github.com/geerlingguy/ansible-role-docker and I get this when running ansible-playbook -K setup_docker.yml:

failed: [localhost] (item=docker) => {"changed": false, "cmd": "dnf install -y python2-dnf", "item": "docker", "msg": "Error: This command has to be run under the root user.", "rc": 1, "stderr": "Error: This command has to be run under the root user.\n", "stderr_lines": ["Error: This command has to be run under the root user."], "stdout": "", "stdout_lines": []} failed: [localhost] (item=docker-common) => {"changed": false, "cmd": "dnf install -y python2-dnf", "item": "docker-common", "msg": "Error: This command has to be run under the root user.", "rc": 1, "stderr": "Error: This command has to be run under the root user.\n", "stderr_lines": ["Error: This command has to be run under the root user."], "stdout": "", "stdout_lines": []} failed: [localhost] (item=docker-engine) => {"changed": false, "cmd": "dnf install -y python2-dnf", "item": "docker-engine", "msg": "Error: This command has to be run under the root user.", "rc": 1, "stderr": "Error: This command has to be run under the root user.\n", "stderr_lines": ["Error: This command has to be run under the root user."], "stdout": "", "stdout_lines": []}

thatnerdjosh avatar Aug 31 '18 21:08 thatnerdjosh

@NerdsvilleCEO Hi, you can make whole playbook run as a sudo, but I am afraid that you can not do that for particular task which causes failure - I am using patched version of this repository where I use yum module instead of package, you can do same if you like, but it is not really nice ... better to get fix ;-) for dnf module ...

lukas-bednar avatar Sep 24 '18 08:09 lukas-bednar