soloist icon indicating copy to clipboard operation
soloist copied to clipboard

Error with node_attributes in env_variable_switches

Open JohnBernas opened this issue 11 years ago • 2 comments

When I try to use node_attributes in env_variable_switches, like this:

recipes:
- sprout-git::git_projects

node_attributes:
  git_projects:
    -
      - repo1
      - https://github.com/me/repo1.git

env_variable_switches:
  PROJECT:
    p2:
      node_attributes:
        git_projects:
          -
            - repo2
            - https://github.com/me/repo2.git

I get the following error:

/Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/royal_crown.rb:75:in `+': no implicit conversion of nil into Array (TypeError)
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/royal_crown.rb:75:in `merge_array_property'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/royal_crown.rb:30:in `merge_cookbook_paths'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/royal_crown.rb:19:in `merge!'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:81:in `block (3 levels) in compiled'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:80:in `each'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:80:in `block (2 levels) in compiled'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:79:in `each'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:79:in `block in compiled'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:77:in `tap'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:77:in `compiled'
    from /Users/joao/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/soloist-1.0.3/lib/soloist/config.rb:46:in `cookbook_paths'

I've noticed an old issue that mentions this error, but it has been closed for half a year now...

JohnBernas avatar Apr 29 '14 20:04 JohnBernas

I think there are actually 2 different problems here.

The first (seen in the error above) happens when your switch is incomplete (either missing recipes, cookbook_paths or node_attributes), I created a PR for that (#37)

Second is when the switch shares a node attribute key (like git_projects in the example above). When switch is active, the switch values overwrite the default ones, instead of merging... Is that the intended behaviour is it a bug as well? I guess it comes down to what we want to accomplish... Do we want the switch node attributes to override the default ones or compound on them?

JohnBernas avatar May 02 '14 10:05 JohnBernas

not sure, where is the problem here. I am testing to use this, to installed oracle jdk7 on my test laptop. i have installed the gem. Then created the 2 files as per the doc here.. Then i ran the 'soloist'. I got the below error.

okram@lapz:~/workspace/testapp1$ LOG_LEVEL=debug soloist Installing java (1.32.0) /home/okram/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:370:in parse': (<unknown>): could not find expected ':' while scanning a simple key at line 5 column 1 (Psych::SyntaxError) from /home/okram/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:370:inparse_stream' from /home/okram/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:318:in parse' from /home/okram/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/psych.rb:245:inload' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/soloist-1.0.3/lib/soloist/royal_crown.rb:61:in read_config' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/soloist-1.0.3/lib/soloist/royal_crown.rb:56:infrom_file' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/soloist-1.0.3/lib/soloist/config.rb:10:in from_file' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/soloist-1.0.3/lib/soloist/cli.rb:46:insoloist_config' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/soloist-1.0.3/lib/soloist/cli.rb:17:in chef' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/thor-0.19.1/lib/thor/command.rb:27:inrun' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/thor-0.19.1/lib/thor.rb:359:indispatch' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/thor-0.19.1/lib/thor/base.rb:440:in start' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/gems/soloist-1.0.3/bin/soloist:4:in<top (required)>' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/bin/soloist:23:in load' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/bin/soloist:23:in

' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/bin/ruby_executable_hooks:15:in eval' from /home/okram/.rvm/gems/ruby-2.1.1@testapp1/bin/ruby_executable_hooks:15:in
'

This is the dir structure... that i have

okram@lapz:~/workspace/testapp1$ ll total 36 drwxrwxr-x 4 okram okram 4096 Apr 19 23:11 ./ drwxrwxr-x 4 okram okram 4096 Apr 19 20:44 ../ -rw-rw-r-- 1 okram okram 124 Apr 19 22:49 Cheffile -rw-rw-r-- 1 okram okram 177 Apr 19 23:00 Cheffile.lock drwxrwxr-x 3 okram okram 4096 Apr 19 23:11 cookbooks/ -rw-rw-r-- 1 okram okram 9 Apr 19 20:38 .ruby-gemset -rw-rw-r-- 1 okram okram 11 Apr 19 20:21 .ruby-version -rw-rw-r-- 1 okram okram 258 Apr 19 22:53 soloistrc drwxrwxr-x 3 okram okram 4096 Apr 19 22:59 tmp/

This is the Cheffile: site "http://community.opscode.com/api/v1" cookbook "java", :git => "https://github.com/agileorbit-cookbooks/java"

Then the soloistrc file

recipes: -java::default node_attributes: name "java" description "Install Oracle Java" default_attributes( "java" => { "install_flavor" => "oracle", "jdk_version" => "7", "oracle" => { "accept_oracle_download_terms" => true } } ) ~
~

okram999 avatar Apr 20 '15 06:04 okram999