2016-04-11 12 views

cevap

2

Her zaman olduğu gibi bir users veri torba dayalı başına düğüm kullanıcı erişimini yapılandırmak nasıl Here is :-) olasılıklar çok çeşitli vardır. group: sysadmin ile

  • Tüm kullanıcılar otomatik sudo ayrıcalıkları ile tüm düğümlere atanır.
  • Diğer tüm kullanıcılar, belirli ana bilgisayarlara atanmalarına göre eklenir. Bütün düğümler kullanıcı kaldırmak amacıyla
{ 
    "id": "a-srv123-admin", 
    ... 
    "nodes": { 
      "srv123.typo3.org": { 
        "sudo": "true" 
      } 
    } 
} 

, action: remove ayarlanabilir: users veri çanta veri torbanın "nodes" anahtarında node['fqdn'] için bir giriş içeren öğeleri aranır en yüksek düzeyde: belli bir düğümden bir kullanıcıyı kaldırmak için

{ 
    "id": "a-user-to-remove", 
    "action": "remove" 
} 

, action: removeayarlanabilir düğüm seviyesinde:

node_attribute = "fqdn" 
log "Searching for users associated with node #{node[node_attribute]}" 
begin 
    users = search(users_databag_name, "nodes:#{node[node_attribute]}") 
rescue Net::HTTPServerException 
    Chef::Log.warn "Searching for users in the 'users' databag failed, search for users associated with node '#{node[node_attribute]}'" 
    users = {} 
end 

users.each do |u| 
    node_options = u['nodes'][node[node_attribute]] 
    Chef::Log.info "Got node options: #{node_options}" 
    if u['action'] == "remove" || node_options['action'] == "remove" 
    user u['username'] ||= u['id'] do 
     action :remove 
    end 
    else 
    # snip... 

    # Create user object. 
    user u['username'] do 
     uid u['uid'] if u['uid'] 
     gid u['gid'] if u['gid'] 
     shell u['shell'] 
     comment u['comment'] 
     password u['password'] if u['password'] 
     supports manage_home: true 
     home home_dir 
     action u['action'] if u['action'] 
    end 

    # sudo management 
    if node_options['sudo'] == "true" 
     sudo u['username'] do 
     nopasswd true 
     user u['username'] 
     end 
    else 
     sudo u['username'] do 
     action :remove 
     end 
    end 
    end 
end 

EDIT:

{ 
    "id": "a-user-to-remove", 
    ... 
    "nodes": { 
      "srv123.typo3.org": { 
        "action": "remove" 
      } 
    } 
} 

implementation of this (maalesef gerçeği çok temiz değil), sadece node[fqdn] ile ilişkili tüm kullanıcılar için arar herhangi bir kullanıcı ile uyardı Şefin istemci sertifikasına erişim, istemcinin okuyabileceği bilgilere dayalı olarak verileri sorgulayabilir. Bu, diğer düğümün niteliklerinde saklanan şifreler içerebilir. RBAC veya chef-tonoz bunu hafifletebilir.

İlgili konular