簡體   English   中英

在人偶中使用事實事實

[英]Use facter facts in puppet

我是p的新手,並計划在我們的環境中實施它。

我有在不同版本的Redhat上運行的人偶代理。

現在,我計划從人偶主文件中推送回購文件,並且需要您的指導以實現相同的目的。

我有以下清單。

file { 'local_repo':
  ensure => file,
  path   => '/etc/yum.repos.d/local.repo',
  mode   => "600",
  source => 'puppet:///modules/repo/rhel7.1',
}

file { 'local_repo':
  ensure => file,
  path   => '/etc/yum.repos.d/local.repo',
  mode   => "600",
  source => 'puppet:///modules/repo/rhel6.7',
}

當我執行Facter CLI時,得到以下輸出。

[root@dheera ~]# facter os
{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "RedHat",
  release => {
    full => "7.2",
    major => "7",
    minor => "2"
  }
}

我想利用以上輸出並相應地執行清單。 也就是說,如果人偶代理在Redhat 7.1上執行,則人偶主服務器將使用相應的文件。

您可以通過使用source屬性中的Facter變量,然后在字符串中進行插值來實現。 請注意, '必須改變,以"內插字符串中的變量。

因素2 /人偶3:

file { 'local_repo':
  ensure => file,
  path   => '/etc/yum.repos.d/local.repo',
  mode   => "600",
  source => "puppet:///modules/repo/rhel${::os['release']['full']}",
}

因素3 /人偶4:

file { 'local_repo':
  ensure => file,
  path   => '/etc/yum.repos.d/local.repo',
  mode   => "600",
  source => "puppet:///modules/repo/rhel${facts['os']['release']['full']}",
}

您可以在此處找到有用的文檔: https : //docs.puppet.com/puppet/4.8/reference/lang_facts_and_builtin_vars.html

它適用於最新版本,但也包含舊版人偶/因素信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM