<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                Foreman架構的引入10-hostgroup如何轉換為本地的fact 在Foreman上可以根據業務邏輯設置多個主機組(Host Groups),并且可以將不同的節點加入到不同的主機組,這樣在每次操作“puppet run”的時候,只需要在搜索按鈕里搜索對應的主機組即可找到里面包含的所有節點,如下圖所示 但是,foreman目前在`puppet run`上對mcollective的集成度很低,基本就是只能運行一條命令。那么如果要在shell終端上通過mco命令去對這些自定義的`Host Groups`進行操作應該如何做呢。答案是轉換為facter。 自定義facter有四種方式,如下:[http://kisspuppet.com/2014/03/30/puppet_learning_base10/](http://kisspuppet.com/2014/03/30/puppet_learning_base10/) 這里介紹第三種方式將Foreman上設置的主機組(Host Groups)轉換為每個節點自己的facter ### 1、首先創建主機組 ### 2、查看節點的主機組信息 其實相當于自定義了一個外部變量,變量名叫hostgroup,值為節點加入的組名稱 ### 3、編寫一個fact模塊 模塊的功能就是將Foreman上的變量“hostgroup”落地到每個節點的/etc/facter/facts.d/${hostname}.txt文件中,內容為fact的標準格式。 ~~~ #模塊結構 [root@puppetmaster162 modules]# tree fact fact ├── files ├── manifests │ ├── config.pp │ ├── fact.pp │ ├── init.pp │ └── params.pp └── templates └── hostgroup.erb 3 directories, 5 files #模塊主配置文件init.pp [root@puppetmaster162 modules]# cat fact/manifests/init.pp class fact { tag("puppet_env") require fact::params $hostgroup_erb = $fact::params::hostgroup_erb include fact::config include fact::facter } #創建目錄以及文件 [root@puppetmaster162 modules]# cat fact/manifests/config.pp class fact::config{ file { '/etc/facter' : ensure => directory, owner => 'root', group => 'root', mode => '0644', } file { '/etc/facter/facts.d' : ensure => directory, owner => 'root', group => 'root', mode => '0644', require => File['/etc/facter'] } file{ "/etc/facter/facts.d/$hostname.txt": owner => "root", group => "root", mode => 0400, content => template($fact::hostgroup_erb), require => File['/etc/facter/facts.d'], } } #定義變量 [root@puppetmaster162 modules]# cat fact/manifests/params.pp class fact::params{ $hostgroup_erb = 'fact/hostgroup.erb' } #定義fact模板(原因可參考http://kisspuppet.com/2013/11/10/mcollective-middleware/) [root@puppetmaster162 manifests]# cat fact.pp class fact::facter{ file{"/etc/mcollective/facts.yaml": owner => root, group => root, mode => 0440, loglevel => debug, # reduce noise in Puppet reports content => inline_template('<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime.*|path|timestamp|free|.*password.*|.*psk.*|.*key)/ }.to_yaml %>'), } } #設置文件模板 [root@puppetmaster162 modules]# cat fact/templates/hostgroup.erb hostgroup=<%= @hostgroup %> foreman_env=<%= @foreman_env %> ~~~ ### 4、Foreman上管理主機組和模塊fact 先導入類,然后在主機組里進行關聯即可,由于fact模塊是針對所有主機的,建議關聯到1級主機組,加入的節點會自動繼承。關聯完成后的效果如下 ### 5、在Foreman上對兩個節點執行“puppet run”操作 ### 6、查看facter信息是否生成 ~~~ [root@foreman163 ~]# facter hostgroup prd [root@puppetmaster162 ~]# facter hostgroup prd/kisspuppet ~~~ ### 7、通過mco命令結合fact進行過濾查看 ~~~ [root@puppetmaster162 ~]# mco ping -F hostgroup=prd foreman163.kisspuppet.com time=98.55 ms ---- ping statistics ---- 1 replies max: 98.55 min: 98.55 avg: 98.55 [root@puppetmaster162 ~]# mco ping -F hostgroup=prd/kisspuppet puppetmaster162.kisspuppet.com time=94.14 ms ---- ping statistics ---- 1 replies max: 94.14 min: 94.14 avg: 94.14 [root@puppetmaster162 ~]# mco puppet -v runonce -F hostgroup=prd/kisspuppet Discovering hosts using the mc method for 2 second(s) .... 1 * [ ============================================================> ] 1 / 1 puppetmaster162.kisspuppet.com : OK {:summary=> "Started a Puppet run using the 'puppet agent --test --color=false --splay --splaylimit 30' command"} ---- rpc stats ---- Nodes: 1 / 1 Pass / Fail: 1 / 0 Start Time: Thu Dec 18 15:13:09 +0800 2014 Discovery Time: 2004.07ms Agent Time: 85.19ms Total Time: 2089.26ms ~~~ **注:**以上方式只是提供了一種思路,更多的方式還需要根據具體的實際環境而改變,總之一點,fact很強大,看你怎么用。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看