꼭두각시로 / etc / profile에 줄을 추가 하시겠습니까? ensure

꼭두각시를 사용하여 현재 JDK와 바람둥이를 설치합니다.

package {
    [ "openjdk-6-jdk", "openjdk-6-doc", "openjdk-6-jre",
      "tomcat6", "tomcat6-admin", "tomcat6-common", "tomcat6-docs",
      "tomcat6-user" ]:
    ensure => present,
}

이제 추가하고 싶습니다

JAVA_HOME="/usr/lib/java"
export JAVA_HOME

/etc/profile막기 위해. 나는 문서에서 직접적인 대답을 찾지 못했습니다. 권장되는 방법이 있습니까?

일반적으로 퍼펫에이 파일을 배치하거나 수정하도록 어떻게 지시합니까? 단일 노드 (독립형 모드)에 꼭두각시를 사용하여 시도 하고 서버 설정 로그 를 유지 합니다 .



답변

/etc/profile.d/접미사 로 파일을 추가하십시오 .sh. Red Hat과 Debian 및 파생 상품에서 / etc / profile의 일부로 제공되며 다른 배포판에서는 말할 수 없습니다. 일반적으로 말하자면 가능하면 분산 파일을 대체하는 것보다 스 니펫을 추가하는 것이 더 안전합니다.

꼭두각시에서 다음을 수행하십시오.

file { "/etc/profile.d/set_java_home.sh":
    ensure => present,
    source => ...[whatever's appropriate for your setup]...,
    ...
}

이것이 당신이 찾고 있거나 더 자세한 내용이 필요합니까?


답변

mark의 솔루션은 모든 사람의 프로필에 물건을 추가하는 데 가장 적합하지만, 일부 라인이 파일에 있는지 확인 해야하는 경우 Puppet Labs에는 stdlib 라는 훌륭한 모듈 이 있습니다. 이전에는 exec 유형에서 echo와 grep을 사용 하여이 작업을 수행했지만 file_line이 훨씬 쉽고 깨끗합니다.

여기에 도움이됩니다 :

Ensures that a given line is contained within a file. The implementation
matches the full line, including whitespace at the beginning and end. If
the line is not contained in the given file, Puppet will add the line to
ensure the desired state. Multiple resources may be declared to manage
multiple lines in the same file.

Example:

file_line { 'sudo_rule':
   path => '/etc/sudoers',
   line => '%sudo ALL=(ALL) ALL',
}
file_line { 'sudo_rule_nopw':
   path => '/etc/sudoers',
   line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
}

In this example, Puppet will ensure both of the specified lines are
contained in the file /etc/sudoers.


답변