简体   繁体   中英

Chef / kitchen - how to generate from a template locally (without creating the VM)

I have a Chef cookbook. One of it's goals is to generate configuration file from a .erb template. That's done as one goal in a recipe, and the template input map is filled from the node tree.

template node['bbcpd-bpds-api']['api_config_path'] do
  source "opt/bpds-api/conf/api/bpds-api.yml.erb"
  mode 0644
  owner node['bbcpd-bpds-api']['user']
  group node['bbcpd-bpds-api']['group']
  variables(
      :application_protocol => node['bbcpd-bpds-api']['application_protocol'],
      :application_port => node['bbcpd-bpds-api']['application_port'],
  ...

I would like to generate this template locally (ie to the dir with the cookbook source) without all the other actions which prepare a virtual machine.

Basically, I would like to have something parse the files in /attributes and prepare the node tree and then only run the ERB templating engine, without invoking kitchen converge . Or ideally, kitchen altogether. The preferred target environment is Java / JRuby / Maven.

Is that possible? Or is my best shot to separate the recipe with the template goal above and to call kitchen converge with only that recipe? How to do that?

See Kitchen commands docs .
I can only see kitchen converge PLATFORM as an option - I could add a suite. But I don't know what then.

There's also run_lists . But I don't see an explanation of what is run by what form of the runlist entry.

This is not possible. Chef only operates in the context of converging a node. You could write your own code generator of some kind, but it would be unrelated to Chef for the most part (though you might be able to jury rig chef-apply into being helpful, maybe?).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM