mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Revert "Add 'stdin' argument to command/shell modules"
This reverts commit 393909d0cc
.
Reverte so that we can maintain authorship
This commit is contained in:
parent
4729981eba
commit
872255b791
3 changed files with 1 additions and 44 deletions
|
@ -49,12 +49,6 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: 'yes'
|
default: 'yes'
|
||||||
version_added: "1.8"
|
version_added: "1.8"
|
||||||
stdin:
|
|
||||||
version_added: "2.4"
|
|
||||||
description:
|
|
||||||
- Set the stdin of the command directly to the specified value.
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
notes:
|
notes:
|
||||||
- If you want to run a command through the shell (say you are using C(<), C(>), C(|), etc), you actually want the M(shell) module instead.
|
- If you want to run a command through the shell (say you are using C(<), C(>), C(|), etc), you actually want the M(shell) module instead.
|
||||||
The C(command) module is much more secure as it's not affected by the user's environment.
|
The C(command) module is much more secure as it's not affected by the user's environment.
|
||||||
|
@ -127,7 +121,6 @@ def main():
|
||||||
creates=dict(type='path'),
|
creates=dict(type='path'),
|
||||||
removes=dict(type='path'),
|
removes=dict(type='path'),
|
||||||
warn=dict(type='bool', default=True),
|
warn=dict(type='bool', default=True),
|
||||||
stdin=dict(required=False),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -138,7 +131,6 @@ def main():
|
||||||
creates = module.params['creates']
|
creates = module.params['creates']
|
||||||
removes = module.params['removes']
|
removes = module.params['removes']
|
||||||
warn = module.params['warn']
|
warn = module.params['warn']
|
||||||
stdin = module.params['stdin']
|
|
||||||
|
|
||||||
if not shell and executable:
|
if not shell and executable:
|
||||||
module.warn("As of Ansible 2.4, the parameter 'executable' is no longer supported with the 'command' module. Not using '%s'." % executable)
|
module.warn("As of Ansible 2.4, the parameter 'executable' is no longer supported with the 'command' module. Not using '%s'." % executable)
|
||||||
|
@ -182,7 +174,7 @@ def main():
|
||||||
args = shlex.split(args)
|
args = shlex.split(args)
|
||||||
startd = datetime.datetime.now()
|
startd = datetime.datetime.now()
|
||||||
|
|
||||||
rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell, encoding=None, data=stdin)
|
rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell, encoding=None)
|
||||||
|
|
||||||
endd = datetime.datetime.now()
|
endd = datetime.datetime.now()
|
||||||
delta = endd - startd
|
delta = endd - startd
|
||||||
|
|
|
@ -60,12 +60,6 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: True
|
default: True
|
||||||
version_added: "1.8"
|
version_added: "1.8"
|
||||||
stdin:
|
|
||||||
version_added: "2.4"
|
|
||||||
description:
|
|
||||||
- Set the stdin of the command directly to the specified value.
|
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
notes:
|
notes:
|
||||||
- If you want to execute a command securely and predictably, it may be
|
- If you want to execute a command securely and predictably, it may be
|
||||||
better to use the M(command) module instead. Best practices when writing
|
better to use the M(command) module instead. Best practices when writing
|
||||||
|
|
|
@ -121,35 +121,6 @@
|
||||||
that:
|
that:
|
||||||
- "command_result4.changed != True"
|
- "command_result4.changed != True"
|
||||||
|
|
||||||
|
|
||||||
- name: pass stdin to cat via command
|
|
||||||
command: "cat"
|
|
||||||
args:
|
|
||||||
stdin: 'foobar'
|
|
||||||
register: command_result5
|
|
||||||
|
|
||||||
- name: assert that stdin is passed
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "command_result5.stdout == 'foobar'"
|
|
||||||
|
|
||||||
- name: send to stdin literal multiline block
|
|
||||||
command: "{{ sha1sum.stdout }}"
|
|
||||||
args:
|
|
||||||
stdin: |-
|
|
||||||
this is the first line
|
|
||||||
this is the second line
|
|
||||||
this line is after an empty line
|
|
||||||
this line is the last line
|
|
||||||
register: command_result6
|
|
||||||
|
|
||||||
- debug: var=command_result6
|
|
||||||
|
|
||||||
- name: assert the multiline input was passed correctly
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- "command_result6.stdout == 'b1a4df888d8d261876dc33ded211ba3ebe803010 -'"
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## shell
|
## shell
|
||||||
##
|
##
|
||||||
|
|
Loading…
Reference in a new issue