您好,欢迎访问三七文档
puppet入门puppet简介3puppet是什么3Helloworld4puppet安装5debian系发行版安装puppet5redhat系发行版安装puppet5源代码安装puppet6配置c/s模式的puppet试验环境6puppet语法8资源8类和函数10节点11变量和数组12模块13几个常用的资源14file资源14package资源15service资源15exec资源16puppet高级内容17FAQ181第0章2前言2第1章puppet简介1puppet是什么2Figure1.1:puppetstructure123第1章puppet简介4Helloworldfile{/tmp/test:content=hello\n,mode=0644;}package{[gcc,make]:ensure=installed;}再次提醒:不同的资源有不同的属性,但是又有一些属性是所有资源都共有的,例如tag,这种属性叫做元属性。4第2章puppet安装1debian系发行版安装puppet2apt getinstallpuppetpuppetmasterredhat系发行版安装puppetrpm Uvh release 5 3.noarch.rpmyuminstallpuppet125第2章puppet安装6源代码安装puppetbase64cgidigest/md5etcfileutilsipaddropensslstrscansysloguriwebrickwebrick/httpsxmlrpctarzxffacter 1.5.7.tar.gzcdfacter 1.5.7rubyinstall.rbtarzxfpuppet 0.25.4.tar.gzcdpuppet 0.25.4rubyinstall.rb配置c/s模式的puppet试验环境6第2章puppet安装7apt getinstallpuppetapt getinstallpuppetmasterecho192.168.0.10␣server.puppet.com/etc/hosts注意:要在安装软件以前先设置主机名,因为生成证书的时候要把主机名写入证书,如果证书生成好了再改主机名,就连不上,这是很多初学者遇到的问题。puppetd test serverserver.puppet.compupetca listpupetca s anodedefault{file{/tmp/temp1.txt:content=hello;}}pupetd test serverserver.puppet.com7第3章puppet语法资源file{/etc/passwd:name=/etc/passd,owner=root,group=root,mode=644;}file{sshdconfig:name=$operatingsystem?{solaris=/usr/local/etc/ssh/sshd_config,default=/etc/ssh/sshd_config,},owner=root,8第3章puppet语法9group=root,mode=644,}service{sshd:subscribe=File[sshdconfig],}file{[/etc/passwd,/etc/hosts]:owner=root,group=root,mode=644;}File{owner=root,mode=644;}file{/etc/apache2/port.conf:content=80,require=Package[apache2];}package{apache2:9第3章puppet语法10ensure=installed;}类和函数classssh{file{/etc/ssh/sshd_config:source=puppet://$fileserver/ssh/sshd_config.cfg;}package{ssh:ensure=installed;}service{ssh:ensure=running;}}10第3章puppet语法11definesvn_repo($path){exec{/usr/bin/svnadmin␣create␣$path/$title:unless=/bin/test␣ d␣$path,}}svn_repo{puppet_repo:path=/var/svn_puppet}svn_repo{other_repo:path=/var/svn_other}12节点3node'host1.example.com'{includessh}node'host2.example.com'{includeapache,mysql,php}12311第3章puppet语法12node'host4.example.com'{$networktype=tele$nagioscheckport=80,22,3306includessh,apache,mysql}变量和数组$test=hello,guysfile{/tmp/test:content=$test;}[apache2,httpd,ssh]definephp::pear(){package{`php ${name}:ensure=installed}}php::pear{['ldap','mysql','ps','snmp','sqlite','tidy','xmlrpc']:}12第3章puppet语法13模块13第4章几个常用的资源file资源source=puppet://${fileserver}/lvs/${corp}.${idc}.keepalived.conf14第4章几个常用的资源15file{/etc/squid/squid.conf:mode=0644,content=template(squid/squid.conf.erb);}1cache_mem%=Integer(vmx_memsize.to_i*0.45) %MBvisible_hostname%=fqdn%package资源package{[vim,iproute,x window system]:ensure=installed;[pppoe,pppoe conf]:ensure=absent;}service资源service{ssh:ensure=running;nfs:ensure=stoped;115第4章几个常用的资源16}exec资源exec{delete␣config:path=/bin:/usr/bin,command=rm␣/etc/ssh/ssh_config;}16第5章puppet高级内容17第6章FAQpuppetd test serverserver.example.com#发送证书请求puppetca list#列出所有证书请求puppetca s a#签名所有证书puppetd test serverserver.example.com#得到证书18第6章FAQ19后记huangmingyouhouqpfrostynovaaaniao999kuuyeeedison7500minxu270175100douzlDanielHounlinewtopppxw2014chifengdywerLiuNan19
本文标题:puppet 入门
链接地址:https://www.777doc.com/doc-5893306 .html