GithubHelp home page GithubHelp logo

Comments (17)

sawanoboly avatar sawanoboly commented on July 30, 2024

First, thank you for your interest to the knife-zero.
I give you due warning, I have never used the knife-solo and usually use the librarian-chef instead of the berkshelf.

Knife-Solo(Kitchen) to Knife-Zero

I think that it can be in the following procedure.

  • collect remote cookbooks to cookbooks/ and put your cookbooks to site-cookbooks/.
  • update knife.rb.
  • backup nodes/.
  • bootstrap nodes by knife-zero.
  • set run_list to nodes.
  • run chef-client by knife-zero.

collect remote cookbooks

If you have own cookbooks, please move to site-cookbooks/ their.

Next, run berks vendor to collect community-cookbooks.

$ berks vendor cookbooks

update knife.rb

You should set two settings to .chef/knife.rb.

cookbook_path [File.expand_path('../../cookbooks' , __FILE__), File.expand_path('../../site-cookbooks' , __FILE__)]
local_mode true

Run knife cookbook list to confirm list of cookbooks.

$ knife cookbook list

...your cookbooks will shown here

Once set local_mode to knife.rb, knife command retrieves policies from local directory.
For example, knife role list, knife environment list ,knife data_bag list.

(Optional)We can run chef-zero as server with current directory by knife serve.

$ knife serve

(on other terminal)$ knife cookbook list -s localhost:4000

...your cookbooks will shown here

The knife-zero uses this server when bootstrapping or converging as ephemeral chef-server.

bootstrap, set run_list, converge remote nodes.

Please see README

Back to Knife-Solo

I think that the knife-solo and the knife-zero doesn't conflict each other. It might work together on same directory(chef-repo, also known as kitchen).

If you want to cleanup, please see following.

  • stop using knife-zero.
  • restore nodes/.
  • clean up files which was created by knife-zero on node.
    • rm /etc/chef/*(might exclude solo.rb if exist.)
  • remove local_mode from knife.rb.

Regards,

from knife-zero.

allaire avatar allaire commented on July 30, 2024

Thank you very much for this detailed answer! Is there a way to use Berkshelf from their centralized directory (~/.berkshelf), a bit like this? https://github.com/matschaffer/knife-solo/blob/master/lib/knife-solo/berkshelf.rb

Thanks!

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

@allaire
hmm... we can set ~/.berkshelf/cookbooks to cookbook_path.
But it take many time to loading and all cookbooks has version number as suffix like below.

$ ./bin/knife cookbook list  ## (Case: '~/.berkshelf/cookbooks' is set to cookbook_path)
7-zip-1.0.2                                                       1.0.2
apache2-1.10.4                                                    1.10.4
apache2-1.3.2                                                     1.3.2
apache2-1.8.14                                                    1.8.14
apt-1.5.0                                                         1.5.0
apt-1.6.0                                                         1.6.0
apt-1.8.0                                                         1.8.0
apt-2.3.4                                                         2.3.4
apt-2.3.8                                                         2.3.8
apt-2.4.0                                                         2.4.0
apt-2.6.0                                                         2.6.0
apt-2.6.1                                                         2.6.1
...

I seem to better that cookbooks are collected under current directory by using berks subcommands such as vendor, install or upload.
If we want to manage all cookbooks (both of community and own) under Berksfile ,site-cookbooks do not have to use.

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

Can I close it?

from knife-zero.

yoshiwaan avatar yoshiwaan commented on July 30, 2024

Hi,
I have a question on the same topic. Using chef-solo the node and roles directory contain node and role information json files respectively.
When migrating to knife-zero is there a way to pick up the existing node file if there is one when bootstrapping instead of overwriting them? This is useful if you want to recreate a node in the same fashion and install the chef-client with knife-zero but use the existing config.

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

@yoshiwaan

hmm.. I have an idea about it. (I can't guarantee that this will work. πŸ˜… )

Probably, we can pass existing node.json when bootstrapping with knife zero.

Such as below,

knife zero bootstrap $remote_node -j "cat nodes/node.json"

All attributes which is provided by node.json will be set as normal attributes into nodes/remote_node.json after bootstrap. Maybe.

Please let me know if successful.

from knife-zero.

yoshiwaan avatar yoshiwaan commented on July 30, 2024

Hi @sawanoboly,

Unfortunately this doesn't work. For starters when using expansion of a file like this there are problems with the matching of escapes within json and the bash shell. So for example if there is any json with Windows style paths in json with escaped backslashes then you run into problems (e.g. \System32\etc or something). To get around this I could do a bit of sed work but it's a bit messy:

node=cat nodes/node.json | sed 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'
bundle exec knife zero bootstrap ec2-54-153-51-61.us-west-1.compute.amazonaws.com --sudo -j "$node"

But then the run list from the file still doesn't get pushed over to the new node. If I don't specify the --run-list option then no run list is sent even when reading in the file with a run_list attribute.

I think this will have to be a feature request (i.e. read in from file on bootstrap).

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

@yoshiwaan Thanks for your report!

I don't like create own expansion to The knife-zero from The Chef.

Please request to Chef read from file function.

from knife-zero.

patcon avatar patcon commented on July 30, 2024

That's unfortunate @sawanoboly. A response like that will scare prospective users away, as it makes it seem like you aren't interested in resolving problems for real production use-cases :(

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

@patcon
see chef/chef#3459

from knife-zero.

patcon avatar patcon commented on July 30, 2024

❀️

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

waiting. chef/chef#3900

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

merged. chef/chef#4105

from knife-zero.

Paul424 avatar Paul424 commented on July 30, 2024

Justed wanted to comment on some issue's i encountered while moving from chef-solo to chef-zero.

  • roles can only be in json format; so for instance you cannot open encrypted databags from the role to assign attributes....
  • Integration with Berkshelf works for me as i have set BERKSHELF_PATH to install cookbooks into the chef repo (./cookbooks).
  • One issue i encountered was ContentLengthMismatch exceptions; these only disappeared after i upgraded chef/zero from rvm.
  • Another thing is that automatic_attribute_whitelist does not always seem to work as the fqdn is sometimes overwritten with the private dns (aws) so the next run won't connect.

One very good thing: Search is working!!!!! THANK YOU SO MUCH!!!

from knife-zero.

allaire avatar allaire commented on July 30, 2024

@sawanoboly The new website helped a lot. I'm now running knife-zero as well, thanks!

Needed to dig a little bit to find the Berkshelf hack, but it works!

from knife-zero.

sawanoboly avatar sawanoboly commented on July 30, 2024

@allaire Thanks πŸ˜„ If you don't mind, I would like to reflect your hack as tips to knife-zero documentation.

@Paul424

Thanks for report πŸ‘ If there is a problem you want to still something resolved, please make a separate Issue by theme, please.

from knife-zero.

allaire avatar allaire commented on July 30, 2024

@sawanoboly I used the tip you already provided! Thanks :)

from knife-zero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.