Open webframp opened 7 years ago
I've just worked on this, but failed miserably. The problem is that lazy is not really intended to be used in a recipe. And you can only use it for variables or attributes it seems. For environment variables like here, it doesn't seem to work: I get
---- Begin output of composer config --global secure-http false ----
STDOUT:
STDERR: /opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:174:in `[]=': no implicit conversion of Chef::DelayedEvaluator into String (TypeError)
from /opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:174:in `block in set_environment'
from /opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:173:in `each'
from /opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:173:in `set_environment'
ruby_block, lambda have been tried too, to no avail. I think the only way to do this properly is to rewrite some of the recipe as a resource, but that is too much work for me ATM. Feel free to open up a PR for this though :)
BTW, i've committed my work on a separate branch on my fork of this cookbook, and added the basis for tests for this as well, feel free to work from there.
Hi there! Thanks for this cookbook.
I ran into a fun issue due to the delightful multi-phase execution model of chef figured I'd report it. I did find a workaround, but it's just slightly ugly.
The root issue is this spot in the global_configs recipe which is troublesome with a custom user: https://github.com/djoos-cookbooks/composer/blob/master/recipes/global_configs.rb#L12
When
node['composer']['global_configs']
contains a user that does not yet exist, but will be created during the chef recipe, thencomposer::global_configs
will fail with something like this beautiful message:The workaround is to make your user resource (wherever it is) run during the compile phase and it looks like this:
With that little method tagged onto the end of the resource it worked as intended I think. So it may be useful to do one of:
global_configs
in some way to use a lazy eval style so it only runs during the converge phaseHope this info is helpful in some way.