Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.57 KB

File metadata and controls

65 lines (49 loc) · 1.57 KB

Relationships & Ordering

← Back to Language Reference


By default, Puppet applies resources in a non-deterministic order. To enforce ordering, use relationships:

Arrow Notation

# Ordering: install package BEFORE starting service
Package['httpd'] -> Service['httpd']

# Notification: restart service WHEN config changes
File['/etc/httpd/conf/httpd.conf'] ~> Service['httpd']
Arrow Meaning
-> "before" (ordering only)
~> "notify" (ordering + trigger refresh)
<- "require" (reverse ordering)
<~ "subscribe" (reverse notify)

Metaparameters

service { 'httpd':
  ensure    => running,
  require   => Package['httpd'],        # Don't start until package exists
  subscribe => File['/etc/httpd/conf/httpd.conf'],  # Restart when config changes
}

file { '/etc/httpd/conf/httpd.conf':
  ensure => file,
  notify => Service['httpd'],           # Same as subscribe, other direction
}

package { 'httpd':
  ensure => installed,
  before => Service['httpd'],           # Same as require, other direction
}

Chaining

# Common pattern: install → configure → service
package { 'nginx': ensure => installed }
-> file { '/etc/nginx/nginx.conf':
  ensure => file,
  source => 'puppet:///modules/nginx/nginx.conf',
}
~> service { 'nginx':
  ensure => running,
  enable => true,
}

← Back to Language Reference

This document was created with the assistance of AI (Grok, xAI). All technical content has been reviewed and verified by human contributors.