httpd_install.pp
class httpd::install{
package{'httpd':
name => 'httpd',
ensure => installed,
}
}
httpd_service.pp
class httpd::service{
service{'starthttpd':
name => 'httpd',
ensure => running,
start => '/usr/bin/systemctl start httpd',
restart => '/usr/bin/systemctl restart httpd',
require => Class['httpd::install'],
}
}
httpd_init.pp
class httpd{
include httpd::install
}
class httpd{
include httpd::service
}
mysql_install.pp
class mysql::install{
exec{'mysqlmakecache':
name => 'mysql',
path => '/usr/bin/env:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/root/',
onlyif => 'cd /root/ && wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm',
command => 'yum -y localinstall mysql57-community-release-el7-8.noarch.rpm && rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022'
}
package{'mysql-community-server':
name => 'mysql-community-server',
ensure => installed,
require => Exec['mysqlmakecache']
}
}
mysql_server.pp
class mysql::service{
service{'mysql':
name => 'mysql',
ensure => running,
start => '/usr/bin/systemctl start mysqld',
require => Class['mysql::install']
}
}
mysql_init.pp
class mysql{
include mysql::install
}
class mysql{
include mysql::service
}
puppet_site.pp
$puppetmaster = server.cn
node 'slave.cn'{
include httpd,mysql
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/844c30a6594c4927ada89bc5f8c996e0.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bu255OSQHlhbmtlcnA=,size_20,color_FFFFFF,t_70,g_se,x_16)