172. EPMO Open Source Coordination Office Redaction File Detail Report

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.

172.1 Files compared

# Location File Last Modified
1 chef-repo.zip\chef-repo Rakefile Fri Dec 4 18:27:52 2015 UTC
2 chef-repo.zip\chef-repo Rakefile Mon Oct 2 12:37:23 2017 UTC

172.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 672
Changed 1 2
Inserted 0 0
Removed 0 0

172.3 Comparison options

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

172.4 Active regular expressions

No regular expressions were active.

172.5 Comparison detail

  1   #
  2   # Rakefile  for Chef  Server Rep ository
  3   #
  4   # Author::  Adam Jaco b (<adam@o pscode.com >)
  5   # Copyrigh t:: Copyri ght (c) 20 08 Opscode , Inc.
  6   # License: : Apache L icense, Ve rsion 2.0
  7   #
  8   # Licensed  under the  Apache Li cense, Ver sion 2.0 ( the "Licen se");
  9   # you may  not use th is file ex cept in co mpliance w ith the Li cense.
  10   # You may  obtain a c opy of the  License a t
  11   #
  12   #     http ://www.apa che.org/li censes/LIC ENSE-2.0
  13   #
  14   # Unless r equired by  applicabl e law or a greed to i n writing,  software
  15   # distribu ted under  the Licens e is distr ibuted on  an "AS IS"  BASIS,
  16   # WITHOUT  WARRANTIES  OR CONDIT IONS OF AN Y KIND, ei ther expre ss or impl ied.
  17   # See the  License fo r the spec ific langu age govern ing permis sions and
  18   # limitati ons under  the Licens e.
  19   #
  20  
  21   require 'r ubygems'
  22   require 'j son'
  23   require 'o pen-uri'
  24  
  25   JSON.creat e_id = nil
  26  
  27   # Load con stants fro m rake con fig file.
  28   require Fi le.join(Fi le.dirname (__FILE__) , 'config' , 'rake')
  29  
  30   require Fi le.dirname (__FILE__)  + "/no_in ternet/no_ internet.r b"
  31  
  32   # Detect t he version  control s ystem and  assign to  $vcs. Used  by the up date
  33   # task in  chef_repo. rake (belo w). The in stall task  calls upd ate, so th is
  34   # is run w henever th e repo is  installed.
  35   #
  36   # Comment  out these  lines to s kip the up date.
  37  
  38   if File.di rectory?(F ile.join(T OPDIR, ".s vn"))
  39     $vcs = : svn
  40   elsif File .directory ?(File.joi n(TOPDIR,  ".git"))
  41     $vcs = : git
  42   end
  43  
  44   $knife_rb  = "#{ENV[" HOME"]}/Pr ojects/vis tacore/.ch ef/knife.r b"
  45  
  46  
  47   desc "Bund le a singl e cookbook  for distr ibution"
  48   task :bund le_cookboo k => [ :me tadata ]
  49   task :bund le_cookboo k, :cookbo ok do |t,  args|
  50     tarball_ name = "#{ args[:cook book]}.tar .gz"
  51     temp_dir  = File.jo in(Dir.tmp dir, "chef -upload-co okbooks")
  52     temp_coo kbook_dir  = File.joi n(temp_dir , args[:co okbook])
  53     tarball_ dir = File .join(TOPD IR, "pkgs" )
  54     FileUtil s.mkdir_p( tarball_di r)
  55     FileUtil s.mkdir(te mp_dir)
  56     FileUtil s.mkdir(te mp_cookboo k_dir)
  57  
  58     child_fo lders = [  "cookbooks /#{args[:c ookbook]}" , "site-co okbooks/#{ args[:cook book]}" ]
  59     child_fo lders.each  do |folde r|
  60       file_p ath = File .join(TOPD IR, folder , ".")
  61       FileUt ils.cp_r(f ile_path,  temp_cookb ook_dir) i f File.dir ectory?(fi le_path)
  62     end
  63  
  64     system(" tar", "-C" , temp_dir , "-cvzf",  File.join (tarball_d ir, tarbal l_name), " #{args[:co okbook]}")
  65  
  66     FileUtil s.rm_rf te mp_dir
  67   end
  68  
  69   task :task s do |t, a rgs|
  70     exec("/u sr/bin/rak e -T")
  71   end
  72  
  73   desc "Depl oy a machi ne using c hef-repo f or cookboo k/environm ents/roles /etc"
  74   task :test _deploy, [ :machine,  :driver, : log_level,  :environm ent] => :u pload_node
  75  
  76   desc "Depl oy a machi ne using c hef-repo f or cookboo k/environm ents/roles /etc"
  77   task :test _setup, [: machine, : driver, :l og_level,  :environme nt] => :up load_node_ setup
  78  
  79   task :zero _deploy =>  :download _nodes do  |t, args|
  80     execute_ chef("conv erge", arg s[:driver] , args[:en vironment] , args[:lo g_level],  machine_na me: args[: machine],  zero: true )
  81   end
  82  
  83   task :zero _setup =>  :download_ nodes do | t, args|
  84     execute_ chef("setu p", args.d river, arg s.environm ent, args. log_level,  machine_n ame: args. machine, z ero: true)
  85   end
  86  
  87   desc "Depl oy a machi ne using c hef-server  for cookb ook/enviro nments/rol es/etc"
  88   task :depl oy, [:mach ine, :driv er, :log_l evel, :env ironment,  :project_p arams] do  |t, args|
  89     execute_ chef("conv erge", arg s[:driver] , args[:en vironment] , args[:lo g_level],  machine_na me: args[: machine],  project_pa rams: args [:project_ params])
  90   end
  91  
  92   desc "Depl oy a colon -delimited  list of m achines in  parallel;  example:  rake multi _deploy[jd s:mocks:so lr]"
  93   task :mult i_deploy,  [:machines , :driver,  :log_leve l, :enviro nment] do  |t, args|
  94     execute_ chef("conv erge", arg s[:driver] , args[:en vironment] , args[:lo g_level],  machines:  args[:mach ines], rec ipe: "mult i_deploy")
  95   end
  96  
  97   desc "Depl oy the ful l ehmp bac kend in pa rallel [jd s, mocks,  solr, vist a-kodak, v ista-panor ama] => vx sync"
  98   task :depl oy_backend , [:driver , :log_lev el, :envir onment] do  |t, args|
  99     execute_ chef("conv erge", arg s[:driver] , args[:en vironment] , args[:lo g_level],  recipe: "f ull_backen d")
  100   end
  101  
  102   desc "Brin g up a mac hine witho ut provisi oning"
  103   task :setu p, [:machi ne, :drive r, :log_le vel, :envi ronment] d o |t, args |
  104     execute_ chef("setu p", args.d river, arg s.environm ent, args. log_level,  machine_n ame: args. machine)
  105   end
  106  
  107   desc "Dest roy a mach ine agains t chef-rep o and dele te the nod e from che f server"
  108   task :test _destroy,  [:machine,  :driver,  :log_level , :environ ment] => : delete_nod e
  109  
  110   task :zero _destroy d o |t, args |
  111     execute_ chef("dest roy", args [:driver],  args[:env ironment],  args[:log _level], m achine_nam e: args[:m achine], z ero: true)
  112   end
  113  
  114   desc "Dest roy a mach ine agains t chef ser ver"
  115   task :dest roy, [:mac hine, :dri ver, :log_ level, :en vironment]  do |t, ar gs|
  116     execute_ chef("dest roy", args [:driver],  args[:env ironment],  args[:log _level], m achine_nam e: args[:m achine])
  117   end
  118  
  119   desc "Stop  all virtu albox mach ines using  the vagra nt directo ry"
  120   task :stop _all do |t , args|
  121     Dir.chdi r("#{ENV[' HOME']}/Pr ojects/vis tacore/.ch ef/vms"){
  122       exec(" vagrant ha lt")
  123     }
  124   end
  125  
  126   desc "Stop  a single  virtualbox  machine u sing the v agrant dir ectory"
  127   task :stop , :machine  do |t, ar gs|
  128     Dir.chdi r("#{ENV[' HOME']}/Pr ojects/vis tacore/.ch ef/vms"){
  129        exec( "vagrant h alt #{args [:machine] }-#{ENV['U SER']}")
  130     }
  131   end
  132  
  133   desc "Star t all virt ualbox mac hines usin g the vagr ant direct ory"
  134   task :star t_all do | t, args|
  135     Dir.chdi r("#{ENV[' HOME']}/Pr ojects/vis tacore/.ch ef/vms"){
  136       exec(" vagrant up  --no-prov ision")
  137     }
  138   end
  139  
  140   desc "Star t a single  virtualbo x machine  using the  vagrant di rectory"
  141   task :star t, :machin e do |t, a rgs|
  142     Dir.chdi r("#{ENV[' HOME']}/Pr ojects/vis tacore/.ch ef/vms"){
  143       exec(" vagrant up  --no-prov ision #{ar gs[:machin e]}-#{ENV[ 'USER']}")
  144     }
  145   end
  146  
  147   desc "Down load all t he current  user's no des from c hef server "
  148   task :down load_nodes  do |t, ar gs|
  149     system(
  150       "/opt/ chefdk/bin /knife dow nload /nod es/*-#{ENV ['USER']}. json --con fig #{$kni fe_rb}"
  151     )
  152   end
  153  
  154   task :uplo ad_node =>  :zero_dep loy do |t,  args|
  155     upload_n ode(args.m achine)
  156   end
  157  
  158   task :uplo ad_node_se tup => :ze ro_setup d o |t, args |
  159     upload_n ode(args.m achine)
  160   end
  161  
  162   task :dele te_node =>  :zero_des troy do |t , args|
  163     stack =  ENV['JOB_N AME'] || E NV['USER']
  164     system(
  165       "/opt/ chefdk/bin /knife nod e delete # {args[:mac hine]}-#{s tack} --co nfig #{$kn ife_rb}"
  166     )
  167   end
  168  
  169   desc "SSH  into a mac hine by sp ecifying t he machine  name, dri ver and st ack (drive r and stac k are opti onal)"
  170   task :ssh,  [:machine , :driver,  :stack] d o |t, args |
  171     machine  = args[:ma chine]
  172     stack =  args[:stac k] || ENV[ "JOB_NAME" ] || ENV[" USER"]
  173     driver =  args[:dri ver] || "l ocal"
  174     ip = kni fe_search_ for_ip(mac hine, stac k, driver)
  175     key = kn ife_search _for_key_n ame(machin e, stack,  driver)
  176     case dri ver
  177     when "aw s"
  178         user = " DNS       "
  179     when "lo cal"
  180       user =  "vagrant"
  181     end
  182     exec('ss h', '-o',  'StrictHos tKeyChecki ng=no', '- i', "#{key }", "#{use r}@#{ip}")
  183   end
  184  
  185   desc "Uplo ad a data  bag item"
  186   task :uplo ad_databag _item, [:d atabag,:it em] do |t,  args|
  187     upload_d atabag_ite m(args[:da tabag],arg s[:item])
  188   end
  189  
  190   desc "Crea te data ba g"
  191   task :crea te_databag , [:databa g] do |t,  args|
  192     create_d atabag(arg s[:databag ])
  193   end
  194  
  195   desc "Uplo ad all dat abags"
  196   task :uplo ad_databag s do
  197     #Create  the databa g for data bags not c urrently i n server
  198     new_bags  = get_new _databags
  199     new_bags .each do | bag|
  200       create _databag(b ag)
  201     end
  202  
  203     #Upload  every data bag item
  204     Dir.glob ("data_bag s/**/*.jso n") do |it em|
  205       bag =  File.basen ame(File.d irname(ite m)) #Gets  the data b ag name fr om the fil epath
  206       upload _databag_i tem(bag,it em)
  207     end
  208   end
  209  
  210   # requirin g other fi les
  211   Dir.glob(" rake/**/*. rb") do |r b_file|
  212     require_ relative r b_file
  213   end
  214  
  215  
  216   ########## ########## ########## ########## ########## #
  217   ########## ########## ########## ########## ########## #
  218   ########## ##### METH OD DEFINIT IONS ##### ########## #
  219   ########## ########## ########## ########## ########## #
  220   ########## ########## ########## ########## ########## #
  221  
  222   def upload _node(mach ine)
  223     stack =  ENV['JOB_N AME'] || E NV['USER']
  224     system(
  225       "/opt/ chefdk/bin /knife nod e from fil e #{ENV['H OME']}/Pro jects/vist acore/chef -repo/node s/#{machin e}-#{stack }.json --c onfig #{$k nife_rb}"
  226     )
  227   end
  228  
  229   def knife_ search_for _ip(machin e_name, st ack, drive r)
  230     raw_sear ch = `/opt /chefdk/bi n/knife se arch node  \'name:#{m achine_nam e}-#{stack }\' -Fj -- config ~/P rojects/vi stacore/.c hef/knife. rb`
  231     parsed_s earch = JS ON.parse(r aw_search)
  232     fail "Mo re than on e node wit h that nam e found" i f parsed_s earch["res ults"] > 1
  233     fail "No  node foun d with the  name:  #{ machine_na me}-#{stac k}" if par sed_search ["results" ] == 0
  234     case dri ver
  235     when "aw s"
  236     ip = par sed_search ["rows"][0 ]['automat ic']['ec2' ]['public_ ipv4']
  237     when "lo cal"
  238       ip = p arsed_sear ch["rows"] [0]['autom atic']['ip address']
  239     end
  240     return i p
  241   end
  242  
  243   def knife_ search_for _key_name( machine_na me, stack,  driver)
  244     case dri ver
  245     when "aw s"
  246       raw_se arch = `/o pt/chefdk/ bin/knife  search nod e \'name:# {machine_n ame}-#{sta ck}\' -Fj  --config # {$knife_rb }`
  247       parsed _search =  JSON.parse (raw_searc h)
  248       fail " More than  one key wa s found fo r: #{machi ne_name}"  if parsed_ search["re sults"] >  1
  249       fail " No key was  found for : #{machin e_name}" i f parsed_s earch["res ults"] ==  0
  250       begin
  251         key  = parsed_s earch["row s"][0]['no rmal']["ch ef_provisi oning"]["r eference"] ["key_name "]
  252       rescue  NoMethodE rror
  253         begi n
  254           ke y = parsed _search["r ows"][0][' normal'][" chef_provi sioning"][ "location" ]["key_nam e"] 
  255         resc ue 
  256           ra ise %/
  257           No  attribute  found for  #{machine _name}-#{s tack} at:  ['rows'][0 ]['normal' ]['chef_pr ovisioning ']['locati on']['key_ name'] 
  258           or  ['rows'][ 0]['normal ']['chef_p rovisionin g']['refer ence']['ke y_name']
  259           /
  260         end
  261       end
  262       key_pa th = File. expand_pat h(key, "#{ ENV['HOME' ]}/.vagran t.d/aws/ke ys")
  263       unless  File.exis ts?(key_pa th)
  264         key_ path = Fil e.expand_p ath(File.b asename(ke y_path), " #{ENV['HOM E']}/Proje cts/vistac ore/.vagra nt.d/aws/k eys")
  265       end
  266     when "lo cal"
  267       key_pa th = File. expand_pat h("insecur e_private_ key", "#{E NV['HOME'] }/Projects /vistacore /.vagrant. d/")
  268     end
  269     unless F ile.exists ?(key_path )
  270       raise  %/
  271       ****** ********** ********** ********** ********** ********** *****
  272       Could  not find t he ssh key  for: mach ine_name
  273       Most l ikely this  means you  do not ha ve the pro per creden tials
  274       to acc ess this m achine.
  275       ****** ********** ********** ********** ********** ********** *****
  276       /
  277     end
  278     return k ey_path
  279   end
  280  
  281   def execut e_chef(act ion, drive r, environ ment, log_ level, opt ions = {})
  282     env_vars  = {
  283       "ACTIO N" => acti on,
  284       "MACHI NE_NAME" = > options[ :machine_n ame],
  285       "MACHI NES" => op tions[:mac hines],
  286       "DRIVE R" => driv er || "loc al",
  287       "PROJE CT_PARAMS"  => option s[:project _params],
  288       "BRANC H" => opti ons[:branc h] || "dev ",
  289       "DRIVE R" => driv er || "loc al"
  290     }
  291     environm ent = envi ronment ||  "dev"
  292     log_leve l = log_le vel || "wa rn"
  293     recipe =  options[: recipe] ||  "default"
  294     if optio ns[:zero]
  295       system (env_vars,  "chef-cli ent -z -o  machine::# {recipe} - -force-for matter --e nvironment  #{environ ment} --co nfig #{$kn ife_rb} -- log_level  #{log_leve l}")
  296     else  
  297       system (env_vars,  "chef-cli ent -o mac hine::#{re cipe} --fo rce-format ter --envi ronment #{ environmen t} --confi g #{$knife _rb} --log _level #{l og_level}" )
  298     end
  299   end
  300  
  301   def get_ne w_databags ()
  302     local =  get_databa gs(true)
  303     server =  get_datab ags(false)
  304     diff = l ocal - ser ver
  305     return d iff
  306   end
  307  
  308   def get_da tabags(loc al=true)
  309     zero = l ocal ? '-z ' : ''
  310     databag_ array = []
  311     `knife d ata bag li st --confi g #{$knife _rb} #{zer o} > datab ag_list`
  312     File.ope n("databag _list", "r ") do |fi|
  313       fi.eac h_line do  |line|
  314         data bag = line .strip
  315         next  if databa g.start_wi th?('WARN: ')  #To re move the ' WARN: foun d in multi ple direct ories' mes sage
  316         data bag_array. push(datab ag)
  317       end
  318     end
  319     File.del ete("datab ag_list")
  320     return d atabag_arr ay
  321   end
  322  
  323   def create _databag(d ata_bag)
  324     puts "Cr eating dat a bag #{da ta_bag}... "
  325     cmd = "k nife data  bag create  #{data_ba g} --confi g #{$knife _rb}"
  326     `#{cmd}`
  327     raise "F ailed to c reate data bag #{data _bag}" unl ess $?.exi tstatus==0
  328   end
  329  
  330   def upload _databag_i tem(data_b ag, item)
  331     puts "Up loading #{ item} in b ag: #{data _bag}"
  332     item_pat h = File.e xpand_path (item, Fil e.dirname( __FILE__))
  333     cmd = "k nife data  bag from f ile #{data _bag} #{it em_path} - -config #{ $knife_rb} "
  334     `#{cmd}`
  335     raise "F ailed to u pload data bag item # {item} in  databag #{ data_bag}"  unless $? .exitstatu s==0
  336   end
  337