Guest User

Untitled

a guest
Jul 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. case $ensure {
  2. present: {
  3. $key = file("/etc/puppet/files/idcadmin/auth/keys/$sourcekeys.pub")
  4. line {
  5. [ $sourcekeys ]:
  6. line => $key,
  7. ensure => present,
  8. require => File["/home/$destuser/.ssh/authorized_keys"],
  9. file => "/home/$destuser/.ssh/authorized_keys";
  10. }
  11. }
  12. }
  13.  
  14.  
  15.  
  16. define line( $file, $line, $ensure = 'present') {
  17. case $ensure {
  18. default : { err ( "unknown ensure value '${ensure}'" ) }
  19. present: {
  20. exec { "echo ${line} to ${file}":
  21. command => "echo '${line}' >> '${file}'",
  22. unless => "grep -qFx '${line}' '${file}'",
  23. }
  24. }
  25. absent: {
  26. exec { "remove the ${line} from ${file}":
  27. command => "perl -ni -e 'print if \$_ ne \"${line}\n\";' '${file}'",
  28. onlyif => "grep -qFx '${line}' '${file}'"
  29. }
  30. }
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38. $dhg_user_keys = [ "bob", "joe" ]
  39.  
  40. auth::key { "add dhg_user_keys to IDC user for remote mgmt":
  41. ensure => present,
  42. destuser => "idc",
  43. sourcekeys => $dhg_user_keys,
  44. }
  45.  
  46.  
  47. err: Could not retrieve catalog: Could not find any files from /etc/puppet/files/idcadmin/auth/keys/bobjoe.pub at /etc/puppet/modules/auth/manifests/init.pp:94 on node vdc01b01ubuntu01
Add Comment
Please, Sign In to add comment