Produced by Araxis Merge on 10/2/2017 1:40:11 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | chef-repo.zip\chef-repo\third_party_cookbooks\windows | README.md | Wed Jun 3 20:37:07 2015 UTC |
| 2 | chef-repo.zip\chef-repo\third_party_cookbooks\windows | README.md | Mon Oct 2 12:52:07 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 9 | 1546 |
| Changed | 8 | 16 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | Windows Co okbook | |
| 2 | ========== ====== | |
| 3 | Provides a set of Wi ndows-spec ific primi tives (Che f resource s) meant t o aid in t he creatio n of cookb ooks/recip es targeti ng the Win dows platf orm. | |
| 4 | ||
| 5 | ||
| 6 | Requiremen ts | |
| 7 | ---------- --- | |
| 8 | Version 1. 3.0+ of th is cookboo k requires Chef 0.10 .10+. | |
| 9 | ||
| 10 | ||
| 11 | ### Platfo rms | |
| 12 | * Windows XP | |
| 13 | * Windows Vista | |
| 14 | * Windows Server 200 3 R2 | |
| 15 | * Windows 7 | |
| 16 | * Windows Server 200 8 (R1, R2) | |
| 17 | ||
| 18 | The `windo ws_task` L WRP requir es Windows Server 20 08 due to its API us age. | |
| 19 | ||
| 20 | ### Cookbo oks | |
| 21 | The follow ing cookbo oks provid ed by Chef Software are requir ed as note d: | |
| 22 | ||
| 23 | * chef_han dler (`win dows::rebo ot_handler ` leverage s the chef _handler L WRP) | |
| 24 | ||
| 25 | Attributes | |
| 26 | ---------- | |
| 27 | * `node['w indows'][' allow_pend ing_reboot s']` - use d to confi gure the ` WindowsReb ootHandler ` (via the `windows: :reboot_ha ndler` rec ipe) to ac t on pendi ng reboots . default is true (i e act on p ending reb oots). Th e value of this attr ibute only has an ef fect if th e `windows ::reboot_h andler` is in a node 's run lis t. | |
| 28 | * `node['w indows'][' allow_rebo ot_on_fail ure']` - u sed to reg ister the `WindowsRe bootHandle r` (via th e `windows ::reboot_h andler` re cipe) as a n exceptio n handler too to act on reboot s not only at the en d of succe ssful Chef runs, but even at t he end of failed run s. default is false (ie reboot only afte r successf ul runs). The value of this a ttribute o nly has an effect if the `wind ows::reboo t_handler` is in a n ode's run list. | |
| 29 | ||
| 30 | ||
| 31 | Resource/P rovider | |
| 32 | ---------- ------- | |
| 33 | ### window s_auto_run | |
| 34 | #### Actio ns | |
| 35 | - :create: Create an item to b e run at l ogin | |
| 36 | - :remove: Remove an item that was previ ously setu p to run a t login | |
| 37 | ||
| 38 | #### Attri bute Param eters | |
| 39 | - :name: N ame attrib ute. The n ame of the value to be stored in the reg istry | |
| 40 | - :program : The prog ram to be run at log in | |
| 41 | - :args: T he argumen ts for the program | |
| 42 | ||
| 43 | #### Examp les | |
| 44 | Run BGInfo at login | |
| 45 | ||
| 46 | ```ruby | |
| 47 | windows_au to_run 'BG INFO' do | |
| 48 | program 'C:/Sysint ernals/bgi nfo.exe' | |
| 49 | args '\'C:/Sysi nternals/C onfig.bgi\ ' /NOLICPR OMPT /TIME R:0' | |
| 50 | not_if { Registry .value_exi sts?(AUTO_ RUN_KEY, ' BGINFO') } | |
| 51 | action :create | |
| 52 | end | |
| 53 | ``` | |
| 54 | ||
| 55 | ### window s_batch | |
| 56 | (Chef 11.6 .0 include s a built- in [batch] (http://do cs.chef.io /resource_ batch.html ) resource , so use t hat in pre ference to `windows_ batch` if possible.) | |
| 57 | ||
| 58 | Execute a batch scri pt using t he cmd.exe interpret er (much l ike the sc ript resou rces for b ash, csh, powershell , perl, py thon and r uby). A te mporary fi le is crea ted and ex ecuted lik e other sc ript resou rces, rath er than ru n inline. By their n ature, Scr ipt resour ces are no t idempote nt, as the y are comp letely up to the use r's imagin ation. Use the `not_ if` or `on ly_if` met a paramete rs to guar d the reso urce for i dempotence . | |
| 59 | ||
| 60 | #### Actio ns | |
| 61 | - :run: ru n the batc h file | |
| 62 | ||
| 63 | #### Attri bute Param eters | |
| 64 | - command: name attr ibute. Nam e of the c ommand to execute. | |
| 65 | - code: qu oted strin g of code to execute . | |
| 66 | - creates: a file th is command creates - if the fi le exists, the comma nd will no t be run. | |
| 67 | - cwd: cur rent worki ng directo ry to run the comman d from. | |
| 68 | - flags: c ommand lin e flags to pass to t he interpr eter when invoking. | |
| 69 | - user: A user name or user ID that we s hould chan ge to befo re running this comm and. | |
| 70 | - group: A group nam e or group ID that w e should c hange to b efore runn ing this c ommand. | |
| 71 | ||
| 72 | #### Examp les | |
| 73 | ```ruby | |
| 74 | windows_ba tch 'unzip _and_move_ ruby' do | |
| 75 | code <<- EOH | |
| 76 | 7z.exe x #{Chef::C onfig[:fil e_cache_pa th]}/ruby- 1.8.7-p352 -i386-ming w32.7z -o C:\\source -r -y | |
| 77 | xcopy C: \\source\\ ruby-1.8.7 -p352-i386 -mingw32 C :\\ruby /e /y | |
| 78 | EOH | |
| 79 | end | |
| 80 | ``` | |
| 81 | ||
| 82 | ```ruby | |
| 83 | windows_ba tch 'echo some env v ars' do | |
| 84 | code <<- EOH | |
| 85 | echo %TE MP% | |
| 86 | echo %SY STEMDRIVE% | |
| 87 | echo %PA TH% | |
| 88 | echo %WI NDIR% | |
| 89 | EOH | |
| 90 | end | |
| 91 | ``` | |
| 92 | ||
| 93 | ### window s_feature | |
| 94 | Windows Ro les and Fe atures can be though t of as bu ilt-in ope rating sys tem packag es that sh ip with th e OS. A s erver role is a set of softwar e programs that, whe n they are installed and prope rly config ured, lets a compute r perform a specific function for multip le users o r other co mputers wi thin a net work. A R ole can ha ve multipl e Role Ser vices that provide f unctionali ty to the Role. Rol e services are softw are progra ms that pr ovide the functional ity of a r ole. Featu res are so ftware pro grams that , although they are not direct ly parts o f roles, c an support or augmen t the func tionality of one or more roles , or impro ve the fun ctionality of the se rver, rega rdless of which role s are inst alled. Co llectively we refer to all of these attr ibutes as 'features' . | |
| 95 | ||
| 96 | This resou rce allows you to ma nage these 'features ' in an un attended, idempotent way. | |
| 97 | ||
| 98 | There are two provid ers for th e `windows _features` which map into Micr osoft's tw o major to ols for ma naging rol es/feature s: [Deploy ment Image Servicing and Manag ement (DIS M)](http:/ /msdn.micr osoft.com/ en-us/libr ary/dd3717 19%28v=vs. 85%29.aspx ) and [Ser vermanager cmd](http: //technet. microsoft. com/en-us/ library/ee 344834%28W S.10%29.as px) (The C LI for Ser ver Manage r). As Se rvermanage rcmd is de precated, Chef will set the de fault prov ider to `C hef::Provi der::Windo wsFeature: :DISM` if DISM is pr esent on t he system being conf igured. T he default provider will fall back to `C hef::Provi der::Windo wsFeature: :ServerMan agerCmd`. | |
| 99 | ||
| 100 | For more i nformation on Roles, Role Serv ices and F eatures se e the [Mic rosoft Tec hNet artic le on the topic](htt p://techne t.microsof t.com/en-u s/library/ cc754923.a spx). For a complet e list of all featur es that ar e availabl e on a nod e type eit her of the following commands at a comma nd prompt: | |
| 101 | ||
| 102 | ```text | |
| 103 | dism /onli ne /Get-Fe atures | |
| 104 | servermana gercmd -qu ery | |
| 105 | ``` | |
| 106 | ||
| 107 | #### Actio ns | |
| 108 | - :install : install a Windows role/featu re | |
| 109 | - :remove: remove a Windows ro le/feature | |
| 110 | ||
| 111 | #### Attri bute Param eters | |
| 112 | - feature_ name: name of the fe ature/role to instal l. The sa me feature may have different names depe nding on t he provide r used (ie DHCPServe r vs DHCP; DNS-Serve r-Full-Rol e vs DNS). | |
| 113 | - all: Boo lean. Opti onal. Defa ult: false . DISM pro vider only . Forces a ll depende ncies to b e installe d. | |
| 114 | - source: String. Op tional. DI SM provide r only. Us es local r epository for featur e install. | |
| 115 | ||
| 116 | #### Provi ders | |
| 117 | - **Chef:: Provider:: WindowsFea ture::DISM **: Uses D eployment Image Serv icing and Management (DISM) to manage ro les/featur es. | |
| 118 | - **Chef:: Provider:: WindowsFea ture::Serv erManagerC md**: Uses Server Ma nager to m anage role s/features . | |
| 119 | - **Chef:: Provider:: WindowsFea turePowers hell**: Us es Powersh ell to man age roles/ features. (see [COOK -3714](htt ps://ticke ts.chef.io /browse/CO OK-3714) | |
| 120 | ||
| 121 | #### Examp les | |
| 122 | Enable the node as a DHCP Serv er | |
| 123 | ||
| 124 | ```ruby | |
| 125 | windows_fe ature 'DHC PServer' d o | |
| 126 | action : install | |
| 127 | end | |
| 128 | ``` | |
| 129 | ||
| 130 | Enable TFT P | |
| 131 | ||
| 132 | ```ruby | |
| 133 | windows_fe ature 'TFT P' do | |
| 134 | action : install | |
| 135 | end | |
| 136 | ``` | |
| 137 | ||
| 138 | Enable .Ne t 3.5.1 on Server 20 12 using r epository files on D VD and | |
| 139 | install al l dependen cies | |
| 140 | ||
| 141 | ```ruby | |
| 142 | windows_fe ature "Net Fx3" do | |
| 143 | action : install | |
| 144 | all true | |
| 145 | source " d:\sources \sxs" | |
| 146 | end | |
| 147 | ``` | |
| 148 | ||
| 149 | Disable Te lnet clien t/server | |
| 150 | ||
| 151 | ```ruby | |
| 152 | %w[TelnetS erver Teln etClient]. each do |f eature| | |
| 153 | windows_ feature fe ature do | |
| 154 | action :remove | |
| 155 | end | |
| 156 | end | |
| 157 | ``` | |
| 158 | ||
| 159 | ### window s_font | |
| 160 | Installs a font. | |
| 161 | ||
| 162 | Font files should be included in the coo kbooks | |
| 163 | ||
| 164 | #### Actio ns | |
| 165 | - :install : install a font to the system fonts dir ectory. | |
| 166 | ||
| 167 | #### Attri bute Param eters | |
| 168 | - file: Th e name of the font f ile name t o install. It should exist in the files/ default di rectory of the cookb ook you're calling w indows_fon t from. De faults to the resour ce name. | |
| 169 | ||
| 170 | #### Examp les | |
| 171 | ||
| 172 | ```ruby | |
| 173 | windows_fo nt 'Code N ew Roman.o tf' | |
| 174 | ``` | |
| 175 | ||
| 176 | ### window s_package | |
| 177 | Manage Win dows appli cation pac kages in a n unattend ed, idempo tent way. | |
| 178 | ||
| 179 | The follow ing applic ation inst allers are currently supported : | |
| 180 | ||
| 181 | * MSI pack ages | |
| 182 | * InstallS hield | |
| 183 | * Wise Ins tallMaster | |
| 184 | * Inno Set up | |
| 185 | * Nullsoft Scriptabl e Install System | |
| 186 | ||
| 187 | If the pro per instal ler type i s not pass ed into th e resource 's install er_type at tribute, t he provide r will do it's best to identif y the type by intros pecting th e installa tion packa ge. If th e installa tion type cannot be properly i dentified the `:cust om` value can be pas sed into t he install er_type at tribute al ong with t he proper flags for silent/qui et install ation (usi ng the `op tions` att ribute..se e example below). | |
| 188 | ||
| 189 | __PLEASE N OTE__ - Fo r proper i dempotence the resou rce's `pac kage_name` should be the same as the 'Di splayName' registry value in t he uninsta llation da ta that is created d uring pack age instal lation. T he easiest way to de finitively find the proper 'Di splayName' value is to install the packa ge on a ma chine and search for the unins tall infor mation und er the fol lowing reg istry keys : | |
| 190 | ||
| 191 | * `HKEY_LO CAL_MACHIN E\Software \Microsoft \Windows\C urrentVers ion\Uninst all` | |
| 192 | * `HKEY_CU RRENT_USER \Software\ Microsoft\ Windows\Cu rrentVersi on\Uninsta ll` | |
| 193 | * `HKEY_LO CAL_MACHIN E\Software \Wow6464No de\Microso ft\Windows \CurrentVe rsion\Unin stall` | |
| 194 | ||
| 195 | For maximu m flexibil ity the `s ource` att ribute sup ports both remote an d local in stallation packages. | |
| 196 | ||
| 197 | #### Actio ns | |
| 198 | - :install : install a package | |
| 199 | - :remove: remove a package. T he remove action is completely hit or mi ss as many applicati on uninsta llers do n ot support a full si lent/quiet mode. | |
| 200 | ||
| 201 | #### Attri bute Param eters | |
| 202 | - package_ name: name attribute . The 'Dis playName' of the app lication i nstallatio n package. | |
| 203 | - source: The source of the wi ndows inst aller. Th is can eit her be a U RI or a lo cal path. | |
| 204 | - installe r_type: Th ey type of windows i nstallatio n package. valid val ues are: : msi, :inno , :nsis, : wise, :ins tallshield , :custom. If this value is n ot provide d, the pro vider will do it's b est to ide ntify the installer type throu gh introsp ection of the file. | |
| 205 | - checksum : useful i f source i s remote, the SHA-25 6 checksum of the fi le--if the local fil e matches the checks um, Chef w ill not do wnload it | |
| 206 | - options: Additiona l options to pass th e underlyi ng install ation comm and | |
| 207 | - timeout: set a tim eout for t he package download (default 6 00 seconds ) | |
| 208 | - version: The versi on number of this pa ckage, as indicated by the 'Di splayVersi on' value in one of the 'Unins tall' regi stry keys. If the g iven versi on number does equal the 'Disp layVersion ' in the r egistry, t he package will be i nstalled. | |
| 209 | - success_ codes: set an array of possibl e successf ul install ation | |
| 210 | return c odes. Prev iously thi s was hard coded, but certain M SIs may | |
| 211 | have a d ifferent r eturn code , e.g. 301 0 for rebo ot require d. Must be | |
| 212 | an array , and defa ults to `[ 0, 42, 127 ]`. | |
| 213 | ||
| 214 | #### Examp les | |
| 215 | ||
| 216 | Install Pu TTY (InnoS etup insta ller) | |
| 217 | ```ruby | |
| 218 | windows_pa ckage 'PuT TY version 0.60' do | |
| 219 | source ' http://the .earth.li/ ~sgtatham/ putty/late st/x86/put ty-0.60-in staller.ex e' | |
| 220 | installe r_type :in no | |
| 221 | action : install | |
| 222 | end | |
| 223 | ``` | |
| 224 | ||
| 225 | Install 7- Zip (MSI i nstaller) | |
| 226 | ```ruby | |
| 227 | windows_pa ckage '7-Z ip 9.20 (x 64 edition )' do | |
| 228 | source ' http://dow nloads.sou rceforge.n et/sevenzi p/7z920-x6 4.msi' | |
| 229 | action : install | |
| 230 | end | |
| 231 | ``` | |
| 232 | ||
| 233 | Install No tepad++ (Y U No Emac s?) using a local in staller | |
| 234 | ```ruby | |
| 235 | windows_pa ckage 'Not epad++' do | |
| 236 | source ' c:/install ation_file s/npp.5.9. 2.Installe r.exe' | |
| 237 | action : install | |
| 238 | end | |
| 239 | ``` | |
| 240 | ||
| 241 | Install VL C for that Xvid (NSI S installe r) | |
| 242 | ```ruby | |
| 243 | windows_pa ckage 'VLC media pla yer 1.1.10 ' do | |
| 244 | source ' http://sup erb-sea2.d l.sourcefo rge.net/pr oject/vlc/ 1.1.10/win 32/vlc-1.1 .10-win32. exe' | |
| 245 | action : install | |
| 246 | end | |
| 247 | ``` | |
| 248 | ||
| 249 | Install Fi refox as c ustom inst aller and manually s et the sil ent instal l flags | |
| 250 | ```ruby | |
| 251 | windows_pa ckage 'Moz illa Firef ox 5.0 (x8 6 en-US)' do | |
| 252 | source ' http://arc hive.mozil la.org/pub /mozilla.o rg/mozilla .org/firef ox/release s/5.0/win3 2/en-US/Fi refox%20Se tup%205.0. exe' | |
| 253 | options '-ms' | |
| 254 | installe r_type :cu stom | |
| 255 | action : install | |
| 256 | end | |
| 257 | ``` | |
| 258 | ||
| 259 | Google Chr ome FTW (M SI install er) | |
| 260 | ```ruby | |
| 261 | windows_pa ckage 'Goo gle Chrome ' do | |
| 262 | source ' https://dl -ssl.googl e.com/tag/ s/appguid% 3D%7B8A69D 345-D564-4 63C-AFF1-A 69D9E530F9 6%7D%26iid %3D%7B806F 36C0-CB54- 4A84-A3F3- 0CF8A86575 E0%7D%26la ng%3Den%26 browser%3D 3%26usages tats%3D0%2 6appname%3 DGoogle%25 20Chrome%2 6needsadmi n%3Dfalse/ edgedl/chr ome/instal l/GoogleCh romeStanda loneEnterp rise.msi' | |
| 263 | action : install | |
| 264 | end | |
| 265 | ``` | |
| 266 | ||
| 267 | Remove Goo gle Chrome | |
| 268 | ```ruby | |
| 269 | windows_pa ckage 'Goo gle Chrome ' do | |
| 270 | action : remove | |
| 271 | end | |
| 272 | ``` | |
| 273 | ||
| 274 | Remove 7-Z ip | |
| 275 | ```ruby | |
| 276 | windows_pa ckage '7-Z ip 9.20 (x 64 edition )' do | |
| 277 | action : remove | |
| 278 | end | |
| 279 | ``` | |
| 280 | ||
| 281 | ### window s_printer_ port | |
| 282 | ||
| 283 | Create and delete TC P/IPv4 pri nter ports . | |
| 284 | ||
| 285 | #### Actio ns | |
| 286 | - :create: Create a TCIP/IPv4 printer po rt. This i s the defa ult action . | |
| 287 | - :delete: Delete a TCIP/IPv4 printer po rt | |
| 288 | ||
| 289 | #### Attri bute Param eters | |
| 290 | - :ipv4_ad dress: Nam e attribut e. Require d. IPv4 ad dress, e.g . ' IP ' | |
| 291 | - :port_na me: Port n ame. Optio nal. Defau lts to 'IP _' + :ipv4 _address | |
| 292 | - :port_nu mber: Port number. O ptional. D efaults to 9100. | |
| 293 | - :port_de scription: Port desc ription. O ptional. | |
| 294 | - :snmp_en abled: Boo lean. Opti onal. Defa ults to fa lse. | |
| 295 | - :port_pr otocol: Po rt protoco l, 1 (RAW) , or 2 (LP R). Option al. Defaul ts to 1. | |
| 296 | ||
| 297 | #### Examp les | |
| 298 | ||
| 299 | Create a T CP/IP prin ter port n amed 'IP_ IP ' with all defaults | |
| 300 | ```ruby | |
| 301 | windows_pr inter_port ' IP ' do | |
| 302 | end | |
| 303 | ``` | |
| 304 | ||
| 305 | Delete a p rinter por t | |
| 306 | ```ruby | |
| 307 | windows_pr inter_port ' IP ' do | |
| 308 | action : delete | |
| 309 | end | |
| 310 | ``` | |
| 311 | ||
| 312 | Delete a p ort with a custom po rt_name | |
| 313 | ```ruby | |
| 314 | windows_pr inter_port ' IP ' do | |
| 315 | port_nam e 'My awes ome port' | |
| 316 | action : delete | |
| 317 | end | |
| 318 | ``` | |
| 319 | ||
| 320 | Create a p ort with m ore option s | |
| 321 | ```ruby | |
| 322 | windows_pr inter_port ' IP ' do | |
| 323 | port_nam e 'My awes ome port' | |
| 324 | snmp_ena bled true | |
| 325 | port_pro tocol 2 | |
| 326 | end | |
| 327 | ``` | |
| 328 | ||
| 329 | ### window s_printer | |
| 330 | ||
| 331 | Create Win dows print er. Note t hat this d oesn't cur rently ins tall a pri nter | |
| 332 | driver. Yo u must alr eady have the driver installed on the sy stem. | |
| 333 | ||
| 334 | The Window s Printer LWRP will automatica lly create a TCP/IP printer po rt for you using the `ipv4_add ress` prop erty. If y ou want mo re granula r control over the p rinter por t, just cr eate it us ing the `w indows_pri nter_port` LWRP befo re creatin g the prin ter. | |
| 335 | ||
| 336 | #### Actio ns | |
| 337 | - :create: Create a new printe r | |
| 338 | - :delete: Delete a new printe r | |
| 339 | ||
| 340 | #### Attri bute Param eters | |
| 341 | - :device_ id: Name a ttribute. Required. Printer qu eue name, e.g. 'HP L J 5200 in fifth floo r copy roo m' | |
| 342 | - :comment : Optional string de scribing t he printer queue. | |
| 343 | - :default : Boolean. Optional. Defaults to false. Note that Windows se ts the fir st printer defined t o the defa ult printe r regardle ss of this setting. | |
| 344 | - :driver_ name: Stri ng. Requir ed. Exact name of pr inter driv er. Note t hat the pr inter driv er must al ready be i nstalled o n the node . | |
| 345 | - :locatio n: Printer location, e.g. 'Fif th floor c opy room', or 'US/NY C/Floor42/ Room4207' | |
| 346 | - :shared: Boolean. Defaults t o false. | |
| 347 | - :share_n ame: Print er share n ame. | |
| 348 | - :ipv4_ad dress: Pri nter IPv4 address, e .g. ' IP '. You don 't have to be able t o ping the IP addres ss to set it. Requir ed. | |
| 349 | ||
| 350 | An error o f "Set-Wmi Instance : Generic f ailure" is most like ly due to the printe r driver n ame not ma tching or not being installed. | |
| 351 | ||
| 352 | #### Examp les | |
| 353 | ||
| 354 | Create a p rinter | |
| 355 | ```ruby | |
| 356 | windows_pr inter 'HP LaserJet 5 th Floor' do | |
| 357 | driver_n ame 'HP La serJet 410 0 Series P CL6' | |
| 358 | ipv4_addre ss ' IP ' | |
| 359 | end | |
| 360 | ``` | |
| 361 | ||
| 362 | Delete a p rinter. No te: this d oesn't del ete the as sociated p rinter por t. See `wi ndows_prin ter_port` above for how to del ete the po rt. | |
| 363 | ```ruby | |
| 364 | windows_pr inter 'HP LaserJet 5 th Floor' do | |
| 365 | action : delete | |
| 366 | end | |
| 367 | ``` | |
| 368 | ||
| 369 | ### window s_reboot | |
| 370 | Sets requi red data i n the node 's run_sta te to noti fy `Window sRebootHan dler` a re boot is re quested. If Chef ru n complete s successf ully a reb oot will o ccur if th e `Windows RebootHand ler` is pr operly reg istered as a report handler. As an acti on of `:re quest` wil l cause a node to re boot every Chef run, this reso urce is us ually noti fied by ot her resour ces...ie r estart nod e after a package is installed (see exam ple below) . | |
| 371 | ||
| 372 | #### Actio ns | |
| 373 | - :request : requests a reboot at complet ion of suc cessful Ch er run. r equires `W indowsRebo otHandler` to be reg istered as a report handler. | |
| 374 | - :cancel: remove re boot reque st from no de.run_sta te. this will cance l *ALL* pr eviously r equested r eboots as this is a binary sta te. | |
| 375 | ||
| 376 | #### Attri bute Param eters | |
| 377 | - :timeout : Name att ribute. ti meout dela y in secon ds to wait before pr oceeding w ith the re quested re boot. defa ult is 60 seconds | |
| 378 | - :reason: comment o n the reas on for the reboot. d efault is 'Chef Soft ware Chef initiated reboot' | |
| 379 | ||
| 380 | #### Examp les | |
| 381 | If the pac kage insta lls, sched ule a rebo ot at end of chef ru n | |
| 382 | ```ruby | |
| 383 | windows_re boot 60 do | |
| 384 | reason ' cause chef said so' | |
| 385 | action : nothing | |
| 386 | end | |
| 387 | ||
| 388 | windows_pa ckage 'som e_package' do | |
| 389 | action : install | |
| 390 | notifies :request, 'windows_ reboot[60] ' | |
| 391 | end | |
| 392 | ``` | |
| 393 | ||
| 394 | Cancel the previousl y requeste d reboot | |
| 395 | ```ruby | |
| 396 | windows_re boot 60 do | |
| 397 | action : cancel | |
| 398 | end | |
| 399 | ``` | |
| 400 | ||
| 401 | ### window s_registry | |
| 402 | (Chef 11.6 .0 include s a built- in [regist ry_key](ht tp://docs. chef.io/re source_reg istry_key. html) reso urce, so u se that in preferenc e to `wind ows_regist ry` if pos sible.) | |
| 403 | ||
| 404 | Creates an d modifies Windows r egistry ke ys. | |
| 405 | ||
| 406 | *Change in v1.3.0: T he Win32 c lasses use `::Win32` to avoid namespace conflict w ith `Chef: :Win32` (i ntroduced in Chef 0. 10.10).* | |
| 407 | ||
| 408 | #### Actio ns | |
| 409 | - :create: create a new regist ry key wit h the prov ided value s. | |
| 410 | - :modify: modify an existing registry k ey with th e provided values. | |
| 411 | - :force_m odify: mod ify an exi sting regi stry key w ith the pr ovided val ues. ensu res the va lue is act ually set by checkin g multiple times. us eful for f ighting ra ce conditi ons where two proces ses are tr ying to se t the same registry key. This will be u pdated in the near f uture to u se 'RegNot ifyChangeK eyValue' w hich is ex posed by t he WinAPI and allows a process to regist er for not ification on a regis try key ch ange. | |
| 412 | - :remove: removes a value fro m an exist ing regist ry key | |
| 413 | ||
| 414 | #### Attri bute Param eters | |
| 415 | - key_name : name att ribute. Th e registry key to cr eate/modif y. | |
| 416 | - values: hash of th e values t o set unde r the regi stry key. The indivi dual hash items will become re spective ' Value name ' => 'Valu e data' it ems in the registry key. | |
| 417 | - type: Ty pe of key to create, defaults to REG_SZ. Must be a symbol, s ee the ove rview belo w for vali d values. | |
| 418 | ||
| 419 | #### Regis try key ty pes | |
| 420 | - :binary: REG_BINAR Y | |
| 421 | - :string: REG_SZ | |
| 422 | - :multi_s tring: REG _MULTI_SZ | |
| 423 | - :expand_ string: RE G_EXPAND_S Z | |
| 424 | - :dword: REG_DWORD | |
| 425 | - :dword_b ig_endian: REG_DWORD _BIG_ENDIA N | |
| 426 | - :qword: REG_QWORD | |
| 427 | ||
| 428 | #### Examp les | |
| 429 | ||
| 430 | Make the l ocal windo ws proxy m atch the o ne set for Chef | |
| 431 | ```ruby | |
| 432 | proxy = UR I.parse(Ch ef::Config [:http_pro xy]) | |
| 433 | windows_re gistry 'HK CU\Softwar e\Microsof t\Windows\ CurrentVer sion\Inter net Settin gs' do | |
| 434 | values ' ProxyEnabl e' => 1, ' ProxyServe r' => "#{p roxy.host} :#{proxy.p ort}", 'Pr oxyOverrid e' => '<lo cal>' | |
| 435 | end | |
| 436 | ``` | |
| 437 | ||
| 438 | Enable Rem ote Deskto p and poke the firew all hole | |
| 439 | ```ruby | |
| 440 | windows_re gistry 'HK LM\SYSTEM\ CurrentCon trolSet\Co ntrol\Term inal Serve r' do | |
| 441 | values ' FdenyTSCon nections' => 0 | |
| 442 | end | |
| 443 | ``` | |
| 444 | ||
| 445 | Delete an item from the regist ry | |
| 446 | ```ruby | |
| 447 | windows_re gistry 'HK CU\Softwar e\Test' do | |
| 448 | #Key is the name o f the valu e that you want to d elete the value is a lways empt y | |
| 449 | values ' ValueToDel ete' => '' | |
| 450 | action : remove | |
| 451 | end | |
| 452 | ``` | |
| 453 | ||
| 454 | Add a REG_ MULTI_SZ v alue to th e registry | |
| 455 | ```ruby | |
| 456 | windows_re gistry 'HK CU\Softwar e\Test' do | |
| 457 | values ' MultiStrin g' => ['li ne 1', 'li ne 2', 'li ne 3'] | |
| 458 | type :mu lti_string | |
| 459 | end | |
| 460 | ``` | |
| 461 | ||
| 462 | ### window s_shortcut | |
| 463 | Creates an d modifies Windows s hortcuts. | |
| 464 | ||
| 465 | #### Actio ns | |
| 466 | - :create: create or modify a windows sh ortcut | |
| 467 | ||
| 468 | #### Attri bute Param eters | |
| 469 | - name: na me attribu te. The sh ortcut to create/mod ify. | |
| 470 | - target: what the s hortcut li nks to | |
| 471 | - argument s: argumen ts to pass to the ta rget when the shortc ut is exec uted | |
| 472 | - descript ion: | |
| 473 | - cwd: Wor king direc tory to us ed when th e target i s executed | |
| 474 | - iconloca tion: Icon to use, i n the form at of ```" path, inde x"``` wher e index is which ico n in that file to us e (See [Ws hShortcut. IconLocati on](https: //msdn.mic rosoft.com /en-us/lib rary/3s9bx 7at.aspx)) | |
| 475 | ||
| 476 | #### Examp les | |
| 477 | ||
| 478 | Add a shor tcut all u sers deskt op: | |
| 479 | ```ruby | |
| 480 | require 'w in32ole' | |
| 481 | all_users_ desktop = WIN32OLE.n ew("WScrip t.Shell"). SpecialFol ders("AllU sersDeskto p") | |
| 482 | ||
| 483 | windows_sh ortcut "#{ all_users_ desktop}/N otepad.lnk " do | |
| 484 | target "C:\\WIND OWS\\notep ad.exe" | |
| 485 | descri ption "Lau nch Notepa d" | |
| 486 | iconlo cation "C: \\windows\ \notepad.e xe, 0" | |
| 487 | end | |
| 488 | ``` | |
| 489 | ||
| 490 | #### Libra ry Methods | |
| 491 | ||
| 492 | ```ruby | |
| 493 | Registry.v alue_exist s?('HKLM\S OFTWARE\Mi crosoft\Wi ndows\Curr entVersion \Run','BGI NFO') | |
| 494 | Registry.k ey_exists? ('HKLM\SOF TWARE\Micr osoft') | |
| 495 | BgInfo = R egistry.ge t_value('H KLM\SOFTWA RE\Microso ft\Windows \CurrentVe rsion\Run' ,'BGINFO') | |
| 496 | ``` | |
| 497 | ||
| 498 | ### window s_path | |
| 499 | #### Actio ns | |
| 500 | - :add: Ad d an item to the sys tem path | |
| 501 | - :remove: Remove an item from the syste m path | |
| 502 | ||
| 503 | #### Attri bute Param eters | |
| 504 | - :path: N ame attrib ute. The n ame of the value to add to the system pa th | |
| 505 | ||
| 506 | #### Examp les | |
| 507 | ||
| 508 | Add Sysint ernals to the system path | |
| 509 | ```ruby | |
| 510 | windows_pa th 'C:\Sys internals' do | |
| 511 | action : add | |
| 512 | end | |
| 513 | ``` | |
| 514 | ||
| 515 | Remove 7-Z ip from th e system p ath | |
| 516 | ```ruby | |
| 517 | windows_pa th 'C:\7-Z ip' do | |
| 518 | action : remove | |
| 519 | end | |
| 520 | ``` | |
| 521 | ||
| 522 | ### window s_task | |
| 523 | Creates, d eletes or runs a Win dows sched uled task. Requires Windows | |
| 524 | Server 200 8 due to A PI usage. | |
| 525 | ||
| 526 | #### Actio ns | |
| 527 | - :create: creates a task (or updates ex isting if user or co mmand has changed) | |
| 528 | - :delete: deletes a task | |
| 529 | - :run: ru ns a task | |
| 530 | - :end: en ds a task | |
| 531 | - :change: changes t he un/pw o r command of a task | |
| 532 | - :enable: enable a task | |
| 533 | - :disable : disable a task | |
| 534 | ||
| 535 | #### Attri bute Param eters | |
| 536 | - task_nam e: name at tribute, T he task na me. ("Task Name" or "/Task Nam e") | |
| 537 | - force: W hen used w ith create , will upd ate the ta sk. | |
| 538 | - command: The comma nd the tas k will run . | |
| 539 | - cwd: The directory the task will be ru n from. | |
| 540 | - user: Th e user to run the ta sk as. (de faults to 'SYSTEM') | |
| 541 | - password : The user 's passwor d. (requir es user) | |
| 542 | - run_leve l: Run wit h limited or highest privilege s. | |
| 543 | - frequenc y: Frequen cy with wh ich to run the task. (default is :hourly . Other va lid values include : minute, :h ourly, :da ily, :week ly, :month ly, :once, :on_logon , :onstart , :on_idle ) | |
| 544 | - frequenc y_modifier : Multiple for frequ ency. (15 minutes, 2 days) | |
| 545 | - start_da y: Specifi es the fir st date on which the task runs . Optional string (M M/DD/YYYY) | |
| 546 | - start_ti me: Specif ies the st art time t o run the task. Opti onal strin g (HH:mm) | |
| 547 | - interact ive_enable d: (Allow task to ru n interact ively or n on-interac tively. R equires us er and pas sword.) | |
| 548 | - day: For monthly o r weekly t asks, the day(s) on which the task runs. (MON - S UN, *, 1 - 31) | |
| 549 | ||
| 550 | #### Examp les | |
| 551 | ||
| 552 | Run Chef e very 15 mi nutes | |
| 553 | ```ruby | |
| 554 | windows_ta sk 'Chef c lient' do | |
| 555 | user 'Ad ministrato r' | |
| 556 | password '$ecR3t' | |
| 557 | cwd 'C:\ \chef\\bin ' | |
| 558 | command 'chef-clie nt -L C:\\ tmp\\' | |
| 559 | run_leve l :highest | |
| 560 | frequenc y :minute | |
| 561 | frequenc y_modifier 15 | |
| 562 | end | |
| 563 | ``` | |
| 564 | ||
| 565 | Update Che f Client t ask with n ew passwor d and log location | |
| 566 | ```ruby | |
| 567 | windows_ta sk 'Chef c lient' do | |
| 568 | user 'Ad ministrato r' | |
| 569 | password 'N3wPassW 0Rd' | |
| 570 | cwd 'C:\ \chef\\bin ' | |
| 571 | command 'chef-clie nt -L C:\\ chef\\logs \\' | |
| 572 | action : change | |
| 573 | end | |
| 574 | ``` | |
| 575 | ||
| 576 | Delete a t aks named 'old task' | |
| 577 | ```ruby | |
| 578 | windows_ta sk 'old ta sk' do | |
| 579 | action : delete | |
| 580 | end | |
| 581 | ``` | |
| 582 | ||
| 583 | Enable a t ask named 'Chef clie nt' | |
| 584 | ```ruby | |
| 585 | windows_ta sk 'Chef c lient' do | |
| 586 | action : enable | |
| 587 | end | |
| 588 | ``` | |
| 589 | ||
| 590 | Disable a task named 'Chef cli ent' | |
| 591 | ```ruby | |
| 592 | windows_ta sk 'Chef c lient' do | |
| 593 | action : disable | |
| 594 | end | |
| 595 | ``` | |
| 596 | ||
| 597 | ### window s_zipfile | |
| 598 | Most versi on of Wind ows do not ship with native cl i utility for managi ng compres sed files. This res ource prov ides a pur e-ruby imp lementatio n for mana ging zip f iles. Be s ure to use the `not_ if` or `on ly_if` met a paramete rs to guar d the reso urce for i dempotence or action will be t aken every Chef run. | |
| 599 | ||
| 600 | #### Actio ns | |
| 601 | - :unzip: unzip a co mpressed f ile | |
| 602 | - :zip: zi p a direct ory (recur sively) | |
| 603 | ||
| 604 | #### Attri bute Param eters | |
| 605 | - path: na me attribu te. The pa th where f iles will be (un)zip ped to. | |
| 606 | - source: source of the zip fi le (either a URI or local path ) for :unz ip, or dir ectory to be zipped for :zip. | |
| 607 | - overwrit e: force a n overwrit e of the f iles if th ey already exist. | |
| 608 | - checksum : for :unz ip, useful if source is remote , if the l ocal file matches th e SHA-256 checksum, Chef will not downlo ad it. | |
| 609 | ||
| 610 | #### Examp les | |
| 611 | ||
| 612 | Unzip a re mote zip f ile locall y | |
| 613 | ```ruby | |
| 614 | windows_zi pfile 'c:/ bin' do | |
| 615 | source ' http://dow nload.sysi nternals.c om/Files/S ysinternal sSuite.zip ' | |
| 616 | action : unzip | |
| 617 | not_if { ::File.exi sts?('c:/b in/PsExec. exe')} | |
| 618 | end | |
| 619 | ``` | |
| 620 | ||
| 621 | Unzip a lo cal zipfil e | |
| 622 | ```ruby | |
| 623 | windows_zi pfile 'c:/ the_codez' do | |
| 624 | source ' c:/foo/baz /the_codez .zip' | |
| 625 | action : unzip | |
| 626 | end | |
| 627 | ``` | |
| 628 | ||
| 629 | Create a l ocal zipfi le | |
| 630 | ```ruby | |
| 631 | windows_zi pfile 'c:/ foo/baz/th e_codez.zi p' do | |
| 632 | source ' c:/the_cod ez' | |
| 633 | action : zip | |
| 634 | end | |
| 635 | ``` | |
| 636 | ||
| 637 | Libraries | |
| 638 | ---------- ---------- ----- | |
| 639 | ### Window sHelper | |
| 640 | ||
| 641 | Helper tha t allows y ou to use helpful fu nctions in windows | |
| 642 | ||
| 643 | #### insta lled_packa ges | |
| 644 | Returns a hash of al l DisplayN ames insta lled | |
| 645 | ```ruby | |
| 646 | # usage in a recipe | |
| 647 | ::Chef::Re cipe.send( :include, Windows::H elper) | |
| 648 | hash_of_in stalled_pa ckages = i nstalled_p ackages | |
| 649 | ``` | |
| 650 | ||
| 651 | #### is_pa ckage_inst alled? | |
| 652 | - `package _name`: Th e name of the packag e you want to query to see if it is inst alled | |
| 653 | - `returns `: true if the packa ge is inst alled, fal se if it t he package is not in stalled | |
| 654 | ||
| 655 | Download a file if a package i sn't insta lled | |
| 656 | ```ruby | |
| 657 | # usage in a recipe to not dow nload a fi le if pack age is alr eady insta lled | |
| 658 | ::Chef::Re cipe.send( :include, Windows::H elper) | |
| 659 | is_win_sdk _installed = is_pack age_instal led?('Wind ows Softwa re Develop ment Kit') | |
| 660 | ||
| 661 | remote_fil e 'C:\wind ows\temp\w indows_sdk .zip' do | |
| 662 | source ' http://url _to_downlo ad/windows _sdk.zip' | |
| 663 | action : create_if_ missing | |
| 664 | not_if { is_win_sdk _installed } | |
| 665 | end | |
| 666 | ``` | |
| 667 | Do somethi ng if a pa ckage is i nstalled | |
| 668 | ```ruby | |
| 669 | # usage in a provide r | |
| 670 | include Wi ndows::Hel per | |
| 671 | if is_pack age_instal led?('Wind ows Softwa re Develop ment Kit') | |
| 672 | # do som ething if package is installed | |
| 673 | end | |
| 674 | ``` | |
| 675 | ||
| 676 | Exception/ Report Han dlers | |
| 677 | ---------- ---------- ----- | |
| 678 | ### Window sRebootHan dler | |
| 679 | Required r eboots are a necessa ry evil of configuri ng and man aging Wind ows nodes. This rep ort handle r (ie fire s at the e nd of Chef runs) act s on reque sted (Chef initiated ) or pendi ng (as det ermined by the OS pe r configur ation acti on we perf ormed) reb oots. The `allow_pe nding_rebo ots` initi alization argument s hould be s et to fals e if you d o not want the handl er to auto matically reboot a n ode if it has been d etermined a reboot i s pending. Reboots can still be request ed explici tly via th e `windows _reboot` L WRP. | |
| 680 | ||
| 681 | ### Initia lization A rguments | |
| 682 | - `allow_p ending_reb oots`: ind icator on whether th e handler should act on a the Window's ' pending re boot' stat e. default is true | |
| 683 | - `timeout `: timeout delay in seconds to wait befo re proceed ing with t he reboot. default i s 60 secon ds | |
| 684 | - `reason` : comment on the re ason for t he reboot. default i s 'Chef So ftware Che f initiate d reboot' | |
| 685 | ||
| 686 | ||
| 687 | Windows Ch efSpec Mat chers | |
| 688 | ---------- ---------- ----- | |
| 689 | The Window s cookbook includes custom [Ch efSpec](ht tps://gith ub.com/set hvargo/che fspec) mat chers you can use to test your own cookb ooks that consume Wi ndows cook book LWRPs . | |
| 690 | ||
| 691 | ###Example Matcher U sage | |
| 692 | ```ruby | |
| 693 | expect(che f_run).to install_wi ndows_pack age('Node. js').with( | |
| 694 | source: 'http://no dejs.org/d ist/v0.10. 26/x64/nod e-v0.10.26 -x64.msi') | |
| 695 | ``` | |
| 696 | ||
| 697 | ###Windows Cookbook Matchers | |
| 698 | * install_ windows_pa ckage | |
| 699 | * remove_w indows_pac kage | |
| 700 | * install_ windows_fe ature | |
| 701 | * remove_w indows_fea ture | |
| 702 | * delete_w indows_fea ture | |
| 703 | * create_w indows_tas k | |
| 704 | * delete_w indows_tas k | |
| 705 | * run_wind ows_task | |
| 706 | * change_w indows_tas k | |
| 707 | * add_wind ows_path | |
| 708 | * remove_w indows_pat h | |
| 709 | * run_wind ows_batch | |
| 710 | * set_wind ows_pagefi le | |
| 711 | * unzip_wi ndows_zipf ile_to | |
| 712 | * zip_wind ows_zipfil e_to | |
| 713 | * create_w indows_sho rtcut | |
| 714 | * create_w indows_aut o_run | |
| 715 | * remove_w indows_aut o_run | |
| 716 | * create_w indows_pri nter | |
| 717 | * delete_w indows_pri nter | |
| 718 | * create_w indows_pri nter_port | |
| 719 | * delete_w indows_pri nter_port | |
| 720 | * request_ windows_re boot | |
| 721 | * cancel_w indows_reb oot | |
| 722 | * create_w indows_sho rtcut | |
| 723 | ||
| 724 | ||
| 725 | Usage | |
| 726 | ----- | |
| 727 | ||
| 728 | Place an e xplicit de pendency o n this coo kbook (usi ng depends in the co okbook's m etadata.rb ) from any cookbook where you would like to use th e Windows- specific r esources/p roviders t hat ship w ith this c ookbook. | |
| 729 | ||
| 730 | ```ruby | |
| 731 | depends 'w indows' | |
| 732 | ``` | |
| 733 | ||
| 734 | ### defaul t | |
| 735 | Convenienc e recipe t hat instal ls support ing gems f or many of the resou rces/provi ders that ship with this cookb ook. | |
| 736 | ||
| 737 | *Change in v1.3.0: U ses chef_g em instead of gem_pa ckage to e nsure gem installati on in Chef 0.10.10.* | |
| 738 | ||
| 739 | ### reboot _handler | |
| 740 | Leverages the `chef_ handler` L WRP to reg ister the `WindowsRe bootHandle r` report handler th at ships a s part of this cookb ook. By de fault this handler i s set to a utomatical ly act on pending re boots. If you would like to c hange this behavior override ` node['wind ows']['all ow_pending _reboots'] ` and set the value to false. For examp le: | |
| 741 | ||
| 742 | ```ruby | |
| 743 | name 'base ' | |
| 744 | descriptio n 'base ro le' | |
| 745 | override_a ttributes( | |
| 746 | 'windows ' => { | |
| 747 | 'allow _pending_r eboots' => false | |
| 748 | } | |
| 749 | ) | |
| 750 | ``` | |
| 751 | ||
| 752 | This will still allo w a reboot to be exp licitly re quested vi a the `win dows_reboo t` LWRP. | |
| 753 | ||
| 754 | By default , the hand ler will o nly be reg istered as a report handler, m eaning tha t it will only fire at the end of succes sful Chef runs. If t he run fai ls, pendin g or reque sted reboo ts will be ignored. This can l ead to a s ituation w here some package wa s installe d and noti fied a reb oot reques t via the `windows_r eboot` LWR P, and the n the run fails for some unrel ated reaso n, and the reboot re quest gets dropped b ecause the resource that notif ied the re boot reque st will al ready be u p-to-date at the nex t run and will not r equest a r eboot agai n, and thu s the requ ested rebo ot will ne ver be per formed. To change th is behavio r and regi ster the h andler as an excepti on handler that fire s at the e nd of fail ed runs to o, overrid e `node['w indows'][' allow_rebo ot_on_fail ure']` and set the v alue to tr ue. | |
| 755 | ||
| 756 | ||
| 757 | License & Authors | |
| 758 | ---------- ------- | |
| 759 | - Author:: Seth Chis amore (<sc hisamo@che f.io>) | |
| 760 | - Author:: Doug MacE achern (<d ougm@vmwar e.com>) | |
| 761 | - Author:: Paul Mort on (<pmort on@biaprot ect.com>) | |
| 762 | - Author:: Doug Iret on (<doug. ireton@nor dstrom.com >) | |
| 763 | ||
| 764 | ```text | |
| 765 | Copyright 2011-2013, Chef Soft ware, Inc. | |
| 766 | Copyright 2010, VMwa re, Inc. | |
| 767 | Copyright 2011, Busi ness Intel ligence As sociates, Inc | |
| 768 | Copyright 2012, Nord strom, Inc . | |
| 769 | ||
| 770 | Licensed u nder the A pache Lice nse, Versi on 2.0 (th e "License "); | |
| 771 | you may no t use this file exce pt in comp liance wit h the Lice nse. | |
| 772 | You may ob tain a cop y of the L icense at | |
| 773 | ||
| 774 | http:/ /www.apach e.org/lice nses/LICEN SE-2.0 | |
| 775 | ||
| 776 | Unless req uired by a pplicable law or agr eed to in writing, s oftware | |
| 777 | distribute d under th e License is distrib uted on an "AS IS" B ASIS, | |
| 778 | WITHOUT WA RRANTIES O R CONDITIO NS OF ANY KIND, eith er express or implie d. | |
| 779 | See the Li cense for the specif ic languag e governin g permissi ons and | |
| 780 | limitation s under th e License. | |
| 781 | ``` |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.