diff --git a/docsite/rst/intro_inventory.rst b/docsite/rst/intro_inventory.rst index efa6653f52b..789f4ac438a 100644 --- a/docsite/rst/intro_inventory.rst +++ b/docsite/rst/intro_inventory.rst @@ -200,6 +200,8 @@ mentioned:: Connection type of the host. Candidates are local, ssh or paramiko. The default is paramiko before Ansible 1.2, and 'smart' afterwards which detects whether usage of 'ssh' would be feasible based on whether ControlPersist is supported. ansible_ssh_private_key_file Private key file used by ssh. Useful if using multiple keys and you don't want to use SSH agent. + ansible_shell_type + The shell type of the target system. By default commands are formatted using 'sh'-style syntax by default. Setting this to 'csh' or 'fish' will cause commands executed on target systems to follow those shell's syntax instead. ansible_python_interpreter The target host python path. This is useful for systems with more than one Python or not located at "/usr/bin/python" such as \*BSD, or where /usr/bin/python diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 7b943003f2e..cd09993e587 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -287,6 +287,10 @@ class Runner(object): def _compute_environment_string(self, inject=None): ''' what environment variables to use when running the command? ''' + shell_type = inject.get('ansible_shell_type') + if not shell_type: + shell_type = os.path.basename(C.DEFAULT_EXECUTABLE) + default_environment = dict( LANG = C.DEFAULT_MODULE_LANG, LC_CTYPE = C.DEFAULT_MODULE_LANG, @@ -301,7 +305,10 @@ class Runner(object): result = "" for (k,v) in default_environment.iteritems(): - result = "%s=%s %s" % (k, pipes.quote(unicode(v)), result) + if shell_type in ('csh', 'fish'): + result = "env %s=%s %s" % (k, pipes.quote(unicode(v)), result) + else: + result = "%s=%s %s" % (k, pipes.quote(unicode(v)), result) return result # *****************************************************