choria-mcorpc-support 2.20.5 → 2.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mcollective.rb +1 -1
  3. data/lib/mcollective/application/facts.rb +8 -0
  4. data/lib/mcollective/application/plugin.rb +19 -7
  5. data/lib/mcollective/applications.rb +2 -1
  6. data/lib/mcollective/ddl/agentddl.rb +17 -11
  7. data/lib/mcollective/ddl/base.rb +34 -20
  8. data/lib/mcollective/ddl/dataddl.rb +5 -5
  9. data/lib/mcollective/ddl/discoveryddl.rb +2 -2
  10. data/lib/mcollective/ddl/validatorddl.rb +1 -1
  11. data/lib/mcollective/pluginpackager/agent_definition.rb +33 -19
  12. data/lib/mcollective/pluginpackager/{puppet_module_packager.rb → forge_packager.rb} +57 -50
  13. data/lib/mcollective/pluginpackager/standard_definition.rb +23 -12
  14. data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/README.md.erb +1 -1
  15. data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/data/defaults.yaml.erb +0 -0
  16. data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/data/plugin.yaml.erb +0 -0
  17. data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/hiera.yaml.erb +0 -0
  18. data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/manifests/init.pp.erb +2 -0
  19. data/lib/mcollective/pluginpackager/templates/{puppet_module → forge}/metadata.json.erb +2 -2
  20. data/lib/mcollective/validator.rb +2 -2
  21. data/lib/mcollective/validator/array_validator.rb +1 -1
  22. data/lib/mcollective/validator/ipv4address_validator.rb +5 -7
  23. data/lib/mcollective/validator/ipv6address_validator.rb +5 -7
  24. data/lib/mcollective/validator/shellsafe_validator.rb +1 -1
  25. data/lib/mcollective/validator/typecheck_validator.rb +19 -15
  26. metadata +11 -25
  27. data/lib/mcollective/pluginpackager/debpackage_packager.rb +0 -237
  28. data/lib/mcollective/pluginpackager/modulepackage_packager.rb +0 -127
  29. data/lib/mcollective/pluginpackager/ospackage_packager.rb +0 -59
  30. data/lib/mcollective/pluginpackager/rpmpackage_packager.rb +0 -180
  31. data/lib/mcollective/pluginpackager/templates/debian/Makefile.erb +0 -7
  32. data/lib/mcollective/pluginpackager/templates/debian/changelog.erb +0 -5
  33. data/lib/mcollective/pluginpackager/templates/debian/compat.erb +0 -1
  34. data/lib/mcollective/pluginpackager/templates/debian/control.erb +0 -15
  35. data/lib/mcollective/pluginpackager/templates/debian/copyright.erb +0 -8
  36. data/lib/mcollective/pluginpackager/templates/debian/rules.erb +0 -6
  37. data/lib/mcollective/pluginpackager/templates/module/Modulefile.erb +0 -5
  38. data/lib/mcollective/pluginpackager/templates/module/README.md.erb +0 -37
  39. data/lib/mcollective/pluginpackager/templates/module/_manifest.pp.erb +0 -9
  40. data/lib/mcollective/pluginpackager/templates/redhat/rpm_spec.erb +0 -63
