diff --git a/providers/secret.rb b/providers/secret.rb new file mode 100644 index 0000000..3bb2d02 --- /dev/null +++ b/providers/secret.rb @@ -0,0 +1,25 @@ +def load_current_resource + @current_resource = Chef::Resource::LibvirtSecret.new(new_resource.name) + @libvirt = ::Libvirt.open(new_resource.uri) + @current_resource +end + +action :define do + require 'base64' + uuid = new_resource.uuid || ::UUIDTools::UUID.random_create + begin + new_secret_xml = <<-EOF + + #{new_resource.uuid} + + #{new_resource.name} + + + EOF + conn = Libvirt::open(new_resource.uri) + secret = conn.define_secret_xml(new_secret_xml) + secret.value = Base64.decode64(new_resource.value) + rescue Libvirt::RetrieveError + raise "ERROR" + end +end diff --git a/resources/secret.rb b/resources/secret.rb new file mode 100644 index 0000000..9a22a41 --- /dev/null +++ b/resources/secret.rb @@ -0,0 +1,14 @@ +actions :define, :undefine + +def initialize(*args) + super + @action = :define +end + +attribute :name, :kind_of => String, :name_attribute => true +attribute :type, :kind_of => String, :required => true, :default => 'ceph' +attribute :ephemeral, :kind_of => String, :default => 'no' +attribute :private, :kind_of => String, :default => 'no' +attribute :uuid, :kind_of => String +attribute :value, :kind_of => String, :required => true +attribute :uri, :kind_of => String, :default => 'qemu:///system'