Top Level Namespace
Defined Under Namespace
Modules: ChefLxc, Helpers, LxcMonkey, Vagabond Classes: Chef, Lxc, LxcFileConfig
Instance Attribute Summary collapse
-
#subresources ⇒ Object
readonly
Returns the value of attribute subresources.
Instance Method Summary collapse
-
#build_pref(package_name, pin, pin_priority) ⇒ Object
Build preferences.d file contents.
-
#build_repo(uri, distribution, components, arch, add_deb_src) ⇒ Object
build repo file contents.
- #config(cname, &block) ⇒ Object
-
#extract_gpg_ids_from_cmd(cmd) ⇒ Object
run command and extract gpg ids.
- #fstab_mount(fname, &block) ⇒ Object
- #initialize(*args) ⇒ Object
-
#install_key_from_keyserver(key, keyserver) ⇒ Object
install apt key from keyserver.
-
#install_key_from_uri(uri) ⇒ Object
install apt key from URI.
- #interface(iname, &block) ⇒ Object
- #load_current_resource ⇒ Object
- #whyrun_supported? ⇒ Boolean
Instance Attribute Details
#subresources ⇒ Object (readonly)
Returns the value of attribute subresources.
54 55 56 |
# File 'lib/vagabond/cookbooks/lxc/resources/container.rb', line 54 def subresources @subresources end |
Instance Method Details
#build_pref(package_name, pin, pin_priority) ⇒ Object
Build preferences.d file contents
21 22 23 |
# File 'lib/vagabond/cookbooks/apt/providers/preference.rb', line 21 def build_pref(package_name, pin, pin_priority) preference_content = "Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n" end |
#build_repo(uri, distribution, components, arch, add_deb_src) ⇒ Object
build repo file contents
81 82 83 84 85 86 87 88 |
# File 'lib/vagabond/cookbooks/apt/providers/repository.rb', line 81 def build_repo(uri, distribution, components, arch, add_deb_src) components = components.join(' ') if components.respond_to?(:join) repo_info = "#{uri} #{distribution} #{components}\n" repo_info = "[arch=#{arch}] #{repo_info}" if arch repo = "deb #{repo_info}" repo << "deb-src #{repo_info}" if add_deb_src repo end |
#config(cname, &block) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/vagabond/cookbooks/lxc/resources/container.rb', line 47 def config(cname, &block) conf = Chef::Resource::LxcConfig.new("lxc_config[#{self.name} - #{cname}]", nil) conf.container self.name conf.action :nothing @subresources << [conf, block] end |
#extract_gpg_ids_from_cmd(cmd) ⇒ Object
run command and extract gpg ids
40 41 42 43 44 45 46 47 48 |
# File 'lib/vagabond/cookbooks/apt/providers/repository.rb', line 40 def extract_gpg_ids_from_cmd(cmd) so = Mixlib::ShellOut.new(cmd) so.run_command so.stdout.split(/\n/).collect do |t| if z = t.match(/^pub\s+\d+\w\/([0-9A-F]{8})/) z[1] end end.compact end |
#fstab_mount(fname, &block) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/vagabond/cookbooks/lxc/resources/container.rb', line 32 def fstab_mount(fname, &block) fstab = Chef::Resource::LxcFstab.new("lxc_fstab[#{self.name} - #{fname}]", nil) fstab.action :nothing fstab.container self.name @subresources << [fstab, block] end |
#initialize(*args) ⇒ Object
1 2 3 4 |
# File 'lib/vagabond/cookbooks/lxc/resources/container.rb', line 1 def initialize(*args) @subresources = [] super end |
#install_key_from_keyserver(key, keyserver) ⇒ Object
install apt key from keyserver
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagabond/cookbooks/apt/providers/repository.rb', line 27 def install_key_from_keyserver(key, keyserver) execute "install-key #{key}" do if !node['apt']['key_proxy'].empty? command "apt-key adv --keyserver-options http-proxy=#{node['apt']['key_proxy']} --keyserver #{keyserver} --recv #{key}" else command "apt-key adv --keyserver #{keyserver} --recv #{key}" end action :run not_if "apt-key list | grep #{key}" end end |
#install_key_from_uri(uri) ⇒ Object
install apt key from URI
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vagabond/cookbooks/apt/providers/repository.rb', line 51 def install_key_from_uri(uri) key_name = uri.split(/\//).last cached_keyfile = "#{Chef::Config[:file_cache_path]}/#{key_name}" if new_resource.key =~ /http/ remote_file cached_keyfile do source new_resource.key mode 00644 action :create end else cookbook_file cached_keyfile do source new_resource.key cookbook new_resource.cookbook mode 00644 action :create end end execute "install-key #{key_name}" do command "apt-key add #{cached_keyfile}" action :run not_if do installed_ids = extract_gpg_ids_from_cmd("apt-key finger") key_ids = extract_gpg_ids_from_cmd("gpg --with-fingerprint #{cached_keyfile}") (installed_ids & key_ids).sort == key_ids.sort end end end |
#interface(iname, &block) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/vagabond/cookbooks/lxc/resources/container.rb', line 40 def interface(iname, &block) iface = Chef::Resource::LxcInterface.new("lxc_interface[#{self.name} - #{iname}]", nil) iface.container self.name iface.action :nothing @subresources << [iface, block] end |
#load_current_resource ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/vagabond/cookbooks/lxc/providers/fstab.rb', line 1 def load_current_resource if(new_resource.auto_join_rootfs_mount) new_resource.mount_point( ::Lxc.new(new_resource.container).rootfs.join( new_resource.mount_point ).to_path ) end node.run_state[:lxc] ||= Mash.new node.run_state[:lxc][:fstabs] ||= Mash.new node.run_state[:lxc][:fstabs][new_resource.container] ||= [] end |
#whyrun_supported? ⇒ Boolean
22 23 24 |
# File 'lib/vagabond/cookbooks/apt/providers/repository.rb', line 22 def whyrun_supported? true end |