cfer-provisioning 0.2.0.pre.alpha2 → 0.2.0.pre.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfer/provisioning/chef.rb +48 -15
- data/lib/cfer/provisioning/client.rb.erb +22 -0
- data/lib/cfer/provisioning/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2520949babb6365f2733e61d18c71a96a12f5f48
|
4
|
+
data.tar.gz: 08f82cfdaf461eb8ff0ed718d62c1f4002a62334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bd9096d6e34abbcca2f144d4e56904604812fe50db14490ef7036039f11f6829c506dfcb9916994db4606e96a99bc90ed439d87afd3aa8a8068ce3d9b245110
|
7
|
+
data.tar.gz: 8090b41ad1cbc2e9cf4e48f3e02d5680f22021881dd00463b5edc94e4a64567806197526fc975baf80e8a1bcdb55708c7b2c570deba884d53f3edb958450520e
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Cfer::Provisioning
|
2
|
-
def
|
2
|
+
def install_chef_with_cloud_init(options = {})
|
3
3
|
# we can't use the cloud-init `chef` module because it expects a server/validator.
|
4
4
|
|
5
5
|
cloud_init_bootcmds <<
|
@@ -77,6 +77,41 @@ module Cfer::Provisioning
|
|
77
77
|
Cfer.cfize(cmd)
|
78
78
|
end
|
79
79
|
|
80
|
+
def chef_client(options = {})
|
81
|
+
raise "Chef already configured on this resource" if @chef
|
82
|
+
@chef = true
|
83
|
+
|
84
|
+
raise "must specify chef_server_url" if options[:chef_server_url].nil?
|
85
|
+
raise "must specify validation_client_name" if options[:validation_client_name].nil?
|
86
|
+
|
87
|
+
options[:config_path] ||= '/etc/chef/client.rb'
|
88
|
+
options[:json_path] ||= '/etc/chef/node.json'
|
89
|
+
options[:cookbook_path] ||= '/var/chef/cookbooks'
|
90
|
+
options[:data_bag_path] ||= '/var/chef/data_bags'
|
91
|
+
options[:log_path] ||= '/var/log/chef-client.log'
|
92
|
+
|
93
|
+
options[:service_type] ||= :upstart
|
94
|
+
|
95
|
+
run_set = []
|
96
|
+
|
97
|
+
install_chef_with_cloud_init(options) unless options[:no_install]
|
98
|
+
|
99
|
+
add_write_chef_json(options)
|
100
|
+
run_set << :write_chef_json
|
101
|
+
|
102
|
+
cfn_init_config :run_chef_client do
|
103
|
+
client_rb = Erubis::Eruby.new(IO.read("#{__dir__}/client.rb.erb")).result(options: options)
|
104
|
+
|
105
|
+
file options[:config_path], content: Cfer.cfize(options[:client_rb] || client_rb),
|
106
|
+
mode: '000400', owner: 'root', group: 'root'
|
107
|
+
|
108
|
+
command :'00_run_chef_once', 'chef-client --once'
|
109
|
+
end
|
110
|
+
run_set << :run_chef_client
|
111
|
+
|
112
|
+
cfn_init_config_set :run_chef_client, run_set
|
113
|
+
end
|
114
|
+
|
80
115
|
def chef_solo(options = {})
|
81
116
|
raise "Chef already configured on this resource" if @chef
|
82
117
|
@chef = true
|
@@ -89,7 +124,7 @@ module Cfer::Provisioning
|
|
89
124
|
options[:data_bag_path] ||= '/var/chef/data_bags'
|
90
125
|
options[:log_path] ||= '/var/log/chef-solo.log'
|
91
126
|
|
92
|
-
|
127
|
+
install_chef_with_cloud_init(options) unless options[:no_install]
|
93
128
|
|
94
129
|
if must_install_berkshelf
|
95
130
|
install_berkshelf(options) if must_install_berkshelf # places cloud-init runners
|
@@ -107,10 +142,7 @@ module Cfer::Provisioning
|
|
107
142
|
run_set << :run_berkshelf
|
108
143
|
end
|
109
144
|
|
110
|
-
|
111
|
-
cfn_init_config :write_chef_json do
|
112
|
-
command :write_chef_json, build_write_json_cmd(options[:json_path])
|
113
|
-
end
|
145
|
+
add_write_chef_json(options)
|
114
146
|
run_set << :write_chef_json
|
115
147
|
|
116
148
|
cfn_init_config :run_chef_solo do
|
@@ -124,15 +156,7 @@ module Cfer::Provisioning
|
|
124
156
|
file options[:config_path], content: options[:solo_rb] || solo_rb,
|
125
157
|
mode: '000400', owner: 'root', group: 'root'
|
126
158
|
|
127
|
-
|
128
|
-
|
129
|
-
chef_cmd = "chef-solo -c '#{options[:config_path]}' -j '#{options[:json_path]}'"
|
130
|
-
chef_cmd << " -o '#{options[:run_list].join(',')}'" unless options[:run_list].empty?
|
131
|
-
|
132
|
-
file '/usr/local/bin/run-chef-solo.bash', content: chef_cmd,
|
133
|
-
mode: '000500', owner: 'root', group: 'root'
|
134
|
-
|
135
|
-
command :run_chef, 'bash /usr/local/bin/run-chef-solo.bash'
|
159
|
+
command :run_chef, 'chef-solo'
|
136
160
|
end
|
137
161
|
run_set << :run_chef_solo
|
138
162
|
|
@@ -140,5 +164,14 @@ module Cfer::Provisioning
|
|
140
164
|
end
|
141
165
|
|
142
166
|
private
|
167
|
+
def add_write_chef_json(options)
|
168
|
+
options[:run_list] ||= []
|
169
|
+
options[:json] ||= {}
|
170
|
+
|
171
|
+
cfn_metadata['CferExt::Provisioning::Chef'] = options[:json].merge(run_list: options[:run_list])
|
172
|
+
cfn_init_config :write_chef_json do
|
173
|
+
command :write_chef_json, build_write_json_cmd(options[:json_path])
|
174
|
+
end
|
175
|
+
end
|
143
176
|
end
|
144
177
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
chef_server_url '<%= options[:chef_server_url] %>'
|
2
|
+
validation_client_name '<%= options[:validation_client_name] %>'
|
3
|
+
log_level <%= (options[:log_level] || :info).inspect %>
|
4
|
+
log_location '<%= options[:log_path] %>'
|
5
|
+
json_attribs '<%= options[:json_path] %>'
|
6
|
+
cookbook_path '<%= options[:cookbook_path] %>'
|
7
|
+
|
8
|
+
<%- case options[:node_name]
|
9
|
+
when nil -%>
|
10
|
+
<%- when :hostname -%>
|
11
|
+
node_name `hostname`.strip
|
12
|
+
<%- else -%>
|
13
|
+
node_name '<%= options[:node_name] %>'
|
14
|
+
<%- end %>
|
15
|
+
|
16
|
+
<%- unless options[:environment].nil? -%>
|
17
|
+
environment '<%= options[:environment] %>'
|
18
|
+
<%- end -%>
|
19
|
+
|
20
|
+
<%- unless options[:validation_key].nil? -%>
|
21
|
+
validation_key '<%= options[:validation_key] %>'
|
22
|
+
<%- end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfer-provisioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.pre.
|
4
|
+
version: 0.2.0.pre.alpha3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Edwards
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/cfer/provisioning/cfn-bootstrap.bash.erb
|
116
116
|
- lib/cfer/provisioning/cfn-bootstrap.rb
|
117
117
|
- lib/cfer/provisioning/chef.rb
|
118
|
+
- lib/cfer/provisioning/client.rb.erb
|
118
119
|
- lib/cfer/provisioning/cloud-init.rb
|
119
120
|
- lib/cfer/provisioning/extensions.rb
|
120
121
|
- lib/cfer/provisioning/version.rb
|