Your SlideShare is downloading. ×
0
Better node.js software
release practice using open
source tool
????????
Software release to production is such a hard practice, especially considering the business
impact and the quality of software . I will demonstrate how to use open source tools to
enhance a node.js web software release process and ensure the better release quality.
The open source tools I will mention will includes Jenkins, Git, Ubuntu dpkg system, node.js
language , ruby , rake, jshint , nodeunit, expresso , YETI, Selenium, and mongodb
?, ??????? 100+ ???? = =
Web Software release best
practice
Agenda
Who am I ?
Release engineering in Y! Shopping
Process
Testing
Deploy Tools
Configuration Management
Who am I ?
thegiive
• A open source lover
• Release manager of Taiwan Yahoo! Shopping site
• Continuous study on software development, release engineering and software quality
• Fall in love with Ruby, VIM, Puppet and Rake
• Trying to do more work rather than write more blog
Release engineering in Y! Shopping
Common image about release
engineer
Yahoo! Shopping release manager
integration hub for more complex software development teams, sitting at the cross between
development, product management, quality assurance and other engineering efforts, also known
as DevOps
DevOps
Release???1 : ???
??????????????
• RD Team ???? , PHP Team , .Net Team , Search Team
• User Team ???? , ?? Team , ?? Team , Search team
Release???1 : ???
?????
Release???2 : bug????
From Book "Beautiful Testing" Chaptor 2
TestROI : ????????
• ACPB : Average Cost of a Production Bug
• ACTB : Average Cost of a Test Bug
• TBN : Total Bug Number
• TDBC : Total Defect Bug Cost
Taiwan Shopping ? ACPB?????? Test ROI ???
Test ROI ??????????? testing ????
Release???2 : bug????
Release???3 : User????
• ??RD?bug?QA????????SE??????RM?????
• User ???? monitor script , ????????????
???? Release Manager , not release engineer
Release???4 : ??????
PHP Team
• Dev process : Scrum
• Source Code Management : Subversion
• Language : PHP and partial C++
• OS : Linux
.Net Team
• Dev process : Waterfall
• Source Code Management : VSS
• Language : ASP.Net and ASP
• OS : Windows
????????????? ... ?????? 100??
release ?release 2000 ??
item
??????
Release quality ??
Y axies stands for ehnancement number / release number
Throughput ??
Y axies stands for
release item / release number
User ?? , ???????
??Release Quality ??????
• 2011 Q4 24? release ??, ? 12??(02:00 ~ 06:00) release
• ???? user ?? manager ?????
??????????????? , ??????? release ???????, ????? 6???
?? release qulaity ???user ???????????
• 2012 Q2 11? release ??, ? 0??(02:00 ~ 06:00) release
• 2012 Q2? 1??07:30 release
????????
Process
Communication : No Surprise !
• ???????????, ?????????????????????? briefing and retrospective , ??????? 18%
• Communication ???? 9???
???????
?????????
• ????
• ???
• double confirm ??????????
??
• ????
• ?? 30min ??, 30???????????? 20000 NTD
??????
• ?????? sharing information ?????
????????
?????????
• Information syncing : 40%
• Discussion : 30%
• decision making : 30%
?????
• Information sync : 5% => ?????????
• Discussion : 15%
• decision making : 10%
Convention over configuration
Release??
• Release ????? ???????????
• ??????? release ??
• ????????? release
• Release ???????? release briefing
• Release ??? Code Freeze
• ???? cost , ?????? retrospective
??????????? sync ??
• ???? Release Plan
• ????????? Plan ??
◦ Item ????,???? , ????
◦ Item ?????? , ???? , ????
◦ ??????? item ????????????
release briefing ?????
• Information sync : 5% => information double confirm
• Discussion : 15% => ???? sync , ??????????
• decision making : 10% => ??sync??????????????
???????
• ???????? ??? release????? ????email
• ????????????????? , ????????????
• ????? , ???? surprise , ???????
Testing
Release Manager ???
• Unit Test : nodeunit , YETI
• Automation : Selenium
• CI ( Continuous Integration ) : Jenkins
????????????????
Unit Test ?????
?? code ???? , 100% RD ???
Automation
• ??????? SLA (Service-level agreement)
• ???? ?? automation coverage rate ??? SLA ? 100%
• ?? release ?????? automation
• Presentation layer ? coverage rate ???? 100% , ???????
Continuous Integration
• ??????? Unit Test and Automation , ???????
• CI ????????????? Unit Test , Automation
• ?????? CI ? auto build ??
Deploy Tool
???SE/Ops ??? Deploy Tool
??: ???? Yinst/Igor
Use os level package system
• Debian/Ubuntu : dpkg
• RedHat/Centos/Fedora : rpm
• FreeBSD : port
• Windows : MSI
Dont use language level package system , ????????? relay on ???????? server
• Webservr : apache, nginx
• Cache : memcached , redis
• SQL : MySQL , PosgreSQL , MongoDB
????? Deploy Script
?????????? script ? deploy code
1   apt-get install npm
2   apt-get install pip
3   apt-get install rubygem
4   apt-get install nginx #web server
5   apt-get install memcached #cache server
6   npm install -g express # Web framework
7   npm install -d
8   pip install pykml
9   gem install amqp # node.js has no rabbitmq client , so use ruby XD
10   apt-get install rabbitmq-server # rabbitmq server
11   wget http://mydev.server/mycode_package.tgz   # get my code from dev server
12   tar zxcf mycode_package.tgz   # unpack the code package
• ???? hybrid ?? package system , package dependency ?????
• SE/Ops team ?? language package system ??? , ???? RD ????
?? Deploy Script
????? package system , ?????? package version
1   apt-get install nginx=0.1.19-1
2   apt-get install memcached=1.4.13-0ubuntu2
3   apt-get install node-express=2.5.9-1
4   apt-get install pykml=0.0.3
5   apt-get install ruby-amqp=0.9.5-1.
6   apt-get install rabbitmq-server=2.8.4-1
7   apt-get install mycode_package=1.2.3 # ???? code ?? package
??
• SE/Ops team ??????? deploy ???
• CI server ????
???? pkg version
Production System ? ???? pkg system ? depentency
How to pack your package
• ?? code ????? (Code,Config,template)
• ??? code ??? prodcut ????? (??,??????,???,????)
• ????????? (??lib ,??lib ,?? config , ??config )
• ???????????? ( 100? , 10? , 1? , ???? , ???? )
???? Framework ???
Change Management
??? code ???????
• mycode-1.2.3.zip : ?????? change ???? ???? readme
PKG list : ?? SE/Ops ?????
• Upgrade : functionA-config-1.2.3-2012.07.08
• Upgrade : Member-template-2.3.2-2012.07.11
• Donwgrade : functionC-code-3.2.1-2012.03.05
• Upgrade : ShoppingCart-lib-100W-1.2.3-2012.07.20
• Upgrade : WS-stock-lib-200W-3.2.1-2012.07.21
Package pack script ???
Script best practice
• ???
• ? package ???? source code version ???
• Version ??????
• Package ????? package server
• Readme ???????? svn log
Package Version 2.3.1-2012.08.12
[thegiive v123] add some slides change
[RD2 v121] change function a
Configuration Management
debconf
???? config package
• mypkg-config.2.2.3-2012.07.17
• ?????? config ? ????? readme
?????? config ??
1   echo "mypkg mypkg/use_memached boolean true"|debconf-set-selections
2   echo "mypkg mypkg/ws_host string ws1.coscup.org"|debconf-set-selections
3   echo "mypkg mypkg/title string coscup"|debconf-set-selections
4   debian_frontend=noninteractive dpkg-reconfigure
package ??? postinst
1   db_get mypkg/use_memached
2   echo $RET #??? debconf ?????
3   do_config_change($RET)
??????SE/Ops?????
Cache Server ???SE?????? disable cache
1   echo "mypkg mypkg/use_memached boolean false"|debconf-set-selections
2   debian_frontend=noninteractive dpkg-reconfigure
WS1.coscup.org ??????SE???? WS2.coscup.org
1   echo "mypkg mypkg/ws_host string ws2.coscup.org"|debconf-set-selections
2   debian_frontend=noninteractive dpkg-reconfigure
???? title , SE ????? XD
1   echo "mypkg mypkg/title string coscup.org"|debconf-set-selections
2   debian_frontend=noninteractive dpkg-reconfigure
• ????RD ???SE?Daily work?????? RD , SE ??????
• ?? incident ??? , SE ????config ???? , RD??? SE?????
?? mobile login server ??
• ?? mobile loging server ?????????????????
• ?????????? RD ???????RD,SE,??????
• ???? config change , ????? mobile login ?? Web?? login ??
Debconf ????...???
????????deploy script
1   # pkg
2   export debian_frontend=noninteractive
3   apt-get install -y nginx=0.1.19-1
4   apt-get install -y memcached=1.4.13-0ubuntu2
5   apt-get install -y node-express=2.5.9-1
6   apt-get install -y pykml=0.0.3
7   apt-get install -y ruby-amqp=0.9.5-1.
8   apt-get install -y rabbitmq-server=2.8.4-1
9   apt-get install -y mycode_package=1.2.3
10   # config
11   echo "mypkg mypkg/use_memached boolean true"|debconf-set-selections
12   echo "mypkg mypkg/ws_host string ws1.coscup.org"|debconf-set-selections
13   echo "mypkg mypkg/title string coscup"|debconf-set-selections
14   dpkg-reconfigure
• ??????? script ? deploy ?????????? , VM , Cloud instance
• script ???? non-interactive mode ? disable ??????? step
• ?? CI server ?? auto build , auto config
deploy script ?? version
control
?? tag ??? deploy , rollback
7??1? release ? tag ? v2012_07_01 , 7??2? release ? tag ? v2012_07_02
1   # ???1? release
2   git tag v2012_07_01
3   exec_deploy_script
4   # ???2? release
5   git tag v2012_07_02
6   exec_deploy_script
? v2012_07_02 release ??????? rollback ??????(v2012_07_01)
1   git checkout v2012_07_01
2   exec_deploy_script
?? git diff ?????? change
????7??2? release ?????
1   git diff v2012_07_01 v2012_07_02
2   #git diff output
3   .....
4   -apt-get install -y mycode_package=1.2.3
5   +apt-get install -y mycode_package=1.3.1
6   -echo "mypkg mypkg/use_memached boolean true"|debconf-set-selections
7   +echo "mypkg mypkg/use_memached boolean false"|debconf-set-selections
8   .....
9   -echo "mypkg mypkg/title string coscup"|debconf-set-selections
10   +echo "mypkg mypkg/title string coscup.org"|debconf-set-selections
11   .....
• package ????? , config management ????change ???
• ?? RD ??????? diff ???????????
?? git branch ?????
• ?? git ??? branch ???????? deploy script
• ???????? alpha , beta , staging , production ?? branch
??? alpha ???????? beta ??? git merge
1   git checkout beta
2   git merge alpha
3   ...solve confict...
4   git commit
One More Thing
Deploy System : Puppet
• Open source deploy system written by Ruby
• Client Server ????????? pure client
• Config is language, built by Ruby DSL !!!
• ??? template system ???? perfect configuration manage System
• ???OS ? package system , ???????? OS ????
• From Wikipedia ????: Google, Zynga, Sun, Wikipedia, Dell, Twitter...
Puppet Node config
In module
1   class ntpd {
2   package { "ntp": ensure => installed, }
3   file { "/etc/ntp.conf": owner => root, group => root,
4   require => package["ntp"] }
5   @service { "ntpd": ensure => running, enable => true,
6   subscribe => File["/etc/ntp.conf"] }
7   }
8   class ci{ package { "jenkins" :   ensure => installed,} }
9   class Webservr{ package { "nginx" :   ensure => installed,} }
In main config
1   node basenode { include ntpd }
2   node ci.coscup.org inherits basenode {
3   include ci
4   }
5   node web.example.com inherits basenode {
6   include webserver
7   }
Puppet Package config
?? Package ??
1   package {vim: ensure => installed }
2   package { "apache2": ensure => 2.2.22-1ubuntu1 }
3   package { mysql: ensure   => installed,
4   provider   => msi,
5   source   => N:/packages/mysql-xxx.msi,
6   install_options => { INSTALLDIR => C:mysql-5.5 }, }
??????? Deploy Script
• Debian / Ubuntu : Apt-get
• RedHat / Fedora / CentOS : yum
• FreeBSD : port
• MacOS : macport
• Windows : msi
• Gentoo : portage
Puppet Template System
Configure Management ??? : ERB
??????? config file
1   $server_name = domain.coscup.org
2   $server_port = 80
3   file {"/usr/conf/nginx.conf": mode   => "664",
4   content => template("nginx/config.erb"), }
template
1   server {
2   listen   <%= $server_port%>;
3   server_name   <%= $server_name %>;
4   .....
5   }
Pure ruby config menas
1   Given I run "ssh localhost -p 2222" interactively
2   And I type "apache2ctl configtest"
3   And the exit status should be 0
• We can write unit test ... so we can TDD
• We can write rspec and cucumber ... so we can BDD
• We can commit our config in Hudson... so we can CI our config
??? Deploy Script ??
1   class web{ package { "nginx": ensure => 0.1.19-1 } }
2 class cache{ package { "memcached" : ensure => 1.4.13-0ubuntu2 }}
3   class kml_lib{ package { "pykml" : ensure =>0.0.3 }}
4   class message_quene{
5   package { "ruby-amqp" : ensure => 0.9.5-1 }
6   package { "rabbitmq-server": ensure => 2.8.4-1 }
7   }
8   class code_package{
9   include kml_lib
10   include message_quene
11   package { "node-express" : ensure => 2.5.9-1 }
12   package { "mycode" : ensure => 1.2.3 }
13   }
14   node "w1.coscup.com" {
15   include web
16   include cache
17   include code_package
18   }
Q&A
Puppet Config
?? Command
1   exec { remove file : command => rm /tmp/pup/etd , path => /bin   }
?? Windows Command
1   exec { wincommand: command => C:Windows..powershell.exe -executionpolicy remotesigned -fi
?? file
1 file{/tmp/pup: ensure => directory}
2 file{ /tmp/pup/et: ensure => present, content => look at me,
3   require => File[/tmp/pup]}
4   file { "/etc/ntp.conf": owner => root, group => root,
5   mode => 0644, source => "puppet:///ntpd/ntp.conf",
6   require => package["ntp"]
7   }
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Coscup
Upcoming SlideShare
Loading in...5
×

Coscup

236

Published on

License by http://creativecommons.org/licenses/by-nc-nd/2.5/tw/

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
236
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Coscup"

  1. 1. Better node.js software
  2. 2. release practice using open
  3. 3. source tool
  4. 4. ????????
  5. 5. Software release to production is such a hard practice, especially considering the business
  6. 6. impact and the quality of software . I will demonstrate how to use open source tools to
  7. 7. enhance a node.js web software release process and ensure the better release quality.
  8. 8. The open source tools I will mention will includes Jenkins, Git, Ubuntu dpkg system, node.js
  9. 9. language , ruby , rake, jshint , nodeunit, expresso , YETI, Selenium, and mongodb
  10. 10. ?, ??????? 100+ ???? = =
  11. 11. Web Software release best
  12. 12. practice
  13. 13. Agenda
  14. 14. Who am I ?
  15. 15. Release engineering in Y! Shopping
  16. 16. Process
  17. 17. Testing
  18. 18. Deploy Tools
  19. 19. Configuration Management
  20. 20. Who am I ?
  21. 21. thegiive
  22. 22. • A open source lover
  23. 23. • Release manager of Taiwan Yahoo! Shopping site
  24. 24. • Continuous study on software development, release engineering and software quality
  25. 25. • Fall in love with Ruby, VIM, Puppet and Rake
  26. 26. • Trying to do more work rather than write more blog
  27. 27. Release engineering in Y! Shopping
  28. 28. Common image about release
  29. 29. engineer
  30. 30. Yahoo! Shopping release manager
  31. 31. integration hub for more complex software development teams, sitting at the cross between
  32. 32. development, product management, quality assurance and other engineering efforts, also known
  33. 33. as DevOps
  34. 34. DevOps
  35. 35. Release???1 : ???
  36. 36. ??????????????
  37. 37. • RD Team ???? , PHP Team , .Net Team , Search Team
  38. 38. • User Team ???? , ?? Team , ?? Team , Search team
  39. 39. Release???1 : ???
  40. 40. ?????
  41. 41. Release???2 : bug????
  42. 42. From Book "Beautiful Testing" Chaptor 2
  43. 43. TestROI : ????????
  44. 44. • ACPB : Average Cost of a Production Bug
  45. 45. • ACTB : Average Cost of a Test Bug
  46. 46. • TBN : Total Bug Number
  47. 47. • TDBC : Total Defect Bug Cost
  48. 48. Taiwan Shopping ? ACPB?????? Test ROI ???
  49. 49. Test ROI ??????????? testing ????
  50. 50. Release???2 : bug????
  51. 51. Release???3 : User????
  52. 52. • ??RD?bug?QA????????SE??????RM?????
  53. 53. • User ???? monitor script , ????????????
  54. 54. ???? Release Manager , not release engineer
  55. 55. Release???4 : ??????
  56. 56. PHP Team
  57. 57. • Dev process : Scrum
  58. 58. • Source Code Management : Subversion
  59. 59. • Language : PHP and partial C++
  60. 60. • OS : Linux
  61. 61. .Net Team
  62. 62. • Dev process : Waterfall
  63. 63. • Source Code Management : VSS
  64. 64. • Language : ASP.Net and ASP
  65. 65. • OS : Windows
  66. 66. ????????????? ... ?????? 100??
  67. 67. release ?release 2000 ??
  68. 68. item
  69. 69. ??????
  70. 70. Release quality ??
  71. 71. Y axies stands for ehnancement number / release number
  72. 72. Throughput ??
  73. 73. Y axies stands for
  74. 74. release item / release number
  75. 75. User ?? , ???????
  76. 76. ??Release Quality ??????
  77. 77. • 2011 Q4 24? release ??, ? 12??(02:00 ~ 06:00) release
  78. 78. • ???? user ?? manager ?????
  79. 79. ??????????????? , ??????? release ???????, ????? 6???
  80. 80. ?? release qulaity ???user ???????????
  81. 81. • 2012 Q2 11? release ??, ? 0??(02:00 ~ 06:00) release
  82. 82. • 2012 Q2? 1??07:30 release
  83. 83. ????????
  84. 84. Process
  85. 85. Communication : No Surprise !
  86. 86. • ???????????, ?????????????????????? briefing and retrospective , ??????? 18%
  87. 87. • Communication ???? 9???
  88. 88. ???????
  89. 89. ?????????
  90. 90. • ????
  91. 91. • ???
  92. 92. • double confirm ??????????
  93. 93. ??
  94. 94. • ????
  95. 95. • ?? 30min ??, 30???????????? 20000 NTD
  96. 96. ??????
  97. 97. • ?????? sharing information ?????
  98. 98. ????????
  99. 99. ?????????
  100. 100. • Information syncing : 40%
  101. 101. • Discussion : 30%
  102. 102. • decision making : 30%
  103. 103. ?????
  104. 104. • Information sync : 5% => ?????????
  105. 105. • Discussion : 15%
  106. 106. • decision making : 10%
  107. 107. Convention over configuration
  108. 108. Release??
  109. 109. • Release ????? ???????????
  110. 110. • ??????? release ??
  111. 111. • ????????? release
  112. 112. • Release ???????? release briefing
  113. 113. • Release ??? Code Freeze
  114. 114. • ???? cost , ?????? retrospective
  115. 115. ??????????? sync ??
  116. 116. • ???? Release Plan
  117. 117. • ????????? Plan ??
  118. 118. ◦ Item ????,???? , ????
  119. 119. ◦ Item ?????? , ???? , ????
  120. 120. ◦ ??????? item ????????????
  121. 121. release briefing ?????
  122. 122. • Information sync : 5% => information double confirm
  123. 123. • Discussion : 15% => ???? sync , ??????????
  124. 124. • decision making : 10% => ??sync??????????????
  125. 125. ???????
  126. 126. • ???????? ??? release????? ????email
  127. 127. • ????????????????? , ????????????
  128. 128. • ????? , ???? surprise , ???????
  129. 129. Testing
  130. 130. Release Manager ???
  131. 131. • Unit Test : nodeunit , YETI
  132. 132. • Automation : Selenium
  133. 133. • CI ( Continuous Integration ) : Jenkins
  134. 134. ????????????????
  135. 135. Unit Test ?????
  136. 136. ?? code ???? , 100% RD ???
  137. 137. Automation
  138. 138. • ??????? SLA (Service-level agreement)
  139. 139. • ???? ?? automation coverage rate ??? SLA ? 100%
  140. 140. • ?? release ?????? automation
  141. 141. • Presentation layer ? coverage rate ???? 100% , ???????
  142. 142. Continuous Integration
  143. 143. • ??????? Unit Test and Automation , ???????
  144. 144. • CI ????????????? Unit Test , Automation
  145. 145. • ?????? CI ? auto build ??
  146. 146. Deploy Tool
  147. 147. ???SE/Ops ??? Deploy Tool
  148. 148. ??: ???? Yinst/Igor
  149. 149. Use os level package system
  150. 150. • Debian/Ubuntu : dpkg
  151. 151. • RedHat/Centos/Fedora : rpm
  152. 152. • FreeBSD : port
  153. 153. • Windows : MSI
  154. 154. Dont use language level package system , ????????? relay on ???????? server
  155. 155. • Webservr : apache, nginx
  156. 156. • Cache : memcached , redis
  157. 157. • SQL : MySQL , PosgreSQL , MongoDB
  158. 158. ????? Deploy Script
  159. 159. ?????????? script ? deploy code
  160. 160. 1 apt-get install npm
  161. 161. 2 apt-get install pip
  162. 162. 3 apt-get install rubygem
  163. 163. 4 apt-get install nginx #web server
  164. 164. 5 apt-get install memcached #cache server
  165. 165. 6 npm install -g express # Web framework
  166. 166. 7 npm install -d
  167. 167. 8 pip install pykml
  168. 168. 9 gem install amqp # node.js has no rabbitmq client , so use ruby XD
  169. 169. 10 apt-get install rabbitmq-server # rabbitmq server
  170. 170. 11 wget http://mydev.server/mycode_package.tgz # get my code from dev server
  171. 171. 12 tar zxcf mycode_package.tgz # unpack the code package
  172. 172. • ???? hybrid ?? package system , package dependency ?????
  173. 173. • SE/Ops team ?? language package system ??? , ???? RD ????
  174. 174. ?? Deploy Script
  175. 175. ????? package system , ?????? package version
  176. 176. 1 apt-get install nginx=0.1.19-1
  177. 177. 2 apt-get install memcached=1.4.13-0ubuntu2
  178. 178. 3 apt-get install node-express=2.5.9-1
  179. 179. 4 apt-get install pykml=0.0.3
  180. 180. 5 apt-get install ruby-amqp=0.9.5-1.
  181. 181. 6 apt-get install rabbitmq-server=2.8.4-1
  182. 182. 7 apt-get install mycode_package=1.2.3 # ???? code ?? package
  183. 183. ??
  184. 184. • SE/Ops team ??????? deploy ???
  185. 185. • CI server ????
  186. 186. ???? pkg version
  187. 187. Production System ? ???? pkg system ? depentency
  188. 188. How to pack your package
  189. 189. • ?? code ????? (Code,Config,template)
  190. 190. • ??? code ??? prodcut ????? (??,??????,???,????)
  191. 191. • ????????? (??lib ,??lib ,?? config , ??config )
  192. 192. • ???????????? ( 100? , 10? , 1? , ???? , ???? )
  193. 193. ???? Framework ???
  194. 194. Change Management
  195. 195. ??? code ???????
  196. 196. • mycode-1.2.3.zip : ?????? change ???? ???? readme
  197. 197. PKG list : ?? SE/Ops ?????
  198. 198. • Upgrade : functionA-config-1.2.3-2012.07.08
  199. 199. • Upgrade : Member-template-2.3.2-2012.07.11
  200. 200. • Donwgrade : functionC-code-3.2.1-2012.03.05
  201. 201. • Upgrade : ShoppingCart-lib-100W-1.2.3-2012.07.20
  202. 202. • Upgrade : WS-stock-lib-200W-3.2.1-2012.07.21
  203. 203. Package pack script ???
  204. 204. Script best practice
  205. 205. • ???
  206. 206. • ? package ???? source code version ???
  207. 207. • Version ??????
  208. 208. • Package ????? package server
  209. 209. • Readme ???????? svn log
  210. 210. Package Version 2.3.1-2012.08.12
  211. 211. [thegiive v123] add some slides change
  212. 212. [RD2 v121] change function a
  213. 213. Configuration Management
  214. 214. debconf
  215. 215. ???? config package
  216. 216. • mypkg-config.2.2.3-2012.07.17
  217. 217. • ?????? config ? ????? readme
  218. 218. ?????? config ??
  219. 219. 1 echo "mypkg mypkg/use_memached boolean true"|debconf-set-selections
  220. 220. 2 echo "mypkg mypkg/ws_host string ws1.coscup.org"|debconf-set-selections
  221. 221. 3 echo "mypkg mypkg/title string coscup"|debconf-set-selections
  222. 222. 4 debian_frontend=noninteractive dpkg-reconfigure
  223. 223. package ??? postinst
  224. 224. 1 db_get mypkg/use_memached
  225. 225. 2 echo $RET #??? debconf ?????
  226. 226. 3 do_config_change($RET)
  227. 227. ??????SE/Ops?????
  228. 228. Cache Server ???SE?????? disable cache
  229. 229. 1 echo "mypkg mypkg/use_memached boolean false"|debconf-set-selections
  230. 230. 2 debian_frontend=noninteractive dpkg-reconfigure
  231. 231. WS1.coscup.org ??????SE???? WS2.coscup.org
  232. 232. 1 echo "mypkg mypkg/ws_host string ws2.coscup.org"|debconf-set-selections
  233. 233. 2 debian_frontend=noninteractive dpkg-reconfigure
  234. 234. ???? title , SE ????? XD
  235. 235. 1 echo "mypkg mypkg/title string coscup.org"|debconf-set-selections
  236. 236. 2 debian_frontend=noninteractive dpkg-reconfigure
  237. 237. • ????RD ???SE?Daily work?????? RD , SE ??????
  238. 238. • ?? incident ??? , SE ????config ???? , RD??? SE?????
  239. 239. ?? mobile login server ??
  240. 240. • ?? mobile loging server ?????????????????
  241. 241. • ?????????? RD ???????RD,SE,??????
  242. 242. • ???? config change , ????? mobile login ?? Web?? login ??
  243. 243. Debconf ????...???
  244. 244. ????????deploy script
  245. 245. 1 # pkg
  246. 246. 2 export debian_frontend=noninteractive
  247. 247. 3 apt-get install -y nginx=0.1.19-1
  248. 248. 4 apt-get install -y memcached=1.4.13-0ubuntu2
  249. 249. 5 apt-get install -y node-express=2.5.9-1
  250. 250. 6 apt-get install -y pykml=0.0.3
  251. 251. 7 apt-get install -y ruby-amqp=0.9.5-1.
  252. 252. 8 apt-get install -y rabbitmq-server=2.8.4-1
  253. 253. 9 apt-get install -y mycode_package=1.2.3
  254. 254. 10 # config
  255. 255. 11 echo "mypkg mypkg/use_memached boolean true"|debconf-set-selections
  256. 256. 12 echo "mypkg mypkg/ws_host string ws1.coscup.org"|debconf-set-selections
  257. 257. 13 echo "mypkg mypkg/title string coscup"|debconf-set-selections
  258. 258. 14 dpkg-reconfigure
  259. 259. • ??????? script ? deploy ?????????? , VM , Cloud instance
  260. 260. • script ???? non-interactive mode ? disable ??????? step
  261. 261. • ?? CI server ?? auto build , auto config
  262. 262. deploy script ?? version
  263. 263. control
  264. 264. ?? tag ??? deploy , rollback
  265. 265. 7??1? release ? tag ? v2012_07_01 , 7??2? release ? tag ? v2012_07_02
  266. 266. 1 # ???1? release
  267. 267. 2 git tag v2012_07_01
  268. 268. 3 exec_deploy_script
  269. 269. 4 # ???2? release
  270. 270. 5 git tag v2012_07_02
  271. 271. 6 exec_deploy_script
  272. 272. ? v2012_07_02 release ??????? rollback ??????(v2012_07_01)
  273. 273. 1 git checkout v2012_07_01
  274. 274. 2 exec_deploy_script
  275. 275. ?? git diff ?????? change
  276. 276. ????7??2? release ?????
  277. 277. 1 git diff v2012_07_01 v2012_07_02
  278. 278. 2 #git diff output
  279. 279. 3 .....
  280. 280. 4 -apt-get install -y mycode_package=1.2.3
  281. 281. 5 +apt-get install -y mycode_package=1.3.1
  282. 282. 6 -echo "mypkg mypkg/use_memached boolean true"|debconf-set-selections
  283. 283. 7 +echo "mypkg mypkg/use_memached boolean false"|debconf-set-selections
  284. 284. 8 .....
  285. 285. 9 -echo "mypkg mypkg/title string coscup"|debconf-set-selections
  286. 286. 10 +echo "mypkg mypkg/title string coscup.org"|debconf-set-selections
  287. 287. 11 .....
  288. 288. • package ????? , config management ????change ???
  289. 289. • ?? RD ??????? diff ???????????
  290. 290. ?? git branch ?????
  291. 291. • ?? git ??? branch ???????? deploy script
  292. 292. • ???????? alpha , beta , staging , production ?? branch
  293. 293. ??? alpha ???????? beta ??? git merge
  294. 294. 1 git checkout beta
  295. 295. 2 git merge alpha
  296. 296. 3 ...solve confict...
  297. 297. 4 git commit
  298. 298. One More Thing
  299. 299. Deploy System : Puppet
  300. 300. • Open source deploy system written by Ruby
  301. 301. • Client Server ????????? pure client
  302. 302. • Config is language, built by Ruby DSL !!!
  303. 303. • ??? template system ???? perfect configuration manage System
  304. 304. • ???OS ? package system , ???????? OS ????
  305. 305. • From Wikipedia ????: Google, Zynga, Sun, Wikipedia, Dell, Twitter...
  306. 306. Puppet Node config
  307. 307. In module
  308. 308. 1 class ntpd {
  309. 309. 2 package { "ntp": ensure => installed, }
  310. 310. 3 file { "/etc/ntp.conf": owner => root, group => root,
  311. 311. 4 require => package["ntp"] }
  312. 312. 5 @service { "ntpd": ensure => running, enable => true,
  313. 313. 6 subscribe => File["/etc/ntp.conf"] }
  314. 314. 7 }
  315. 315. 8 class ci{ package { "jenkins" : ensure => installed,} }
  316. 316. 9 class Webservr{ package { "nginx" : ensure => installed,} }
  317. 317. In main config
  318. 318. 1 node basenode { include ntpd }
  319. 319. 2 node ci.coscup.org inherits basenode {
  320. 320. 3 include ci
  321. 321. 4 }
  322. 322. 5 node web.example.com inherits basenode {
  323. 323. 6 include webserver
  324. 324. 7 }
  325. 325. Puppet Package config
  326. 326. ?? Package ??
  327. 327. 1 package {vim: ensure => installed }
  328. 328. 2 package { "apache2": ensure => 2.2.22-1ubuntu1 }
  329. 329. 3 package { mysql: ensure => installed,
  330. 330. 4 provider => msi,
  331. 331. 5 source => N:/packages/mysql-xxx.msi,
  332. 332. 6 install_options => { INSTALLDIR => C:mysql-5.5 }, }
  333. 333. ??????? Deploy Script
  334. 334. • Debian / Ubuntu : Apt-get
  335. 335. • RedHat / Fedora / CentOS : yum
  336. 336. • FreeBSD : port
  337. 337. • MacOS : macport
  338. 338. • Windows : msi
  339. 339. • Gentoo : portage
  340. 340. Puppet Template System
  341. 341. Configure Management ??? : ERB
  342. 342. ??????? config file
  343. 343. 1 $server_name = domain.coscup.org
  344. 344. 2 $server_port = 80
  345. 345. 3 file {"/usr/conf/nginx.conf": mode => "664",
  346. 346. 4 content => template("nginx/config.erb"), }
  347. 347. template
  348. 348. 1 server {
  349. 349. 2 listen <%= $server_port%>;
  350. 350. 3 server_name <%= $server_name %>;
  351. 351. 4 .....
  352. 352. 5 }
  353. 353. Pure ruby config menas
  354. 354. 1 Given I run "ssh localhost -p 2222" interactively
  355. 355. 2 And I type "apache2ctl configtest"
  356. 356. 3 And the exit status should be 0
  357. 357. • We can write unit test ... so we can TDD
  358. 358. • We can write rspec and cucumber ... so we can BDD
  359. 359. • We can commit our config in Hudson... so we can CI our config
  360. 360. ??? Deploy Script ??
  361. 361. 1 class web{ package { "nginx": ensure => 0.1.19-1 } }
  362. 362. 2 class cache{ package { "memcached" : ensure => 1.4.13-0ubuntu2 }}
  363. 363. 3 class kml_lib{ package { "pykml" : ensure =>0.0.3 }}
  364. 364. 4 class message_quene{
  365. 365. 5 package { "ruby-amqp" : ensure => 0.9.5-1 }
  366. 366. 6 package { "rabbitmq-server": ensure => 2.8.4-1 }
  367. 367. 7 }
  368. 368. 8 class code_package{
  369. 369. 9 include kml_lib
  370. 370. 10 include message_quene
  371. 371. 11 package { "node-express" : ensure => 2.5.9-1 }
  372. 372. 12 package { "mycode" : ensure => 1.2.3 }
  373. 373. 13 }
  374. 374. 14 node "w1.coscup.com" {
  375. 375. 15 include web
  376. 376. 16 include cache
  377. 377. 17 include code_package
  378. 378. 18 }
  379. 379. Q&A
  380. 380. Puppet Config
  381. 381. ?? Command
  382. 382. 1 exec { remove file : command => rm /tmp/pup/etd , path => /bin }
  383. 383. ?? Windows Command
  384. 384. 1 exec { wincommand: command => C:Windows..powershell.exe -executionpolicy remotesigned -fi
  385. 385. ?? file
  386. 386. 1 file{/tmp/pup: ensure => directory}
  387. 387. 2 file{ /tmp/pup/et: ensure => present, content => look at me,
  388. 388. 3 require => File[/tmp/pup]}
  389. 389. 4 file { "/etc/ntp.conf": owner => root, group => root,
  390. 390. 5 mode => 0644, source => "puppet:///ntpd/ntp.conf",
  391. 391. 6 require => package["ntp"]
  392. 392. 7 }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×