安装启动
apt install puppet puppet-master
systemctl restart puppet-master.service puppet
看下是什么东西
这些配置文件可以熟悉一下
root@instance-1:~# tree /etc/puppet/
/etc/puppet/
├── auth.conf
├── code
│ └── modules
├── hiera.yaml
└── puppet.conf
2 directories, 3 files
开始写代码
在哪写?
root@instance-1:~# puppet config print modulepath
/etc/puppet/code/modules:/usr/share/puppet/modules
在这两个目录下面
创建个自己的模块 创建个文件试试
root@instance-1:/usr/share/puppet/modules# mkdir -p ./test/manifests ./test/template ./test/file ./test/test
root@instance-1:/usr/share/puppet/modules# tree
.
└── test
├── file
├── manifests
├── template
└── test
5 directories, 0 files
写个测试的文件
root@instance-1:/usr/share/puppet/modules/test/manifests# ls
base.pp init.pp
root@instance-1:/usr/share/puppet/modules/test/manifests# cat base.pp
class test::base{
file {"/testfile":
ensure => file,
owner => "root",
group => "root",
mode => "700",
}
}
root@instance-1:/usr/share/puppet/modules/test/manifests# cat init.pp
class test() {
include test::base
}
root@instance-1:/usr/share/puppet/modules/test# puppet apply test/site.pp
Notice: Compiled catalog for instance-1.asia-east2-a.c.hallowed-welder-273506.internal in environment production in 0.11 seconds
Notice: /Stage[main]/Test::Base/File[/testfile]/ensure: created
Notice: Applied catalog in 0.02 seconds
看日志执行成功了
root@instance-1:/usr/share/puppet/modules/test# ls / |grep testfile
testfile