Class: Vagabond::Server
Constant Summary
Constants included from Vagabond
Instance Method Summary collapse
- #auto_upload ⇒ Object
-
#initialize(me, actions) ⇒ Server
constructor
A new instance of Server.
- #stop ⇒ Object
- #upload_cookbooks ⇒ Object
- #upload_databags ⇒ Object
- #upload_environments ⇒ Object
- #upload_roles ⇒ Object
Methods included from Vagabond
Constructor Details
#initialize(me, actions) ⇒ Server
Returns a new instance of Server.
9 10 11 12 13 14 15 16 |
# File 'lib/vagabond/server.rb', line 9 def initialize(me, actions) @name = me @base_template = 'ubuntu_1204' # TODO: Make this dynamic @action = actions.shift setup_ui load_configurations Config[:disable_auto_provision] = true end |
Instance Method Details
#auto_upload ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/vagabond/server.rb', line 32 def auto_upload ui.info 'Auto uploading all assets to local Chef server...' upload_roles upload_databags upload_environments upload_cookbooks ui.info ui.color(' -> All assets uploaded!', :green) end |
#stop ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagabond/server.rb', line 18 def stop if(lxc.exists?) if(lxc.running?) ui.info 'Shutting down Chef server container...' lxc.shutdown ui.info 'Chef server container shut down!' else ui.error 'Chef server container not currently running' end else ui.error 'Chef server container has not been created' end end |
#upload_cookbooks ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/vagabond/server.rb', line 78 def upload_cookbooks am_uploading('cookbooks') do if(vagabondfile[:local_chef_server][:berkshelf]) berks_upload else raw_upload end end end |
#upload_databags ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/vagabond/server.rb', line 51 def upload_databags am_uploading('data bags') do Dir.glob(File.join(base_dir, "data_bags/*")).each do |b| next if %w(. ..).include?(b) coms = [ "knife data bag create #{File.basename(b)} #{Config[:knife_opts]}", "knife data bag from file #{File.basename(b)} #{Config[:knife_opts]} --all" ].each do |com| debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => Config[:debug]) cmd.run_command cmd.error! end end end end |
#upload_environments ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/vagabond/server.rb', line 68 def upload_environments am_uploading('environments') do com = "knife environment from file #{File.join(base_dir, 'environments/*')} #{Config[:knife_opts]}" debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => Config[:debug]) cmd.run_command cmd.error! end end |
#upload_roles ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/vagabond/server.rb', line 41 def upload_roles am_uploading('roles') do com = "knife role from file #{File.join(base_dir, 'roles/*')} #{Config[:knife_opts]}" debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => Config[:debug]) cmd.run_command cmd.error! end end |