
나는 꼭두각시가 다음과 같은 구성 파일을 만들도록 하려고 합니다.
[All]
Hosts=apt-dater@puppetmaster;apt-dater@blaster; (etc...)
기본적으로 이 파일에는 apt-dater 클래스를 포함하는 각 노드에 대한 항목이 필요합니다. 내보낸 리소스를 실험해 봤지만 이를 하나로 합치는 깔끔한 방법을 찾을 수 없습니다. 이 파일을 만들려면 어떻게 해야 합니까?
답변1
개별 유형의 리소스를 내보내고 수집하는 원리를 이미 이해하고 있다고 가정합니다. 이러한 개별 리소스를 단일 파일로 변환하는 방법은 아닙니다. Puppet에는 이를 수행하는 두 가지 방법이 있습니다.
Augeas는 매우 영리한 도구이지만 자신의 렌즈를 작성하고 배포해야 하는 경우 복잡할 수 있습니다. 그러나 puppet-concat
이해하기는 매우 간단합니다. 구문에 대해 다음을 테스트하지는 않았지만 올바른 방향으로 설정해야 합니다.
# apt-dater/manifests/server.pp
class apt-dater::server {
file { "/somepath/apt-dater/hosts.conf": }
concat::fragment{ "apt-dater_hosts_header":
content => "[All]\nHosts=",
order => 1,
}
Apt-dater::Client <<| |>>
}
# apt-dater/manifests/defines/register.pp
define apt-dater::register($order=10) {
concat::fragment{ "apt-dater_hosts_$name":
target => "/somepath/apt-dater/hosts.conf",
content => "apt-dater@${name};",
}
}
# apt-dater/manifests/client.pp
class apt-dater::client {
@apt-dater::register{ "$hostname": }
}
그런 다음 노드를 설정합니다.
# On the central server.
include apt-dater::server
# On each of the client nodes.
include apt-dater::client