diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/type.rb | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 656b8f264..1dbf12451 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -957,13 +957,13 @@ class Type schedule object, and then reference the name of that object to use that for your schedule: - schedule { daily: + schedule { 'daily': period => daily, - range => \"2-4\" + range => \"2-4\" } exec { \"/usr/bin/apt-get update\": - schedule => daily + schedule => 'daily' } The creation of the schedule object does not need to appear in the @@ -1055,9 +1055,9 @@ class Type newmetaparam(:alias) do desc "Creates an alias for the object. Puppet uses this internally when you - provide a symbolic name: + provide a symbolic title: - file { sshdconfig: + file { 'sshdconfig': path => $operatingsystem ? { solaris => \"/usr/local/etc/ssh/sshd_config\", default => \"/etc/ssh/sshd_config\" @@ -1065,30 +1065,30 @@ class Type source => \"...\" } - service { sshd: - subscribe => File[sshdconfig] + service { 'sshd': + subscribe => File['sshdconfig'] } - When you use this feature, the parser sets `sshdconfig` as the name, + When you use this feature, the parser sets `sshdconfig` as the title, and the library sets that as an alias for the file so the dependency - lookup for `sshd` works. You can use this parameter yourself, + lookup in `Service['sshd']` works. You can use this metaparameter yourself, but note that only the library can use these aliases; for instance, the following code will not work: file { \"/etc/ssh/sshd_config\": owner => root, group => root, - alias => sshdconfig + alias => 'sshdconfig' } - file { sshdconfig: + file { 'sshdconfig': mode => 644 } There's no way here for the Puppet parser to know that these two stanzas should be affecting the same file. - See the [Language Tutorial](http://docs.puppetlabs.com/guides/language_tutorial.html) for more information. + See the [Language Guide](http://docs.puppetlabs.com/guides/language_guide.html) for more information. " @@ -1222,7 +1222,7 @@ class Type # solution, but it works. newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do - desc "One or more objects that this object depends on. + desc "References to one or more objects that this object depends on. This is used purely for guaranteeing that changes to required objects happen before the dependent object. For instance: @@ -1232,8 +1232,8 @@ class Type } file { \"/usr/local/scripts/myscript\": - source => \"puppet://server/module/myscript\", - mode => 755, + source => \"puppet://server/module/myscript\", + mode => 755, require => File[\"/usr/local/scripts\"] } @@ -1247,7 +1247,7 @@ class Type ways to autorequire objects, so if you think Puppet could be smarter here, let us know. - In fact, the above code was redundant -- Puppet will autorequire + In fact, the above code was redundant --- Puppet will autorequire any parent directories that are being managed; it will automatically realize that the parent directory should be created before the script is pulled down. @@ -1263,40 +1263,41 @@ class Type end newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do - desc "One or more objects that this object depends on. Changes in the - subscribed to objects result in the dependent objects being - refreshed (e.g., a service will get restarted). For instance: + desc "References to one or more objects that this object depends on. This + metaparameter creates a dependency relationship like **require,** + and also causes the dependent object to be refreshed when the + subscribed object is changed. For instance: class nagios { - file { \"/etc/nagios/nagios.conf\": + file { 'nagconf': + path => \"/etc/nagios/nagios.conf\" source => \"puppet://server/module/nagios.conf\", - alias => nagconf # just to make things easier for me } - service { nagios: - ensure => running, - subscribe => File[nagconf] + service { 'nagios': + ensure => running, + subscribe => File['nagconf'] } } - Currently the `exec`, `mount` and `service` type support + Currently the `exec`, `mount` and `service` types support refreshing. " end newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do - desc %{This parameter is the opposite of **require** -- it guarantees - that the specified object is applied later than the specifying - object: + desc %{References to one or more objects that depend on this object. This + parameter is the opposite of **require** --- it guarantees that + the specified object is applied later than the specifying object: file { "/var/nagios/configuration": source => "...", recurse => true, - before => Exec["nagios-rebuid"] + before => Exec["nagios-rebuid"] } exec { "nagios-rebuild": command => "/usr/bin/make", - cwd => "/var/nagios/configuration" + cwd => "/var/nagios/configuration" } This will make sure all of the files are up to date before the @@ -1304,15 +1305,18 @@ class Type end newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do - desc %{This parameter is the opposite of **subscribe** -- it sends events - to the specified object: + desc %{References to one or more objects that depend on this object. This + parameter is the opposite of **subscribe** --- it creates a + dependency relationship like **before,** and also causes the + dependent object(s) to be refreshed when this object is changed. For + instance: file { "/etc/sshd_config": source => "....", - notify => Service[sshd] + notify => Service['sshd'] } - service { sshd: + service { 'sshd': ensure => running } @@ -1328,24 +1332,24 @@ class Type By default, all classes get directly added to the 'main' stage. You can create new stages as resources: - stage { [pre, post]: } + stage { ['pre', 'post']: } To order stages, use standard relationships: - stage { pre: before => Stage[main] } + stage { 'pre': before => Stage['main'] } Or use the new relationship syntax: - Stage[pre] -> Stage[main] -> Stage[post] + Stage['pre'] -> Stage['main'] -> Stage['post'] Then use the new class parameters to specify a stage: - class { foo: stage => pre } + class { 'foo': stage => 'pre' } Stages can only be set on classes, not individual resources. This will fail: - file { '/foo': stage => pre, ensure => file } + file { '/foo': stage => 'pre', ensure => file } } end @@ -1478,7 +1482,7 @@ class Type newparam(:provider) do desc "The specific backend for #{self.name.to_s} to use. You will - seldom need to specify this -- Puppet will usually discover the + seldom need to specify this --- Puppet will usually discover the appropriate provider for your platform." # This is so we can refer back to the type to get a list of |