OS Centos 6
INFO global: Vagrant version: 1.7.2
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: - vagrant-triggers = 0.5.0

So I have a problem with running a command in vagrant-triggers.

Essentially I'm trying to run this /bin/sed command, which works fine on 
the command line:
/bin/sed -i -r 's/"groups": [$/"groups": [\n "TEST_admin",/' 
/user/chef-repo/data_bags/users/vagrant.json

For testing here’s the pertinent portion of vagrant.json that /bin/sed is 
working on the /bin/sed command should add a line between groups and 
lastentry:

  "groups": [
    "lastentry"
  ],

Here’s the line in my Vagrantfile that executes the command:

   #Before we do anything with this box:
   config.trigger.before :up do
    admimquote = '"TEST_admin"'
    groupquote = '"groups"'
    runthis = "/bin//bin/sed -i -r 's/" + groupquote + ": \[$/" + 
groupquote + ": \["+'\n' + "    " + admimquote + ",/' 
/user/chef-repo/data_bags/users/vagrant.json"

    run runthis
   end


The error I get is:


INFO warden: Calling OUT action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x000000024d1ed8>
ERROR vagrant: Vagrant experienced an error! Details:
ERROR vagrant: #<VagrantPlugins::Triggers::Errors::CommandFailed: The 
command "/bin/sed -i -r 's/"groups": [$/"groups": [\n    "TEST_admin",/' 
/user/chef-repo/data_bags/users/vagrant.json" returned a failed exit code. 
The
error output is shown below:

/bin/sed: -e expression #1, char 47: unterminated `s' command
>
ERROR vagrant: The command "/bin/sed -i -r 's/"groups": [$/"groups": [\n   
 "TEST_admin",/' /user/chef-repo/data_bags/users/vagrant.json" returned a 
failed exit code. The
error output is shown below:

/bin/sed: -e expression #1, char 47: unterminated `s' command

ERROR vagrant: 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/dsl.rb:101:in
 
`process_result'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/dsl.rb:54:in
 
`run'
/user/vagrant/Vagrantfile:38:in `block (2 levels) in <top (required)>'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:55:in
 
`instance_eval'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:55:in
 
`block in fire_triggers'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:51:in
 
`each'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:51:in
 
`fire_triggers'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:16:in
 
`call'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in
 
`call'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:17:in
 
`call'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in
 
`call'
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:17:in
 
`call'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in
 
`call'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in
 
`call'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in
 
`block in run'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in 
`busy'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in
 
`run'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:214:in 
`action_raw'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:191:in 
`block in action'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:516:in 
`lock'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in 
`call'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in 
`action'
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/batch_action.rb:82:in 
`block (2 levels) in run'
 INFO interface: error: The command "/bin/sed -i -r 's/"groups": 
[$/"groups": [\n    "TEST_admin",/' 
/user/chef-repo/data_bags/users/vagrant.json" returned a failed exit code. 
The
error output is shown below:

/bin/sed: -e expression #1, char 47: unterminated `s' command

The command "/bin/sed -i -r 's/"groups": [$/"groups": [\n   
 "TEST_admin",/' /user/chef-repo/data_bags/users/vagrant.json" returned a 
failed exit code. The
error output is shown below:

/bin/sed: -e expression #1, char 47: unterminated `s' command

 INFO interface: Machine: error-exit 
["VagrantPlugins::Triggers::Errors::CommandFailed", "The command \"/bin/sed 
-i -r 's/\"groups\": [$/\"groups\": [\\n    \"TEST_admin\",/' 
/user/chef-repo/data_bags/users/vagrant.json\" returned a failed exit code. 
The\nerror output is shown below:\n\n/bin/sed: -e expression #1, char 47: 
unterminated `s' command\n"]




Another thing I tried was moving the command to a bash shell script 
(prebootstrap.sh).


INFO interface: info: Running triggers before up...
 INFO interface: info: ==> default: Running triggers before up...
==> default: Running triggers before up...
 INFO interface: info: Executing command "prebootstrap.sh"...
 INFO interface: info: ==> default: Executing command "prebootstrap.sh"...
==> default: Executing command "prebootstrap.sh"...
 INFO subprocess: Starting process: ["prebootstrap.sh"]
ERROR warden: Error occurred: No such file or directory - prebootstrap.sh
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO warden: Beginning recovery process...
 INFO warden: Recovery complete.
 INFO environment: Relea/bin/sed process lock: 
machine-action-92cb79e7b5444cdf0349bca3ac36999e
 INFO environment: Running hook: environment_unload
 INFO runner: Preparing hooks for middleware sequence...
 INFO runner: 3 hooks defined.
 INFO runner: Running action: #<Vagrant::Action::Builder:0x00000002261ec8>
 INFO warden: Calling IN action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x00000002268db8>
 INFO warden: Calling IN action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x0000000228d078>
 INFO warden: Calling IN action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x000000022b5eb0>
 INFO warden: Calling OUT action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x000000022b5eb0>
 INFO warden: Calling OUT action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x0000000228d078>
 INFO warden: Calling OUT action: 
#<VagrantPlugins::Triggers::Action::Trigger:0x00000002268db8>
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:109:in
 
`rescue in execute': No such file or directory - prebootstrap.sh 
(Vagrant::Util::Subprocess::LaunchError)
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:102:in
 
`execute'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/subprocess.rb:22:in
 
`execute'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/dsl.rb:44:in
 
`block in run'
    from 
/opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler.rb:236:in `block 
in with_clean_env'
    from 
/opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler.rb:223:in 
`with_original_env'
    from 
/opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler.rb:229:in 
`with_clean_env'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/dsl.rb:41:in
 
`run'
    from /user/vagrant/Vagrantfile:33:in `block (2 levels) in <top 
(required)>'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:55:in
 
`instance_eval'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:55:in
 
`block in fire_triggers'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:51:in
 
`each'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:51:in
 
`fire_triggers'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:16:in
 
`call'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in
 
`call'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:17:in
 
`call'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in
 
`call'
    from 
/user/.vagrant.d/gems/gems/vagrant-triggers-0.5.0/lib/vagrant-triggers/action/trigger.rb:17:in
 
`call'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in
 
`call'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/builder.rb:116:in
 
`call'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in
 
`block in run'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/util/busy.rb:19:in 
`busy'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:66:in
 
`run'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:214:in 
`action_raw'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:191:in 
`block in action'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:516:in 
`lock'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in 
`call'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in 
`action'
    from 
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/batch_action.rb:82:in 
`block (2 levels) in run'

So is this a vagrant-triggers issue or a 
/vagrant-1.7.2/lib/vagrant/util/subprocess.rb issue? or an environment 
variable issue? I don't think its the latter, as I've give the full path to 
/bin/sed and vagrant.json in the bash script. The error: No such file or 
directory is vague. If I run the prebootstrap.sh script it works fine. If I 
make a short test ruby scrip and exec('./prebootstrap.sh') it it works fine.

Does anyone have any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to