Hi All, I am new to Puppet and have a question on dependency cycle. I am currently applying my resource directly using the command prompt on Windows ''puppet apply --noop init.pp''. When I try to test it, I encounter a dependency cycle error. Error: Could not apply complete catalog: Found 1 dependency cycle: (Registry_key[delete_hklm_test_foo1_key_step_1_2] => Registry_key[delete_hklm_test_key_step_1_3] => Registry_key[delete_hklm_test_foo2_key_step_1_1] => Registry_key[delete_hklm_test_foo1_key_step_1_2]) Try the ''--graph'' option and opening the resulting ''.dot'' file in OmniGraffle or GraphViz My init.pp is like this. include deletion_key_only class deletion_key_only { registry_key { ''delete_hklm_test_foo2_key_step_1_1'': ensure => absent, purge_values => false, path => ''hklm\software\Test\foo2'', } registry_key { ''delete_hklm_test_foo1_key_step_1_2'': ensure => absent, purge_values => false, path => ''hklm\software\Test\foo1'', require => Registry_Key[''delete_hklm_test_foo2_key_step_1_1''], } registry_key { ''delete_hklm_test_key_step_1_3'': ensure => absent, purge_values => false, path => ''hklm\software\Test'', require => Registry_Key[''delete_hklm_test_foo1_key_step_1_2''], } } I am not sure why I hit a dependency cycle error because I thought I have the dependency lay out correctly on my manifest where ''delete_hklm_test_foo2_key_step_1_1'' will go first, then ''delete_hklm_test_foo1_key_step_1_2'' and family ''delete_hklm_test_key_step_1_3''. Can anyone please explain why I am encountering a dependency cycle error? Thanks! David -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Is it possible that the registry_key type, like dirs and subdirs, has an implied dependency? Sorry, not in a position to test at the moment and I''ve actually not used that type in a while. On Tue, Apr 2, 2013 at 12:09 PM, <beyonddc.storage@gmail.com> wrote:> Hi All, > > I am new to Puppet and have a question on dependency cycle. > > I am currently applying my resource directly using the command prompt on > Windows ''puppet apply --noop init.pp''. > > When I try to test it, I encounter a dependency cycle error. > Error: Could not apply complete catalog: Found 1 dependency cycle: > (Registry_key[delete_hklm_test_foo1_key_step_1_2] => > Registry_key[delete_hklm_test_key_step_1_3] => > Registry_key[delete_hklm_test_foo2_key_step_1_1] => > Registry_key[delete_hklm_test_foo1_key_step_1_2]) > Try the ''--graph'' option and opening the resulting ''.dot'' file in > OmniGraffle or GraphViz > > My init.pp is like this. > > include deletion_key_only > class deletion_key_only { > registry_key { ''delete_hklm_test_foo2_key_step_1_1'': > ensure => absent, > purge_values => false, > path => ''hklm\software\Test\foo2'', > } > registry_key { ''delete_hklm_test_foo1_key_step_1_2'': > ensure => absent, > purge_values => false, > path => ''hklm\software\Test\foo1'', > require => Registry_Key[''delete_hklm_test_foo2_key_step_1_1''], > } > registry_key { ''delete_hklm_test_key_step_1_3'': > ensure => absent, > purge_values => false, > path => ''hklm\software\Test'', > require => Registry_Key[''delete_hklm_test_foo1_key_step_1_2''], > } > } > > I am not sure why I hit a dependency cycle error because I thought I have > the dependency lay out correctly on my manifest where > ''delete_hklm_test_foo2_key_step_1_1'' will go first, then > ''delete_hklm_test_foo1_key_step_1_2'' and family > ''delete_hklm_test_key_step_1_3''. > > Can anyone please explain why I am encountering a dependency cycle error? > > Thanks! > > David > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- --- Nathan Valentine - nathan@puppetlabs.com Puppet Labs Professional Services GV: 415.504.2173 Skype: nrvale0 *Join us at PuppetConf 2013, August 22-23 in San Francisco - * http://bit.ly/pupconf13 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Tuesday, April 2, 2013 2:09:41 PM UTC-5, beyonddc...@gmail.com wrote:> > Hi All, > > I am new to Puppet and have a question on dependency cycle. > > I am currently applying my resource directly using the command prompt on > Windows ''puppet apply --noop init.pp''. > > When I try to test it, I encounter a dependency cycle error. > Error: Could not apply complete catalog: Found 1 dependency cycle: > (Registry_key[delete_hklm_test_foo1_key_step_1_2] => > Registry_key[delete_hklm_test_key_step_1_3] => > Registry_key[delete_hklm_test_foo2_key_step_1_1] => > Registry_key[delete_hklm_test_foo1_key_step_1_2]) > Try the ''--graph'' option and opening the resulting ''.dot'' file in > OmniGraffle or GraphViz > > My init.pp is like this. > > include deletion_key_only > class deletion_key_only { > registry_key { ''delete_hklm_test_foo2_key_step_1_1'': > ensure => absent, > purge_values => false, > path => ''hklm\software\Test\foo2'', > } > registry_key { ''delete_hklm_test_foo1_key_step_1_2'': > ensure => absent, > purge_values => false, > path => ''hklm\software\Test\foo1'', > require => Registry_Key[''delete_hklm_test_foo2_key_step_1_1''], > } > registry_key { ''delete_hklm_test_key_step_1_3'': > ensure => absent, > purge_values => false, > path => ''hklm\software\Test'', > require => Registry_Key[''delete_hklm_test_foo1_key_step_1_2''], > } > } > > I am not sure why I hit a dependency cycle error because I thought I have > the dependency lay out correctly on my manifest where > ''delete_hklm_test_foo2_key_step_1_1'' will go first, then > ''delete_hklm_test_foo1_key_step_1_2'' and family > ''delete_hklm_test_key_step_1_3''. > > Can anyone please explain why I am encountering a dependency cycle error? > >The dependency cycle is not caused directly by your code. I don''t know what ''registry_key'' type you are using (since there isn''t one in the Puppet core), but it looks like it probably implements an autorequire based on the registry path. The type documentation should mention that, but the meaning of "autorequire" may not be evident. The way it works for Files is that if both a file and its parent directory are managed resources, AND no relationship between them is otherwise declared, then Puppet automatically gives the file a "require" relationship on its parent directory (hence "autorequire"). That is what you want in most cases, because it is much more common to want to ensure a file (or registry key) present, which requires the parent directory also to be present, than to ensure it absent. When you want the file and parent directory absent, however, it is the wrong order, and in that case you must explicitly declare the correct ordering relationship. Puppet has general-purpose support for autorequires, so it is likely that your Registry_key type behaves similarly. For your particular code, I would add: before => Registry_key[''delete_hklm_test_key_step_1_3''] to both the other Registry_key resources, and remove the then-redundant ''require'' from Registry_key[''delete_hklm_test_key_step_1_3'']. That should be more than enough to solve the problem, but I would also remove the needless ''require'' from Registry_Key[''delete_hklm_test_foo2_key_step_1_2'']: it doesn''t matter whether 1_1 or 1_2 is applied first, only that both are applied before 1_3. As a general rule, you should not attempt to model sequences of action in Puppet. Instead, model only the true constraints on the order of resource application, and let Puppet choose whatever order it likes that is consistent with those constraints. Whether you should use ''require'' or ''before'' relationships, or their signaling counterparts, is a context-sensitive issue. I like ''before'' in this case because it allows the relationship to be owned by the child key, which necessarily knows about its parent; the parent key, on the other hand, should not be required to know about all its children. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
beyonddc.storage@gmail.com
2013-Apr-03 14:42 UTC
[Puppet Users] Re: Dependency Cycle Question
Hi John, Your explanation should be correct. I believe the registry_key is behaving like the file resource since I was able to replace the problem using a file resource instead. You are also correct that the registry_key has autorequire implemented. The registry_key resource is downloaded from puppet forge https://forge.puppetlabs.com/puppetlabs/registry Thanks again for your explanation. David On Wednesday, April 3, 2013 9:48:47 AM UTC-4, jcbollinger wrote:> > > > On Tuesday, April 2, 2013 2:09:41 PM UTC-5, beyonddc...@gmail.com wrote: >> >> Hi All, >> >> I am new to Puppet and have a question on dependency cycle. >> >> I am currently applying my resource directly using the command prompt on >> Windows ''puppet apply --noop init.pp''. >> >> When I try to test it, I encounter a dependency cycle error. >> Error: Could not apply complete catalog: Found 1 dependency cycle: >> (Registry_key[delete_hklm_test_foo1_key_step_1_2] => >> Registry_key[delete_hklm_test_key_step_1_3] => >> Registry_key[delete_hklm_test_foo2_key_step_1_1] => >> Registry_key[delete_hklm_test_foo1_key_step_1_2]) >> Try the ''--graph'' option and opening the resulting ''.dot'' file in >> OmniGraffle or GraphViz >> >> My init.pp is like this. >> >> include deletion_key_only >> class deletion_key_only { >> registry_key { ''delete_hklm_test_foo2_key_step_1_1'': >> ensure => absent, >> purge_values => false, >> path => ''hklm\software\Test\foo2'', >> } >> registry_key { ''delete_hklm_test_foo1_key_step_1_2'': >> ensure => absent, >> purge_values => false, >> path => ''hklm\software\Test\foo1'', >> require => Registry_Key[''delete_hklm_test_foo2_key_step_1_1''], >> } >> registry_key { ''delete_hklm_test_key_step_1_3'': >> ensure => absent, >> purge_values => false, >> path => ''hklm\software\Test'', >> require => Registry_Key[''delete_hklm_test_foo1_key_step_1_2''], >> } >> } >> >> I am not sure why I hit a dependency cycle error because I thought I have >> the dependency lay out correctly on my manifest where >> ''delete_hklm_test_foo2_key_step_1_1'' will go first, then >> ''delete_hklm_test_foo1_key_step_1_2'' and family >> ''delete_hklm_test_key_step_1_3''. >> >> Can anyone please explain why I am encountering a dependency cycle error? >> >> > > The dependency cycle is not caused directly by your code. I don''t know > what ''registry_key'' type you are using (since there isn''t one in the Puppet > core), but it looks like it probably implements an autorequire based on the > registry path. The type documentation should mention that, but the meaning > of "autorequire" may not be evident. > > The way it works for Files is that if both a file and its parent directory > are managed resources, AND no relationship between them is otherwise > declared, then Puppet automatically gives the file a "require" relationship > on its parent directory (hence "autorequire"). That is what you want in > most cases, because it is much more common to want to ensure a file (or > registry key) present, which requires the parent directory also to be > present, than to ensure it absent. When you want the file and parent > directory absent, however, it is the wrong order, and in that case you must > explicitly declare the correct ordering relationship. Puppet has > general-purpose support for autorequires, so it is likely that your > Registry_key type behaves similarly. > > For your particular code, I would add: > before => Registry_key[''delete_hklm_test_key_step_1_3''] > to both the other Registry_key resources, and remove the then-redundant > ''require'' from Registry_key[''delete_hklm_test_key_step_1_3'']. That should > be more than enough to solve the problem, but I would also remove the > needless ''require'' from Registry_Key[''delete_hklm_test_foo2_key_step_1_2'']: > it doesn''t matter whether 1_1 or 1_2 is applied first, only that both are > applied before 1_3. > > As a general rule, you should not attempt to model sequences of action in > Puppet. Instead, model only the true constraints on the order of resource > application, and let Puppet choose whatever order it likes that is > consistent with those constraints. > > Whether you should use ''require'' or ''before'' relationships, or their > signaling counterparts, is a context-sensitive issue. I like ''before'' in > this case because it allows the relationship to be owned by the child key, > which necessarily knows about its parent; the parent key, on the other > hand, should not be required to know about all its children. > > > John > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Wed, Apr 3, 2013 at 7:42 AM, <beyonddc.storage@gmail.com> wrote:> Hi John, > > Your explanation should be correct. I believe the registry_key is > behaving like the file resource since I was able to replace the problem > using a file resource instead. > > You are also correct that the registry_key has autorequire implemented. > > The registry_key resource is downloaded from puppet forge > https://forge.puppetlabs.com/puppetlabs/registry > > Thanks again for your explanation. > > David > > On Wednesday, April 3, 2013 9:48:47 AM UTC-4, jcbollinger wrote: >> >> >> >> On Tuesday, April 2, 2013 2:09:41 PM UTC-5, beyonddc...@gmail.com wrote: >>> >>> Hi All, >>> >>> I am new to Puppet and have a question on dependency cycle. >>> >>> I am currently applying my resource directly using the command prompt on >>> Windows ''puppet apply --noop init.pp''. >>> >>> When I try to test it, I encounter a dependency cycle error. >>> Error: Could not apply complete catalog: Found 1 dependency cycle: >>> (Registry_key[delete_hklm_**test_foo1_key_step_1_2] => >>> Registry_key[delete_hklm_test_**key_step_1_3] => >>> Registry_key[delete_hklm_test_**foo2_key_step_1_1] => >>> Registry_key[delete_hklm_test_**foo1_key_step_1_2]) >>> Try the ''--graph'' option and opening the resulting ''.dot'' file in >>> OmniGraffle or GraphViz >>> >>> My init.pp is like this. >>> >>> include deletion_key_only >>> class deletion_key_only { >>> registry_key { ''delete_hklm_test_foo2_key_**step_1_1'': >>> ensure => absent, >>> purge_values => false, >>> path => ''hklm\software\Test\foo2'', >>> } >>> registry_key { ''delete_hklm_test_foo1_key_**step_1_2'': >>> ensure => absent, >>> purge_values => false, >>> path => ''hklm\software\Test\foo1'', >>> require => Registry_Key[''delete_hklm_**test_foo2_key_step_1_1''], >>> } >>> registry_key { ''delete_hklm_test_key_step_1_**3'': >>> ensure => absent, >>> purge_values => false, >>> path => ''hklm\software\Test'', >>> require => Registry_Key[''delete_hklm_**test_foo1_key_step_1_2''], >>> } >>> } >>> >>> I am not sure why I hit a dependency cycle error because I thought I >>> have the dependency lay out correctly on my manifest where >>> ''delete_hklm_test_foo2_key_**step_1_1'' will go first, then >>> ''delete_hklm_test_foo1_key_**step_1_2'' and family >>> ''delete_hklm_test_key_step_1_**3''. >>> >>> Can anyone please explain why I am encountering a dependency cycle error? >>> >>> >> >> The dependency cycle is not caused directly by your code. I don''t know >> what ''registry_key'' type you are using (since there isn''t one in the Puppet >> core), but it looks like it probably implements an autorequire based on the >> registry path. The type documentation should mention that, but the meaning >> of "autorequire" may not be evident. >> >> The way it works for Files is that if both a file and its parent >> directory are managed resources, AND no relationship between them is >> otherwise declared, then Puppet automatically gives the file a "require" >> relationship on its parent directory (hence "autorequire"). That is what >> you want in most cases, because it is much more common to want to ensure a >> file (or registry key) present, which requires the parent directory also to >> be present, than to ensure it absent. When you want the file and parent >> directory absent, however, it is the wrong order, and in that case you must >> explicitly declare the correct ordering relationship. Puppet has >> general-purpose support for autorequires, so it is likely that your >> Registry_key type behaves similarly. >> >> For your particular code, I would add: >> before => Registry_key[''delete_hklm_**test_key_step_1_3''] >> to both the other Registry_key resources, and remove the then-redundant >> ''require'' from Registry_key[''delete_hklm_**test_key_step_1_3'']. That >> should be more than enough to solve the problem, but I would also remove >> the needless ''require'' from Registry_Key[''delete_hklm_**test_foo2_key_step_1_2'']: >> it doesn''t matter whether 1_1 or 1_2 is applied first, only that both are >> applied before 1_3. >> >> As a general rule, you should not attempt to model sequences of action in >> Puppet. Instead, model only the true constraints on the order of resource >> application, and let Puppet choose whatever order it likes that is >> consistent with those constraints. >> >> Whether you should use ''require'' or ''before'' relationships, or their >> signaling counterparts, is a context-sensitive issue. I like ''before'' in >> this case because it allows the relationship to be owned by the child key, >> which necessarily knows about its parent; the parent key, on the other >> hand, should not be required to know about all its children. >> >> >> John >> >> -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >I filed an issue on this a little while ago[1], and I''m sure there are older tickets relating to it[2]. The basic problem is that autorequire relationships are created in the wrong "direction" when using `ensure => absent`, which when combined with explicit dependencies to ensure resources are unwinded correctly leads to circular dependencies. Josh [1] https://projects.puppetlabs.com/issues/14518 [2] https://projects.puppetlabs.com/issues/4806 -- Josh Cooper Developer, Puppet Labs *Join us at PuppetConf 2013, August 22-23 in San Francisco - * http://bit.ly/pupconf13* **Register now and take advantage of the Final Countdown discount - save 15%!* -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.