puppet - How to ensure Service is restarted before commands from Exec resource execute? -


(update) left out important line of code in original question.

i write puppet module create local storage. un-automated way of is.

  1. edit /etc/multipath.conf file
  2. restart multipathd daemon
  3. execute pvcreate $device
  4. execute vgcreate $volume_name $device

so in puppet module want make sure multipathd daemon gets restarted if /etc/multipath.conf file changes. wrote puppet manifest way.

service['multipathd'] -> anchor['create_storage_volume::begin']  ...  file { '/etc/multipath.conf':     ensure  => file,     content => template( 'local_storage::hadoop/multipath.conf.erb' ),     owner   => 'root',     mode    => '0600',     notify  => service['multipathd'], } ->  service { 'multipathd':     enable => true,     ensure => running, }  anchor { 'create_storage_volume::begin': } ->  exec { "pvcreate ${device}":     path   => ['/usr/sbin', '/bin'],     unless => "pvs | grep ${"volume_name}, } -> exec { "vgcreate ${volume_name} ${device}":     path   => ['/usr/sbin', '/bin'],     unless => "pvs | grep ${"volume_name}, } -> # -> nova config stuff anchor { 'create_storage_volume::end': }  ... 

my question is, "does above code guarantee multipathd daemon gets restarted before pvcreate , vgcreate commands executed"? need add more resource order ...

 service['multipathd'] -> anchor['local_storage::begin'] 

?

my question is, "does above code guarantee multipathd daemon gets restarted before pvcreate , vgcreate commands executed"?

no. both service['multipathd'] , exec["pvcreate ${device}"] applied after file['/etc/multipath.conf'], nothing in you've presented relative order of application of service , exec.

i'd write this, instead:

file { '/etc/multipath.conf':     ensure  => file,     content => template( 'local_storage::hadoop/multipath.conf.erb' ),     owner   => 'root',     mode    => '0600', } ~> service['multipathd'] -> exec { "pvcreate ${device}":     path   => ['/usr/sbin', '/bin'],     unless => "pvs | grep ${"volume_name}, } -> # ... 

note use of the notifying chain operator; less-used feature of puppet language.


with respect update question, key requirement service refreshed before exec applied there ordering relationship between two, whether direct or transitive. in modified question, resources involved have such relationship already.

the original answer gloss on fine point here, called out in comments: puppet not document explicitly when resource refreshes happen relative else. documented semantics have implications that, no firm rule given. in practice, through puppet 4, if resource refresh happens, happen after resource synced -- or after have been synced if had needed be.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -