From 697980d7cc053753fb4e07321de3c5096238d640 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 3 Feb 2016 13:07:30 -0800 Subject: [PATCH] Add example of using non-posix shellisms to raw and shell Fixes #14262 --- lib/ansible/modules/commands/raw.py | 14 +++++++++++++- lib/ansible/modules/commands/shell.py | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/commands/raw.py b/lib/ansible/modules/commands/raw.py index 5ce66016b53..f9b83ecd0de 100644 --- a/lib/ansible/modules/commands/raw.py +++ b/lib/ansible/modules/commands/raw.py @@ -45,7 +45,10 @@ description: - This module does not require python on the remote system, much like the M(script) module. notes: - - If you want to execute a command securely and predictably, it may be + - "If using raw from a playbook, you may need to disable fact gathering + using C(gather_facts: no) if you're using C(raw) to bootstrap python + onto the machine." + - 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 playbooks will follow the trend of using M(command) unless M(shell) is explicitly required. When running ad-hoc commands, use your best @@ -58,4 +61,13 @@ author: EXAMPLES = ''' # Bootstrap a legacy python 2.4 host - raw: yum -y install python-simplejson + +# Bootstrap a host without python2 installed +- raw: dnf install -y python2 python2-dnf libselinux-python + +# Run a command that uses non-posix shell-isms (in this example /bin/sh +# doesn't handle redirection and wildcards together but bash does) +- raw: cat < /tmp/*txt + args: + executable: /bin/bash ''' diff --git a/lib/ansible/modules/commands/shell.py b/lib/ansible/modules/commands/shell.py index 23d4962e55f..840296cc182 100644 --- a/lib/ansible/modules/commands/shell.py +++ b/lib/ansible/modules/commands/shell.py @@ -92,4 +92,10 @@ EXAMPLES = ''' args: chdir: somedir/ creates: somelog.txt + +# Run a command that uses non-posix shell-isms (in this example /bin/sh +# doesn't handle redirection and wildcards together but bash does) +- shell: cat < /tmp/*txt + args: + executable: /bin/bash '''