ITILïŒv3ïŒã§èª¬æãããŠããããã»ã¹ã«ã¯ãç¹ã«èå³æ·±ããã®ã2ã€ãããŸãããæ§æ管çããã»ã¹ããšãå€æŽç®¡çããã»ã¹ãã§ãã·ã¹ãã æ§æã®å€æŽãåæããã³ç®¡çããŸãã 話ãç¶ããã«ã¯ããã·ã¹ãã ããšã¯äœãã決ããå¿ èŠããããŸãã ãã®æŠå¿µã«ã¯ããµãŒãã¹ã®æäŸã«ïŒçŽæ¥çãŸãã¯éæ¥çã«ïŒåœ±é¿ãäžããèšå€§ãªæ°ã®ã³ã³ããŒãã³ããå«ãŸããŸãã
- ãµãŒããŒ
- ã»ãã¥ãªãã£èšå®ïŒãŠãŒã¶ãŒãã°ã«ãŒããæš©å©ããã¡ã€ã¢ãŠã©ãŒã«ïŒ;
- ã€ã³ã¹ããŒã«ãããã¢ããªã±ãŒã·ã§ã³ãšã©ã€ãã©ãªã
- ã¢ããªã±ãŒã·ã§ã³èšå®ïŒèšè¿°åãã¡ã¢ãªãCPUæéãªã©ã®å¶éïŒ;
- ããã¯ã¢ãã
- ã¢ããªã±ãŒã·ã§ã³ããã³ã·ã¹ãã ãœãããŠã§ã¢ã®ç£èŠã·ã¹ãã ã
- 補åèªäœã®æ§æãã¡ã€ã«ããã®ã³ã³ããŒãã³ããè£å©ã·ã¹ãã ãããã³ã¢ããªã±ãŒã·ã§ã³ã¢ããªã±ãŒã·ã§ã³
- ...
ãããžã§ã¯ãã®ã·ã¹ãã ã®èŒªéãæå°éã«ããããšãããšïŒã¿ã€ããã·ã¹ãã ã®æ©èœã«ã¯ããã¯ã¢ããã¯é©çšãããŸããïŒãèªåã§ç©Žãæãããšã«ãªããé ããæ©ãã倱æããŸãã
ãã®ã·ã¹ãã ã³ã³ããŒãã³ãã®ãªã¹ãã¯ãè€æ°ã®ãµãŒããŒïŒããã«ã¯1å°ïŒã«å±éãããŠããã»ãšãã©ã®ãããžã§ã¯ãã«ãšã£ãŠæäœéã®ãã®ã§ãã ããã«ããããžã§ã¯ããé²ãã«ã€ããŠããã®æ°ã¯å€åããå¢å ããŸãã äŒèšããã»ã¹ããªãå Žåããããäœã«ã€ãªããã®ããæããã«ãªããŸãïŒãã¹ãŠãå®å šã«æ©èœãããã¹ããã³ãïŒãŸãã¯éçºã¹ã¿ã³ãïŒããããŸããã補åã«è€è£œããããæ°ããã¹ã¿ã³ããäœæããããšãããšã
- éåžžã«é·ãå±é/è€è£œããã»ã¹ïŒé害ãçºçãããšãã«äœãã©ã®ããã«æ§æãããŠãããã誰ããèŠããŠãããå€ãã®å Žåãæ¢åã®ã¹ã¿ã³ããšèšå®ãæ¯èŒããŸãïŒã
- äºæ³å€ã«ãå±éããã補åã®æäœäžã«åé¡ãçºçããŸãïŒãã¹ããã³ãã§æåŸã®ç¬éã«è¡ããããã補åã«è»¢éãããªãã£ãèšå®ãå¿ããããšããããŸãïŒã
- ãã¹ãããã»ã¹ã®é床ãäœäžããŸãïŒå éšãã¹ã¿ãŒã§ãã£ãŠããæ°ããã¢ã»ã³ããªã®å ¬éã¯ãæéãšè€éãã®äž¡æ¹ã§åæ¥ã§ãïŒã
- ãããŠæåŸã«ãæ°ããããŒãžã§ã³ã®ãªãªãŒã¹åã«éçºè ã®éã§æããããããã®çµæãæ°ãããªãªãŒã¹ã®èšç®ãé ããŸãïŒèª°ãå ¬ç¶ãšè©±ããªããããã®å¹æã¯åžžã«æããããŸãïŒã
ãã®çµæã補åãæ£ããåäœããããã®ç°å¢ã¯å¶åŸ¡äžèœã«ãªãã䜿çšå¯èœãªèªååããã³ããŒãžã§ã³ç®¡çããŒã«ã䜿çšã§ããªããªããŸãã
ããæ°
ç©äºã¯æãããªããã«èŠããŸãããã»ãšãã©ã®éçºã°ã«ãŒãã§ã¯åœŒãã«ç®ãã€ã¶ã£ãŠããŸã-å€ãã®äººã¯ããµãŒããŒã1ã€ãèšå®ãå°ãªããåŽåè ã®èœåããããšäž»åŒµããŠããŸããªã¹ã¯ãªã© ãªã©
ITILã«èšèŒãããŠãããã®ã®èŠããã®è€éããšåé·æ§ïŒå®éã«ã¯å€ãã®èšè¿°ããããŸãïŒã«ããããããããŸãããããã®ããã»ã¹ã®èªååã®ããã®èŠä»¶ãããããåãå ¥ããå¿ èŠããããŸãã ã¢ã»ã³ããªã®èªååããã¹ãã®èªååãè匱æ§ã®æ€çŽ¢ã®èªåå-ãããã¯ãã¹ãŠå®è£ ãããŠãããéçºäžã«å¿ èŠãªæå°éã®ãã®ãšã¿ãªãããŸãã èªååã¯ããã»ã¹ãå éããèªä¿¡ãæ€ãä»ããéææ§ãšä¿èšŒãããçµæãæäŸããæéãšçµæã«å¯Ÿããããã©ãŒããŒããã®ææãåãé€ããŸãã
åäžã®éçºè ã®åæ©
åã®æ®µèœã®åŒ·åãªå°å ¥éšåãèãããšãåäžã®éçºè ã«ãšã£ãŠã®å©ç¹ã¯ãããç°¡åãã€ç°¡åã«èª¬æãããŸãã
- ãªããªã éçºã¯æ¯æ¥è¡ãããŸããããã®çµæãããã€ãã®å±éæ©èœã¯æ°æ¥åŸã«ã¹ã ãŒãºã«æ¶ããŸãã
- ããŒã³ã®èªåå-æãä¿¡é Œã§ããããŒãããŒã
- èªååã«ãã£ãŠæäŸãããäœæ¥ã®é床ã«ããããèåããšãããžã§ã¯ãéçºãžã®æ欲ã倱ãããšããªããªããŸãïŒããã¯éåžžã«éèŠãªç¹å®ã®ãã€ã³ãã§ãïŒã
ITILã«é¢ããéèŠãªå 責äºé
ITILã«èšèŒãããŠããããã»ã¹ãããããã«èšèŒãããŠãããã¹ãŠã®æé ãå®è¡ããããšããªãã§ãã ãããç¶æ³ã¯ä»¥åãããæªåããŸãã äžéšã®éè¡ã·ã¹ãã ã§ãã®ãããªæé ãã©ã®ããã«å®è£ ããããããäœãããããããç¥ã£ãŠããŸãïŒç¹ã«èªååãªãïŒ-å®åçãªæ©æ¢°ã¯ãåçã«éçºäžã®ãããžã§ã¯ã/ã·ã¹ãã ãåæ¢ãããŸãã
人圢
ç§ã®å Žåã ãããããéžã°ããŸããã ChefãšAnsibleã®ã©ã¡ããéžæãããã¯ã åªããããã¥ã¡ã³ãããŒã¹ ãåªãããµããŒããååãªæ°ã®ã¢ãžã¥ãŒã«ïŒéçºè ãšã³ãã¥ããã£ããïŒ ããããžã§ã¯ãã®ç©æ¥µçãªéçºãšRubyã®å®è£ ïŒå€ããå°ãªããç¥ã£ãŠããŸãïŒãèæ ®ããŠéžæãããŸããã
ççŽã«èšã£ãŠãããããã®åŠç¿æ²ç·ã¯ãŸã£ããç©ããã§ã¯ãããŸããã§ããã éçºãããã·ã¹ãã ã¯ããããçš®é¡ã®èŠçŽ ã倧éã«äœ¿çšããããããããããå¥ã ã«æ§æãããã¹ãŠãç°ãªãã¹ã¿ã³ãã«å±éã§ããŸããããŒã«ã®åŸ¹åºçãã€åŸ¹åºçãªèª¿æ»ãå¿ èŠã§ããã ããŒã«ãç 究ãããã«ã€ããŠããã®æ¬ ç¹ïŒã»ãšãã©ã®å Žåããèšèšã«ãããïŒãšå¶éïŒ ããã€ãã®ã¢ãŒããã¯ãã£ãœãªã¥ãŒã·ã§ã³ã説æããPuppetå²åŠã«é¢ããåªããèšäº ïŒã®ããã€ããæããã«ãªããŸããã ãŸããå¿ èŠãªã¹ã¯ãªãããç 究ãããã§ã«éšåçã«å®è£ ããŠãããããPuppetã«ååšããåé¡ã®äžéšã解決ããAnsibleã«ã€ããŠããå°ãåŠã³ãŸããïŒPuppetã«ãªãç¬èªã®åé¡ãçºçããå¯èœæ§ãæé€ããŸããïŒã ãããã£ãŠããã®åŸã®ã¹ããŒãªãŒã¯Puppetã®åºåã§ã¯ãªãã䜿çšã®å¯èœæ§ãšçµéšã®èª¬æã§ãã
Puppetã«ã€ããŠ
Puppetã¯ãã·ã¹ãã 管çè ãã¢ã¯ã»ã¹ã§ããããã«éçºãããç¬èªã®æ§æèšèªïŒDSLïŒã䜿çšããŸãã Puppetèšèªã¯ãæ£åŒãªããã°ã©ãã³ã°ç¥èãå¿ èŠãšããªããšäœçœ®ä»ããããŠããããã®æ§æã¯Nagiosæ§æãã¡ã€ã«åœ¢åŒã®åœ±é¿äžã§åœ¢æãããŸããã
Puppetèšèªã®äž»ãªç®çã¯ããªãœãŒã¹ïŒPuppetã®ãªãœãŒã¹-ãã¡ã€ã«ããã£ã¬ã¯ããªããµãŒãã¹ãå¶éããã¡ã€ã¢ãŠã©ãŒã«ããŠãŒã¶ãŒãªã©ïŒãå®çŸ©ããããšã§ãã èšèªã®ä»ã®éšåã¯ãã¹ãŠããªãœãŒã¹ã®å®çŸ©æ¹æ³ã«æè»æ§ãšå©äŸ¿æ§ãè¿œå ããããã«ã®ã¿ååšããŠããŸãã
ãªãœãŒã¹ã°ã«ãŒãã¯ããã倧ããªæ§æåäœã§ããã¯ã©ã¹ã«ç·šæã§ããŸãã ãªãœãŒã¹ã¯åäžã®ãã¡ã€ã«/ãã£ã¬ã¯ããªãŸãã¯ããã±ãŒãžãèšè¿°ããããšãã§ããŸãããã¯ã©ã¹ã¯ãµãŒãã¹ãŸãã¯ã¢ããªã±ãŒã·ã§ã³ã®æ§æã«å¿ èŠãªãã¹ãŠãèšè¿°ããããšãã§ããŸãïŒå¿ èŠãªæ°ã®ããã±ãŒãžãæ§æãã¡ã€ã«ãããŒã¢ã³/ãµãŒãã¹ãã¡ã³ããã³ã¹ã¿ã¹ã¯ãå«ãïŒã å°ããã¯ã©ã¹ãçµã¿åãããŠãã·ã¹ãã å šäœã®åœ¹å²ãèšè¿°ãã倧ããªã¯ã©ã¹ïŒãããŒã¿ããŒã¹ãµãŒããŒããŸãã¯ãã¯ã©ã¹ã¿ãŒäœæ¥ããŒããïŒã«ããããšãã§ããŸãã
å éšã«ãªãœãŒã¹ãããã¯ã©ã¹ã®äŸïŒ
class apache (String $version = 'latest') { package {'httpd': ensure => $version, # Using the class parameter from above before => File['/etc/httpd.conf'], } file {'/etc/httpd.conf': ensure => file, owner => 'httpd', content => template('apache/httpd.conf.erb'), # Template from a module } service {'httpd': ensure => running, enable => true, subscribe => File['/etc/httpd.conf'], } }
ç°ãªã圹å²ãå®è¡ãããã·ã³ã¯ãäžè¬çãªå Žåãç°ãªãã¯ã©ã¹ã®ã»ãããåãåãå¿ èŠããããŸãã ã©ã®ã¯ã©ã¹ãã©ã®ãã·ã³ã«é©çšããããæ§æããã¿ã¹ã¯ã¯ãPuppetããŒãã®ã¿ã¹ã¯ã§ãã
PuppetããŒãã®å®çŸ©äŸ
node 'www1.example.com', 'www2.example.com', 'www3.example.com' { include common include apache, squid } node /^(foo|bar)\.example\.com$/ { include common }
Hieraã®äºå®ãšããŒã¿ããŒã¹ã Puppetã³ãŒããå®è¡ããåã«ãããŒãã«é¢ããæ å ±ãåéãããåéãããæ å ±ã¯äºåå®çŸ©ããããã¡ã¯ãïŒã³ãŒãå ã®ã©ãã§ã䜿çšã§ããå€æ°ïŒã®åœ¢åŒã§è¡šç€ºãããŸãã Hieraã¯ãçµã¿èŸŒã¿ã®ãããŒå€ãããŒã¿ããŒã¹ã§ãã ããã©ã«ãã§ã¯ãYAMLãŸãã¯JSONãã¡ã€ã«ãããŒã¿ãœãŒã¹ãšããŠäœ¿çšãããŸãããä»»æã®ããŒã¿ãœãŒã¹ã䜿çšããããã«æ¡åŒµããããšãã§ããŸãã ãã®éå±€ãšããŒãã«å¿ããŠããŒã¿ãå€æŽããæ©èœã«ããããã®äœ¿çšã¯ã»ãšãã©ã®ã¢ãžã¥ãŒã«/ã¯ã©ã¹ã®äœæ¥ã®äžå¯æ¬ ãªéšåã§ãã
ã¢ãžã¥ãŒã«ã¯ãã³ãŒããšããŒã¿ã®èªå·±å®çµåãããã¯ã§ãïŒã¯ã©ã¹ããã³ãã¬ãŒãããã¡ã€ã«ãªã©ïŒã ãããã®åå©çšå¯èœã§äžè¬ã«ã¢ã¯ã»ã¹å¯èœãªã¢ã€ãã ã¯ãPuppetã®äž»èŠãªæ§æèŠçŽ ã§ãã
Puppetã®äœ¿çšãèšç»ããŠãã人ã¯ãã»ãšãã©ã®å Žåã¯ã©ã¹ãšãæã«ã¯ã¢ãžã¥ãŒã«ãäœæããå¿ èŠããããŸãã
å±éãªãã·ã§ã³
Puppetãå®è£ ããå Žåãéäžæ§æã¹ãã¬ãŒãžã䜿çšããå Žåãšäœ¿çšããªãå Žåã®2ã€ã®ãªãã·ã§ã³ããããŸãã
- äžå åãããæ§æã¹ãã¬ãŒãžïŒå€ãã®ãµãŒããŒãããå Žåããã®å©ç¹ã¯æ確ã«èŠããŸãã ãã®å Žåããã·ã³ã®ã¿ã«é¢ããæ å ±ãã¯ã©ã€ã¢ã³ããã·ã³ã«éä¿¡ãããŸããããã«ãããäžå®ã¬ãã«ã®ã»ãã¥ãªãã£ãæäŸããããã©ãã£ãã¯ãæå°éã«æããããŸãã
- æ§æã®åæ£ã¹ãã¬ãŒãžïŒå°æ°ã®ãµãŒããŒã§æ£åœåãããŸããããã·ã³ã«ã¯æ§æã¹ã¯ãªãããšãã¡ã€ã«ã®å®å šãªã»ãããå¿ èŠã§ããããšãŒãžã§ã³ãã®èµ·åæã«ããããã³ã³ãã€ã«ããããã®ãã·ã³ã®äžéšãå®è¡ãããŸãã 15åããšã«å®è¡ãããéåžžã®cronã¿ã¹ã¯ã«ãã£ãŠå®è£ ãããŸãã
ç§ã®ã¹ã¯ãªããã¯æ¬¡ã®ããã«ãªããŸãã
#!/bin/sh PUPPET_BIN='/opt/puppetlabs/bin/puppet' # apt-get update && apt-get -y install git mc htop apt-transport-https nano wget lsb-release apt-utils curl python # `puppet-agent` if [ ! -d /etc/puppetlabs ]; then rm *.deb.* *.deb # possible trash wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb && dpkg -i puppetlabs-release-pc1-xenial.deb apt-get update && apt-get -y install puppet-agent fi # `environment` /opt/puppetlabs/bin/puppet config set environment $PUPPET_ENV if [ ! -d /etc/puppetlabs/code/environments/$PUPPET_ENV ]; then cp -r /etc/puppetlabs/code/environments/production /etc/puppetlabs/code/environments/$PUPPET_ENV fi # Install puppet modules $PUPPET_BIN module install puppetlabs-ntp $PUPPET_BIN module install aco-oracle_java $PUPPET_BIN module install puppetlabs-firewall $PUPPET_BIN module install saz-ssh $PUPPET_BIN module install saz-sudo $PUPPET_BIN module install saz-limits $PUPPET_BIN module install thias-sysctl $PUPPET_BIN module install yo61-logrotate $PUPPET_BIN module install puppetlabs-apt $PUPPET_BIN module install puppet-archive # git pull "deployment" project and go in it only if POVISION_NO_GIT_CLONE set to "true" if [ ${POVISION_NO_GIT_CLONE:-"false"} = "true" ]; then echo "do nothing" else LOCAL_REV="" if [ -f local_latest.sha1 ]; then LOCAL_REV=`cat local_latest.sha1` fi REMOTE_REV=`git ls-remote --tags | grep "latest" | awk '{print $1}'` if [ $LOCAL_REV = $REMOTE_REV ]; then exit 0 fi git fetch --all --tags --prune git checkout -f tags/latest fi # replace puppet configs cp puppet_config/hiera.yaml /etc/puppetlabs/code/environments/$PUPPET_ENV/ # replace hiera db rm /etc/puppetlabs/code/environments/$PUPPET_ENV/hieradata/* cp -r $PUPPET_ENV/hieradata/* /etc/puppetlabs/code/environments/$PUPPET_ENV/hieradata # replace storyline_* modules rm -r /etc/puppetlabs/code/environments/$PUPPET_ENV/modules/storyline_* cp -r modules/* /etc/puppetlabs/code/environments/$PUPPET_ENV/modules # copy site.pp cp $PUPPET_ENV/site.pp /etc/puppetlabs/code/environments/$PUPPET_ENV/manifests/site.pp #echo "hostname:" #hostname $PUPPET_BIN apply /etc/puppetlabs/code/environments/$PUPPET_ENV/manifests/site.pp echo $REMOTE_REV > local_latest.sha1
ç§ã®å Žåããã¡ãããåæ£ã·ã¹ãã ã䜿çšãããŸãããªããªãã å®è£ ãç°¡åã§ïŒã€ã³ãã©ã¹ãã©ã¯ãã£ã®ç·šæã®èŠ³ç¹ããïŒããã¹ããã³ããå±éããããã®ãã«ãã¹ã¯ãªãããå€§å¹ ã«ç°¡çŽ åãããŸãããã¹ããã³ãã¯1æ¥ã«æ°ååäœæããŠå®è¡ããŸãã
æå®ãããã¹ã¯ãªãããå®è¡ããå ŽåïŒ
- Puppetã¯ã©ã€ã¢ã³ãèªäœãšå¿ èŠãªããã±ãŒãžãã€ã³ã¹ããŒã«ãããŠãã
- å¿ èŠãªPuppetã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ãããŠããŸã
- ãææ°ã®ãã©ãã«ã®ã³ãããçªå·ã®å€æŽãæ€èšŒãããŸãïŒæ°ããããŒãžã§ã³ã®çµ±åãã¹ããæåãããšãã«è¡ãããŸãïŒ
- çŸåšã®ç°å¢ã®Hiera PuppetããŒã¿ããŒã¹ã®æ§æïŒhiera.yamlïŒã眮ãæããããŸãïŒ$ PUPPET_ENVå€æ°ïŒã
- Hiera PuppetããŒã¿ããŒã¹ã®ããŒã¿ãå«ãYAMLãã¡ã€ã«ã¯çœ®ãæããããŸãã
- ã¢ãžã¥ãŒã«ã®èª¬æã眮ãæããããã«ã³ããŒãããŸããã
- ããŒãïŒç§ã®ã·ã¹ãã ã®ãµãŒããŒïŒã®æ§æãã³ããŒãããŸãã
- ã³ããŒ/ã€ã³ã¹ããŒã«ããããã¹ãŠã®èšå®ã®ã¢ããªã±ãŒã·ã§ã³ãåŒã³åºãããŸãïŒ$ PUPPET_BIN apply ....ïŒ
Puppetã¯ã©ã€ã¢ã³ããèµ·åæã«å®è¡ããã¿ã¹ã¯ã®ãªã¹ãã¯èšå€§ã§ãïŒæåã§ã®æ€èšŒãšå¿ èŠãªå®è¡ã¯åã«äžå¯èœã§ãïŒïŒ
- éããŠãããã¡ã€ã«ãé¢é£ããã¡ã¢ãªéãã¹ã¯ãããæ¥ç¶æ°ã«å¶éãèšå®ãããŸãã
- ãã°ããŒããŒã·ã§ã³ãæ§æãããŸãïŒã·ã¹ãã ãšãã¢ããªã±ãŒã·ã§ã³ãšå¿ èŠãªãµãŒãã¹ã®äž¡æ¹ïŒã
- å¿ èŠãªã°ã«ãŒããšæš©éã§å¿ èŠãªç®¡çã¢ã«ãŠã³ããäœæãããŸãã
- NTPãµãŒããŒãã€ã³ã¹ããŒã«ããã³æ§æãããŠããŸãã
- SSHãµãŒããŒãã€ã³ã¹ããŒã«ããã³æ§æãããŠããŸãã
- Oracle JDKã®ã€ã³ã¹ããŒã«
- ãã¡ã€ã¢ãŠã©ãŒã«ãæ§æãã
- ãã®ç¹å®ã®ããŒãã§ãããžã§ã¯ããŸãã¯ãã®ã³ã³ããŒãã³ããæ©èœããããã«å¿ èŠãªå€æ°ã®ã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ããã³æ§æãããŸãã
人çã®äŸ
ã¹ã¿ã³ãçšã®Puppetã¹ã¯ãªããã·ã¹ãã ãéçºãããšããPuppetã³ãŒããå®è¡ããããã·ã³/ã³ã³ããã«ã³ããŒãããç¬èªã®ã¢ãžã¥ãŒã«ãéçºããŸããã ã¢ãžã¥ãŒã«ã«ã¯ãããŒã¿ïŒã»ãšãã©ã®æ§æãã¡ã€ã«å ïŒããã³æ§æçšã®Puppetã³ãŒããå«ãŸããŠããŸãã Hieraã®ã¹ã¯ãªããããåºæ¬èšå®ãè¡ããŸããããã®çµæãã¹ã¯ãªããã¯éåžžã«æ®éçã§ãå®è¡ãããããŒãã«äŸåããªãããšãå€æããŸããã
ã³ãŒããšèšå®ã®äŸãããã€ã瀺ããŸãã
ngnixã®èšå®ïŒããã±ãŒãžããã§ã¯ãªãããã€ãã£ããªããžããªããïŒïŒãµã€ãºã®ããã«ãŠãããã«ã¹ãã€ã©ãŒãé ããŸãããããããèå³ããã人ã¯ãå匷ãããšãã«éåžžã«å€ãã®ãã¥ã¢ã³ã¹ãèŠããããã«ããå¿ èŠããããŸãïŒ
storyline_infraã¢ãžã¥ãŒã«ã®Nginxã¯ã©ã¹
class storyline_infra::nginx () { $params = lookup({"name" => "storyline_infra.nginx", "merge" => {"strategy" => "deep"}}) $reverse_port = $params['reverse_port'] $reverse_url = $params['reverse_url'] $pid_file = $params['pid_file'] $init_script = $params['init_script'] $dir_data = $params['dir_data'] $dir_logs = $params['dir_logs'] $version = $params['version'] $enabled_startup = $params['enabled_startup'] $enabled_running = $params['enabled_running'] # topology_configuration $enabled_topology_configuration = $params['enabled_topology_configuration'] $topology_configuration_port = $params['topology_configuration_port'] # ( ) user { 'nginx': ensure => "present", managehome => true, } # ( ) exec { "nginx-mkdir": command => "/bin/mkdir -p /data/db && /bin/mkdir -p /data/logs", cwd => "/", unless => '/usr/bin/test -d /data/db -a -d /data/logs', } -> # working dir file { [ $dir_logs, $dir_data] : ensure => "directory", recurse => "true", owner => "nginx", group=> "nginx", require => Exec['nginx-mkdir'], } # ( ) # see by "gpg --verify keyfile" apt::key { 'nginx-key': id => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62', source => 'http://nginx.org/keys/nginx_signing.key', } -> # ( ) # deb http://nginx.org/packages/ubuntu/ xenial nginx apt::source { 'nginx-repo': comment => 'nginx repo', location => "http://nginx.org/packages/ubuntu/", release => "xenial", repos => "nginx", include => { 'deb' => true, 'deb-src' => true, }, } -> # ( ) package { 'nginx': ensure => $version, # notify => Exec['disable_nginx'], } â # ( ). , . !!! file { "/etc/nginx/nginx.conf": replace => true, content => epp('storyline_infra/nginx.epp'), owner => "nginx", group=> "nginx", notify => Service['nginx'], }-> # ( ) file { "/etc/nginx/conf.d/default.conf": replace => true, content => epp('storyline_infra/nginx_default.epp'), owner => "nginx", group=> "nginx", notify => Service['nginx'], }â # ( ) file { $init_script: replace => true, content => epp('storyline_infra/nginx_startup.epp'), mode=>"ug=rwx,o=r", notify => Service['nginx'], }â # / ( ) service { 'nginx': ensure => $enabled_running, enable => $enabled_startup, start => "${init_script} start", stop => "${init_script} stop", status => "${init_script} status", restart => "${init_script} restart", hasrestart => true, hasstatus => true, } # nginx ( ) if $enabled_topology_configuration { file { "/etc/nginx/conf.d/topology.conf": replace => true, content => epp('storyline_infra/nginx_topology.epp'), mode=>"ug=rwx,o=r", notify => Service['nginx'], } } # ( ) if $enabled_startup != true { exec { "disable_nginx": require => Package['nginx'], command => "/bin/systemctl disable nginx", cwd => "/", } } }
åã³ã¡ã³ãã§ãããããã«ããªãœãŒã¹å®çŸ©ã瀺ãããå-ãå¿ èŠãªå Žåã ãªãœãŒã¹ã®ç¶æ ããã§ã«å®çŸ©ãšäžèŽããŠããå ŽåãPuppetã¯æäœãå®è¡ããŸããã
ãã®å Žåãã³ãŒã
«$params = lookup({"name" => "storyline_infra.nginx", "merge" => {"strategy" => "deep"}})»
䜿çšããŠHieraããããŒã¿
«$params = lookup({"name" => "storyline_infra.nginx", "merge" => {"strategy" => "deep"}})»
ååŸããæ¹æ³
«$params = lookup({"name" => "storyline_infra.nginx", "merge" => {"strategy" => "deep"}})»
ã§ããŸãïŒäŸåŸã§ãã®ããŒã¿ãæäŸããŸãïŒããã®åŸããã¹ãŠã®å€æ°ãåããããã«äœ¿çšãããŸãã
Hieraæ§æãã¡ã€ã«ïŒ
--- version: 5 defaults: datadir: "hieradata" data_hash: yaml_data hierarchy: - name: "1" path: "nodes/%{trusted.certname}.yaml" - name: "2" path: "version.yaml" - name: "3" path: "common.yaml"
ãã®å Žåãéå±€ã¯è¡šç€ºãããïŒãéå±€ãããŒïŒãœãŒã¹ã§ãããé«ãã¬ãã«ã®åãœãŒã¹ã¯ããäœãã¬ãã«ã®ããŒå€ãåå®çŸ©ããŸãã ããã«ããããcommon.yamlãã®å€ãã80ãã§ããnodes / webserver1.yamlãã®å€ãã81ãã§ãããwww.server.portããªã©ã®ããŒãæã€ããšãã§ããŸã-çµæãšããŠãå®è¡æã«ãã®ããŒã®å€ãååŸããŸãã³ãŒãããããïŒãwebserver1ããšããååã®ããŒãã§ã¯ã81ããä»ã®å šå¡ã§ã¯ã80ãã
Hieraã®common.yaml
--- limits::entries: '*/nofile': both: 1048576 '*/memlock': both: unlimited logrotate::config: su_user: root su_group: syslog compress: true # sysctl sysctl::base::purge: false sysctl::base::values: net.core.somaxconn: value: '65536' vm.swappiness: ensure: absent fs.file-max: value: '500000' vm.max_map_count: value: '262144' storyline_base: oracle_java: version: "8u92" storyline_infra: collectd: server_address: "XXX.nlp-project.ru" pid_file: '/data/logs/collectd/collectd.pid' init_script: '/etc/init.d/collectd' dir_data: '/data/db/collectd' dir_logs: '/data/logs/collectd' version: "1.2.0-1" enabled_mongodb: false mongodb_user: "collectd" mongodb_password: "######" enabled_storm: false enabled_elasticsearch: false elasticsearch_port: "####" elasticsearch_cluster: "elastic_storyline" enabled_startup: false enabled_running: true influxdb: port_http: "####" port_rpc: "####" pid_file: '/data/logs/influxdb/influxdb.pid' init_script: '/etc/init.d/influxdb' dir_data: '/data/db/influxdb' dir_logs: '/data/logs/influxdb' version: "present" enabled_auth: true enabled_startup: false enabled_running: true âŠ.
site.ppïŒPuppetããŒãã®å®çŸ©ãå«ããã¡ã€ã«ïŒ
node "XXX.nlp-project.ru" { include ::limits include ::sysctl::base include ::logrotate include storyline_base::ntp include storyline_base::srv_oper include storyline_base::ssh include storyline_base::oracle_java âŠ.. include storyline_infra::monit include storyline_base::firewall } node "YYYY.nlp-project.ru" { include ::limits include ::sysctl::base include ::logrotate include storyline_base::ntp include storyline_base::srv_oper include storyline_base::ssh include storyline_base::oracle_java âŠ. include storyline_infra::zookeeper include storyline_components::server_storm include storyline_infra::monit include storyline_base::firewall }
誰ããã¿ã¹ã¯ã®ç¹å®ã®å®è£ ã«èå³ãããå ŽåïŒæžã蟌ã¿-å®è£ ãã³ã¡ã³ãã§èšè¿°ãããããã³ãã«è¿œå ããŸãã
Puppetã¯ç©æ¥µçã«éçºããŠããŸãïŒäœ¿çšç¶æ³ã«å¿ããŠãæ§æã®æ確ãªæ¹åãšã¯ã©ã¹ã®åäœã®çµ±äžãè¡ãããŸãïŒãã ããããŸããŸãªç¶æ³ã§å€æ°ã解決ããç¹å®ã®æ©èœããããæ··ä¹±ãæãããšããããŸãïŒã
ãã³ã
- ã¢ãžã¥ãŒã«ãéçºãããšãã¯ãé¢æ°ãè¿œå ããã ãã§ãªããç¡å¹ã«ããããã®ã³ãŒããäœæããããšãå¿ããªãã§ãã ããã ãã®ãããªæ©èœããªãå Žåãã³ã³ããŒãã³ããå¥ã®ãµãŒããŒã«è»¢éãããšã2ã€ã®ãµãŒããŒããããŸããæ°ããå Žæãšå€ãå Žæ-å€ãå Žæã§ã¯æåã§åé€ããå¿ èŠããããŸããããã¯ãæ§æ管çã®èªååã®äž»ãªã¿ã¹ã¯ãšççŸããŸãã
- åå¿è ã®ããã®åªãã人圢æ¬- åŠç¿äººåœ¢ãšäººåœ¢4ãšãã»ã³ã·ã£ã« ã
- nexus sonatypeïŒhttps://github.com/cescoffier/puppet-nexusïŒããã¢ãŒãã£ãã¡ã¯ããåä¿¡ããããã®åªããã¢ãžã¥ãŒã«ã
- ããŒãã®æ§æã容æã«ããã¢ãžã¥ãŒã«èªäœã®ã³ãŒãã®æ®éæ§ãå®çŸããããã«ãHieraããŒã¿ãã¡ã€ã«ã«æ倧æ°ã®ãã©ã¡ãŒã¿ãŒãåã蟌ã¿ãŸãã
ãæž èŽããããšãããããŸããïŒ