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

[经验分享] How to Setup Puppet Master and Agent on CentOS 7-Arnold

[复制链接]
YunVN网友  发表于 2019-2-16 06:33:48 |阅读模式
  Puppet is an open source configuration management tool and server automation framework. Puppet can run on Unix-like operating systems, as well as on the Microsoft Windows systems. It allows you to manage and perform administrative tasks and the configuration of hundreds of systems from one master server.
  In this tutorial, I will you how to install Puppet on CentOS 7. I will install and configure a CentOS 7 server as a puppet 'master', and the other one as an 'agent'.
Prerequisites

  •   2 CentOS 7 servers

    •   10.0.15.10      master.hakase.io    2GB Memory
    •   10.0.15.11      agent.hakase.io

  •   Root privileges
What we will do:

  •   Puppet Pre-Installation
  •   Install and Configure Puppet server
  •   Install and Configure Puppet Agent
  •   Verify Puppet Agent Configuration
  •   Create First Puppet Manifest
Step 1 - Puppet Pre-Installation
  In this step, we will perform some tasks including installation and configuration on both servers puppet master and puppet agent. We will configure the host's file, synchronizing time using the NTP server, Disable SELinux, and add the puppet repository to the system.
- Configure hosts
  Connect to the puppet master and agent using your root user.
  ssh root@10.0.15.10
  ssh root@10.0.15.11
  Now edit the hosts using vim editor.
  vim /etc/hosts
  Add the following configuration to the end of the line.
10.0.15.10      master.hakase.io  
10.0.15.11      agent.hakase.io
  Save and exit.
  Now test using the ping command.
  ping master.hakase.io
  ping agent.hakase.io
  And make sure you get the server IP address 10.0.15.10 and 10.0.15.11.
DSC0000.png

- Configure NTP Server
  It's very important to keep in synchronization the time between master and agent server.
  Install the NTP packages on both servers using the yum command.
  yum -y install ntp ntpdate
  After the installation is complete, choose the NTP pool as you want by running the command as below.
  sudo ntpdate 0.centos.pool.ntp.org
  Now start the NTP service and enable it to launch everytime at system boot.
  sudo systemctl start ntpd
  sudo systemctl enable ntpd
  NTP installation and configuration has been completed.
DSC0001.png

- Disable SELinux
  Edit the SELinux configuration using vim.
  vim /etc/sysconfig/selinux
  Change the SELINUX value to 'disabled'.
SELINUX=disabled  Save and exit.
- Add Puppet Repository
  Now add the puppet repository to the system using the rpm command below.
  rpm -Uvh https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm
DSC0002.png

  When it is complete, reboot both servers.
  reboot
  Now we're ready for puppet installation and configuration.
Step 2 - Install and Configure Puppetserver
  In this step, we will install the puppetserver on the master.hakase.io server. Install puppetserver using the yum command below.
  sudo yum -y install puppetserver
  After the installation is complete, we need to configure the memory allocation for puppetserver. We will set the max memory allocation for puppetserver to 1GB.
  Edit the 'puppetserver' configuration using vim.
  vim /etc/sysconfig/puppetserver
  Now change the line as below.
JAVA_ARGS="-Xms1g -Xmx1g ...."  Save and exit.
  Next, go to the puppet configuration directory and edit the 'puppet.conf' file.
  cd /etc/puppetlabs/puppet
  vim puppet.conf
  Add the following configuration.
[master]  
dns_alt_names=master.hakase.io,puppet
  

  
[main]
  
certname = master.hakase.io
  
server = master.hakase.io
  
environment = production
  
runinterval = 1h
  Save and exit.
  Now start the puppetserver and enable it to launch everytime at startup.
  systemctl start puppetserver
  systemctl enable puppetserver
  The Puppetserver installation and configuration has been completed successfully.
DSC0003.png

  If you're using firewalld on your system, add the puppetserver port to the list using the firewall-cmd command below.
  firewall-cmd --add-port=8140/tcp --permanent
  firewall-cmd --reload
DSC0004.png

Step 3 - Install and Configure Puppet Agent
  We will install the puppet agent on the 'agent.hakase.io' server.
  Install puppet agent using the yum command below.
  yum install -y puppet-agent
  After the installation is complete, go to the puppet configuration directory and edit the puppet.conf file.
  cd /etc/puppetlabs/puppet
  vim puppet.conf
  Paste the following configuration.
[main]  
certname = agent.hakase.io
  
server = master.hakase.io
  
environment = production
  
runinterval = 1h
  Save and exit.
  Next, we will register the puppet agent to the puppet master.
  Run the command below on the puppet agent shell.
  /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
  The puppet agent is now running on the server, and it's attempting to register itself to the puppet master.
  Now back to the puppet master shell and run the command below.
  /opt/puppetlabs/bin/puppet cert list
  And you will get the pending Certificate Signing Request (CSR) from the puppet agent server 'agent.hakase.io'.
  Sign the certificate using the command below.
  /opt/puppetlabs/bin/puppet cert sign agent.hakase.io
  And the result should be similar to the following:
DSC0005.png

  The puppet agent is now running on the system, and the certificate for the agent has been signed by the puppet master.
Step 4 - Verify the Puppet Agent Configuration
  After the puppet master signed the certificate file for the agent, run command below on the puppet agent to verify the configuration.
  /opt/puppetlabs/bin/puppet agent --test
  And you will get the result as shown below.
DSC0006.png

  The Puppet agent pulled the configuration from the puppet master and applied to the server without any error.
Step 5 - Create First Manifest
  The puppet master and agent installation and configuration have been completed. And for this step, we will create a simple manifest for testing.
  We will create the manifest for Apache httpd web server installation.
  On the puppet master server, go to the '/etc/puppetlabs/code/' directory and create the new manifest file 'site.pp' using vim.
  cd /etc/puppetlabs/code/
  cd environments/production/manifests
  Create new manifest file.
  vim site.pp
  Paste the following configuration.
node 'agent.hakase.io' {  
     package { 'httpd':
  
         ensure  => "installed",
  
     }
  
     service { 'httpd':
  
         ensure => running,
  
     enable => true
  
     }
  
}
  Save and exit.
  Now open the puppet agent server shell and run the command below.
  /opt/puppetlabs/bin/puppet agent --test
  The command will retrieve new manifest configuration file from the puppet master and then apply it to the agent server.
  Following is the result.
DSC0007.png

  Open your web browser and type the IP address of the puppet agent.
  http://10.0.15.11/
  And you will get the default HTTP page as below.
DSC0008.png

  The httpd web server has been installed using the puppet manifest.
  Installation and configuration of the Puppet Master and Puppet Agent on CentOS 7 has been completed successfully.
Reference

  •   https://docs.puppet.com/



运维网声明 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-672797-1-1.html 上篇帖子: How to Install Rancher Docker on CentOS 7-Arnold 下篇帖子: How to Install Taiga.io Project Software CentOS7-Arnold
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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