ansible / ansible-modules-core

Ansible modules - these modules ship with ansible
1.3k stars 1.95k forks source link

Command should accept argv rather than trying to split arguments itself. #5857

Closed bitdivine closed 7 years ago

bitdivine commented 7 years ago
ISSUE TYPE
COMPONENT NAME

command https://github.com/ansible/ansible-modules-core/blob/devel/commands/command.py

ANSIBLE VERSION
ansible 2.1.1.0
  config file = /home/max/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
OS / ENVIRONMENT

Debian 8

SUMMARY

Command tries to split a command string into arguments. Sometimes it fails. When it does so it can be extremely frustrating, trying to figure out how to escape a command only for it to be parsed correctly. If it can accept an array of arguments that would take the guesswork out, reduce pain, increase reliability and trust.

STEPS TO REPRODUCE

One option:

  command: ["this", "is", "an", "array", "of", "arguments", "{{ lookup('file', 'stuff') | string }}"]

In the code, make shlex.split(args) conditional on args being a string.

Another option:

  command: "/directory with spaces"
  argv: ["some", "stuff", "{{ lookup('file', 'stuff') | string }}"]
EXPECTED RESULTS

I would like command to execute without trying to split the array of arguments.

ACTUAL RESULTS

N/A

bitdivine commented 7 years ago

Would a pull request help?

ansibot commented 7 years ago

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.