foreman架構的引入4-安裝Foreman1.6.3架構(foreman與puppetmaster分離)

零基礎學習Puppet自動化配置管理系列文檔html

注意:本實驗是在離線狀況下安裝的,因此須要在本地建立本身的yum倉庫,建立方法可參考《如何根據版本製做屬於本身的puppet yum源》,如何你實在是比較懶或者搞不定rpm包之間的依賴關係,那就去個人github上下載吧:https://github.com/kisspuppet/foreman-reponode

更多安裝細節請參考官網:http://theforeman.org/manuals/1.6/index.htmlmysql

以前講的all-in-one方式建議只用於測試使用,若是要用於生產環境,建議將foreman和puppetmaster分離安裝,更有利於後期的維護和擴展。還有就是以前你已經部署過puppetmaster了,如何單獨部署foreman和puppetmaster通訊也是值得考慮的問題。linux

一、軟件包的選型以下:

  • puppet-server 3.6.2git

  • puppet 3.6.2github

  • facter 2.0.2web

  • mcollective 2.2.4sql

  • rabbitmq-server 3.2.4數據庫

  • foreman 1.6.3vim

  • foreman-proxy 1.6.3

二、系統環境準備

Foreman安裝

三、安裝puppetmaster

3.一、安裝puppetmaster,並生成CA和證書

[root@puppetmaster162 ~]# yum install puppet puppet-server facter
[root@puppetmaster162 puppet]# vim /etc/puppet/puppet.conf
[agent]
server = puppetmaster162.kisspuppet.com
pluginsync = false
...
[master]
certname = puppetmaster162.kisspuppet.com
environmentpath  = /etc/puppet/environments
basemodulepath   = /etc/puppet/modules:/usr/share/puppet/modules  
environment_timeout = 10

[root@puppetmaster162 ~]# /etc/init.d/puppetmaster start
Starting puppetmaster:                                     [  OK  ]
[root@puppetmaster162 ~]# puppet cert --list --all
+ "puppetmaster162.kisspuppet.com" (SHA256) 2E:B3:73:4F:CD:EE:0C:64:2C:DF:24:E6:D3:62:F3:1C:AC:A3:28:60:67:1D:0C:8C:C5:CA:68:5B:4B:2F:49:B9 (alt names: "DNS:puppet", "DNS:puppet.kisspuppet.com", "DNS:puppetmaster162.kisspuppet.com")

3.二、測試puppetmaster是否可以正常使用

[root@puppetmaster162 ~]# puppet agent -t
Info: Caching catalog for puppetmaster162.kisspuppet.com
Info: Applying configuration version '1417749612'
Notice: Finished catalog run in 0.04 seconds

注:以上安裝方式,puppetmaster工做在Webrick上,性能很是差,須要更換爲性能好的web服務器上,若是更換,請參考http://kisspuppet.com/2014/10/18/puppet_learning_ext3/ http://kisspuppet.com/2014/10/20/puppet_learning_ext4/

四、安裝Foreman

4.一、安裝puppet客戶端並完成認證

#安裝
[root@foreman163 ~]# yum install puppet facter
[root@foreman163 ~]# vim /etc/puppet/puppet.conf 
[main]
...
privatekeydir = $ssldir/private_keys { group = service }  
hostprivkey = $privatekeydir/$certname.pem { mode = 640 }

[agent]
server = puppetmaster162.kisspuppet.com
pluginsync = false

#申請認證
[root@foreman163 ~]# puppet  agent -t
Info: Creating a new SSL key for foreman163.kisspuppet.com
Info: Caching certificate for ca
Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml
Info: Creating a new SSL certificate request for     
Info: Certificate Request fingerprint (SHA256): 35:5D:E5:74:71:E0:FD:D2:67:34:17:92:3D:60:F2:A1:34:26:BA:E5:2D:1F:3A:0E:07:6F:85:38:A8:39:8B:65
Info: Caching certificate for ca
Exiting; no certificate found and waitforcert is disabled

#受權證書
[root@puppetmaster162 ~]# puppet cert --sign foreman163.kisspuppet.com
Notice: Signed certificate request for foreman163.kisspuppet.com
Notice: Removing file Puppet::SSL::CertificateRequest foreman163.kisspuppet.com at '/var/lib/puppet/ssl/ca/requests/foreman163.kisspuppet.com.pem'

#測試
[root@foreman163 ~]# puppet  agent -t
Info: Caching catalog for foreman163.kisspuppet.com
Info: Applying configuration version '1417749612'
Notice: Finished catalog run in 0.05 seconds

4.二、經過foreman-installer安裝foreman

foreman默認安裝選擇的數據庫爲postgresql,這裏選用mysql進行安裝。

注意:openssl版本要升級到1.0.1e版本

#先安裝包
[root@foreman163 ~]# yum install foreman-installer foreman  mod_passenger mod_ssl ruby193-rubygem-passenger-native mysql mysql-server foreman-mysql2   openssl
...
Updated:
  openssl.x86_64 0:1.0.1e-15.el6                                                   
Replaced:
  ruby193-v8.x86_64 1:3.14.5.10-2.el6                                              
Complete!

