Questions tagged [lwrp]

An LWRP is a part of a cookbook that is used to extend the chef-client in a way that allows custom actions to be defined, and then used in recipes in much the same way as any platform resource.

An LWRP is a part of a cookbook that is used to extend the chef-client in a way that allows custom actions to be defined, and then used in recipes in much the same way as any platform resource. A LWRP has two principal components:

  • A lightweight resource that defines a set of actions and attributes
  • A lightweight provider that tells the chef-client how to handle each action, what to do if certain conditions are met, and so on In addition, most lightweight providers are built using platform resources and some lightweight providers are built using custom Ruby code

Once created, a LWRP becomes a Ruby class within the organization. During each chef-client run, the chef-client will read the lightweight resources from recipes and process them alongside all of the other resources. When it is time to configure the node, the chef-client will use the corresponding lightweight provider to determine the steps required to bring the system into the desired state.

Where the lightweight resource represents a piece of the system, its current state, and the action that is needed to move it to the desired state, a lightweight provider defines the steps that are required to bring that piece of the system from its current state to the desired state. A LWRP behaves similar to platform resources and providers:

  • A lightweight resource is a key part of a recipe
  • A lightweight resource defines the actions that can be taken
  • During a chef-client run, each lightweight resource is identified, and then associated with a lightweight provider
  • A lightweight provider does the work to complete the action requested by the lightweight resource

You can read more about how to build custom lightweight resources on the Chef docs.

73 questions
0
votes
0 answers

Halo and Lens flare

I hope you guys are fine and doing great. I am having a problem. Halo and Lens Flare are not visible if we use Light Weight Render Pipeline(LWRP). They are visible in Builtin Render Pipe line but not in LWRP. If anybody knows the solution. please…
Mr Gamer
  • 1
  • 2
0
votes
1 answer

How to access chef resource properties in helper library

How to access resource_name property in library functions. How to add custom action attribute for existing community cookbook resource. Introduction: Sensu cookbook has resource named "sensu_check" having two actions :create or :delete. In recipes…
devzone
  • 49
  • 1
  • 7
0
votes
0 answers

Chef LWRP calling issue

I am creating LWRP for a cookbook azuretrafficmanager, steps are following Created Resource: traffic_manager.rb actions :create default_action :create attribute :resource_group_name attribute :profile_name attribute :subscription attribute…
0
votes
0 answers

Error while using custom LWRP in Chef

I am using a custom LWRP in a recipe in Chef. I have performed the following steps to do that: Create a resources folder with a resource.rb file which contains the necessary attributes and actions. Create a providers folder with a provider.rb file…
0
votes
1 answer

chef exception handling -> simplest way to use chat_message (LWRP) on :run_failed

We have chef-client scheduled on our nodes and I'll like to set up exception handling so the error is reported in our chat. Previously I got help here to write a LWRP which posts to chat chat_message do message "Hello, World" channel…
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
0
votes
1 answer

using include_recipe in LWRP and not run_context.include_recipe

I started using include_recipe in my LWRPs and it just worked- didn't know about run_context.include_recipe. I'm not sure I understand the difference and read some stuff on the internets makes it sound like regular include_recipe shouldn't even…
red888
  • 27,709
  • 55
  • 204
  • 392
0
votes
1 answer

Scoping Chef LWRPs back to the cookbook containing the resource being called

I have a cookbook that contains a LWRP and some files in the "files" folder. cookbook_file put_it_here do source myfile end A recipe in another cookbook that calls this resource will look in its own cookbook's "files" dir, not the files of the…
red888
  • 27,709
  • 55
  • 204
  • 392
0
votes
2 answers

How to write regression tests for custom Chef resources?

Given the minimal example # resources/novowel.rb resource_name :novowel property :name, String, name_property: true, regex: /\A[^aeiou]\z/ I would like to write the unit tests in spec/unit/resources/novowel_spec.rb Resource 'novowel' for name…
arney
  • 795
  • 7
  • 20
0
votes
1 answer

can chef lwrp return the answer as variable (false or true) for later use in a recipe?

So the question is simple. Can I get the answer if my lwrp did the change as false or true? I know that it's visible in Chef Logs, but my idea is to use the results later in a recipe code.
laimison
  • 1,409
  • 3
  • 17
  • 39
0
votes
1 answer

What happens when you assign a resource to a variable in a Chef recipe?

I'm looking at the johnbellone/consul-cookbook on github and I see the following: install = consul_installation node['consul']['version'] do |r| if node['consul']['installation'] node['consul']['installation'].each_pair { |k, v| r.send(k, v) } …
Aslan Brooke
  • 497
  • 2
  • 8
0
votes
1 answer

Error with Custom LWRP when upgrading from Chef 12.3.0 to 12.7.2

I'd really appreciate if someone could explain to me why i'm having a specific issue with a custom LWRP i've created a while back. With Chef 12.3.0, my custom LWRP attributes work perfectly fine defined this way: attribute 'name', …
hartfordfive
  • 1,275
  • 2
  • 11
  • 18
0
votes
1 answer

RESTful LWRP / Library for Chef

I need to be able to send REST calls and save the returning payload to variables within the cookbook (using chef solo). Calls are made in HTTPS Need to be able to get returning cookie header in order to login to API Is there such a community LWRP…
Eytan Avisror
  • 2,860
  • 19
  • 26
0
votes
1 answer

How to use Chef DSL inside LWRP's action

I have LWRP which should create cookbook_file inside its create action resource_name :vuy property :vu_name, String, name_property :true actions :create action :create do log "vuy:@new_resource.vu_name-#{@new_resource.vu_name}" cookbook_file…
zdenko.s
  • 931
  • 1
  • 12
  • 29
0
votes
2 answers

LWRP compile and converge phase

We found out that ruby code inside a LWRP action (especially a library) is always executed at converge phase (also without a ruby_block resource!). Is this the expected behaviour? We didn't find any specific documentation about that and knowing that…
0
votes
2 answers

Modify configuration files with Chef

I am writing a cookbook to install and configure an application. From what I googled, the best way to modify configuration, is to put a template of that config file. But an app can have different versions and config files may vary. What is the best…
Igor Zilberman
  • 1,048
  • 1
  • 11
  • 16