Module: Chef::LXC::ContainerHelper
- Includes:
- Chef::LXCHelper
- Defined in:
- lib/chef/lxc/container_helper.rb
Instance Method Summary collapse
- #command(cmd, opts = {}) ⇒ Object
- #command!(cmd, opts = {}) ⇒ Object
- #recipe(path = nil, &block) ⇒ Object
Methods included from Chef::LXCHelper
Instance Method Details
#command(cmd, opts = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chef/lxc/container_helper.rb', line 14 def command(cmd, opts = {}) live_stream = opts[:live_stream] || $stdout out = execute(wait: true) do cmd = Mixlib::ShellOut.new(cmd) cmd.live_stream = live_stream cmd.run_command cmd.exitstatus end out end |
#command!(cmd, opts = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/chef/lxc/container_helper.rb', line 25 def command!(cmd, opts = {}) exitstatus = command(cmd, opts) raise "Failed to execute: '#{cmd}'.\nExit code: #{exitstatus}" unless exitstatus.zero? exitstatus end |
#recipe(path = nil, &block) ⇒ Object
9 10 11 12 |
# File 'lib/chef/lxc/container_helper.rb', line 9 def recipe(path = nil, &block) recipe_content = path ? File.read(path) : nil recipe_in_container(self, recipe_content, &block) end |