首先,写这篇文章的目的是为了记录我的学习历程,可以与更多的人分享,希望给出更好的建议,帮助我来改进。
1.因为管理puppet需要dns的配置,在这里我不做过多的介绍。
2.关于puppetmaster与puppetclient之间的证书认证,在这里我不做过多的介绍了,接下来进入主题。
DRBD的配置(debian)
首先需要更改一些puppetmaster里面的配置文件。
首先我们进入到puppet的目录下:
/etc/puppet/fileserver.conf
[files] path /etc/puppet allow *.supcorp.lan # deny *.evil.example.com # allow 192.168.0.0/24 [plugins] allow *.supcorp.lan # deny *.evil.example.com # allow 192.168.0.0/24
这样我们的puppetmaster可以作为一个文件服务器进行使用。
下面是我创建的模板,在etc\puppet\modules\drbd\manifests\init.pp写入一下的内容
创建一个drbd的类 class drbd{ 确保有drbd的安装包 package { ‘drbd-utils‘: ensure => installed } 确保drbd的服务开启 service { ‘drbd‘: ensure => running, enable => true, hasstatus => false, hasrestart => true, require => package[‘drbd-utils‘] } File { mode => ‘0644‘, owner => ‘root‘, group => ‘root‘, require => package[‘drbd-utils‘] } file { ‘/etc/drbd.d‘: ensure => directory, mode => ‘0644‘, purge => true, require => package[‘drbd-utils‘] } file { ‘/etc/drbd.d/first-storage.res‘: content => template("drbd/first-storage.res.erb"), require => service[‘drbd‘] } file { ‘/etc/drbd.d/second-storage.res‘: content => template("drbd/second-storage.res.erb"), require => service[‘drbd‘] } Exec {path => ["/usr/bin","/usr/sbin","/bin","/sbin"],} exec { "drbdadm create-md ${storage}": command => "drbdadm create-md ${storage}", refreshonly=> true, subscribe => file["/etc/drbd.d/${storage}.res"], require => file["/etc/drbd.d/${storage}.res"] } exec { "drbdadm up ${storage}": command => "drbdadm up ${storage}", refreshonly=> true, subscribe => exec["drbdadm create-md ${storage}"], require => file["/etc/drbd.d/${storage}.res"] } exec { ‘drbd_make_primary‘: command => "drbdadm -- --overwrite-data-of-peer primary all", refreshonly=> true, subscribe => exec["drbdadm up ${storage}"], require => service[‘drbd‘] } exec { ‘drbdadm secondary all‘: command => "drbdadm secondary all", refreshonly=> true, subscribe => service[‘drbd‘], before => exec[‘drbd_make_primary‘] } exec { "drbdadm primary --force ${storage}": command => "drbdadm primary --force ${storage}", require => package[‘drbd-utils‘] } exec { "mkfs.ext3 ${dev}": command => "mkfs.ext3 ${dev}", path => ["/usr/bin","/usr/sbin","/bin","/sbin"], require => exec["drbdadm primary --force ${storage}"] } }
时间: 2024-10-14 01:31:31