#而後經過foreman-installer調用puppet進行配置
[root@foreman163 ~]# foreman-installer --foreman-db-adapter mysql2 --foreman-db-type mysql --no-enable-puppet --no-enable-foreman-proxy --foreman-configure-epel-repo=false
Installing             Done                                               [100%] []
  Success!
  * Foreman is running at https://foreman163.kisspuppet.com
      Initial credentials are admin / 2kWcqJsW6cLDwo7m
  The full log is at /var/log/foreman-installer/foreman-installer.log

注:以上安裝完成以後,默認登陸密碼爲隨機密碼,這跟以前版本有所不一樣。

安裝完成以後,經過火狐或者谷歌瀏覽器訪問看是否安裝成功https://192.168.20.11

Foreman安裝

Foreman安裝

記得修改默認密碼,不然待會忘了又登陸不了了。 Foreman安裝

五、安裝Foreman-proxy

注:這裏的foreman-proxy主要是代理puppet以及puppetca,因此要安裝在puppetmaster上。

5.一、安裝foreman-proxy

[root@puppetmaster162 ~]# yum install foreman-installer foreman-proxy tftp-server syslinux

[root@puppetmaster162 yum.repos.d]# foreman-installer --no-enable-foreman --no-enable-foreman-cli --no-enable-foreman-plugin-bootdisk --no-enable-foreman-plugin-setup --no-enable-puppet --enable-foreman-proxy  --foreman-proxy-puppetrun=true  --foreman-proxy-puppetrun-provider=mcollective  --foreman-proxy-puppetca=true   --foreman-proxy-dhcp=false  --foreman-proxy-tftp=false  --foreman-proxy-dns=false --foreman-proxy-register-in-foreman=false  --foreman-configure-epel-repo=false --foreman-configure-scl-repo=false
Installing             Done                                               [100%] []
  Success!
  * Foreman Proxy is running at https://puppetmaster162.kisspuppet.com:8443
  The full log is at /var/log/foreman-installer/foreman-installer.log

#檢測8443端口
[root@puppetmaster162 ~]# netstat -nlatp | grep 8443
tcp        0      0 0.0.0.0:8443                0.0.0.0:*                   LISTEN      4635/ruby

5.二、設置ENC

#從foreman-installer中獲取node.rb(貌似不能用,能夠經過all-in-one方式安裝後獲取)
[root@puppetmaster162 ~]# cp /usr/share/foreman-installer/modules/foreman/files/foreman-report_v2.rb  /etc/puppet/node.rb

[root@puppetmaster162 ~]# chown puppet. /etc/puppet/node.rb  #設置屬組和屬主都爲puppet
[root@puppetmaster162 ~]# chmod 550 /etc/puppet/node.rb  #設置執行權限

5.三、設置report

#從foreman-installer中獲取foreman.rb
[root@puppetmaster162 ~]# cp /usr/share/foreman-installer/modules/foreman/files/foreman-report_v2.rb  /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb

5.四、設置鏈接foreman的信息

#這裏跟foreman1.5版本(包括1.5版本)不同,請注意
[root@puppetmaster162 puppet]# vim /etc/puppet/foreman.yaml 
---
:url: "https://foreman163.kisspuppet.com"
:ssl_ca: "/var/lib/puppet/ssl/certs/ca.pem"
:ssl_cert: "/var/lib/puppet/ssl/certs/puppetmaster162.kisspuppet.com.pem"
:ssl_key: "/var/lib/puppet/ssl/private_keys/puppetmaster162.kisspuppet.com.pem"
:user: ""
:password: ""
:puppetdir: "/var/lib/puppet"
:puppetuser: "puppet"
:facts: true
:timeout: 10
:threads: null
[root@puppetmaster162 ~]# /etc/init.d/foreman-proxy restart
Stopping foreman-proxy:                                    [  OK  ]
Starting foreman-proxy:                                    [  OK  ]

六、註冊puppet和puppetca

6.一、在puppetmaster上添加ENC配置和foreman報告

[root@puppetmaster162 ~]# vim /etc/puppet/puppet.conf 
[master]
    ...
    reports        = foreman
    external_nodes = /etc/puppet/node.rb
    node_terminus  = exec
#重啓生效
[root@puppetmaster162 ~]# /etc/init.d/puppetmaster restart
Stopping puppetmaster:                                     [  OK  ]
Starting puppetmaster:                                     [  OK  ]

6.二、登陸foreman註冊foreman-proxy

Foreman安裝

6.三、節點測試

[root@foreman163 ~]# puppet  agent -t
Info: Caching catalog for foreman163.kisspuppet.com
Info: Applying configuration version '1417762929'
Notice: Finished catalog run in 0.13 seconds
[root@puppetmaster162 ~]# puppet  agent -t 
Info: Caching catalog for puppetmaster162.kisspuppet.com
Info: Applying configuration version '1417762858'
Notice: Finished catalog run in 0.14 seconds

Foreman安裝

注:若是測試報錯,請將foreman中的puppet插件的enc_environment選項設置爲false,具體如何使用後續講解

關於如何設置和使用foreman,請關注後續文章....

@KissPuppet

2014年10月28號 上海

返回主目錄

交流方式:

微信公衆號:puppet2014,可微信搜索加入,也能夠掃描如下二維碼進行加入

微信公衆號

QQ交流羣:296934942

QQ交流羣

相關文章
相關標籤/搜索