foreman架构的引入6-整合puppetmaster

零基础学习Puppet自动化配置管理系列文档

注:以下内容是在foreman1.6.3+puppet2.6.2环境下进行操作。更多配置请参考官网http://theforeman.org/manuals/1.6/index.html

安装好foreman和puppetmaster之后,接下来做的事情就是做整合,目前foreman可以管理puppet的环境、类、类里的变量、报告、facter等信息。接下来会逐一进行介绍。

1、首先要保证智能代理已经代理了puppet和puppet CA

Foreman安装

代理puppet以及puppetCA,需要在foreman-proxy中开启。

#配置代理puppet
[[email protected] ~]# cat /etc/foreman-proxy/settings.d/puppet.yml 
---
# Puppet management
:enabled: true   #开启
:puppet_conf: /etc/puppet/puppet.conf
# valid providers:
#   puppetrun   (for puppetrun/kick, deprecated in Puppet 3)
#   mcollective (uses mco puppet)
#   puppetssh   (run puppet over ssh)
#   salt        (uses salt puppet.run)
#   customrun   (calls a custom command with args)
:puppet_provider: mcollective
# customrun command details
# Set :customrun_cmd to the full path of the script you want to run, instead of /bin/false
:customrun_cmd: /bin/false
# Set :customrun_args to any args you want to pass to your custom script. The hostname of the
# system to run against will be appended after the custom commands.
:customrun_args: -ay -f -s
# whether to use sudo before the ssh command
:puppetssh_sudo: false
# the command which will be sent to the host
:puppetssh_command: /usr/bin/puppet agent --onetime --no-usecacheonfailure
# With which user should the proxy connect
#:puppetssh_user: root
#:puppetssh_keyfile: /etc/foreman-proxy/id_rsa
# Which user to invoke sudo as to run puppet commands
:puppet_user: root
# URL of the puppet master itself for API requests
:puppet_url: https://puppetmaster162.kisspuppet.com:8140
# SSL certificates used to access the puppet master API
:puppet_ssl_ca: /var/lib/puppet/ssl/certs/ca.pem
:puppet_ssl_cert: /var/lib/puppet/ssl/certs/puppetmaster162.kisspuppet.com.pem
:puppet_ssl_key: /var/lib/puppet/ssl/private_keys/puppetmaster162.kisspuppet.com.pem
# Override use of Puppet‘s API to list environments, by default it will use only if
# environmentpath is given in puppet.conf, else will look for environments in puppet.conf
#:puppet_use_environment_api: true

#配置代理puppet ca
[[email protected] ~]# cat /etc/foreman-proxy/settings.d/puppetca.yml 
---
# PuppetCA management
:enabled: true
:ssldir: /var/lib/puppet/ssl
:puppetdir: /etc/puppet

2、管理puppet环境

2.1、配置puppetmaster环境

puppet从2.6版本开始增加了“目录环境”的功能,更多详情请访问官网https://docs.puppetlabs.com/puppet/latest/reference/environments.html

[[email protected] ~]# cat /etc/puppet/puppet.conf 
[master]
    ...
    environmentpath  = /etc/puppet/environments
    basemodulepath   = /etc/puppet/modules:/usr/share/puppet/modules
    environment_timeout = 2  #多长时间刷新一次

[[email protected] ~]# ll /etc/puppet/environments/
total 24
drwxr-xr-x 4 root root 4096 Dec  5 16:46 development
drwxr-xr-x 4 root root 4096 Dec  5 16:46 example42
drwxr-xr-x 4 root root 4096 Dec  5 16:39 example_env
drwxr-xr-x 5 root root 4096 Dec  5 17:03 production
drwxr-xr-x 4 root root 4096 Dec  5 16:46 puppetlabs
drwxr-xr-x 7 root root 4096 Dec  5 17:03 temp

注意:从以上配置可以看得出设置了两个环境。

2.2、foreman上导入puppet环境

Foreman安装

3、管理puppet类

3.1、配置puppet类

