chef / chef-apply

The ad-hoc execution tool for the Chef ecosystem.
https://www.chef.sh/
Apache License 2.0
14 stars 14 forks source link

`bash: - : invalid option` #40

Closed cheeseplus closed 5 years ago

cheeseplus commented 6 years ago

Description

EDIT: moving on behalf of @rbngzlv https://github.com/chef/chef-workstation/issues/230

When I run chef-run to test it, it outputs the following error:

$ chef-run -i ~/.ssh/my_key root@15x.xx.xx.xxx package ntp action=install
[✔] Generated local policyfile
[✔] [15x.xx.xx.xxx] Connected.
[✔] [15x.xx.xx.xxx] Chef client version 14.3.37 already installed on target.
[✖] [15x.xx.xx.xxx] The command 'bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); chmod 777 $d; echo $d'' exited with return code '2' on '15x.xx.xx.xxx'.

CHEFRMT001

The command 'bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); chmod 777 $d; echo $d'' exited with return code '2' on '15x.xx.xx.xxx'.

The following error was reported:

  bash: - : invalid option
Usage:  bash [GNU long option] [option] ...
    bash [GNU long option] [option] script-file ...
GNU long options:
    --debug
    --debugger
    --dump-po-strings
    --dump-strings
    --help
    --init-file
    --login
    --noediting
    --noprofile
    --norc
    --posix
    --rcfile
    --restricted
    --verbose
    --version
Shell options:
    -ilrsD or -c command or -O shopt_option     (invocation only)
    -abefhkmnptuvxBCHP or -o option

If you are not able to resolve this issue, please contact Chef support
at beta@chef.io

But the command doesn't throw an error if is executed manually on the target machine:

# bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); chmod 777 $d; echo $d'
/tmp/chef_hCy7nW

Chef Workstation Version

$ chef -v
Chef Development Kit Version: 3.1.0
chef-client version: 14.2.0
delivery version: master (6862f27aba89109a9630f0b6c6798efec56b4efe)
berks version: 7.0.4
kitchen version: 1.22.0
inspec version: 2.1.72

$ chef-run --version
chef-run: 0.1.0

Platform Version

Chef Workstation is running on OSX El Capitan 10.11.6 and the target machine is an Ubuntu 14.04.5 LTS

I'm not sure if this the better place to report this, so if I have to do it somewhere else, tell me please.

cheeseplus commented 6 years ago

Want to acknowledge that we've seen this one pop-up on our mailing list as well but so far nothing that we've been able to reproduce. As part of a broader refactoring I think we might inadvertently solve this moving some of our one-liner commands into scripts that the code consumes.

pwoestelandt commented 6 years ago

I have the same error when I try to run

chef-run XX.XX.XX.XX  package ntp action=install

or

chef-run XX.XX.XX.XX  my_receipe

The target host is a Ubuntu 18.04 x64 Digital Ocean droplet

[✔] Packaging cookbook... done!
[✔] Generating local policyfile... exporting... done!
[✖] Applying my_receipe::default from /Users/xxxxxxxxxxxxx to target.─ [✖] [xx.xx.xx.xx] The command 'bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX);chmod 777 $d; echo $d'' exited with return code '2' on 'xx.xx.xx.xx'.
CHEFRMT001

The command 'bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); chmod 777 $d; echo $d''exited with return code '2' on 'xx.xx.xx.xx'.

The following error was reported:

  bash: - : invalid option
Usage:  bash [GNU long option] [option] ...
        bash [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --rcfile
        --restricted
        --verbose
        --version
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option

If you are not able to resolve this issue, please contact Chef support
at beta@chef.io

I'm using chef-run: 0.1.21 under macOS Mojave

jsirianni commented 6 years ago

I also have the same error. chef-run: 0.1.21 macos high sierra

jsirianni commented 6 years ago

I rolled back to version 0.1.18, and it seems to have the same issue.

This is the output. I have redacted company information

chef-run -i /path/to/ssh/key some_ip_address /somepath/git/cookbook
[✔] Generating local policyfile... exporting... done!
[✖] Applying cookbook::default from /somepath/git/cookbook to target.
└── [✖] [target ip address] The command 'bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); chmod 777 $d; echo $d'' exited with return code '2' on 'someip'.
CHEFRMT001

The command 'bash -c 'd=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); chmod 777 $d; echo $d'' exited with return code '2' on 'someip'.

The following error was reported:

  bash: - : invalid option
Usage:  bash [GNU long option] [option] ...
    bash [GNU long option] [option] script-file ...
GNU long options:
    --debug
    --debugger
    --dump-po-strings
    --dump-strings
    --help
    --init-file
    --login
    --noediting
    --noprofile
    --norc
    --posix
    --protected
    --rcfile
    --rpm-requires
    --restricted
    --verbose
    --version
Shell options:
    -irsD or -c command or -O shopt_option      (invocation only)
    -abefhkmnptuvxBCHP or -o option

If you are not able to resolve this issue, please contact Chef support
at beta@chef.io
lingmann commented 6 years ago

I had the same issue with chef-run 0.1.21 against an Ubuntu 18.04 host (Digital Ocean). It seems to be related to sudo execution, since I was able to work around it with the following:

chef-run --user root --no-sudo cookbook
cheeseplus commented 6 years ago

Thanks for the update @lingmann, that just might help us track this one down.

rbngzlv commented 5 years ago

Hi, I'm the one who initially opened the problem and I have just tested with the latest chef-workstation version and it is solved for me.

From

Mac OS X 10.14.2 (macOS Mojave)

$ chef -v
Chef Workstation: 0.2.43
  chef-run: 0.2.4
  chef-client: 14.8.12
  delivery-cli: master (5fb4908da53579c9dcf4894d4acf94d2d9ee6475)
  berks: 7.0.7
  test-kitchen: 1.24.0
  inspec: 3.2.6

Target

Digital Ocean droplet
Ubuntu 18.04 x64

Trace

$ chef-run -i ~/.ssh/github root@167.xxx.xxx.xxx package ntp action=install
[✔] Packaging cookbook... done!
[✔] Generating local policyfile... exporting... done!
[✔] Applying package[ntp] from resource to target.
└── [✔] [167.xxx.xxx.xxx] Successfully converged package[ntp].

So I guess that we can close this, or are you waiting on something else?