Puppet 实战

2023-12-17 21:04
文章标签 实战 puppet

本文主要是介绍Puppet 实战,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

官方网址:https://www.puppet.com/
架构:https://www.puppet.com/docs/puppet/5.5/architecture.html
用途: 自动化运维
库:https://forge.puppet.com/

Puppet_Labs_Logo-700x268.png

📠样例:安装Apache

这里使用Amazon Lightsail两台机器去演示,其中Server为master节点,Node为slave节点
image.png

样例步骤

  • Server中执行 设置一些基础信息
$ sudo hostnamectl set-hostname puppet
$ hostname
puppet
  • 必须让两个主机可以通信 ,你可以通过命令关闭防火墙,如果你正在使用云产品,也可以在界面中进行配置(不同云厂商在不同位置,一般在安全组进行配置)image.png

  • Server中执行 安装

$ sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
$ sudo yum install -y puppetserver
  • Server中执行 修改一些配置,根据你当前的需求进行配置

/etc/sysconfig/puppetserver
image.png

  • Server中执行 启动(如果无法启动可能是因为你的服务器资源不满足,请修改上述配置文件)
$ sudo systemctl start puppetserver
$ sudo systemctl status puppetserver
● puppetserver.service - puppetserver ServiceLoaded: loaded (/usr/lib/systemd/system/puppetserver.service; disabled; vendor preset: disabled)Active: active (running) since Sun 2023-12-17 07:02:10 UTC; 20s agoProcess: 1713 ExecStart=/opt/puppetlabs/server/apps/puppetserver/bin/puppetserver start (code=exited, status=0/SUCCESS)Main PID: 1722 (java)CGroup: /system.slice/puppetserver.service└─1722 /usr/bin/java -Xms512m -Xmx512m -XX:MaxPermSize=256m -Djava.security.egd=/dev/ur...Dec 17 07:01:22 puppet systemd[1]: Starting puppetserver Service...
Dec 17 07:01:22 puppet puppetserver[1713]: OpenJDK 64-Bit Server VM warning: ignoring option Ma...8.0
Dec 17 07:02:10 puppet systemd[1]: Started puppetserver Service.
Hint: Some lines were ellipsized, use -l to show in full.
$ sudo systemctl enable puppetserver
Created symlink from /etc/systemd/system/multi-user.target.wants/puppetserver.service to /usr/lib/systemd/system/puppetserver.service.

  • Node中执行 vi /etc/hosts文件中添加
[puppetserver-IP] puppet puppet-master
  • Node中执行 安装

$ sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
$ sudo yum install -y puppet-agent
  • Node中执行 启动,同时生成SSL认证
$ sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
Notice: /Service[puppet]/ensure: ensure changed 'stopped' to 'running'
service { 'puppet':ensure => 'running',enable => 'true',
}$ hostname
ip-172-26-8-25.ap-southeast-1.compute.internal

Server中执行

$ sudo /opt/puppetlabs/bin/puppet cert list"ip-172-26-8-25.ap-southeast-1.compute.internal" (SHA256) AA:C7:01:DE:70:6A:95:84:E6:84:6C:AD:4E:5D:4E:45:B3:47:06:FB:99:9F:32:C7:BA:7F:06:5A:6C:1F:44:C1
  • Server中执行 签署认证
$sudo /opt/puppetlabs/bin/puppet cert sign ip-172-26-8-25.ap-southeast-1.compute.internal
Signing Certificate Request for:"ip-172-26-8-25.ap-southeast-1.compute.internal" (SHA256) AA:C7:01:DE:70:6A:95:84:E6:84:6C:AD:4E:5D:4E:45:B3:47:06:FB:99:9F:32:C7:BA:7F:06:5A:6C:1F:44:C1
Notice: Signed certificate request for ip-172-26-8-25.ap-southeast-1.compute.internal
Notice: Removing file Puppet::SSL::CertificateRequest ip-172-26-8-25.ap-southeast-1.compute.internal at '/etc/puppetlabs/puppet/ssl/ca/requests/ip-172-26-8-25.ap-southeast-1.compute.internal.pem'
  • Server中执行
$ sudo touch /etc/puppetlabs/code/environments/production/manifests/smaple.pp
  • Node中执行 查看
$ /opt/puppetlabs/bin/puppet agent --test
Info: Caching certificate for ip-172-26-8-25.ap-southeast-1.compute.internal
Info: Caching certificate_revocation_list for ca
Info: Caching certificate for ip-172-26-8-25.ap-southeast-1.compute.internal
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Notice: /File[/home/centos/.puppetlabs/opt/puppet/cache/facts.d]/mode: mode c
hanged '0775' to '0755'
Info: Retrieving plugin
Info: Caching catalog for ip-172-26-8-25.ap-southeast-1.compute.internal
Info: Applying configuration version '1702800941'
Info: Creating state file /home/centos/.puppetlabs/opt/puppet/cache/state/sta
te.yaml
Notice: Applied catalog in 0.01 seconds
  • Server中执行 编辑 模板参考 https://www.puppet.com/docs/puppet/5.5/lang_template.html

