Chef LWRP calling issue

72 Views Asked by At

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 :traffic_manager
    attribute :azure_token
    
  • Created Provider: traffic_manager.rb

    def whyrun_supported?
       true
    end
    
    action :create do
      converge_by("Creating.") do
        traffic_manager_processor = TrafficManagers.new(@new_resource.resource_group_name,
                                                   @new_resource.profile_name,
                                                   @new_resource.subscription,
                                                   @new_resource.traffic_manager,
                                                   @new_resource.azure_token)
        traffic_manager_processor.create_update_profile
      end # Move on next line, copy/paste error or root cause ?
    
      @new_resource.updated_by_last_action(true) 
    end
    
  • And then I am calling this in my recipe

    azuretrafficmanager_traffic_manager 'createtrafficmanager' do
      resource_group_name resource_group_name
      profile_name profile_name
      subscription subscription
      traffic_manager traffic_manager
      azure_token azure_token
      action :create
    end
    
  • The above method of calling lwrp isn't working, but when i try the second method which is:

    azuretrafficmanager_traffic_manager 'createtrafficmanager' do
      resource_group_name resource_group_name
      profile_name profile_name
      subscription subscription
      traffic_manager traffic_manager
      azure_token azure_token
      action :nothing
    end.run_action(:create)
    
  • By following this method(run_action) of calling lwrp, it is working perfectly.

The problem is, why the first syntax of calling lwrps isn't working?

0

There are 0 best solutions below