Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use the command module consecutively. #2058

Closed
megoix opened this issue Feb 12, 2013 · 1 comment
Closed

Unable to use the command module consecutively. #2058

megoix opened this issue Feb 12, 2013 · 1 comment

Comments

@megoix
Copy link

megoix commented Feb 12, 2013

Ansible version: 1.0

Problem:

Using "action: command /usr/sbin/setenforce 0" in a playbook to disable SELinux only works once. Any consecutive runs after that will fail with the following message.

CentOS 6.3:
"failed: [el6_ansible_1] => {"changed": true, "cmd": ["/usr/sbin/setenforce", "0"], "delta": "0:00:00.001085", "end": "2013-02-12 10:36:39.363762", "rc": 1, "start": "2013-02-12 10:36:39.362677"}
stderr: /usr/sbin/setenforce: SELinux is disabled"

CentOS 5.9:
"failed: [el5_ansible_1] => {"changed": true, "cmd": ["/usr/sbin/setenforce", "0"], "delta": "0:00:00.000992", "end": "2013-02-12 10:36:39.294839", "rc": 1, "start": "2013-02-12 10:36:39.293847"}
stderr: /usr/sbin/setenforce: SELinux is disabled"

Expected behavior:

That it will behave like it does from the terminal, set SELinux to disabled every time it is run. Which it in a sense does, but from an ansible perspective it fails.

Workaround:

Install the python dependency for selinux and use the selinux module.

Test bed:

CentOS 5.9 and CentOS 6.3

@mpdehaan
Copy link
Contributor

Use ignore_errors: True in this case or adapt your command string to only run if the command is in the right state.

It's not a fault of ansible that the command returned a non-zero return code.

@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants