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.

Spaniard89
  • 107
  • 1
  • 3
  • 7

1 Answers1

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'],
    ...
  }
Craig Watson
  • 9,370
  • 3
  • 30
  • 46