注意以下几点:

  • puppet.conf中basemodulepath的值所设置的路径为环境目录下所有环境的公共环境,里面的所有模块都会被其他环境搜索到(在没有配置environment.conf的前提下)
  • 环境目录中每个环境目录里面默认应该包含manifests(存放主配置文件site.pp)目录和modules(存放模块)目录,目录结构如下。
      [[email protected] environments]# tree production/
      production/
      ├── environment.conf
      ├── manifests
      │   └── site.pp
      ├── modules
      │   ├── jenkins
      │   │   ├── files
      │   │   │   └── jenkins.repo
      │   │   ├── manifests
      │   │   │   ├── init.pp
      │   │   │   ├── install.pp
      │   │   │   ├── service.pp
      │   │   │   └── yum.pp
      │   │   ├── README
      │   │   └── templates
      │   └── motd
      │       ├── files
      │       │   └── motd
      │       ├── manifests
      │       │   └── init.pp
      │       └── templates
      └── system
          └── ssh
              ├── files
              ├── manifests
              │   ├── backup.pp
              │   ├── config.pp
              │   ├── init.pp
              │   ├── install.pp
              │   └── service.pp
              ├── Modulefile
              ├── README
              ├── spec
              │   └── spec_helper.rb
              ├── templates
              │   └── sshd_config.erb
              └── tests
                  └── init.pp
      17 directories, 20 files
  • 如果你想在一个环境里包含多个目录,每个目录里面又包含模块,应该添加environment.conf文件
      [[email protected] environments]# ll temp/
      total 24
      -rw-r--r--  1 root root   95 Dec  5 17:03 environment.conf  #添加环境搜索配置文件
      drwxr-xr-x 11 root root 4096 Dec  5 17:02 juhailu
      drwxr-xr-x  2 root root 4096 Dec  5 16:48 kisspuppet
      drwxr-xr-x  4 root root 4096 Dec  5 16:56 lin
      drwxr-xr-x  2 root root 4096 Dec  5 16:48 manifests
      drwxr-xr-x  5 root root 4096 Dec  5 16:47 puppetlabs
      [[email protected] environments]# ll temp/puppetlabs/
      total 12
      drwxr-xr-x 5 root root 4096 Dec  5 16:46 propuppet-demoapp
      drwxr-xr-x 5 root root 4096 Dec  5 16:46 puppetlabs-demoapp
      drwxr-xr-x 4 root root 4096 Dec  5 16:46 puppet-module-skeleton
      [[email protected] environments]# cat temp/environment.conf #添加搜索路径
      modulepath = $basemodulepath:puppetlabs:modules:lin:modules:juhailu:modules:kisspuppet:modules

注意:添加搜索路径需要添加$basemodulepath,否则不会去搜索默认公共环境路径。

3.2、Foreman上导入puppet类

Foreman安装

4、设置ENC

4.1、通过节点直接管理模块

Foreman安装

备注:添加主类就可以了

这样节点和模块就关联上了,相当于在site.pp中添加如下代码

node  puppetmaster162.kisspuppet.com{
  include ssh
}

4.2、通过组继承模块

Foreman安装

Foreman安装

备注:如果使用组管理模块,不建议为某个节点单独勾选模块,否则你会发现如果先给节点添加了模块A,然后再给节点对应的组里添加了模块A,那么节点的puppet类哪里就会显示包含的类有两个同名的模块。

5、组与模块之间的管理

5.1、添加配置组

注:foreman从1.5版本开始增加了“配置组”功能,可以将多个模块添加到“配置组”,然后给配置组命名,这样,主机组在勾选模块的时候,只需要勾选配置组即可集成里面所有的模块

Foreman安装Foreman安装

6、查看设置是否成功

Foreman安装

Foreman安装

#可以通过以下方式查看,前提是需要先运行node.rb,可通过"puppet agent"命令或者"node.rb  <certname>" 进行触发。
[[email protected] ~]# cat /var/lib/puppet/yaml/foreman/puppetmaster162.kisspuppet.com.yaml 
---
classes:
  ssh: 
parameters:
  puppetmaster: puppetmaster162.kisspuppet.com
  hostgroup: prd
  root_pw: 
  foreman_env: production
  owner_name: Admin User
  owner_email: [email protected]

设置以上信息,可以完成ENC的功能,基本可以保障节点和class之间的勾连。可以在节点通过puppet agent命令进行测试。至于如何在foreman上进行推送,关注后续文章。

时间: 2024-08-25 23:13:21

foreman架构的引入6-整合puppetmaster的相关文章

foreman架构的引入1-foreman作为自动化运维工具为什么会如此强大

零基础学习Puppet自动化配置管理系列文档 在引入foreman之前,笔者曾经大幅度测试过puppet的另外一个生态圈前端软件,那就是KermIT(kermit.fr需要墙).说实话基于KermIT这套架构还是相当不错的,尤其是在于mcollective的各种插件结合上做的很完美,可惜社区太不活跃,软件版本更新超慢,坑超多,最终还是放弃了.不过,他的架构还是值得借鉴的,对于那些想自己在puppet前端做UI的朋友可以多参考参考. 本文引入另外一个非常出色的前端管理工具Foreman,什么是fo

