0

I have the following puppet code:

  exec { 'set mysql root password':
    user    => root,
    path   => "/usr/bin:/usr/sbin:/bin",
    command => "/usr/bin/mysqladmin -u root password \'${root_pwd}\'",
    onlyif  => 'grep /etc/mysql_root_password_setup.cf -nrw -e \'0\'', 
  }

  exec { 'set mysql hostname password':
    user    => root,
    path   => "/usr/bin:/usr/sbin:/bin",
    command => "/usr/bin/mysqladmin -u root -h ${::fqdn} password \'${root_pwd}\'",
    onlyif  => 'grep /etc/mysql_root_password_setup.cf -nrw -e \'0\'',
  }

  exec { 'Modify the Breadcrumb':
    user    => root,
    path   => "/usr/bin:/usr/sbin:/bin",
    command => "echo 1 > /etc/mysql_root_password_setup.cf",
    onlyif  => 'grep /etc/mysql_root_password_setup.cf -nrw -e \'0\'',
  }

As you can see, I am running three exec command. The first one sets the Mysql password, the second does the same, the third one though, write 1 into a breadcrumb file /etc/mysql_root_password_setup.cf.

I want the the third exec to be executed only after the completion of first two exec.

How can I tell puppet to execute them in the order they are defined in the class file.

3

You can use Puppet's require parameter.

For example:

  exec { 'set mysql root password':
    ... 
  }

  exec { 'set mysql hostname password':
    require => Exec['set mysql root password'],
    ...
  }

  exec { 'Modify the Breadcrumb':
    require => Exec['set mysql hostname password'],
    ...
  }
  • thanks that was much easier than I though. – Spaniard89 Oct 26 '15 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.