| 
                         由于服务端和客户端的sshs_config文件默认一样,此时将服务端的/etc/ssh/sshd_config复制到模块默认路径中去。 
- [root@master puppet]# cp /etc/ssh/sshd_config /etc/puppet/modules/ssh/files/ssh/ 
 - [root@master puppet]# chown -R puppet /etc/puppet/modules/ssh/files/ssh/ #修改权限 
 
  
9)创建测试节点配置文件,并将ssh加载进去。 
- [root@master puppet]# vim /etc/puppet/manifests/nodes/ssh.pp 
 - node 'client01.test.cn'{ 
 - include ssh 
 - } 
 -  
 - node 'client02.test.cn'{ 
 - include ssh 
 - } 
 
  
10)将测试节点载入puppet,即修改site.pp。 
- [root@master puppet]# vim /etc/puppet/manifests/site.pp 
 -  
 - import "nodes/ssh.pp" 
 
  
11)修改服务器维护的sshd_config配置文件 
- [root@master puppet]# vim /etc/puppet/modules/ssh/files/ssh/sshd_config 
 - Port 22    #修改为9922 
 
  
12)重启puppet服务 
- [root@master puppet]# systemctl restart puppetmaster.service 
 
  
2.客户端主动拉取 
一般在小规模自动化集群中,如代码上线需要重启服务时,为了防止出现网站暂时性无法访问的问题,每台客户端运行一次puppet agent  -t命令,选择模式根据客户端集群规模的大小。根据经验,一般puppet服务器到各客户端会建立ssh信任,然后自定义shell脚本,ssh批量让客户端执行puppet同步命令。 
1)Client01端: 
- [root@client01 ~]# puppet agent -t 
 - .....//省略 
 - Notice: /Stage[main]/Ssh::Config/File[/etc/ssh/sshd_config]/content: 
 - --- /etc/ssh/sshd_config    2017-08-07 10:28:25.000000000 +0800 
 - +++ /tmp/puppet-file20180806-5162-jc80yr    2018-08-06 22:25:58.726506429 +0800 
 - @@ -14,7 +14,7 @@ 
 -  # SELinux about this change. 
 -  # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER 
 -  # 
 - -#Port 22 
 - +Port 9922 
 -  #AddressFamily any 
 -  #ListenAddress 0.0.0.0 
 -  #ListenAddress :: 
 - .....//省略 
 -  
 - Client02端:....//省略 
 - Notice: /Stage[main]/Ssh::Config/File[/etc/ssh/sshd_config]/content: 
 - --- /etc/ssh/sshd_config    2017-08-07 10:28:25.000000000 +0800 
 - +++ /tmp/puppet-file20180806-4667-149tj11   2018-08-06 22:27:39.362282788 +0800 
 - @@ -14,7 +14,7 @@ 
 -  # SELinux about this change. 
 -  # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER 
 -  # 
 - -#Port 22 
 - +Port 9922 
 -  #AddressFamily any 
 -  #ListenAddress 0.0.0.0 
 -  #ListenAddress :: 
 - ......//省略 
 
  
2)此时命令在客户端执行成功,验证如下: 
- [root@client01 ~]# cat /etc/ssh/sshd_config | grep Port 
 - Port 9922 
 - #GatewayPorts no 
 
  
3)查看服务器ssh服务是否重启,端口是否生效。 
- [root@client01 ~]# netstat -tunlp | grep ssh 
 - tcp        0      0 0.0.0.0:9922            0.0.0.0:*               LISTEN      5428/sshd 
 - tcp6       0      0 :::9922                 :::*                    LISTEN      5428/sshd 
 
  
3.服务器推送同步                         (编辑:我爱故事小小网_铜陵站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |