dtk-node-agent 0.5.14 → 0.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/README.md +1 -1
- data/lib/dtk-node-agent/installer.rb +7 -5
- data/lib/dtk-node-agent/version.rb +1 -1
- data/mcollective_additions/plugins/v2.2/agent/execute_tests_v2.ddl +9 -0
- data/mcollective_additions/plugins/v2.2/agent/execute_tests_v2.rb +115 -0
- data/mcollective_additions/plugins/v2.2/agent/puppet_apply.rb +1 -1
- data/mcollective_additions/plugins/v2.2/facts/pbuilder_facts.rb +3 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NTdkZTBkZTY5YjM2ZDcwMWRhZmVkYTc0MTk2YzkxZDVkYmI4MGNkZg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66132611a40d998867d1dd8ec4cd86a47d8cda1b
|
4
|
+
data.tar.gz: 9ed30e7ef2172f4590367ca5c6dc21dc0ada2ad3
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OTQ0Nzc0NWU5YmYyOWFlYTI3NTE4ZDIxYWVmZjZhMWIzZTkyNDRmMjMxYzVh
|
11
|
-
YzMzMTNjY2Q2Mjg0NTk0MTYzMDZlYjUzMGJhNzRlNTA1ZDA1ZTY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YzNjODhlNzVmOWYxYWZmMWE2ZDVjZjg5ZDlkZmNhNDg0MGM1NTFkODVhNzNl
|
14
|
-
OGI1ODI3YjhiYjc5YjRkMTgzNGJmMmMzMWJhZmY4Y2ZiMTU3Zjc5MTgzM2Rm
|
15
|
-
NThmOTBlZDE3NDQ0YTU5MmMxMTBiZWFlMDExMTc1MzNiZTFiMmQ=
|
6
|
+
metadata.gz: b9fdae9f7469c55b728d01e974985b45d332b4264f50561f67acc76bb2130adb85e96f83c9451192909ca5838cffaed8f1c122ee63343de89eeab017d0d6e83f
|
7
|
+
data.tar.gz: 2100a2a17c316444105d1722c0a3a3f41179f3ac13583282e773f3805ce6644828af911cc8bb8207b442ad64035aacac5cb66be15e85d7876780e3266619c980
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Code that is present in AMIs that server basis for nodes being spun up
|
|
10
10
|
`sudo dtk-node-agent`
|
11
11
|
|
12
12
|
#### Intalling the node agent on a running machine (with puppet omnibus)
|
13
|
-
`sudo ./install_agent.sh`
|
13
|
+
`sudo ./install_agent.sh [--sanitize]`
|
14
14
|
|
15
15
|
#### Create a new AMI image with the node agent
|
16
16
|
```
|
@@ -31,7 +31,7 @@ module DTK
|
|
31
31
|
puts "Installing MCollective..."
|
32
32
|
shell "apt-get -y install mcollective"
|
33
33
|
elsif Facter.operatingsystem == 'CentOS' || Facter.operatingsystem == 'RedHat'
|
34
|
-
shell "yum -y install yum-utils wget"
|
34
|
+
shell "yum -y install yum-utils wget bind-utils"
|
35
35
|
case Facter.operatingsystemmajrelease
|
36
36
|
when "5"
|
37
37
|
shell "rpm -ivh #{CONFIG[:puppetlabs_el5_rpm_repo]}"
|
@@ -50,10 +50,12 @@ module DTK
|
|
50
50
|
shell "chkconfig mcollective on"
|
51
51
|
shell "yum -y install git"
|
52
52
|
# install ec2-run-user-data init script
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
# but only if the machine is running on AWS
|
54
|
+
if `host instance-data.ec2.internal`.include? 'has address'
|
55
|
+
FileUtils.cp("#{base_dir}/src/etc/init.d/ec2-run-user-data", "/etc/init.d/ec2-run-user-data") unless File.exist?("/etc/init.d/ec2-run-user-data")
|
56
|
+
shell "chmod +x /etc/init.d/ec2-run-user-data"
|
57
|
+
shell "chkconfig --level 345 ec2-run-user-data on"
|
58
|
+
end
|
57
59
|
else
|
58
60
|
echo "Unsuported OS for automatic agent installation. Exiting now..."
|
59
61
|
exit(1)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
metadata :name => "component module tests executor v2",
|
2
|
+
:description => "Agent to executing component module infrastructure tests v2",
|
3
|
+
:author => "Reactor8",
|
4
|
+
:license => "",
|
5
|
+
:version => "",
|
6
|
+
:url => "",
|
7
|
+
:timeout => 10
|
8
|
+
action "execute_tests_v2", :description => "execute all component module infrastructure tests v2" do
|
9
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/formatters/json_formatter'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
ModulePath = "/etc/puppet/modules"
|
7
|
+
ServerspecPath = "serverspec/spec/localhost"
|
8
|
+
|
9
|
+
module MCollective
|
10
|
+
module Agent
|
11
|
+
class ServerSpecHelper
|
12
|
+
def execute(spec_path, vars=[])
|
13
|
+
vars.each do |var|
|
14
|
+
var.each_pair do |k,v|
|
15
|
+
Thread.current[k] = v
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
config = RSpec.configuration
|
20
|
+
json_formatter = RSpec::Core::Formatters::JsonFormatter.new(config.output)
|
21
|
+
reporter = RSpec::Core::Reporter.new(json_formatter)
|
22
|
+
config.instance_variable_set(:@reporter, reporter)
|
23
|
+
::RSpec::Core::Runner.run([spec_path,'--format','j'])
|
24
|
+
json_formatter.output_hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Execute_tests_v2 < RPC::Agent
|
29
|
+
def initialize()
|
30
|
+
super()
|
31
|
+
@log = Log.instance
|
32
|
+
end
|
33
|
+
|
34
|
+
def pull_modules(module_version_context, git_server)
|
35
|
+
ENV['GIT_SHELL'] = nil #This is put in because if vcsrepo Puppet module used it sets this
|
36
|
+
begin
|
37
|
+
repo_dir = "#{ModulePath}/#{module_version_context[:implementation]}"
|
38
|
+
remote_repo = "#{git_server}:#{module_version_context[:repo]}"
|
39
|
+
opts = Hash.new
|
40
|
+
begin
|
41
|
+
if File.exists?(repo_dir)
|
42
|
+
@log.info("Branch already exists. Checkout to branch and pull latest changes...")
|
43
|
+
git_repo = ::DTK::NodeAgent::GitClient.new(repo_dir)
|
44
|
+
git_repo.pull_and_checkout_branch?(module_version_context[:branch],opts)
|
45
|
+
else
|
46
|
+
@log.info("Branch does not exist. Cloning branch...")
|
47
|
+
git_repo = ::DTK::NodeAgent::GitClient.new(repo_dir,:create=>true)
|
48
|
+
git_repo.clone_branch(remote_repo,module_version_context[:branch],opts)
|
49
|
+
end
|
50
|
+
rescue Exception => e
|
51
|
+
log_error(e)
|
52
|
+
#to achieve idempotent behavior; fully remove directory if any problems
|
53
|
+
FileUtils.rm_rf repo_dir
|
54
|
+
raise e
|
55
|
+
end
|
56
|
+
rescue Exception => e
|
57
|
+
log_error(e)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def log_error(e)
|
62
|
+
log_error = ([e.inspect]+e.backtrace).join("\n")
|
63
|
+
@log.info("\n----------------error-----\n#{log_error}\n----------------error-----")
|
64
|
+
end
|
65
|
+
|
66
|
+
action "execute_tests_v2" do
|
67
|
+
spec_helper = ServerSpecHelper.new
|
68
|
+
all_tests = Dir["#{ModulePath}/*/#{ServerspecPath}/*.rb"]
|
69
|
+
all_spec_results = []
|
70
|
+
|
71
|
+
#Pull latest changes for modules if any
|
72
|
+
git_server = Facts["git-server"]
|
73
|
+
|
74
|
+
begin
|
75
|
+
request[:components].each do |component|
|
76
|
+
#Filter version context for modules that exist on node
|
77
|
+
filtered_version_context = request[:version_context].select { |x| x[:implementation] == component[:module_name] }.first
|
78
|
+
pull_modules(filtered_version_context,git_server)
|
79
|
+
|
80
|
+
test = all_tests.select { |test| (test.include? component[:test_name]) && (test.include? component[:module_name]) }
|
81
|
+
@log.info("Executing serverspec test: #{test.first}")
|
82
|
+
|
83
|
+
spec_results = spec_helper.execute(test.first, component[:params])
|
84
|
+
component_name = ""
|
85
|
+
if component[:component].include? "/"
|
86
|
+
component_name = component[:component].split("/").last
|
87
|
+
else
|
88
|
+
component_name = component[:component]
|
89
|
+
end
|
90
|
+
|
91
|
+
spec_results[:examples].each do |spec|
|
92
|
+
spec_result = {}
|
93
|
+
spec_result.store(:module_name, component[:module_name])
|
94
|
+
spec_result.store(:component_name, component_name)
|
95
|
+
spec_result.store(:test_component_name, component[:test_component])
|
96
|
+
spec_result.store(:test_name, component[:test_name])
|
97
|
+
spec_result.store(:test_result, spec[:full_description])
|
98
|
+
spec_result.store(:status, spec[:status])
|
99
|
+
all_spec_results << spec_result
|
100
|
+
end
|
101
|
+
end
|
102
|
+
reply[:data] = all_spec_results
|
103
|
+
reply[:pbuilderid] = Facts["pbuilderid"]
|
104
|
+
reply[:status] = :ok
|
105
|
+
rescue Exception => e
|
106
|
+
@log.info("Error while executing serverspec test")
|
107
|
+
@log.info(e.message)
|
108
|
+
reply[:data] = { :test_error => "#{e.message.lines.first}" }
|
109
|
+
reply[:pbuilderid] = Facts["pbuilderid"]
|
110
|
+
reply[:status] = :notok
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -212,7 +212,7 @@ module MCollective
|
|
212
212
|
if stderr_msg and not stderr_msg.empty?
|
213
213
|
stderr_msg
|
214
214
|
elsif return_code != 0
|
215
|
-
if last_line =
|
215
|
+
if last_line = `tail -1 "#{log_file_path}"`
|
216
216
|
#TODO: might be more general pattern to search
|
217
217
|
if last_line =~ /^.+Puppet \(err\):\s*(.+$)/
|
218
218
|
$1
|
@@ -8,12 +8,14 @@ module MCollective
|
|
8
8
|
class Pbuilder_facts < Base
|
9
9
|
|
10
10
|
def load_facts_from_source
|
11
|
-
ret = {"pbuilderid" => get_pbuilderid()}
|
11
|
+
# ret = {"pbuilderid" => get_pbuilderid()}
|
12
|
+
ret = {}
|
12
13
|
yaml_file = '/etc/mcollective/facts.yaml'
|
13
14
|
if File.exists?(yaml_file)
|
14
15
|
yaml_facts = YAML.load_file(yaml_file)
|
15
16
|
ret.merge!(yaml_facts)
|
16
17
|
end
|
18
|
+
ret.merge!("pbuilderid" => get_pbuilderid()) unless ret.keys.include?('pbuilderid')
|
17
19
|
ret
|
18
20
|
end
|
19
21
|
|
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.5.
|
4
|
+
version: 0.5.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich PELAVIN
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|
@@ -145,6 +145,8 @@ files:
|
|
145
145
|
- mcollective_additions/plugins/v2.2/agent/dtk_node_agent_git_client.rb
|
146
146
|
- mcollective_additions/plugins/v2.2/agent/execute_tests.ddl
|
147
147
|
- mcollective_additions/plugins/v2.2/agent/execute_tests.rb
|
148
|
+
- mcollective_additions/plugins/v2.2/agent/execute_tests_v2.ddl
|
149
|
+
- mcollective_additions/plugins/v2.2/agent/execute_tests_v2.rb
|
148
150
|
- mcollective_additions/plugins/v2.2/agent/get_log_fragment.ddl
|
149
151
|
- mcollective_additions/plugins/v2.2/agent/get_log_fragment.rb
|
150
152
|
- mcollective_additions/plugins/v2.2/agent/git_access.ddl
|
@@ -191,12 +193,12 @@ require_paths:
|
|
191
193
|
- lib
|
192
194
|
required_ruby_version: !ruby/object:Gem::Requirement
|
193
195
|
requirements:
|
194
|
-
- -
|
196
|
+
- - '>='
|
195
197
|
- !ruby/object:Gem::Version
|
196
198
|
version: '0'
|
197
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
200
|
requirements:
|
199
|
-
- -
|
201
|
+
- - '>='
|
200
202
|
- !ruby/object:Gem::Version
|
201
203
|
version: '0'
|
202
204
|
requirements: []
|