puppet使用笔记一

安装启动

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值