Fotolia / knife-sharp

A knife plugin
15 stars 8 forks source link

Repo specific config? #29

Open davidpelaez opened 11 years ago

davidpelaez commented 11 years ago

Hi.

In our company we'd like to track the sharp config in the repository.We have a knife.rb that we can track in git and we'd like to keep our stack files fully containerized. I forked the current version and see it would be very hard to solve.

However, I wanted to check if there's a specific reason why you have avoided this and if you'd think it'd be useful. Then maybe we could contribute this simple add-on.

Looking forward,

DPT

josqu4red commented 11 years ago

Hi,

By tracking the sharp config, you mean in the same repo as cookbooks and chef things ? Well, it is just a path problem, isn't it ?

For us it's just another dotfile, so each one tracks it the way he wants...

Not sure to understand the problem

josqu4red commented 11 years ago

Since knife.rb accepts any directive, you can add an option in it, for instance :

sharp_config_path '/path/to/your/sharp-config.yml'

Then, in SharpAlign#setup, if the option is set, add its value to the array of possible configs or even override its content.

Here: https://github.com/Fotolia/knife-sharp/blob/master/lib/chef/knife/sharp-align.rb#L63

davidpelaez commented 11 years ago

Yeah, I want to have the file in [chef-repo]/config/sharp-config.yml, so I just put in knife.rb the directive you mentioned?

I was going to quit, because I keep getting a "wrong data bag path". The config to the git repo is correct and I just don't know what else to do. I edited the gem locally to show what the path of the problem was, this is the output:

$ knife sharp align master _default -D WARNING: Bad data bag path /var/chef/data_bags, skipping data bag sync. Nothing else to do

I have no idea why the path it's using is that one and not the one set in global, git_cookbook_path in the yaml file.

josqu4red commented 11 years ago

About the config path, if you want to put the directive in knife.rb, you have to retrieve it in the code where I mentionned, no magic there :)

About the data bags, the documentation is indeed lacking that very detail, we will update it in the next days. git_cookbook_path was introduced when the tool only supported cookbook syncing. To use data bag and role syncing, you have to add those options to your knife config :

cookbook_path            '/home/jamiez/sysadmin/chef/cookbooks'
data_bag_path            '/home/jamiez/sysadmin/chef/data_bags'
role_path                '/home/jamiez/sysadmin/chef/roles'

which default to /var/chef/* if absent. Have a look to SharpAlign#setup for the details.

josqu4red commented 11 years ago

Did you work out something about this ?

davidpelaez commented 11 years ago

Sorry for the delay! I did manage to have it working as expected regarding the configuration. However, when I went to align the data bags, I couldn't continue because I had no local data bags and only one in the server I think. It seemed like having no local databags was considered an error. I wanted to save time in handling data bags and ensuring some extra order in our process but this was for a very very fast project and I run out of time to try new things so I kept it very manual without knife-sharp :(