设为首页 收藏本站
查看: 686|回复: 0

[经验分享] 45 puppet基础、资源详解、配置语言、puppet类与模板及模块

[复制链接]

尚未签到

发表于 2018-8-2 06:14:08 | 显示全部楼层 |阅读模式
  01puppet基础
  配置:
  node1:192.168.1.131CentOS7.2
  node2:192.168.1.132CentOS7.2
  
  [root@node1 ~]# rpm -ivh epel-release-latest-7.noarch.rpm
  [root@node1 ~]# yum list all | grep -i "puppet"
  puppet.noarch                           3.6.2-3.el7                    epel     
  puppet-firewalld.noarch                 0.1.3-1.el7                    epel     
  puppet-server.noarch                    3.6.2-3.el7                    epel     
  [root@node2 ~]# ls *rpm
  facter-2.4.4-1.el7.x86_64.rpm  puppet-server-3.8.4-1.el7.noarch.rpm
  puppet-3.8.4-1.el7.noarch.rpm
  [root@node2 ~]# rpm -ivh epel-release-latest-7.noarch.rpm
  [root@node2 ~]# yum install facter-2.4.4-1.el7.x86_64.rpm puppet-3.8.4-1.el7.noarch.rpm
  02puppet资源详解
  #定义资源清单:
  1、group、user示例
  [root@node2 ~]# mkdir mainfests
  [root@node2 ~]# cd mainfests/
  [root@node2 mainfests]# vim test1.pp
  group {'distro':
  gid     => 2000,
  ensure  => present,
  }   
  user {'centos':
  uid     => 2000,
  gid     => 2000,
  shell   => '/bin/bash',
  home    => '/home/centos',
  ensure  => present,
  }   
  [root@node2 mainfests]# puppet apply -v test1.pp
  Notice: Compiled catalog for node2 in environment production in 0.61 seconds
  Info: Applying configuration version '1480767979'
  Notice: Finished catalog run in 0.08 seconds
  [root@node2 mainfests]# tail -5 /etc/group
  avahi:x:70:
  slocate:x:21:
  tcpdump:x:72:
  puppet:x:52:
  distro:x:2000:
  [root@node2 mainfests]# tail -5 /etc/passwd
  gnome-initial-setup:x:988:983::/run/gnome-initial-setup/:/sbin/nologin
  avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
  tcpdump:x:72:72::/:/sbin/nologin
  puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin
  centos:x:2000:2000::/home/centos:/bin/bash
  2、file实例
  [root@node2 mainfests]# vim test2.pp
  file{'/tmp/mydir':
  ensure     =>  directory,
  }
  file{'/tmp/puppet.file';
  content     =>  'puppet testing\nsecond line.',
  ensure      =>  file,
  owner       =>  'centos',
  group       =>  'distro',
  mode        =>  '0400',
  }
  file{'/tmp/fstab.puppet':
  source      =>  '/etc/fstab',
  ensure      =>  file,
  }
  file{'/tmp/puppet.link':
  ensure      =>  link,
  target      =>  '/tmp/puppet.file',
  }
  [root@node2 mainfests]# puppet apply -v -d test2.pp
  3、exec示例
  [root@node2 mainfests]# vim test3.pp
  exec{'/usr/sbin/modprobe ext4':
  user    =>  root,
  group   =>  root,
  refresh =>  '/usr/sbin/modprobe -r ext4 && /usr/sbin/modprobe ext4',
  timeout =>  5,
  tries   =>  2,
  }
  exec {'/bin/echo hello > /tmp/hello.txt':
  user    =>  root,
  group   =>  root,
  creates =>  '/tmp/hello.txt',
  }
  exec {'/bin/echo hello > /tmp/hello2.txt':
  user    =>  root,
  group   =>  root,
  unless  =>  '/usr/bin/test -e /tmp/hello2.txt',
  }
  [root@node2 mainfests]# puppet apply -v test3.pp
  Notice: Compiled catalog for node2 in environment production in 0.23 seconds
  Info: Applying configuration version '1480822653'
  Notice: /Stage[main]/Main/Exec[/usr/sbin/modprobe ext4]/returns: executed successfully
  Notice: Finished catalog run in 0.06 seconds
  4、notify示例
  [root@node2 mainfests]# vim test4.pp
  notify{"hello there.":}
  [root@node2 mainfests]# puppet apply -v test4.pp
  Notice: Compiled catalog for node2 in environment production in 0.09 seconds
  Info: Applying configuration version '1480823772'
  Notice: hello there.
  Notice: /Stage[main]/Main/Notify[hello there.]/message: defined 'message' as 'hello there.'
  Notice: Finished catalog run in 0.06 seconds
  5、cron示例
  [root@node2 mainfests]# vim test5.pp
  cron{"sync time":
  command     =>  '/usr/sbin/ntpdate 192.168.1.62 &> /dev/null',
  minute      =>  '*/10',
  ensure      =>  absent,
  }   
  [root@node2 mainfests]# puppet apply -v test5.pp
  Notice: Compiled catalog for node2 in environment production in 0.26 seconds
  Info: Applying configuration version '1480824444'
  Notice: /Stage[main]/Main/Cron[sync time]/ensure: created
  Notice: Finished catalog run in 0.11 seconds
  
  03puppet配置语言
  6、package示例
  [root@node2 ~]# ls jdk-8u25-linux-x64.rpm
  jdk-8u25-linux-x64.rpm
  [root@node2 ~]# mv jdk-8u25-linux-x64.rpm /usr/local/src/
  [root@node2 ~]# cd mainfests/
  [root@node2 mainfests]# vim test6.pp
  package{'zsh':
  ensure      =>  latest,
  }   
  package{'jdk':
  ensure      =>  installed,
  source      =>  '/usr/local/src/jdk-8u25-linux-x64.rpm',
  provider    =>  rpm,
  }   
  [root@node2 mainfests]# puppet apply -v test6.pp
  Notice: Compiled catalog for node2 in environment production in 1.05 seconds
  Info: Applying configuration version '1480827477'
  Notice: /Stage[main]/Main/Package[zsh]/ensure: created
  Notice: /Stage[main]/Main/Package[jdk]/ensure: created
  Notice: Finished catalog run in 424.65 seconds
  7、service示例
  [root@node2 mainfests]# vim test7.pp
  package{'nginx':
  ensure      =>  latest,
  }   
  service{'nginx':
  ensure      =>  running,
  enable      =>  true,
  hasrestart  =>  true,
  restart     =>  'systemctl>
  }   
  [root@node2 mainfests]# puppet apply -v test7.pp
  Notice: Compiled catalog for node2 in environment production in 1.24 seconds
  Info: Applying configuration version '1480836821'
  Notice: /Stage[main]/Main/Package[nginx]/ensure: created
  Notice: /Stage[main]/Main/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
  Info: /Stage[main]/Main/Service[nginx]: Unscheduling refresh on Service[nginx]
  Notice: Finished catalog run in 41.21 seconds
  [root@node2 mainfests]# vim test8.pp
  group {'linux':
  gid     => 3000,
  ensure  => present,
  }
  user {'suse':
  uid     => 3000,
  gid     => 3000,
  shell   => '/bin/bash',
  home    => '/home/suse',
  ensure  => present,
  }
  [root@node2 mainfests]# puppet apply -v test8.pp
  Notice: Compiled catalog for node2 in environment production in 0.60 seconds
  Info: Applying configuration version '1480837614'
  Notice: /Stage[main]/Main/Group[linux]/ensure: created
  Notice: /Stage[main]/Main/User[suse]/ensure: created
  Notice: Finished catalog run in 0.24 seconds
  8、特殊属性
  [root@node2 mainfests]# mkdir -p /root/modules/nginx/flies
  [root@node2 mainfests]# cp /etc/nginx/nginx.conf /root/modules/nginx/flies/
  [root@node2 mainfests]# vim /root/modules/nginx/flies/nginx.conf
  修改
  worker_processes auto;
  
  worker_processes 2;
  修改
  listen       80
  
  listen       8080
  [root@node2 mainfests]# vim test9.pp
  package{'nginx':
  ensure      =>  latest,
  }
  file{'/etc/nginx/nginx.conf':
  ensure      =>  file,
  source      =>  '/root/modules/nginx/flies/nginx.conf',
  require     =>  Package['nginx'],
  notify      =>  Service['nginx'],
  }
  service{'nginx':
  ensure      =>  running,
  enable      =>  true,
  hasrestart  =>  true,
  #restart        =>  'systemctl>
  require     =>  [ Package['nginx'], File['/etc/nginx/nginx.conf'] ],
  }
  [root@node2 mainfests]# puppet apply -v test9.pp
  Notice: Compiled catalog for node2 in environment production in 1.43 seconds
  Info: Applying configuration version '1480854538'
  Notice: Finished catalog run in 4.68 seconds
  [root@node2 mainfests]# service nginx stop
  Redirecting to /bin/systemctl stop  nginx.service
  [root@node2 mainfests]# vim /etc/nginx/nginx.conf
  修改
  worker_processes 2;
  
  worker_processes auto;
  
  [root@node2 mainfests]# puppet apply -v test9.pp
  Notice: Compiled catalog for node2 in environment production in 1.45 seconds
  Info: Applying configuration version '1480855179'
  Info: Computing checksum on file /etc/nginx/nginx.conf
  Info: FileBucket got a duplicate file {md5}93bc8e01bfd45e7e18b23acc178ae25b
  Info: /Stage[main]/Main/File[/etc/nginx/nginx.conf]: Filebucketed /etc/nginx/nginx.conf to puppet with sum 93bc8e01bfd45e7e18b23acc178ae25b
  Notice: /Stage[main]/Main/File[/etc/nginx/nginx.conf]/content: content changed '{md5}93bc8e01bfd45e7e18b23acc178ae25b' to '{md5}456ddb9d4209543dab23207931473c91'
  Notice: /Stage[main]/Main/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
  Info: /Stage[main]/Main/Service[nginx]: Unscheduling refresh on Service[nginx]
  Notice: Finished catalog run in 5.29 seconds
  [root@node2 mainfests]# vim /root/modules/nginx/flies/nginx.conf
  修改
  worker_processes 2;
  
  worker_processes 3;
  修改
  listen       80 default_server;
  
  listen       808 default_server;
  
  [root@node2 mainfests]# puppet apply -v test9.pp
  Notice: Compiled catalog for node2 in environment production in 1.41 seconds
  Info: Applying configuration version '1480857702'
  Info: Computing checksum on file /etc/nginx/nginx.conf
  Info: /Stage[main]/Main/File[/etc/nginx/nginx.conf]: Filebucketed /etc/nginx/nginx.conf to puppet with sum 456ddb9d4209543dab23207931473c91
  Notice: /Stage[main]/Main/File[/etc/nginx/nginx.conf]/content: content changed '{md5}456ddb9d4209543dab23207931473c91' to '{md5}5aeb19c0057030b2990920a929d8aed3'
  Info: /Stage[main]/Main/File[/etc/nginx/nginx.conf]: Scheduling refresh of Service[nginx]
  Notice: /Stage[main]/Main/Service[nginx]: Triggered 'refresh' from 1 events
  Notice: Finished catalog run in 4.98 seconds
  9、变量
  [root@node2 mainfests]# vim test10.pp
  $webserver=nginx
  package{$webserver:
  ensure      =>  latest,
  }
  file{'/etc/nginx/nginx.conf':
  ensure      =>  file,
  source      =>  '/root/modules/nginx/flies/nginx.conf',
  require     =>  Package['nginx'],
  notify      =>  Service['nginx'],
  }
  service{'nginx':
  ensure      =>  running,
  enable      =>  true,
  hasrestart  =>  true,
  #restart        =>  'systemctl>
  require     =>  [ Package['nginx'], File['/etc/nginx/nginx.conf'] ],
  }
  [root@node2 mainfests]# puppet apply -v test10.pp
  Notice: Compiled catalog for node2 in environment production in 1.42 seconds
  Info: Applying configuration version '1480938332'
  Notice: Finished catalog run in 18.48 seconds
  [root@node2 mainfests]# systemctl stop nginx.service
  [root@node2 mainfests]# yum -y remove nginx
  [root@node2 mainfests]# rm -rf /etc/nginx/
  [root@node2 mainfests]# puppet apply -v test10.pp
  Notice: Compiled catalog for node2 in environment production in 1.44 seconds
  Info: Applying configuration version '1480938505'
  Notice: /Stage[main]/Main/Package[nginx]/ensure: created
  Info: Computing checksum on file /etc/nginx/nginx.conf
  Info: FileBucket got a duplicate file {md5}93bc8e01bfd45e7e18b23acc178ae25b
  Info: /Stage[main]/Main/File[/etc/nginx/nginx.conf]: Filebucketed /etc/nginx/nginx.conf to puppet with sum 93bc8e01bfd45e7e18b23acc178ae25b
  Notice: /Stage[main]/Main/File[/etc/nginx/nginx.conf]/content: content changed '{md5}93bc8e01bfd45e7e18b23acc178ae25b' to '{md5}5aeb19c0057030b2990920a929d8aed3'
  Info: /Stage[main]/Main/File[/etc/nginx/nginx.conf]: Scheduling refresh of Service[nginx]
  Notice: /Stage[main]/Main/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
  Info: /Stage[main]/Main/Service[nginx]: Unscheduling refresh on Service[nginx]
  Notice: Finished catalog run in 12.16 seconds
  10、if语句
  [root@node2 mainfests]# vim test11.pp
  if $processorcount>1 {
  notice("SMP Host.")
  } else {
  notice("Poor Guy.")
  }   
  [root@node2 mainfests]# puppet apply -v test11.pp
  Notice: Scope(Class[main]): SMP Host.
  Notice: Compiled catalog for node2 in environment production in 0.10 seconds
  Info: Applying configuration version '1480939461'
  Notice: Finished catalog run in 0.02 seconds
  [root@node2 mainfests]# vim test12.pp
  if $operatingsystem =~ /^(?i-mx:(centos|redhat|fedora|ubuntu))/ {
  notice("Welcome to $1 distribute linux.")
  }   
  [root@node2 mainfests]# puppet apply -v test12.pp
  Notice: Scope(Class[main]): Welcome to CentOS distribute linux.
  Notice: Compiled catalog for node2 in environment production in 0.10 seconds
  Info: Applying configuration version '1480940033'
  Notice: Finished catalog run in 0.05 seconds
  04puppet类、模板及模块
  1、类声明方式1
  [root@node2 mainfests]# vim test13.pp
  class nginx {
  $webserver=nginx
  package{$webserver:
  ensure      =>  latest,
  }
  file{'/etc/nginx/nginx.conf':
  ensure      =>  file,
  source      =>  '/root/modules/nginx/flies/nginx.conf',
  require     =>  Package['nginx'],
  notify      =>  Service['nginx'],
  }
  service{'nginx':
  ensure      =>  running,
  enable      =>  true,
  hasrestart  =>  true,
  #restart        =>  'systemctl>
  require     =>  [ Package['nginx'], File['/etc/nginx/nginx.conf'] ],
  }
  }
  include nginx
  [root@node2 mainfests]# systemctl stop nginx.service
  [root@node2 mainfests]# yum -y remove nginx
  [root@node2 mainfests]# rm -rf /etc/nginx/
  [root@node2 mainfests]# puppet apply -v test13.pp   
  Notice: Compiled catalog for node2 in environment production in 1.41 seconds
  Info: Applying configuration version '1481026945'
  Notice: /Stage[main]/Nginx/Package[nginx]/ensure: created
  Info: Computing checksum on file /etc/nginx/nginx.conf
  Info: FileBucket got a duplicate file {md5}93bc8e01bfd45e7e18b23acc178ae25b
  Info: /Stage[main]/Nginx/File[/etc/nginx/nginx.conf]: Filebucketed /etc/nginx/nginx.conf to puppet with sum 93bc8e01bfd45e7e18b23acc178ae25b
  Notice: /Stage[main]/Nginx/File[/etc/nginx/nginx.conf]/content: content changed '{md5}93bc8e01bfd45e7e18b23acc178ae25b' to '{md5}5aeb19c0057030b2990920a929d8aed3'
  Info: /Stage[main]/Nginx/File[/etc/nginx/nginx.conf]: Scheduling refresh of Service[nginx]
  Notice: /Stage[main]/Nginx/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
  Info: /Stage[main]/Nginx/Service[nginx]: Unscheduling refresh on Service[nginx]
  Notice: Finished catalog run in 917.40 seconds
  2、类声明方式2
  [root@node2 mainfests]# vim test14.pp
  class nginx($webserver='nginx') {
  package{$webserver:
  ensure      =>  latest,
  }
  file{'/etc/nginx/nginx.conf':
  ensure      =>  file,
  source      =>  '/root/modules/nginx/flies/nginx.conf',
  require     =>  Package['nginx'],
  notify      =>  Service['nginx'],
  }
  service{'nginx':
  ensure      =>  running,
  enable      =>  true,
  hasrestart  =>  true,
  #restart        =>  'systemctl>
  require     =>  [ Package['nginx'], File['/etc/nginx/nginx.conf'] ],
  }
  }
  class {'nginx':
  webserver => 'tengine',
  }
  3、子类调用父类
  [root@node2 mainfests]# vim test15.pp
  class nginx {
  package {'nginx':
  ensure  =>  latest,
  } ->
  service{'nginx':
  enable      =>  true,
  ensure      =>  running,
  hasrestart  =>  true,
  restart     =>  'service nginx>
  }   
  }
  class nginx::webserver inherits nginx {
  file{'/etc/nginx/nginx.conf':
  source  => /root/modules/nginx/files/nginx_web.conf,
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  class nginx::proxy inherits nginx {
  file{'/etc/nginx/nginx.conf':
  source  => /root/modules/nginx/files/nginx_proxy.conf,
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  include nginx::webserverclass nginx {
  package {'nginx':
  ensure  =>  latest,
  } ->
  service{'nginx':
  enable      =>  true,
  ensure      =>  running,
  hasrestart  =>  true,
  restart     =>  'service nginx>
  }   
  }
  class nginx::webserver inherits nginx {
  file{'/etc/nginx/nginx.conf':
  source  => '/root/modules/nginx/files/nginx_web.conf',
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  class nginx::proxy inherits nginx {
  file{'/etc/nginx/nginx.conf':
  source  => '/root/modules/nginx/files/nginx_proxy.conf',
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  include nginx::webserver
  [root@node2 mainfests]# cd /root/modules/nginx/flies/
  [root@node2 flies]# cp nginx.conf nginx_web.conf
  [root@node2 flies]# cp nginx.conf nginx_proxy.conf
  [root@node2 flies]# vim nginx_proxy.conf
  修改
  location / {
  }   
  
  location / {
  proxy_pass http://192.168.1.131/;
  }   
  [root@node2 mainfests]# puppet apply -v test15.pp
  Notice: Compiled catalog for node2 in environment production in 1.49 seconds
  Info: Applying configuration version '1481031545'
  4、在子类中覆盖父类中已经定义的资源的属性值
  [root@node2 mainfests]# vim test16.pp
  class nginx {
  package {'nginx':
  ensure  =>  latest,
  name    =>  nginx,
  } ->
  service{'nginx':
  enable      =>  true,
  ensure      =>  running,
  hasrestart  =>  true,
  restart     =>  'service nginx>
  }   
  }
  class nginx::webserver inherits nginx {
  Package['nginx']{
  name    =>  tengine,
  }   
  file{'/etc/nginx/nginx.conf':
  source  => '/root/modules/nginx/files/nginx_web.conf',
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  class nginx::proxy inherits nginx {
  file{'/etc/nginx/nginx.conf':
  source  => '/root/modules/nginx/files/nginx_proxy.conf',
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  include nginx::webserver
  [root@node2 mainfests]# puppet apply -v test16.pp
  Notice: Compiled catalog for node2 in environment production in 1.40 seconds
  Info: Applying configuration version '1481112014'
  Error: /Stage[main]/Nginx::Webserver/File[/etc/nginx/nginx.conf]: Could not evaluate: Could not retrieve information from environment production source(s) file:/root/modules/nginx/files/nginx_web.conf
  Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y list tengine' returned 1: Error: No matching Packages to list
  Error: /Stage[main]/Nginx/Package[nginx]/ensure: change from absent to latest failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y list tengine' returned 1: Error: No matching Packages to list
  Notice: /Stage[main]/Nginx/Service[nginx]: Dependency Package[nginx] has failures: true
  Notice: /Stage[main]/Nginx/Service[nginx]: Dependency File[/etc/nginx/nginx.conf] has failures: true
  Warning: /Stage[main]/Nginx/Service[nginx]: Skipping because of failed dependencies
  Notice: Finished catalog run in 5.41 seconds
  5、模板
  [root@node2 mainfests]# cd /root/modules/nginx/files/
  [root@node2 flies]# vim nginx_proxy.conf
  修改
  worker_processes 3;
  
  worker_processes <%= @processorcount %>;
  [root@node2 flies]# cd -
  /root/mainfests
  [root@node2 mainfests]# vim test16.pp
  修改
  source  => '/root/modules/nginx/files/nginx_proxy.conf',
  
  content => template('/root/modules/nginx/files/nginx_proxy.conf'),
  修改
  include nginx::webserver
  
  include nginx::proxy
  [root@node2 mainfests]# puppet apply -v test16.pp
  Notice: Compiled catalog for node2 in environment production in 1.35 seconds
  Info: Applying configuration version '1481113843'
  Info: Computing checksum on file /etc/nginx/nginx.conf
  Info: /Stage[main]/Nginx::Proxy/File[/etc/nginx/nginx.conf]: Filebucketed /etc/nginx/nginx.conf to puppet with sum 5aeb19c0057030b2990920a929d8aed3
  Notice: /Stage[main]/Nginx::Proxy/File[/etc/nginx/nginx.conf]/content: content changed '{md5}5aeb19c0057030b2990920a929d8aed3' to '{md5}a7a50e95d479630c400907a161a348b8'
  Info: /Stage[main]/Nginx::Proxy/File[/etc/nginx/nginx.conf]: Scheduling refresh of Service[nginx]
  Notice: /Stage[main]/Nginx/Service[nginx]: Triggered 'refresh' from 1 events
  Notice: Finished catalog run in 22.55 seconds
  6、模块
  #列出可用模块
  [root@node2 ~]# puppet module list
  /etc/puppet/modules (no modules installed)
  /usr/share/puppet/modules (no modules installed)
  #查找模块
  [root@node2 ~]# puppet module search nginx
  #安装模块
  [root@node2 ~]# puppet module install nginx
  #创建模块
  [root@node2 ~]# mkdir -p /etc/puppet/modules/nginx/{mainfets,files,templates,tests,lib,spec}
  [root@node2 ~]# puppet module list                                                         
  /etc/puppet/modules
  └── nginx (???)
  /usr/share/puppet/modules (no modules installed)
  [root@node2 ~]# cd mainfests/
  [root@node2 mainfests]# cp test16.pp /etc/puppet/modules/nginx/mainfets/init.pp
  [root@node2 mainfests]# cp /root/modules/nginx/files/nginx_web.conf /etc/puppet/modules/nginx/files/
  [root@node2 mainfests]# cp /root/modules/nginx/files/nginx_proxy.conf /etc/puppet/modules/nginx/templates/nginx_proxy.conf.erb
  [root@node2 mainfests]# cd /etc/puppet/modules/nginx/
  [root@node2 nginx]# ls
  files  lib  mainfets  spec  templates  tests
  [root@node2 nginx]# cd mainfets/
  [root@node2 mainfets]# ls
  init.pp
  [root@node2 mainfets]# vim init.pp
  class nginx {
  package {'nginx':
  ensure  =>  latest,
  name    =>  nginx,
  } ->
  service{'nginx':
  enable      =>  true,
  ensure      =>  running,
  hasrestart  =>  true,
  restart     =>  'service nginx>
  }   
  }
  class nginx::webserver inherits nginx {
  Package['nginx']{
  name    =>  tengine,
  }   
  file{'/etc/nginx/nginx.conf':
  source  => 'puppet:///modules/nginx/nginx_web.conf',
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  class nginx::proxy inherits nginx {
  file{'/etc/nginx/nginx.conf':
  content => template('nginx/nginx_proxy.conf.erb'),
  ensure  =>  file,
  notify  =>  Service['nginx'],
  }   
  }
  [root@node2 mainfets]# systemctl stop nginx.service
  [root@node2 mainfets]# yum -y remove nginx
  [root@node2 mainfets]# rm -rf /etc/nginx/
  [root@node2 mainfets]# puppet apply --noop -v -e 'include nginx::proxy'

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-544950-1-1.html 上篇帖子: puppet安装应用 下篇帖子: 46 puppet master-agent模型、运维工具介绍及pxe环境的实现、cobbler简单实现、CentOS7 cobbler
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表