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
module is missing interpreter line - running python module #40561
Comments
I cannot reproduce this. Running your module I actually got the following:
I fixed some things up and converted a few things to the way we expect modules to work: #!/usr/bin/python
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
cmd=dict(required=True)
)
)
cmd = module.params.get('cmd')
rc, stdout, stderr = module.run_command(cmd)
if stdout:
status = stdout.strip()
else:
status = 'could not run command: %s' % cmd
module.exit_json(changed=True, msg=str(status))
if __name__ == '__main__':
main() This produces:
needs_info |
Hi Sivel, I used above python module on Linux 3.10.0-693.11.6.el7.x86_64. Still same error. |
I ran into the same error with a different module ( This behaviour isn't reproducible across instances, but is 100% reproducible in the instance where it did happen, which leads me to believe it may have something to do with how Ansible enumerates the |
I hit this too and seems to happen randomly on different servers. I had two python modules in the I shuffled some import lines on top of the module and now I'm not able to reproduce this. No idea if that shuffling had anything to do with it thou. |
I had this too.
Turns out it was caused by a playbook I'd created with the same name as the cron module: |
with -vvv you should see message |
@ajayreddy28390: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information. Here are the items we could not find in your description:
Please set the description of this issue with an appropriate template from: |
Closing this issue due to inactivity. Please feel free to open a new issue if the problem persists. |
SUMMARY
Running python script using Ansible boiler_plate, I get this error "module (run_cmd) is missing interpreter line"
ISSUE TYPE
COMPONENT NAME
lib/ansible/plugins/action/__init__.py
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
I expect to get date output
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: