New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add local_mode to solo.rb #353

Open
runningman84 opened this Issue Mar 4, 2014 · 12 comments

Comments

Projects
None yet
4 participants
@runningman84

runningman84 commented Mar 4, 2014

Please add local_mode to the generated solo.rb in case local_mode is present in the knife.rb file or the -z parameter is used like this:

knife solo cook root@aladin -z

Local mode should be used only in case chef 11.x is found, otherwise print a warning and ignore it. This would allow us to use the same repos and cookbooks using chef 10.x and 11.x.

base = File.expand_path('..', __FILE__)

nodes_path                File.join(base, 'nodes')
role_path                 File.join(base, 'roles')
data_bag_path             File.join(base, 'data_bags')
encrypted_data_bag_secret File.join(base, 'data_bag_key')
environment_path          File.join(base, 'environments')
environment               "_default"

cookbook_path []
cookbook_path << File.join(base, 'cookbooks-1') # /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/knife-solo-0.4.1/lib/knife-solo/resources/patch_cookbooks
cookbook_path << File.join(base, 'cookbooks-2') # /home/user/chefrepo/myrepo/cookbooks
cookbook_path << File.join(base, 'cookbooks-3') # /home/user/chefrepo/myrepo/site-cookbooks

local_mode true
@runningman84

This comment has been minimized.

runningman84 commented Mar 4, 2014

chef 10.x doesn't complain about local_mode in the solo.rb so this change doesn't break anything.

@matschaffer

This comment has been minimized.

Owner

matschaffer commented Mar 4, 2014

Oh wow, I hadn't read up on local mode yet. That looks really promising. I love that they did node write back support too.

Sounds like this could be a great direction for knife solo on newer chef client versions. To @tmatilai's point I don't want to totally stop support for older chef clients but I'm happy focusing on the latest for new feature development.

@tmatilai

This comment has been minimized.

Collaborator

tmatilai commented Mar 5, 2014

The idea is good but note that the local_mode configuration option (and --local-mode/-z CLI option) is only used by chef-client, not by chef-solo. So knife-solo could and should call chef-client -z instead of chef-solo in this case, but doesn't need to set the config option.

@runningman84

This comment has been minimized.

runningman84 commented Mar 5, 2014

Hi I have tested chef solo using the local mode in solo.rb and it works fine. In the long run chef solo will be pprobably removed or replaced by an alias of chef-client -z. But right now my solution works fine and doesn't break existing sudo rules which only allows calling chef-solo in my case.

@tmatilai

This comment has been minimized.

Collaborator

tmatilai commented Mar 5, 2014

Wow, if the config really triggers local-mode then it must be an unexpected feature as all the documentation only references the chef-client executable. And also the -z option exists only for it.

Sure it makes things easier, and -z could even be added to chef-solo command too.

I'll have to play with this tomorrow. =)

@runningman84

This comment has been minimized.

runningman84 commented Mar 12, 2014

Any news here?

@tmatilai

This comment has been minimized.

Collaborator

tmatilai commented Mar 12, 2014

Sorry, I've been too busy lately. But it's on my todo list...

@tmatilai

This comment has been minimized.

Collaborator

tmatilai commented Mar 29, 2014

I gave this a try some time ago and it really seems to work! So I would be happy to see a PR fir including the option to knife-solo. Equally good would be to add the -z option to chef-solo to make things clear. I still think this is just a great side effect that no-one realized. =)

@matschaffer matschaffer added this to the 0.5.0 milestone Jul 29, 2014

@runningman84

This comment has been minimized.

runningman84 commented May 6, 2015

any news here? The local_mode works for 12.x too.

@matschaffer

This comment has been minimized.

Owner

matschaffer commented May 6, 2015

Nothing much yet. I just thought I would try to pick up development a little bit again. I started with the easy tasks but I can take a look at this one next. I'll at least want to get the integration tests fully running before a big shift like this one.

@florian-asche

This comment has been minimized.

florian-asche commented May 5, 2018

Temp fix:

echo local_mode true >> ~/.chefdk/gem/ruby/%VERSION%/gems/knife-solo-0.6.0/lib/knife-solo/resources/solo.rb.erb
@matschaffer

This comment has been minimized.

Owner

matschaffer commented May 8, 2018

You might have to watch out for ruby roles/environments as mentioned on #385 (comment)

I haven't checked in a couple years what the latest is, but last time I used -z roles and environments had to be converted to json first which was the main hold up in merging that PR since it'd cause breakage for anyone using ruby definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment