dtk-node-agent 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8db191267189513117e4624e6fbac5b7e51fcbb3
4
- data.tar.gz: d2ba3f2281f425abb2b0586471df8220fb3fdf4c
3
+ metadata.gz: 9b50a68f952a5501d9689ff70e03c7afae5beaf5
4
+ data.tar.gz: 0407e13ddcc0cde2632e783190ddd113d1538ec5
5
5
  SHA512:
6
- metadata.gz: 5346d1c4d7a668cae356dba258abc9ac2738d3f9106623d164752c1ef1a65604bd3bc2eb3b3f6aa1c27fce68c7c5fcde7ccb9af22c9f52e730ad443889cfa28c
7
- data.tar.gz: 7c943b0420db1bd9f4a4a3f11f6eec46fe9d4713bdd22dca977e34e3dcc4919eec5e07d8ac638e01f35382b2504507dc2740dbd100b4a34789362044673c0419
6
+ metadata.gz: be6caee6a90bc73496dc39c33416950f2e06ee6bde44c97312fbdf735279eade767d797bcbe018d08e639df8e9f2a875727952ac6b81e24275f16d89d676385b
7
+ data.tar.gz: b8784f3b22a332ab6a36ac7a5c3e8f70a4d0993ae2bac91a3e727ec71d5573b3758f97b6294bcaf8ec464f2b1e35da0745278b9a95975890d9de58825b7ace2c
@@ -67,6 +67,8 @@ module DTK
67
67
  FileUtils.cp("#{base_dir}/src/etc/apt/preferences.d/puppetlabs", "/etc/apt/preferences.d/puppetlabs")
68
68
  elsif @osfamily == 'redhat'
69
69
  shell "yum -y install yum-utils wget curl"
70
+ # do a full upgrade
71
+ shell "yum -y update"
70
72
  case @osmajrelease
71
73
  when "5"
72
74
  shell "rpm -ivh #{CONFIG[:puppetlabs_el5_rpm_repo]}"
@@ -164,27 +166,39 @@ module DTK
164
166
  # create puppet group
165
167
  shell "groupadd puppet" unless `grep puppet /etc/group`.include? "puppet"
166
168
  # create necessary dirs
167
- [ '/var/log/puppet/',
169
+ [ '/var/log/puppet/',
168
170
  '/var/lib/puppet/lib/puppet/indirector',
169
- '/etc/puppet/modules'
171
+ '/etc/puppet/modules',
172
+ '/usr/share/dtk/modules'
170
173
  ].map! { |p| FileUtils.mkdir_p(p) unless File.directory?(p) }
171
174
  # copy puppet libs
172
175
  FileUtils.cp_r(Dir.glob("#{base_dir}/puppet_additions/puppet_lib_base/puppet/indirector/*"), "/var/lib/puppet/lib/puppet/indirector/")
173
- # copy r8 puppet module
174
- FileUtils.cp_r(Dir.glob("#{base_dir}/puppet_additions/modules/r8"), "/etc/puppet/modules")
176
+ # copy dtk/r8 puppet module
177
+ FileUtils.cp_r(Dir.glob("#{base_dir}/puppet_additions/modules/*"), "/usr/share/dtk/modules/")
178
+ # symlink dtk/r8 puppet module
179
+ FileUtils.ln_sf("/usr/share/dtk/modules/dtk", "/etc/puppet/modules/")
180
+ FileUtils.ln_sf("/usr/share/dtk/modules/r8", "/etc/puppet/modules/")
175
181
  end
176
182
 
177
183
  def self.base_dir
178
184
  File.expand_path('../..', File.dirname(__FILE__))
179
185
  end
180
186
 
187
+ def self.is_systemd
188
+ File.exist?("/etc/systemd/system")
189
+ end
190
+
181
191
  def self.set_init(script)
182
192
  shell "chmod +x /etc/init.d/#{script}"
183
193
  if @osfamily == 'debian'
184
194
  shell "update-rc.d #{script} defaults"
185
195
  elsif @osfamily == 'redhat'
186
196
  shell "chkconfig --level 345 #{script} on"
187
- shell "systemctl daemon-reload" if @osmajrelease == '7'
197
+ # in case of a systemd system, reload the daemons
198
+ if is_systemd
199
+ shell "systemctl daemon-reload"
200
+ shell "systemctl enable #{script}.service"
201
+ end
188
202
  end
189
203
  end
190
204
 
@@ -194,11 +208,13 @@ module DTK
194
208
  shell "bundle install --without development"
195
209
  puts "Installing dtk-arbiter init script"
196
210
  FileUtils.ln_sf("/usr/share/dtk/dtk-arbiter/etc/#{@osfamily}.dtk-arbiter.init", "/etc/init.d/dtk-arbiter")
211
+ # copy the service file, since systemd doesn't follow symlinks
212
+ FileUtils.cp("/usr/share/dtk/dtk-arbiter/etc/systemd.dtk-arbiter.service", "/etc/systemd/system/dtk-arbiter.service") if is_systemd
197
213
  set_init("dtk-arbiter")
198
214
  puts "Installing dtk-arbiter monit config."
199
215
  monit_cfg_path = (@osfamily == 'debian') ? "/etc/monit/conf.d" : "/etc/monit.d"
200
216
  set_init("monit")
201
- FileUtils.ln_sf("/usr/share/dtk/dtk-arbiter/etc/dtk-arbiter.monit", "#{monit_cfg_path}/dtk-arbiter")
217
+ FileUtils.ln_sf("/usr/share/dtk/dtk-arbiter/etc/dtk-arbiter.monit", "#{monit_cfg_path}/dtk-arbiter") if File.exist?(monit_cfg_path)
202
218
  end
203
219
  end
204
220
  end
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
  #
18
18
  module DtkNodeAgent
19
- VERSION="0.10.0"
19
+ VERSION="0.10.1"
20
20
  end
@@ -0,0 +1,27 @@
1
+ require 'fileutils'
2
+
3
+ Puppet::Type.type(:dtk_export_variable).provide(:default) do
4
+ desc "dtk export variable"
5
+
6
+ def create
7
+ name = resource[:name]
8
+ content = resource[:content]
9
+ if name =~ /(^.+)::(.+$)/
10
+ component = $1
11
+ attribute = $2
12
+ if content = (content == '***' ? scope.lookupvar(name) : content)
13
+ p = Thread.current[:exported_variables] ||= Hash.new
14
+ (p[component] ||= Hash.new)[attribute] = content
15
+ File.open('/tmp/dtk_exported_variables', 'w') { |f| f.write(Marshal.dump(p)) }
16
+ end
17
+ end
18
+ end
19
+
20
+ def destroy
21
+ FileUtils.rm_rf("/tmp/dtk_exported_variables")
22
+ end
23
+
24
+ def exists?
25
+
26
+ end
27
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ # Simple module for logging messages on the client-side
3
+ #
4
+
5
+ module Puppet
6
+ newtype(:dtk_export_file) do
7
+ @doc = "dtk export file content"
8
+
9
+ newparam(:name) do
10
+ desc "component and attribute name in dot notation"
11
+ end
12
+
13
+ newparam(:filename) do
14
+ desc "file name"
15
+ end
16
+
17
+ newparam(:definition_key) do
18
+ desc "Value of name field used when there is a definition"
19
+ end
20
+
21
+ newproperty(:ensure) do
22
+ desc "Whether the resource is in sync or not."
23
+
24
+ defaultto :insync
25
+
26
+ def retrieve
27
+ :outofsync
28
+ end
29
+
30
+ newvalue :insync do
31
+ filename = resource[:filename]
32
+ unless File.exists?(filename)
33
+ raise Puppet::Error, "File #{resource[:filename]} does not exist"
34
+ end
35
+ Puppet.send(@resource[:loglevel], "exporting #{filename} for #{resource[:name]}")
36
+ if resource[:name] =~ /(^.+)\.(.+$)/
37
+ cmp_name = $1
38
+ attr_name = $2
39
+
40
+ cmp_ref = cmp_name.gsub(/[.]/,"::")
41
+ if def_key = resource[:definition_key]
42
+ cmp_ref = "#{cmp_ref}[#{def_key}]"
43
+ end
44
+ p = (Thread.current[:exported_files] ||= Hash.new)[cmp_ref] ||= Hash.new
45
+ p[attr_name] = filename
46
+ File.open('/tmp/dtk_exported_files', 'w') { |f| f.write(Marshal.dump(p)) }
47
+ else
48
+ raise Puppet::Error, "ill-formed component with name (#{resource[:name]})"
49
+ end
50
+ return
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,19 @@
1
+ Puppet::Type.newtype(:dtk_export_variable) do
2
+ @doc = "dtk export variable content"
3
+
4
+ ensurable
5
+
6
+ newparam(:name) do
7
+ desc "component and attribute name in dot notation"
8
+
9
+ validate do |value|
10
+ unless value =~ /.*::.*/
11
+ raise ArgumentError, "name attribute: #{value} is in invalid format, should be in <component>::<attribute> format"
12
+ end
13
+ end
14
+ end
15
+
16
+ newparam(:content) do
17
+ desc "variable content to store in specific attribute"
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ define dtk::export_variable(
2
+ $content = undef,
3
+ ) {
4
+ dtk_export_variable { $name:
5
+ name => $name,
6
+ content => $content,
7
+ ensure => present,
8
+ }
9
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-node-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-16 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -182,6 +182,10 @@ files:
182
182
  - lib/config/install.config
183
183
  - lib/dtk-node-agent/installer.rb
184
184
  - lib/dtk-node-agent/version.rb
185
+ - puppet_additions/modules/dtk/lib/puppet/provider/dtk_export_variable/default.rb
186
+ - puppet_additions/modules/dtk/lib/puppet/type/dtk_export_file.rb
187
+ - puppet_additions/modules/dtk/lib/puppet/type/dtk_export_variable.rb
188
+ - puppet_additions/modules/dtk/manifests/export_variable.pp
185
189
  - puppet_additions/modules/r8/lib/puppet/provider/r8_export_variable/default.rb
186
190
  - puppet_additions/modules/r8/lib/puppet/type/r8_export_file.rb
187
191
  - puppet_additions/modules/r8/lib/puppet/type/r8_export_variable.rb