-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdefault.rb
More file actions
107 lines (90 loc) · 2.08 KB
/
Copy pathdefault.rb
File metadata and controls
107 lines (90 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# Cookbook Name:: deis
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
home_dir = node.deis.dir
username = node.deis.username
# create deis user with ssh access, auth keys
# and the ability to run 'sudo chef-client'
user username do
system true
uid 324 # "reserved" for deis
shell '/bin/bash'
comment 'deis system account'
home home_dir
supports :manage_home => true
action :create
end
directory home_dir do
user username
group username
mode 0755
end
sudo username do
user username
nopasswd true
commands ['/usr/bin/chef-client',
'/bin/cat /etc/chef/client.pem',
'/bin/cat /etc/chef/validation.pem',
'/sbin/restart deis']
end
# create a log directory writeable by the deis user
directory node.deis.log_dir do
user username
group group
mode 0755
end
# TODO: remove forced apt-get update when default indexes are fixed
bash 'force-apt-get-update' do
code "apt-get update && touch #{home_dir}/prevent-apt-update"
not_if "test -e #{home_dir}/prevent-apt-update"
end
# always install these packages
package 'fail2ban'
package 'python-setuptools'
package 'python-pip'
package 'debootstrap'
# install ssh private keys to clone private repos
# TODO: remove all this once its open source
ssh = data_bag('deis-ssh')
ssh.each do |item|
user = data_bag_item('deis-ssh', item)
username = user['id']
id_rsa = user['id_rsa']
known_hosts = user['known_hosts']
if username == 'root'
directory "/root/.ssh" do
user username
group group
mode 0700
end
file '/root/.ssh/id_rsa' do
user 'root'
group 'root'
content id_rsa
mode 0600
end
elsif username == 'deis'
directory "#{home_dir}/.ssh" do
user username
group group
mode 0700
end
file "#{home_dir}/.ssh/id_rsa" do
user username
group group
content id_rsa
mode 0600
end
file "#{home_dir}/.ssh/known_hosts" do
user username
group group
content known_hosts
mode 0644
end
end
end