This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Bryan Kearney (author)
Thu Apr 09 06:59:15 -0700 2009
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 1 | module Puppet | |
| 2 | newtype(:ssh_authorized_key) do | ||||
| 5268487a » | ctrlaltdel | 2008-09-27 | 3 | @doc = "Manages SSH authorized keys. Currently only type 2 keys are | |
| 4 | supported." | ||||
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 5 | ||
| 6 | ensurable | ||||
| 7 | |||||
| 8 | newparam(:name) do | ||||
| 731d0f22 » | jamtur01 | 2008-07-02 | 9 | desc "The SSH key comment." | |
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 10 | ||
| 11 | isnamevar | ||||
| 12 | end | ||||
| 13 | |||||
| 14 | newproperty(:type) do | ||||
| 5268487a » | ctrlaltdel | 2008-09-27 | 15 | desc "The encryption type used: ssh-dss or ssh-rsa." | |
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 16 | ||
| 17 | newvalue("ssh-dss") | ||||
| 18 | newvalue("ssh-rsa") | ||||
| 19 | |||||
| 20 | aliasvalue(:dsa, "ssh-dss") | ||||
| 21 | aliasvalue(:rsa, "ssh-rsa") | ||||
| 22 | end | ||||
| 23 | |||||
| 24 | newproperty(:key) do | ||||
| 25 | desc "The key itself; generally a long string of hex digits." | ||||
| 26 | end | ||||
| 27 | |||||
| 28 | newproperty(:user) do | ||||
| 731d0f22 » | jamtur01 | 2008-07-02 | 29 | desc "The user account in which the SSH key should be installed." | |
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 30 | end | |
| 31 | |||||
| 32 | newproperty(:target) do | ||||
| 731d0f22 » | jamtur01 | 2008-07-02 | 33 | desc "The file in which to store the SSH key." | |
| 39deaf37 » | Francois Deppierraz | 2009-03-21 | 34 | ||
| 35 | defaultto :absent | ||||
| 36 | |||||
| 37 | def should | ||||
| 38 | if defined? @should and @should[0] != :absent | ||||
| 39 | return super | ||||
| 40 | end | ||||
| 41 | |||||
| 42 | if user = resource[:user] | ||||
| 43 | return File.expand_path("~%s/.ssh/authorized_keys" % user) | ||||
| 44 | end | ||||
| 45 | |||||
| 46 | return nil | ||||
| 47 | end | ||||
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 48 | end | |
| 49 | |||||
| 50 | newproperty(:options, :array_matching => :all) do | ||||
| 731d0f22 » | jamtur01 | 2008-07-02 | 51 | desc "Key options, see sshd(8) for possible values. Multiple values | |
| 52 | should be specified as an array." | ||||
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 53 | ||
| 54 | defaultto do :absent end | ||||
| bf5be00f » | masterzen | 2008-11-11 | 55 | ||
| 56 | def is_to_s(value) | ||||
| 57 | if value == :absent or value.include?(:absent) | ||||
| 58 | super | ||||
| 59 | else | ||||
| 60 | value.join(",") | ||||
| 61 | end | ||||
| 62 | end | ||||
| 63 | |||||
| 64 | def should_to_s(value) | ||||
| 65 | if value == :absent or value.include?(:absent) | ||||
| 66 | super | ||||
| 67 | else | ||||
| 68 | value.join(",") | ||||
| 69 | end | ||||
| 70 | end | ||||
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 71 | end | |
| 8c5c949b » | ctrlaltdel | 2008-06-27 | 72 | ||
| 73 | autorequire(:user) do | ||||
| 74 | if should(:user) | ||||
| 75 | should(:user) | ||||
| 76 | end | ||||
| 77 | end | ||||
| 78 | |||||
| 79 | validate do | ||||
| 4c5293b8 » | ctrlaltdel | 2008-07-11 | 80 | unless should(:target) or should(:user) | |
| 8c5c949b » | ctrlaltdel | 2008-06-27 | 81 | raise Puppet::Error, "Attribute 'user' or 'target' is mandatory" | |
| 82 | end | ||||
| 83 | end | ||||
| db8a46c6 » | ctrlaltdel | 2008-04-10 | 84 | end | |
| 85 | end | ||||
| 86 | |||||








