Puppet/ko

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Puppet and the translation is 7% complete.
Outdated translations are marked like this.
Resources

Puppet루비en로 작성한 설정 관리 시스템입니다. 머신 배포 자동화 용도로 활용할 수 있습니다

Currently, there is no distinction between server and client, so the basic installation procedure is the same for both.

USE flags

USE flags for app-admin/puppet A system automation and configuration management software

augeas Enable augeas support
diff Enable diff support
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
emacs Add support for GNU Emacs
hiera Enable hiera support
ldap Add LDAP support (Lightweight Directory Access Protocol)
rrdtool Enable rrdtool support
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
shadow Enable shadow support
sqlite Add support for sqlite - embedded sql database
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
vim-syntax Pulls in related vim syntax scripts

Emerge

우선 emerge로 Puppet을 설치하십시오:

root #emerge --ask puppet
root #emerge --ask app-admin/puppet

설정 및 설치

Puppet 은 주로 INI 방식의 형식을 지닌 /etc/puppet/puppet.conf 파일로 설정합니다. 주석은 해시 기호 (#)로 표시합니다. 설정 파일은 몇가지 섹션 또는 블록으로 구분합니다:

Puppet is mainly configured through /etc/puppet/puppet.conf in an INI-style format. Comments are marked with a hash sign (#).

The configuration file is separated into several sections, or blocks:

  • [main] 에는 다음 섹션에서 설정을 바꾸기 전까지는 Puppet이 기본적으로 동작하도록 하는 모든 부분에 대한 설정이 들어있습니다:
    • [master] 는 Puppetmaster(puppet master), 또는 CA 도구 (puppet cert)에 적용하는 설정이 들어있습니다
    • [agent] 는 Puppet agent (puppet agent)에 적용하는 설정이 들어있습니다

그 밖의 블록과 마찬가지로 더 많은 설명을 찾으신다면 공식 Puppet 문서를 확인하십시오. 또한 모든 설정 목록 을 통해 서버 또는 클라이언트에 적용할 설정 방식을 알아볼 수 있습니다.

서버(Puppetmaster) 설정

이빌드가 puppet.conf에 넣은 기본 설정은 그대로 활용할 수 있습니다. Puppet 2.7.3에서는 다음과 같이 서버 관련 부분이 들어있습니다:

파일 /etc/puppet/puppet.conf서버 관련 기본 설정
[main]
    # The Puppet log directory.
    # The default value is '$vardir/log'.
    logdir = /var/log/puppet
  
    # Where Puppet PID files are kept.
    # The default value is '$vardir/run'.
    rundir = /var/run/puppet
  
    # Where SSL certificates are kept.
    # The default value is '$confdir/ssl'.
    ssldir = $vardir/ssl

파일 서버 설정

파일을 클라이언트에 보내려면, 파일 서버를 설정해야합니다. /etc/puppet/fileserver.conf를 설정하시면 됩니다. 기본적으로 전달하는 파일은 없습니다.

To be able to send files to the clients, the file server has to be configured. This is done in /etc/puppet/fileserver.conf. By default, there are no files being served.

파일 /etc/puppet/fileserver.conffiles 공유 설정
[files]
    path /var/lib/puppet/files
    allow 192.168.0.0/24

위에서 나타난 설정 부분은 /var/lib/puppet/files에서 파일을 찾으며 192.168.0.0/24 네트워크에서 발급받은 IP를 보유한 호스트만 접근 가능한files를 공유합니다(나중에 다시 참조하므로 이 식별자를 기억하십시오). CIDR 표기 방식의 IP 주소를 사용할 수 있고, (*.domain.invalid 처럼 와일드 카드 문자가 들어간) 호스트 이름을 여기에 설정할 수 있습니다. 특정 호스트 또는 IP 영역 범위를 분명하게 차단할 경우 deny 명령을 사용할 수 있습니다.

Puppetmaster 데몬 시작

참고
puppet 호스트 이름을 활용하는 클라이언트에서만 Puppetmaster에 접근할 수 있게 하는게 좋습니다. 그렇지 않으면, 그 동안 열심히 설정한 내용은 무시하고 이름을 중복 우선적용할 수 있습니다.
참고
It is recommended that the Puppetmaster is reachable from the clients using the host name puppet. However, the name can be overridden, which of course causes configuration effort.
중요
이 시점에서 클라이언트에 나타나는 호스트 이름 hostname -f에서 나타나는 이름과 같아야 합니다. 조건을 만족하기 위해 /etc/hosts 파일을 수정하거나 하단에 설명 한대로 직접 인증서를 만들어야합니다.

초기 파일 서버 설정과 기본 설정이 끝나면 Puppetmaster 데몬을 초기화 스크립트로 시작할 수 있습니다.

root #rc-service puppetmaster start

처음 시작하는 동안 Puppet에서 Puppetmaster 호스트용으로 SSL 인증서를 생성하며 위에서 설정한대로 ssldir에 복사합니다.

8140/TCP 포트에서 대기하므로, 클라이언트의 접근을 방해하는 방화벽 규칙이 있는지 확인하십시오.

간단한 매니페스트

Puppet의 용어로 매니페스트가 있는데, 클라이언트 설정을 지정한 파일을 의미합니다. 문서를 찾아보시면 활용 안내서en가 있는데 여기에 매니페스트 마크업 언어에 대한 설명이 있습니다.

Manifests, in Puppet's terminology, are the files in which the client configuration is specified. The documentation contains a comprehensive guide about the manifest markup language.

간단한 예제로 오늘의 메시지(MOTD)를 만들어보겠습니다. Puppetmaster에서 앞서 만든 files 공유 경로에 파일을 만드십시오:

파일 /var/lib/puppet/files/motd서버의 MOTD 파일
Welcome to this Puppet-managed machine!

그 다음 manifests 디렉터리에 주 manifest 파일을 만들겠습니다. 이 파일은 site.pp 입니다:

파일 /etc/puppet/manifests/site.pp서버의 주 매니페스트 파일
node default {
  file { '/etc/motd':
    source => 'puppet:///puppet/files/motd'
  }
}

default node(클라이언트 이름) 정의는 호스트에 별개의 node 구문이 없을 경우에 사용합니다. file 자원을 사용하고, 클라이언트에서 /etc/motd를 요청하여 호스트 puppet에서 공유하는 filesmotd파일과 동일한 파일을 지니도록 하겠습니다. Puppetmaster가 다른 호스트 이름을 사용했을 때 접속할 수 있다면 source URI을 적절하게 적용해야합니다.

클라이언트 설정

중요
클라이언트는 Puppetmaster와 동일한 주/부 버전을 보유해야합니다. Puppetmaster를 2.7.1로 클라이언트를 2.7.2를 쓰는건 괜찮지만, 서버가 2.6이고 클라이언트가 2.7이면 예기치 못한 문제가 나타납니다.
중요
The client must have the same major and minor version as the Puppetmaster. Using a 2.7.1 Puppetmaster with 2.7.2 clients is fine, but using 2.6 for the server and 2.7 for clients can cause unexpected issues at any time.
참고
Puppetmaster가 puppet에 도달하지 않으면 /etc/puppet/puppet.conf[main] 섹션에 server=<your hostname>를 설정하십시오.

Puppet 에이전트를 처음 실행할 때 Puppetmaster가 서명한 인증서를 기다려야합니다. 인증서를 요청하려면 첫 설정을 실행하십시오:

root@client #puppet agent --test --waitforcert 60
info: Creating a new certificate request for client
info: Creating a new SSL key at /var/lib/puppet/ssl/private_keys/client.pem
notice: Did not receive certificate

클라이언트가 연결할 수 있기 전 서버로부터 인증서 요청을 승인 받아야 합니다. 여기서 클라이언트는 인증서 요청 노드 목록에 나타나야합니다:

root@server #puppet cert --list
client
root@server #puppet cert --list
client

이제 요청을 처리하겠습니다:

root@server #puppet cert --sign client
root@server #puppet cert --sign client

클라이언트는 인증서를 이미 발급했는지 여부를 매 60초동안 확인합니다. 확인이 끝나면 다음 설정을 계속 진행하십시오:

info: Caching catalog for client
info: Applying configuration version '1317317379'
notice: /Stage[main]//Node[default]/File[/etc/motd]/ensure: defined content as '{md5}30ed97991ad6f591b9995ad749b20b00'
notice: Finished catalog run in 0.05 seconds
info: Caching catalog for client
info: Applying configuration version '1317317379'
notice: /Stage[main]//Node[default]/File[/etc/motd]/ensure: defined content as '{md5}30ed97991ad6f591b9995ad749b20b00'
notice: Finished catalog run in 0.05 seconds

이 메시지를 보았다면 모든 부분이 동작한다는 뜻입니다. 이제클라이언트에서 /etc/motd 파일 내용을 확인해볼 수 있습니다:

user@client $cat /etc/motd
Welcome to this Puppet-managed machine!
user@client $cat /etc/motd
Welcome to this Puppet-managed machine!

OpenRC

이제 puppet 에이전트를 데몬으로 시작할 수 있으며 부팅할 때 실행합니다:

root@client #/etc/init.d/puppet start
root@client #rc-update add puppet default
root@client #rc-service puppet start
root@client #rc-update add puppet default

systemd

Conversely, when running systemd:

root@client #systemctl start puppet
root@client #systemctl enable puppet

다른 주제

인증서 직접 발급

인증서를 직접 생성한다면 puppet cert 유틸리티를 활용할 수 있습니다. 이 유틸리티는 생성한 인증서를 puppet 설정 디렉터리인 ssldir에 넣고 로컬 Puppet 인증서(CA)의 키에 서명합니다.

To manually generate a certificate, use the puppet cert utility. It will place all generated certificates into the ssldir defined directory as set in the puppet configuration and will sign them with the key of the local Puppet Certificate Authority (CA).

only one Common Name 인증서 생성의 쉬운 예를 들겠습니다.

root #puppet cert --generate host1
root #puppet cert --generate host1

인증서상 유효한 다중 호스트 이름이 필요하다면, --certdnsnames 매개 변수를 활용하고 추가 호스트 이름을 콜론으로 구분하십시오:

root #puppet cert --generate --certdnsnames puppet:puppet.domain.invalid host1.domain.invalid
root #puppet cert --generate --certdnsnames puppet:puppet.domain.invalid host1.domain.invalid

이 예제에서는 3가지 호스트 이름을 유효하다고 판단하는 인증서를 만듭니다.

Refreshing agent certificates

This is the process used to manually refresh agent certificates.

  1. (on master)
    root #puppet cert clean ${AGENT_HOSTNAME}
  2. (on agent)
    root #rm /etc/puppet/ssl/{certs,certificate_requests}/${AGENT_HOSTNAME}.pem
    • This will cause the Puppet agent to regenerate the CSR with the existing SSL key.
    • The old certificate is no longer valid, as it was nuked on the master.
    • When one of the above steps is forgotten, an error will pop up about the certificate mis-matching between agent and master.
    • To replace the SSL keys (optional):
      root #rm /etc/puppet/ssl/{public,private}_keys/${AGENT_HOSTNAME}.pem
  3. (on agent)
    root #puppet agent --onetime --no-daemonize --verbose --test --waitforcert 30
    • When using auto-signing, no further steps are needed.
  4. (on master)
    root #puppet cert list ${AGENT_HOSTNAME}
  5. Verify that the fingerprint listed in the previous two outputs matches
  6. (on master)
    root #puppet cert sign ${AGENT_HOSTNAME}
  7. (on agent)
    root #puppet agent --onetime --no-daemonize --verbose --test

Puppet에서 슬롯 관리하기

Puppet의 기본 포티지 제공자에서 슬롯을 지원하지 않기 때문에 찾으려는 기능을 추가하는 모듈은 따로 존재합니다.

While the default portage provider in puppet does support slots there are puppet modules available which also have this functionality.

For instance, with app-admin/puppet version 4.6.0 and higher, and/or app-admin/puppet-agent, the slot functionality is supported like to:

코드 Defining an absent slotted package
package { 'dev-lang/python:3.3': ensure => absent }

Additional modules are:

See also