Puppet::Type.newtype create_resource with notify

99 views
Skip to first unread message

Bartosz Kupidura

unread,
Jan 29, 2016, 2:09:45 PM1/29/16
to Puppet Users
Hello All!
Im trying to write new type which will add resource to catalog, but i have problem with 'notify' property.

New resources are added to catalog, but unfortunately notify is not working.

parameters = {:name => 'test', :notify => 'Service[test-service]', :value => '10}
res = catalog.create_resource('test_resource', parameters)
target = catalog.resource 'service', 'test-service'
Puppet::Relationship.new(res, target, {:event => :ALL_EVENTS, :callback =>:refresh})


Log:
Debug: /Stage[main]/Main/Asd[test_resource]: test_resource[test]: was not found in the catalog, creating it
Info: Applying configuration version '1454091309'
Notice: /test_resource[test]/value: value changed '123' to '10'
Debug: Executing '/sbin/status test-service'
Debug: Finishing transaction 29127600
Debug: Storing state
Debug: Stored state in 0.75 seconds
Notice: Finished catalog run in 1.45 seconds

Manifest:
asd { 'test_resource':
  data => {
    'test' => {'value'=> '10'},
  },
}

service { 'test-service':
   ensure => running
}

Any hints what im missing?

Felix Frank

unread,
Feb 11, 2016, 6:19:02 PM2/11/16
to puppet...@googlegroups.com
Hi,


On 01/29/2016 07:19 PM, Bartosz Kupidura wrote:
New resources are added to catalog, but unfortunately notify is not working.

parameters = {:name => 'test', :notify => 'Service[test-service]', :value => '10}
res = catalog.create_resource('test_resource', parameters)
target = catalog.resource 'service', 'test-service'
Puppet::Relationship.new(res, target, {:event => :ALL_EVENTS, :callback =>:refresh})

I don't follow. Where is this code from? Are you invoking this? How?



Log:
Debug: /Stage[main]/Main/Asd[test_resource]: test_resource[test]: was not found in the catalog, creating it
Info: Applying configuration version '1454091309'
Notice: /test_resource[test]/value: value changed '123' to '10'
Debug: Executing '/sbin/status test-service'
Debug: Finishing transaction 29127600
Debug: Storing state
Debug: Stored state in 0.75 seconds
Notice: Finished catalog run in 1.45 seconds

Manifest:
asd { 'test_resource':
  data => {
    'test' => {'value'=> '10'},
  },
}

service { 'test-service':
   ensure => running
}

Any hints what im missing?

Well...your manifest does *not* establish a notify relationship between those resources. How about a ~> arrow between them? Or a `notify => Service['test-service']` parameter for the asd resource?

HTH,
Felix
Reply all
Reply to author
Forward
0 new messages