Puppet簡易入門,puppet入門

來源:互聯網
上載者:User

Puppet簡易入門,puppet入門

一、查看官方提供的下載源

      https://docs.puppet.com/guides/puppetlabs_package_repositories.html

 

二、 選擇對應系統的下載源

       因為本機是CentOS 7.1,故選擇YUM源

       https://yum.puppetlabs.com/

 

三、 安裝Puppet

      # wget https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm

      # rpm -ivh puppetlabs-release-el-7.noarch.rpm

      # yum install puppet -y

      # puppet --version

         3.8.7

 

四、 Puppet設定檔介紹

      Puppet的主設定檔均放到/etc/puppet目錄下,3.8.7版本有以下幾個檔案

auth.conf  modules  puppet.conf

     其中:

     puppet.conf是Master守護進程的主設定檔,定義了Master的運行環境,啟動負載檔案等資訊。守護進程在啟動前會根據這個檔案進行預檢,只要預檢成功才能啟動

     守護進程。

     auth.conf主要用來定義Agent訪問Master上目錄的許可權。如果沒有許可權控制的話,Agent可以訪問Master伺服器上的所有資源。

 

五、 安裝nginx包並啟動nginx服務

      安裝nginx包,可先通過puppet resource命令產生相關的模板,然後再對其進行編輯。

[root@master1 ~]# puppet resource package nginxpackage { 'nginx':  ensure => 'absent',}[root@master1 ~]# puppet resource service nginxservice { 'nginx':  ensure => 'stopped',  enable => 'false',}

    其中,puppet resource package是產生安裝包的模板,puppet resource service是產生服務的模板

    最後,nginx包的設定檔如下:

package { 'nginx':  ensure => 'present',}service { 'nginx':  ensure => 'running',}

    在本地應用該設定檔

    # puppet apply nginx.pp 

Notice: Compiled catalog for master1.localdomain in environment production in 0.56 secondsNotice: /Stage[main]/Main/Package[nginx]/ensure: createdNotice: /Stage[main]/Main/Service[nginx]/ensure: ensure changed 'stopped' to 'running'Notice: Finished catalog run in 5.76 seconds

    查看nginx包是否安裝以及服務是否啟動

[root@master1 ~]# rpm -qa |grep nginxnginx-1.6.3-9.el7.x86_64nginx-filesystem-1.6.3-9.el7.noarch[root@master1 ~]# ps -ef |grep nginxroot       3094   3070  0 13:14 pts/2    00:00:00 tailf /var/log/nginx/error.logroot       3423      1  0 13:16 ?        00:00:00 nginx: master process /usr/sbin/nginxnginx      3424   3423  0 13:16 ?        00:00:00 nginx: worker processnginx      3425   3423  0 13:16 ?        00:00:00 nginx: worker processroot       3432   1536  0 13:18 pts/0    00:00:00 grep --color=auto nginx

 

      

 

      

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.