`
iswdhsohu
  • 浏览: 1198 次
  • 性别: Icon_minigender_2
最近访客 更多访客>>
社区版块
存档分类
最新评论

puppet系列之nginx+foreman

阅读更多

 foreman架构:

本文主要讲述搭建foreman,及集成进nginx的过程

环境说明:

CentOS 5.8 x86_64

puppet version:3.1.1

master hostname:server.domain.com

client hostname:client.test.com

----------------------------------------------

  1. 1,puppet,nginx环境 
  2. 均按上篇文章所部署安装好puppet,nginx,ruby等 
  3.  
  4. 2,配置yum源 
  5. # rpm -ivh http://yum.theforeman.org/releases/1.1/el5/x86_64/foreman-release-1.1stable-3.el5.noarch.rpm 
  6.  
  7. 3,安装foreman,foreman-proxy 
  8. # yum -y install foreman-installer 
  9. # ruby /usr/share/foreman-installer/generate_answers.rb 
  10. 分别输入三次 y 
  11. # yum install ruby-mysql 
  12. # yum -y install foreman  foreman-proxy  
  13. # chown foreman.foreman -R /usr/share/foreman 
  14. # su - foreman -s /bin/bash -c /usr/share/foreman/extras/dbmigrate 
  15. # vim /usr/share/foreman/config/database.yml    
  16. 原文件为sqllite的配置,此处改为mysql作为数据库存储  
  17. =================================================  
  18. production:  
  19.   adapter: mysql  
  20.   database: puppet  
  21.   username: puppet  
  22.   password: puppet  
  23.   host: localhost  
  24.   socket: "/tmp/mysql.sock"  
  25. =================================================  
  26. mysql> create database puppet CHARACTER SET utf8;  
  27. mysql> grant all privileges on puppet.* to puppet@'localhost' identified by 'puppet';  
  28. mysql>  flush privileges;  
  29.  
  30. # cd /usr/share/foreman/  
  31. RAILS_ENV=production rake db:migrate  
  32. rake puppet:migrate:populate_hosts RAILS_ENV=production  
  33.   
  34. # chown foreman.foreman /usr/share/foreman/tmp/secret_token  
  35. # vim /etc/foreman-proxy/settings.yml  
  36. ==========================================================  
  37. :trusted_hosts:  
  38. - server.domain.com  
  39. :puppetca: true  
  40. :puppet: true  
  41. :puppet_conf: /etc/puppet/puppet.conf  
  42. ========================================================= 
  43. # /etc/init.d/foreman-proxy start  启动proxy 端口8443 
  44. 4,集成进nginx 
  45. nginx虚拟主机如下: 
  46. server { 
  47.         listen 443; 
  48.         server_name server.domain.com; 
  49.         ssl on; 
  50.         ssl_certificate            /var/lib/puppet/ssl/certs/server.domain.com.pem; 
  51.         ssl_certificate_key        /var/lib/puppet/ssl/private_keys/server.domain.com.pem; 
  52.          
  53.         #Verify puppetmaster clients against Puppet CA 
  54.         ssl_crl                    /var/lib/puppet/ssl/ca/ca_crl.pem; 
  55.         ssl_client_certificate     /var/lib/puppet/ssl/certs/ca.pem; 
  56.         ssl_verify_client optional; 
  57.         ssl_verify_depth 1; 
  58.  
  59.         access_log /usr/local/nginx/logs/foreman_access.log; 
  60.         error_log /usr/local/nginx/logs/foreman_error.log debug; 
  61.         root /usr/share/foreman/public; 
  62.  
  63.         passenger_enabled on; 
  64.         passenger_set_cgi_param HTTPS on; 
  65.         passenger_set_cgi_param SSL_CLIENT_S_DN $ssl_client_s_dn; 
  66.         passenger_set_cgi_param SSL_CLIENT_VERIFY $ssl_client_verify; 
  67.  
  68.        } 
  69. # /etc/init.d/nginxd start  ###启动nginx  
  70.  
  71. 5,访问foreman 
  72. 输入网址:https://server.domain.com 
  73. 默认账号:admin   密码:changeme 
  74. 进入之后配置more-configureation-smart proxies----  
  75. 添加proxy地址: https://server.domain.com:8443 
  76.  
  77. #vim /etc/puppet/node.rb   
  78. :url          => "https://server.domain.com", 
  79.  
  80. 6,设置report自动导入foreman 
  81. # cp /usr/share/foreman-installer/foreman/templates/foreman-report.rb.erb /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb 
  82. # vim foreman.rb 
  83. 修改成一下配置,其他不变(ps:一直就是卡在住错)
  84. #<%= ERB.new(File.read(File.expand_path("_header.erb",File.dirname(file)))).result(binding) -%> 
  85. # copy this file to your report dir - e.g. /usr/lib/ruby/1.8/puppet/reports/ 
  86.  
  87. # add this report in your puppetmaster reports - e.g, in your puppet.conf add: 
  88. reports=log, foreman # (or any other reports you want) 
  89.  
  90. # URL of your Foreman installation 
  91. $foreman_url = 'https://server.domain.com' 
  92. # if CA is specified, remote Foreman host will be verified 
  93. $foreman_ssl_ca = "/var/lib/puppet/ssl/certs/ca.pem" 
  94. # ssl_cert and key are required if require_ssl_puppetmasters is enabled in Foreman 
  95. $foreman_ssl_cert = "/var/lib/puppet/ssl/certs/server.domain.com.pem" 
  96. $foreman_ssl_key = "/var/lib/puppet/ssl/private_keys/server.domain.com.pem" 
  97.  
  98. 客户端需修改 
  99. agent配置如下 
  100. [agent] 
  101.     classfile = $vardir/classes.txt 
  102.     localconfig = $vardir/localconfig 
  103.     report      = true      
  104.     pluginsync  = true 
  105.     masterport  = 8140 
  106.     environment = production 
  107.     certname    = client.test.com 
  108.     server     = server.domain.com 
  109.     listen      = true 
  110. 服务器端修改 
  111. [master] 
  112.     autosign       = $confdir/autosign.conf { mode = 664 } 
  113.     reports        = log,foreman 
  114.     external_nodes = /etc/puppet/node.rb 
  115.     node_terminus  = exec 
  116.     ca             = true 
  117. ======================= 
  118. 7,class,host.facts导入foreman 
  119. #cd /usr/share/foreman
  120. #导入hosts 和facts
  121. rake puppet:import:hosts_and_facts RAILS_ENV=production
  122. 把/etc/puppet/modules底下的模块都复制至/etc/puppet/modules/production 
  123. 在foreman web管理 
  124. mode---configuration---puppet classes 
  125. 点击import from server 即可 

主要截图如下:

 

这样puppet系列文章已基本完成;

在此感谢下itnihao,liu.cy的指导 (ps:为了文章的完整性,所以引用了大量itnihao文章的内容)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics