ansible/ansible-modules-core

Selinux problem using file module with async

riglersc opened this issue · 1 comments

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • file
ANSIBLE VERSION
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/usr/share/ansible']
CONFIGURATION
OS / ENVIRONMENT

RHEL 6 managing RHEL 6

SUMMARY

Tasks using the "file" module fail when run with async (or using "-B" from the command line) when the remote system has selinux enabled. The requested operation completes, however the module reports a failed status.

STEPS TO REPRODUCE
  1. Enable selinux on the remote system
  2. Run a play or command against the remote system using the file module running with async
ansible $REMOTEHOST -m file -B 4 -a 'path=/tmp/junk state=directory'

EXPECTED RESULTS

Module should operate the same as it would if it weren't run with async (not fail)

ACTUAL RESULTS

Module reported an error although the directory on the remote system was created:

Using /etc/ansible/ansible.cfg as config file
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.6/site-packages/ansible/plugins/callback/__init__.pyc
<REMOTEHOST> ESTABLISH SSH CONNECTION FOR USER: None
<REMOTEHOST> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r REMOTEHOST '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181 `" && echo ansible-tmp-1481212453.75-34156038918181="` echo $HOME/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181 `" ) && sleep 0'"'"''
<REMOTEHOST> PUT /tmp/tmpV2yyLb TO /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/file.py
<REMOTEHOST> SSH: EXEC sftp -b - -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[REMOTEHOST]'
<REMOTEHOST> PUT /tmp/tmpU1TDBQ TO /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/async_wrapper.py
<REMOTEHOST> SSH: EXEC sftp -b - -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[REMOTEHOST]'
<REMOTEHOST> ESTABLISH SSH CONNECTION FOR USER: None
<REMOTEHOST> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r REMOTEHOST '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/ /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/file.py /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/async_wrapper.py && sleep 0'"'"''
<REMOTEHOST> ESTABLISH SSH CONNECTION FOR USER: None
<REMOTEHOST> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt REMOTEHOST '/bin/sh -c '"'"' /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/async_wrapper.py 617769614832 4 /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/file.py _ && sleep 0'"'"''
<REMOTEHOST> ESTABLISH SSH CONNECTION FOR USER: None
<REMOTEHOST> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r REMOTEHOST '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1481212453.75-34156038918181/ > /dev/null 2>&1 && sleep 0'"'"''
Using module file /usr/lib/python2.6/site-packages/ansible/modules/core/utilities/logic/async_status.py
<REMOTEHOST> ESTABLISH SSH CONNECTION FOR USER: None
<REMOTEHOST> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=900s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r REMOTEHOST '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''
REMOTEHOST | FAILED! => {
    "ansible_job_id": "617769614832.12942", 
    "changed": false, 
    "failed": true, 
    "finished": 1, 
    "gid": 0, 
    "group": "root", 
    "invocation": {
        "module_args": {
            "backup": null, 
            "content": null, 
            "delimiter": null, 
            "diff_peek": null, 
            "directory_mode": null, 
            "follow": false, 
            "force": false, 
            "group": null, 
            "mode": null, 
            "original_basename": null, 
            "owner": null, 
            "path": "/tmp/junk", 
            "recurse": false, 
            "regexp": null, 
            "remote_src": null, 
            "selevel": null, 
            "serole": null, 
            "setype": null, 
            "seuser": null, 
            "src": null, 
            "state": "directory", 
            "unsafe_writes": null, 
            "validate": null
        }, 
        "module_name": "async_status"
    }, 
    "mode": "0755", 
    "msg": "There was an issue creating /tmp/junk as requested: 'AnsibleModule' object has no attribute '_selinux_special_fs'", 
    "owner": "root", 
    "path": "/tmp/junk", 
    "secontext": "unconfined_u:object_r:user_tmp_t:s0", 
    "size": 4096, 
    "state": "directory", 
    "uid": 0
}

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide.