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

[经验分享] puppet系列之nginx+foreman-TNT、运维之路

[复制链接]

尚未签到

发表于 2018-8-3 07:07:30 | 显示全部楼层 |阅读模式
  foreman架构:

  本文主要讲述搭建foreman,及集成进nginx的过程
  环境说明:
  CentOS 5.8 x86_64
  puppet version:3.1.1
  master hostname:server.domain.com
  client hostname:client.test.com
  ----------------------------------------------
  


  • 1,puppet,nginx环境
  • 均按上篇文章所部署安装好puppet,nginx,ruby等

  • 2,配置yum源
  • # rpm -ivh http://yum.theforeman.org/releases/1.1/el5/x86_64/foreman-release-1.1stable-3.el5.noarch.rpm

  • 3,安装foreman,foreman-proxy
  • # yum -y install foreman-installer
  • # ruby /usr/share/foreman-installer/generate_answers.rb
  • 分别输入三次 y
  • # yum install ruby-mysql
  • # yum -y install foreman  foreman-proxy
  • # chown foreman.foreman -R /usr/share/foreman
  • # su - foreman -s /bin/bash -c /usr/share/foreman/extras/dbmigrate
  • # vim /usr/share/foreman/config/database.yml
  • 原文件为sqllite的配置,此处改为mysql作为数据库存储
  • =================================================
  • production:
  •   adapter: mysql
  •   database: puppet
  •   username: puppet
  •   password: puppet
  •   host: localhost
  •   socket: "/tmp/mysql.sock"
  • =================================================
  • mysql> create database puppet CHARACTER SET utf8;
  • mysql> grant all privileges on puppet.* to puppet@'localhost' identified by 'puppet';
  • mysql>  flush privileges;

  • # cd /usr/share/foreman/
  • RAILS_ENV=production rake db:migrate
  • rake puppet:migrate:populate_hosts RAILS_ENV=production

  • # chown foreman.foreman /usr/share/foreman/tmp/secret_token
  • # vim /etc/foreman-proxy/settings.yml
  • ==========================================================
  • :trusted_hosts:
  • - server.domain.com
  • :puppetca: true
  • :puppet: true
  • :puppet_conf: /etc/puppet/puppet.conf
  • =========================================================
  • # /etc/init.d/foreman-proxy start  启动proxy 端口8443
  • 4,集成进nginx
  • nginx虚拟主机如下:
  • server {
  •         listen 443;
  •         server_name server.domain.com;
  •         ssl on;
  •         ssl_certificate            /var/lib/puppet/ssl/certs/server.domain.com.pem;
  •         ssl_certificate_key        /var/lib/puppet/ssl/private_keys/server.domain.com.pem;

  •         #Verify puppetmaster clients against Puppet CA
  •         ssl_crl                    /var/lib/puppet/ssl/ca/ca_crl.pem;
  •         ssl_client_certificate     /var/lib/puppet/ssl/certs/ca.pem;
  •         ssl_verify_client optional;
  •         ssl_verify_depth 1;

  •         access_log /usr/local/nginx/logs/foreman_access.log;
  •         error_log /usr/local/nginx/logs/foreman_error.log debug;
  •         root /usr/share/foreman/public;

  •         passenger_enabled on;
  •         passenger_set_cgi_param HTTPS on;
  •         passenger_set_cgi_param SSL_CLIENT_S_DN $ssl_client_s_dn;
  •         passenger_set_cgi_param SSL_CLIENT_VERIFY $ssl_client_verify;

  •        }
  • # /etc/init.d/nginxd start  ###启动nginx

  • 5,访问foreman
  • 输入网址:https://server.domain.com
  • 默认账号:admin   密码:changeme
  • 进入之后配置more-configureation-smart proxies----
  • 添加proxy地址: https://server.domain.com:8443

  • #vim /etc/puppet/node.rb
  • :url          => "https://server.domain.com",

  • 6,设置report自动导入foreman
  • # cp /usr/share/foreman-installer/foreman/templates/foreman-report.rb.erb /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb
  • # vim foreman.rb
  • 修改成一下配置,其他不变(ps:一直就是卡在住错)
  • #<%= ERB.new(File.read(File.expand_path(&quot;_header.erb&quot;,File.dirname(file)))).result(binding) -%>
  • # copy this file to your report dir - e.g. /usr/lib/ruby/1.8/puppet/reports/

  • # add this report in your puppetmaster reports - e.g, in your puppet.conf add:
  • # reports=log, foreman # (or any other reports you want)

  • # URL of your Foreman installation
  • $foreman_url = 'https://server.domain.com'
  • # if CA is specified, remote Foreman host will be verified
  • $foreman_ssl_ca = &quot;/var/lib/puppet/ssl/certs/ca.pem&quot;
  • # ssl_cert and key are required if require_ssl_puppetmasters is enabled in Foreman
  • $foreman_ssl_cert = &quot;/var/lib/puppet/ssl/certs/server.domain.com.pem&quot;
  • $foreman_ssl_key = &quot;/var/lib/puppet/ssl/private_keys/server.domain.com.pem&quot;

  • 客户端需修改
  • agent配置如下
  • [agent]
  •     classfile = $vardir/classes.txt
  •     localconfig = $vardir/localconfig
  •     report      = true
  •     pluginsync  = true
  •     masterport  = 8140
  •     environment = production
  •     certname    = client.test.com
  •     server      = server.domain.com
  •     listen      = true
  • 服务器端修改
  • [master]
  •     autosign       = $confdir/autosign.conf { mode = 664 }
  •     reports        = log,foreman
  •     external_nodes = /etc/puppet/node.rb
  •     node_terminus  = exec
  •     ca             = true
  • =======================
  • 7,class,host.facts导入foreman
  • #cd /usr/share/foreman
  • #导入hosts 和facts
  • rake puppet:import:hosts_and_facts RAILS_ENV=production
  • 把/etc/puppet/modules底下的模块都复制至/etc/puppet/modules/production
  • 在foreman web管理
  • mode---configuration---puppet classes
  • 点击import from server 即可
  

  主要截图如下:



  这样puppet系列文章已基本完成;
  在此感谢下itnihao,liu.cy的指导 (ps:为了文章的完整性,所以引用了大量itnihao文章的内容)

运维网声明 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-545572-1-1.html 上篇帖子: puppet集群部署 下篇帖子: puppet资料收集
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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