
Puppet Bolt를 사용하여 nginx 설치
2022-10-04 last update
7 minutes reading 우분투 Puppet infrastructure automation devopsPuppet Bolt는 작업 실행 도구입니다. Puppet 작업 및 매니페스트를 실행할 수 있습니다. 이 문서는 여기 원문를 기반으로 작성되었습니다.
환경
Puppet Bolt 및 Puppet Development Kit 설치 OS : macOS Mojave 10.14.2
nginx가 설치된 OS : ubuntu 4.15.0-1027
Puppet Bolt 버전 : 1.11.0
Puppet Development Kit 버전 : 1.9.0
절차
환경
Puppet Bolt 및 Puppet Development Kit 설치 OS : macOS Mojave 10.14.2
nginx가 설치된 OS : ubuntu 4.15.0-1027
Puppet Bolt 버전 : 1.11.0
Puppet Development Kit 버전 : 1.9.0
절차
Bolt를 설치합니다.
$ brew cask install puppetlabs/puppet/puppet-bolt
PDK를 설치합니다.
$ brew cask install puppetlabs/puppet/pdk
Puppet 모듈을 새로 만듭니다. 질문에는 모두 디폴트로 대답하고 마지막으로 yes라고 대답합니다.
$ cd ~/.puppetlabs/etc/code/modules
$ pdk new module profiles
省略
Metadata will be generated based on this information, continue? Yes
pdk (INFO): Module 'profiles' generated at path '/Users/hisashi_yamaguchi/.puppetlabs/etc/code/modules/profiles', from template 'file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git'.
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
작성한 모듈 디렉토리 바로 아래에 plans 디렉토리를 작성하십시오.
$ mkdir ~/.puppetlabs/etc/code/modules/profiles/plans
plans 디렉토리에 Puppet 매니페스트를 만듭니다.
$ vi ~/.puppetlabs/etc/code/modules/profiles/plans/nginx_install.pp
plan profiles::nginx_install(
TargetSpec $nodes,
String $site_content = 'hello!',
) {
# Install puppet on the target and gather facts
$nodes.apply_prep
# Compile the manifest block into a catalog
apply($nodes) {
package { 'nginx':
ensure => present,
}
file { '/var/www/html/index.html':
content => $site_content,
ensure => file,
}
service { 'nginx':
ensure => 'running',
enable => 'true',
require => Package['nginx'],
}
}
}
Bolt에서 매니페스트를 실행합니다. -n은 호스트 이름을 지정하고 -u는 ssh 로그인 사용자를 지정합니다.
$ bolt plan run profiles::nginx_install -n ubuntu --modulepath ~/.puppetlabs/etc/code/modules/ -u hisashi_yamaguchi --run-as root
Starting: plan profiles::nginx_install
Starting: install puppet and gather facts on ubuntu
Finished: install puppet and gather facts with 0 failures in 73.96 sec
Starting: apply catalog on ubuntu
Finished: apply catalog with 0 failures in 26.5 sec
Finished: plan profiles::nginx_install in 100.48 sec
Plan completed successfully with no result
Chrome에서 http://<호스트 이름>으로 이동합니다. hello!가 표시되면 성공입니다.
$ brew cask install puppetlabs/puppet/puppet-bolt
$ brew cask install puppetlabs/puppet/pdk
$ cd ~/.puppetlabs/etc/code/modules
$ pdk new module profiles
省略
Metadata will be generated based on this information, continue? Yes
pdk (INFO): Module 'profiles' generated at path '/Users/hisashi_yamaguchi/.puppetlabs/etc/code/modules/profiles', from template 'file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git'.
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
$ mkdir ~/.puppetlabs/etc/code/modules/profiles/plans
$ vi ~/.puppetlabs/etc/code/modules/profiles/plans/nginx_install.pp
plan profiles::nginx_install(
TargetSpec $nodes,
String $site_content = 'hello!',
) {
# Install puppet on the target and gather facts
$nodes.apply_prep
# Compile the manifest block into a catalog
apply($nodes) {
package { 'nginx':
ensure => present,
}
file { '/var/www/html/index.html':
content => $site_content,
ensure => file,
}
service { 'nginx':
ensure => 'running',
enable => 'true',
require => Package['nginx'],
}
}
}
$ bolt plan run profiles::nginx_install -n ubuntu --modulepath ~/.puppetlabs/etc/code/modules/ -u hisashi_yamaguchi --run-as root
Starting: plan profiles::nginx_install
Starting: install puppet and gather facts on ubuntu
Finished: install puppet and gather facts with 0 failures in 73.96 sec
Starting: apply catalog on ubuntu
Finished: apply catalog with 0 failures in 26.5 sec
Finished: plan profiles::nginx_install in 100.48 sec
Plan completed successfully with no result