foreman架构的引入4-安装Foreman1.6.3架构(foreman与puppetmaster分离)

零基础学习Puppet自动化配置管理系列文档 注意:本实验是在离线情况下安装的,所以需要在本地创建自己的yum仓库,创建方法可参考<如何根据版本制作属于自己的puppet yum源>,如何你实在是比较懒或者搞不定rpm包之间的依赖关系,那就去我的github上下载吧:https://github.com/kisspuppet/foreman-repo 更多安装细节请参考官网:http://theforeman.org/manuals/1.6/index.html 之前讲的all-in-one方

foreman架构的引入2-安装前环境准备

零基础学习Puppet自动化配置管理系列文档 Foreman官网提供了每个版本非常完善的安装步骤,无论是源码安装还是rpm包安装都变得非常方便.而且Foreman通过puppet模块对安装步骤进行了封装并提供了大量的安装参数可以传输,相当的方便.不过由于其体系过大,代理很多软件,安装的软件包超多,安装过程也并非那么简单. 以下是需要考虑的问题及解决方法 特别说明:接下来的所有的推荐说明.操作和测试都是基于目前最新版1.5.4进行的,而1.6版本只更新了2个Release,还不太稳定. 关于For

foreman架构的引入7-Foreman结合mcollective完成push动作

零基础学习Puppet自动化配置管理系列文档 注:以下内容是在foreman1.6.3+puppet2.6.2环境下进行操作.更多配置请参考官网http://theforeman.org/manuals/1.6/index.html 在foreman-proxy的1.6.3版本,至少提供了以下五种触发puppet agent命令的工具,默认使用的是puppetrun,不过已经过时,这里介绍如何使用mcollective进行触发,下个章节会介绍如何使用puppetssh触发. #   puppet

foreman架构的引入10-hostgroup如何转换为本地的fact

零基础学习Puppet自动化配置管理系列文档 在Foreman上可以根据业务逻辑设置多个主机组(Host Groups),并且可以将不同的节点加入到不同的主机组,这样在每次操作"puppet run"的时候,只需要在搜索按钮里搜索对应的主机组即可找到里面包含的所有节点,如下图所示 Foreman安装 但是,foreman目前在puppet run上对mcollective的集成度很低,基本就是只能运行一条命令.那么如果要在shell终端上通过mco命令去对这些自定义的Host Grou

Android架构设计和软硬整合完整训练:HAL&amp;Framework&amp;Native Service&amp;Android Service&amp;Best Practice

如何理解Android架构设计的初心并开发出搭载Android系统并且具备深度定制和软硬整合能力特色产品,是本课程解决的问题. 课程以Android的五大核心:HAL.Binder.Native Service.Android Service(并以AMS和WMS为例).View System为主轴,一次性彻底掌握Android的精髓. 之所以是开发Android产品的必修课,缘起于: 1,     HAL是Android Framework&Application与底层硬件整合的关键技术和必修技

Android架构设计和软硬整合完整训练

Android架构设计和软硬整合完整训练:HAL&Framework&Native Service&Android Service&Best Practice 如何理解Android架构设计的初心并开发出搭载Android系统并且具备深度定制和软硬整合能力特色产品,是本课程解决的问题. 课程以Android的五大核心:HAL.Binder.Native Service.Android Service(并以AMS和WMS为例).View System为主轴,一次性彻底掌握An

一种基于Qt的可伸缩的全异步C/S架构服务器实现(六) 整合各个模块实现功能

在前面的章节中,介绍了网络传输.任务线程池.数据库和集群四个主要功能模块.到现在为止,这些模块都还只是一种资源,没有产生实际的运行效果.对一个具备真实功能的应用来说,需要有一个整合的过程.整合方法很多,这里以典型的客户 -客户通信来举例说明. (一)类结构 1."客户端" 这个概念被抽象为一个节点类st_clientNode,每个客户端连接对应了该类的一个实例.这个类不但存储了有关该连接的所有背景信息(比如聊天程序中的用户名等),还提供了正确解释数据流的代码实现.由于想分开传输层和应用

从MVC和三层架构说到ssh整合开发-下

这章主要讲整合开发,直接从实战讲起,对与ssh的单方面了解,请继续等待我的兴许文章. 解说不到位的地方欢迎大家指正:联系方式rlovep.com 具体请看源码凝视: 全部代码下载(csdn):链接 Github链接:链接https://github.com/wpeace1212/javaBlog/tree/master/sshDemo 写文章不易,欢迎大家採我的文章,以及给出实用的评论.当然大家也能够关注一下我的github.多谢. 1.整合流程 针对一个简单项目.让大家对三层机构和MVC有一个