/etc/puppetlabs/code/environments/production/manifests/smaple.pp

node 'ip-172-26-8-25.ap-southeast-1.compute.internal' {
package{ 'httpd' :
ensure=> installed,
}
}
  • Node中执行 执行
$ sudo /opt/puppetlabs/bin/puppet agent --test
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for ip-172-26-8-25.ap-southeast-1.compute.internal
Info: Applying configuration version '1702801388'
Notice: /Stage[main]/Main/Node[ip-172-26-8-25.ap-southeast-1.compute.internal
]/Package[httpd]/ensure: created
Notice: Applied catalog in 6.58 seconds
#打开apache服务
$ sudo apachectl start
  • 浏览器访问AgentIP地址,可以访问说明脚本执行成功

image.png

这篇关于Puppet 实战的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/505836

相关文章

Python列表去重的4种核心方法与实战指南详解

《Python列表去重的4种核心方法与实战指南详解》在Python开发中,处理列表数据时经常需要去除重复元素,本文将详细介绍4种最实用的列表去重方法,有需要的小伙伴可以根据自己的需要进行选择... 目录方法1:集合(set)去重法(最快速)方法2:顺序遍历法(保持顺序)方法3:副本删除法(原地修改)方法4:

在Spring Boot中浅尝内存泄漏的实战记录

《在SpringBoot中浅尝内存泄漏的实战记录》本文给大家分享在SpringBoot中浅尝内存泄漏的实战记录,结合实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 目录使用静态集合持有对象引用,阻止GC回收关键点:可执行代码:验证:1,运行程序(启动时添加JVM参数限制堆大小):2,访问 htt

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

Spring Boot + MyBatis Plus 高效开发实战从入门到进阶优化(推荐)

《SpringBoot+MyBatisPlus高效开发实战从入门到进阶优化(推荐)》本文将详细介绍SpringBoot+MyBatisPlus的完整开发流程,并深入剖析分页查询、批量操作、动... 目录Spring Boot + MyBATis Plus 高效开发实战:从入门到进阶优化1. MyBatis

MyBatis 动态 SQL 优化之标签的实战与技巧(常见用法)

《MyBatis动态SQL优化之标签的实战与技巧(常见用法)》本文通过详细的示例和实际应用场景,介绍了如何有效利用这些标签来优化MyBatis配置,提升开发效率,确保SQL的高效执行和安全性,感... 目录动态SQL详解一、动态SQL的核心概念1.1 什么是动态SQL?1.2 动态SQL的优点1.3 动态S

Pandas使用SQLite3实战

《Pandas使用SQLite3实战》本文主要介绍了Pandas使用SQLite3实战,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学... 目录1 环境准备2 从 SQLite3VlfrWQzgt 读取数据到 DataFrame基础用法:读

Python实战之屏幕录制功能的实现

《Python实战之屏幕录制功能的实现》屏幕录制,即屏幕捕获,是指将计算机屏幕上的活动记录下来,生成视频文件,本文主要为大家介绍了如何使用Python实现这一功能,希望对大家有所帮助... 目录屏幕录制原理图像捕获音频捕获编码压缩输出保存完整的屏幕录制工具高级功能实时预览增加水印多平台支持屏幕录制原理屏幕

最新Spring Security实战教程之Spring Security安全框架指南

《最新SpringSecurity实战教程之SpringSecurity安全框架指南》SpringSecurity是Spring生态系统中的核心组件,提供认证、授权和防护机制,以保护应用免受各种安... 目录前言什么是Spring Security?同类框架对比Spring Security典型应用场景传统

最新Spring Security实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)

《最新SpringSecurity实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)》本章节介绍了如何通过SpringSecurity实现从配置自定义登录页面、表单登录处理逻辑的配置,并简单模拟... 目录前言改造准备开始登录页改造自定义用户名密码登陆成功失败跳转问题自定义登出前后端分离适配方案结语前言

OpenManus本地部署实战亲测有效完全免费(最新推荐)

《OpenManus本地部署实战亲测有效完全免费(最新推荐)》文章介绍了如何在本地部署OpenManus大语言模型,包括环境搭建、LLM编程接口配置和测试步骤,本文给大家讲解的非常详细,感兴趣的朋友一... 目录1.概况2.环境搭建2.1安装miniconda或者anaconda2.2 LLM编程接口配置2