Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-6524

The shell used with exec resource provider=shell should be configurable

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Accepted
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Types and Providers
    • Labels:
    • Template:
    • Epic Link:
    • Team:
      Coremunity
    • CS Priority:
      Trivial
    • CS Frequency:
      1 - 1-5% of Customers
    • CS Severity:
      1 - Superficial
    • CS Business Value:
      1 - ?
    • CS Impact:
      Not a lot of requests for this but should be trivial to implement.

      Description

      Customer found that when creating an exec resource, they are unable to run commands with bash process substitions. For example:

      class exectest {
        exec{'run if different':
          provider => 'shell',
          command => '/bin/echo "they are different" > test.log',
          onlyif => "/usr/bin/test `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c` -gt 0",
        }
      }
      

      will fail to parse:

      # puppet apply -td -e "include exectest"
      ...
      Debug: Exec[run if different](provider=shell): Executing check '["/bin/sh", "-c", "/usr/bin/test `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c` -gt 0"]'
      Debug: Executing '/bin/sh -c /usr/bin/test `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c` -gt 0'
      Debug: /Stage[main]/Exectest/Exec[run if different]/onlyif: /bin/sh: command substitution: line 0: syntax error near unexpected token `('
      Debug: /Stage[main]/Exectest/Exec[run if different]/onlyif: /bin/sh: command substitution: line 0: `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c'
      Debug: /Stage[main]/Exectest/Exec[run if different]/onlyif: /usr/bin/test: missing argument after `0'
      ...
      

      This is due to the fact that https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/exec/shell.rb#L19 forces the /bin/sh shell, which cannot parse the bash process substitutions. This is true even on EL systems where /bin/sh is linked to /bin/bash.

      Customer would like to see the shell used by provider=shell be configurable instead of hardcoded to avoid this issue.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              adam.bottchen Adam Bottchen
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:

                  Zendesk Support