我有以下傀儡代码:
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\'',
}
如你所见,我运行了三个 exec 命令。第一个命令设置了 Mysql 密码,第二个命令也设置了密码,第三个命令将 1 写入面包屑文件/etc/mysql_root_password_setup.cf
。
我希望只有在前两个 exec 完成后才能执行第三个 exec。
我如何告诉 puppet 按照它们在类文件中定义的顺序执行它们。
答案1
您可以使用 Puppet 的require
参数。
例如:
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'],
...
}