@@ -1,180 +0,0 @@
1
- module MCollective
2
- module PluginPackager
3
- class RpmpackagePackager
4
- require 'erb'
5
-
6
- def initialize(plugin, pluginpath = nil, signature = nil, verbose = false, keep_artifacts = nil, module_template = nil)
7
- if @buildtool = select_command
8
- @plugin = plugin
9
- @package_name = "#{@plugin.mcname}-#{@plugin.metadata[:name]}"
10
- @package_name_and_version = "#{@package_name}-#{@plugin.metadata[:version]}"
11
- @verbose = verbose
12
- @libdir = pluginpath || '/usr/libexec/mcollective/mcollective/'
13
- @signature = signature
14
- @rpmdir = rpmdir
15
- @srpmdir = srpmdir
16
- @keep_artifacts = keep_artifacts
17
- else
18
- raise("Cannot build package. 'rpmbuild' or 'rpmbuild-md5' is not present on the system")
19
- end
20
- end
21
-
22
- # Determine the build tool present on the system
23
- def select_command
24
- if PluginPackager.command_available?('rpmbuild-md5')
25
- return 'rpmbuild-md5'
26
- elsif PluginPackager.command_available?('rpmbuild')
27
- return 'rpmbuild'
28
- else
29
- return nil
30
- end
31
- end
32
-
33
- def rpmdir
34
- `rpm --eval '%_rpmdir'`.chomp
35
- end
36
-
37
- def srpmdir
38
- `rpm --eval '%_srcrpmdir'`.chomp
39
- end
40
-
41
- # Build Process :
42
- # - create temporary buildroot
43
- # - create the spec file
44
- # - create the tarball
45
- # - run the build script
46
- # - move pacakges to cwd
47
- # - clean up
48
- def create_packages
49
- begin
50
- puts "Building packages for #{@package_name} plugin."
51
-
52
- @tmpdir = Dir.mktmpdir('mcollective_packager')
53
- prepare_tmpdirs
54
-
55
- make_spec_file
56
- run_build
57
- move_packages
58
-
59
- puts "Completed building all packages for #{@package_name} plugin."
60
- ensure
61
- if @keep_artifacts
62
- puts 'Keeping build artifacts'
63
- puts "Build artifacts saved - #{@tmpdir}"
64
- else
65
- cleanup_tmpdirs
66
- end
67
- end
68
- end
69
-
70
- private
71
-
72
- def run_build
73
- begin
74
- tarfile = create_tar
75
- PluginPackager.execute_verbosely(@verbose) do
76
- PluginPackager.safe_system("#{@buildtool} -ta#{" --quiet" unless @verbose}#{" --sign" if @signature} #{tarfile}")
77
- end
78
- rescue => e
79
- puts 'Build process has failed'
80
- raise e
81
- end
82
- end
83
-
84
- # Tar up source
85
- # Expects directory $mcollective-$agent-$version
86
- # Creates file : $tmpbuildroot/$mcollective-$agent-$version
87
- def create_tar
88
- tarfile = File.join(@tmpdir, "#{@package_name_and_version}.tgz")
89
- begin
90
- PluginPackager.execute_verbosely(@verbose) do
91
- Dir.chdir(@tmpdir) do
92
- PluginPackager.safe_system("tar -cvzf #{tarfile} #{@package_name_and_version}")
93
- end
94
- end
95
- rescue => e
96
- puts "Could not create tarball - '#{tarfile}'"
97
- raise e
98
- end
99
- tarfile
100
- end
101
-
102
- # Move rpm's and srpm's to cwd
103
- def move_packages
104
- begin
105
- files_to_copy = []
106
- files_to_copy += Dir.glob(File.join(@rpmdir, 'noarch', "#{@package_name}-*-#{@plugin.metadata[:version]}-#{@plugin.revision}*.noarch.rpm"))
107
- files_to_copy += Dir.glob(File.join(@srpmdir, "#{@package_name}-#{@plugin.metadata[:version]}-#{@plugin.revision}*.src.rpm"))
108
- FileUtils.cp(files_to_copy, '.')
109
- rescue => e
110
- puts 'Could not copy packages to working directory'
111
- raise e
112
- end
113
- end
114
-
115
- # Create the specfile and place as $tmpbuildroot/$mcollective-$agent-$version/$mcollective-$agent-$version.spec
116
- def make_spec_file
117
- spec_file = File.join(@tmpdir, @package_name_and_version, "#{@package_name_and_version}.spec")
118
- begin
119
- spec_template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', 'redhat', 'rpm_spec.erb')), nil, '-')
120
- File.open(spec_file, 'w') do |f|
121
- f.puts spec_template.result(binding)
122
- end
123
- rescue => e
124
- puts "Could not create specfile - '#{spec_file}'"
125
- raise e
126
- end
127
- end
128
-
129
- # Move files contained in the plugin to the correct directory
130
- # relative to the build root.
131
- def prepare_tmpdirs
132
- plugin_files.each do |file|
133
- begin
134
- targetdir = File.join(@tmpdir, @package_name_and_version, @libdir, File.dirname(File.expand_path(file)).gsub(@plugin.target_path, ""))
135
- FileUtils.mkdir_p(targetdir) unless File.directory?(targetdir)
136
- FileUtils.cp_r(file, targetdir)
137
- rescue Errno::EACCES => e
138
- puts "Could not create directory '#{targetdir}'. Permission denied"
139
- raise e
140
- rescue Errno::ENOENT => e
141
- puts "Could not copy file '#{file}' to '#{targetdir}'. File does not exist"
142
- raise e
143
- rescue => e
144
- puts 'Could not prepare temporary build directory'
145
- raise e
146
- end
147
- end
148
- end
149
-
150
- # Extract all the package files from the plugin's package data hash
151
- def plugin_files
152
- files = []
153
- @plugin.packagedata.each do |name, data|
154
- files += data[:files].reject{ |f| File.directory?(f) }
155
- end
156
- files
157
- end
158
-
159
- # Extract the package specific files from the file list and omits directories
160
- def package_files(files)
161
- package_files = []
162
- files.each do |f|
163
- if !File.directory?(f)
164
- package_files << File.join(@libdir, File.expand_path(f).gsub(/#{@plugin.target_path}|\.\//, ''))
165
- end
166
- end
167
- package_files
168
- end
169
-
170
- def cleanup_tmpdirs
171
- begin
172
- FileUtils.rm_r(@tmpdir) if File.directory?(@tmpdir)
173
- rescue => e
174
- puts "Could not remove temporary build directory - '#{@tmpdir}'"
175
- raise e
176
- end
177
- end
178
- end
179
- end
180
- end
@@ -1,7 +0,0 @@
1
- DESTDIR=
2
-
3
- build:
4
-
5
- clean:
6
-
7
- install:
@@ -1,5 +0,0 @@
1
- <%= @package_name -%> (<%= @plugin.metadata[:version]-%>-<%= @plugin.revision-%>) unstable; urgency=low
2
-
3
- * Automated release for <%= @package_name -%> by mco plugin packager.
4
-
5
- -- The Marionette Collective <mcollective-dev@googlegroups.com> <%= Time.new.strftime('%a, %d %b %Y %H:%M:%S %z') %>
@@ -1,15 +0,0 @@
1
- Source: <%= @package_name %>
2
- Homepage: <%= @plugin.metadata[:url] %>
3
- Section: utils
4
- Priority: extra
5
- Build-Depends: debhelper (>= 7), cdbs, dpatch
6
- Maintainer: <%= @plugin.metadata[:author] %>
7
- Standards-Version: 3.9.1
8
- <% @plugin.packagedata.each do |type, data| %>
9
- Package: <%= "#{@package_name}-#{type}" %>
10
- Architecture: all
11
- Depends: <%= build_dependency_string(data) %>
12
- Description: <%= @plugin.metadata[:description]%>
13
- <%= data[:description]%>
14
- .
15
- <% end -%>
@@ -1,8 +0,0 @@
1
- This package was generated by the MCollective plugin packager on
2
- <%= Time.now%>
3
-
4
- Upstream Author:
5
- <%= @plugin.metadata[:author] %> <%= @plugin.metadata[:url] %>
6
-
7
- License:
8
- <%= @plugin.metadata[:license] -%>
@@ -1,6 +0,0 @@
1
- #!/usr/bin/make -f
2
-
3
- include /usr/share/cdbs/1/rules/debhelper.mk
4
- include /usr/share/cdbs/1/rules/dpatch.mk
5
- include /usr/share/cdbs/1/class/makefile.mk
6
- DEB_MAKE_INVOKE = $(DEB_MAKE_ENVVARS) make -f debian/Makefile -C $(DEB_BUILDDIR)
@@ -1,5 +0,0 @@
1
- name '<%= @plugin.vendor %>-<%= @package_name %>'
2
- version '<%= @plugin.metadata[:version] %>'
3
- description '<%= @plugin.metadata[:description] %>'
4
- project_page '<%= @plugin.metadata[:url]%>'
5
- dependency 'puppetlabs/mcollective', '1.x'
@@ -1,37 +0,0 @@
1
- # <%= @package_name %>
2
-
3
- #### Table of Contents
4
-
5
- 1. [Overview](#overview)
6
- 2. [Module Description - What the module does and why it is useful](#module-description)
7
- 3. [Setup - The basics of getting started with <%= @package_name %>](#setup)
8
- * [What the <%= @package_name %> module affects](#what-the-<%= @package_name %>-module-affects)
9
- * [Setup requirements](#setup-requirements)
10
- 4. [Usage - Configuration options and additional functionality](#usage)
11
- 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
12
-
13
-
14
- ## Overview
15
-
16
- The <%= @package_name %> module is a module that wraps a source release of the
17
- <%= @plugin.metadata[:name] %> mcollective plugin for use with the
18
- [puppetlabs mcollective](http://forge.puppetlabs.com/puppetlabs/mcollective)
19
- module.
20
-
21
- ## Module description
22
-
23
- ## Usage
24
-
25
- <% @plugin.packagedata.keys.map { |x| x.to_s }.sort.each do |klass| -%>
26
- <%# Don't document common class -%>
27
- <% if klass != "common" -%>
28
- ### class <%= @package_name %>::<%= klass %>
29
-
30
- Installs the <%= klass %> component of the <%= @plugin.metadata[:name] %> plugin.
31
-
32
- ```puppet
33
- include <%= @package_name%>::<%= klass %>
34
- ```
35
- <% end %>
36
- <% end %>
37
-
@@ -1,9 +0,0 @@
1
- #
2
- class <%= @package_name %>::<%= @klass %> {
3
- <% if @plugin.packagedata[:common] && @klass != 'common' %>
4
- include ::<%= @package_name %>::common
5
- <% end %>
6
- mcollective::plugin { '<%= @package_name %>/<%= @klass %>':
7
- source => 'puppet:///modules/<%= @package_name %>/<%= @klass %>',
8
- }
9
- }
@@ -1,63 +0,0 @@
1
- Name: <%= @package_name %>
2
- Summary: <%= @plugin.metadata[:description] %>
3
- Version: <%= @plugin.metadata[:version] %>
4
- Release: <%= @plugin.revision %>%{?dist}
5
- License: <%= @plugin.metadata[:license]%>
6
- URL: <%= @plugin.metadata[:url]%>
7
- Vendor: <%= @plugin.vendor%>
8
- Packager: <%= @plugin.metadata[:author]%>
9
- BuildArch: noarch
10
- Group: System Tools
11
- BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
12
- Source0: <%= @package_name_and_version%>.tgz
13
-
14
- %description
15
- <%= @plugin.metadata[:description] %>
16
-
17
- %prep
18
- %setup
19
-
20
- %build
21
- <% package_files = plugin_files.map{ |f| File.join(@libdir, File.expand_path(f).gsub(/#{File.expand_path(@plugin.path)}|\.\//, '')) } -%>
22
- <% dirs = package_files.map{ |f| File.dirname(f) }.uniq -%>
23
-
24
- %install
25
- rm -rf %{buildroot}
26
- <% dirs.each do |dir| -%>
27
- %{__install} -d -m0755 %{buildroot}<%= dir%>
28
- <% end -%>
29
- <% package_files.each do |file| -%>
30
- %{__install} -m0644 -v <%= (file[0].chr == '/') ? file[1..file.size-1]: file%> %{buildroot}<%=file %>
31
- <% end -%>
32
-
33
- <% @plugin.packagedata.each do |type, data| %>
34
- %package <%= type %>
35
- Summary: <%= @plugin.metadata[:description] %>
36
- <% if data[:plugindependency] %>
37
- Requires: <%= data[:plugindependency][:name] -%> = <%= data[:plugindependency][:version]%>-<%= data[:plugindependency][:revision]%>%{?dist}
38
- <% end -%>
39
- <% PluginPackager.filter_dependencies('redhat', data[:dependencies]).each do |dep|-%>
40
- Requires: <%= dep[:name] -%> <%= ">= #{dep[:version]}" if dep[:version]%><%="-#{dep[:revision]}" if dep[:revision]%>
41
- <% end -%>
42
- %description <%= type %>
43
- <%= data[:description] %>
44
-
45
- %files <%= type %>
46
- %defattr(-, root, root, -)
47
- <% package_files(data[:files]).each do |file| -%>
48
- <%= file %>
49
- <% end -%>
50
- <% end -%>
51
-
52
- <% if @plugin.preinstall -%>
53
- %pre
54
- <%= @plugin.preinstall %>
55
- <% end -%>
56
- <% if @plugin.postinstall -%>
57
- %post
58
- <%= @plugin.postinstall%>
59
- <% end -%>
60
-
61
- %changelog
62
- * <%= Time.now.strftime("%a %b %d %Y") -%> <%= @plugin.metadata[:author]%> - <%= @plugin.metadata[:version]%>-<%= @plugin.revision %>
63
- - Built Package <%= @plugin.metadata[:name] -%>