dtk-node-agent 0.7.4.1 → 0.7.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aad9f61073297942166730df0ffdb2188c319c68
4
- data.tar.gz: 7808ae91f9347cdf791e92c04f54b0114957d41f
3
+ metadata.gz: 67738c6472f467c7ab9ba074af7bb4a0235f9992
4
+ data.tar.gz: 24cfbf7e9347326c224b2de278aad9fb5d6dfe99
5
5
  SHA512:
6
- metadata.gz: ceb5cadb3bfa6f6bf4c60985ebd543fea6e5caf03119828b2ca49031037c61b3bd269565432f7acefc031bc6c2a3ad7a39da22fd2301c75edc3dc073a20af54d
7
- data.tar.gz: 0a92d6933a07860f759af3bbfd0fb95ae9b6528080b0d5bced6bf700098e8a19d02f5c61746e00722ca295fcd700f0df3165b8c90dd3a7787d3492ca63312b85
6
+ metadata.gz: 88bebb7d0b909a80a3d65c6356693a4fd5515edcb258d34659a9bebb0de7c1182c8fb96918a337323284c6e5861ddb755bf012af773bd33d7222db273c836df9
7
+ data.tar.gz: d449a271411f1d14654c691484e13041a811f5ffdc23564a2178f2ba71dca3173d88da6e65a3e7f61bd84e589ca30c6e0ffa9f359ed6f431f1ec821902354004
data/README.md CHANGED
@@ -12,29 +12,6 @@ Code that is present in AMIs that server basis for nodes being spun up
12
12
  #### Intalling the node agent on a running machine (with puppet omnibus)
13
13
  `sudo ./install_agent.sh [--sanitize]`
14
14
 
15
- #### Create a new AMI image with the node agent
16
- ```
17
- ./create_agent_ami.rb --help
18
- Options:
19
- --region, -r <s>: AWS Region on which to create the AMI image
20
- --aws-key, -a <s>: AWS Access Key
21
- --aws-secret, -w <s>: AWS Secret Access Key
22
- --security-group, -s <s>: AWS Security group (default: default)
23
- --key-pair, -k <s>: AWS keypair for the new instance
24
- --key-path, -e <s>: Path to the PEM file for ssh access
25
- --ssh-username, -u <s>: SSH Username
26
- --ssh-timeout, -t <i>: Time to wait before instance is ssh ready (seconds) (default: 100)
27
- --ami-id, -m <s>: AMI id which to spin up
28
- --image-name, -i <s>: Name of the new image
29
- --help, -h: Show this message
30
- ```
31
-
32
- example:
33
- ```
34
- ruby create_agent_ami.rb --region us-east-1 --ami-id ami-da0000aa --key-pair test_key --key-path /somepath/test_key.pem \
35
- --ssh-username root --image-name dtk-agent-ubuntu-precise
36
- ```
37
-
38
15
  #### Build all supported AMI images with [packer](http://www.packer.io/)
39
16
  ```
40
17
  export AWS_ACCESS_KEY="your aws access key"
@@ -1,3 +1,3 @@
1
1
  module DtkNodeAgent
2
- VERSION="0.7.4.1"
2
+ VERSION="0.7.5"
3
3
  end
@@ -1,11 +1,14 @@
1
1
  require 'base64'
2
+ require 'tmpdir'
3
+ require 'fileutils'
2
4
 
3
5
  module MCollective
4
6
  module Agent
5
7
  class Dev_manager < RPC::Agent
6
8
 
7
9
  AGENT_MCOLLECTIVE_LOCATION = "#{::MCollective::Config.instance.libdir.join}/mcollective/agent/"
8
-
10
+ DTK_AA_TEMP_DIR = File.join(Dir.tmpdir(), 'dtk-action-agent')
11
+
9
12
  action "inject_agent" do
10
13
  begin
11
14
 
@@ -14,7 +17,7 @@ module MCollective
14
17
  # make sure default `service` command paths are set
15
18
  ENV['PATH'] += ":/usr/sbin:/sbin"
16
19
 
17
- request[:agent_files].each do |k,v|
20
+ (request[:agent_files]||[]).each do |k,v|
18
21
  if v == :deleted
19
22
  File.delete("#{AGENT_MCOLLECTIVE_LOCATION}#{k}")
20
23
  next
@@ -24,8 +27,37 @@ module MCollective
24
27
  file << content
25
28
  end
26
29
  end
30
+
27
31
  ret.set_status_succeeded!()
28
32
 
33
+ dtk_aa_url = request[:action_agent_remote_url]
34
+ dtk_aa_branch = request[:action_agent_branch]
35
+
36
+ # DTK Action Agent Sync
37
+ if dtk_aa_url && dtk_aa_branch
38
+ begin
39
+ Log.instance.info("Started DTK Action Agent sync, temp dir '#{DTK_AA_TEMP_DIR}'")
40
+ output = `git clone #{dtk_aa_url} -b #{dtk_aa_branch} #{DTK_AA_TEMP_DIR}`
41
+ result = $?
42
+
43
+ if result.success?
44
+ Log.instance.info("Cloned latest code from branch '#{dtk_aa_branch}' for DTK Action Agent.")
45
+
46
+ output = `cd #{DTK_AA_TEMP_DIR} && /opt/puppet-omnibus/embedded/bin/gem build #{DTK_AA_TEMP_DIR}/dtk-action-agent.gemspec && /opt/puppet-omnibus/embedded/bin/gem install #{DTK_AA_TEMP_DIR}/dtk-action-agent-*.gem --no-ri --no-rdoc`
47
+ result = $?
48
+ if result.success?
49
+ Log.instance.info("DTK Action Agent has been successfully update from branch '#{dtk_aa_branch}'")
50
+ else
51
+ Log.instance.error("DTK Action Agent could not be updated, reason: #{output}")
52
+ end
53
+ else
54
+ Log.instance.error("Not able to clone latest code from '#{dtk_aa_url} branch #{dtk_aa_branch}', aborting DTK Action Agent Sync. #{output}")
55
+ end
56
+ ensure
57
+ FileUtils.rm_rf DTK_AA_TEMP_DIR
58
+ end
59
+ end
60
+
29
61
  t1 = Thread.new do
30
62
  sleep(2)
31
63
  Log.instance.info "Initiating mcollective restart..."
@@ -45,6 +77,7 @@ module MCollective
45
77
  error_info = { :error => { :message => "Error syncing agents: #{e}" } }
46
78
  ret.merge!(error_info)
47
79
  end
80
+
48
81
  return ret
49
82
  end
50
83
  end
@@ -15,6 +15,9 @@ DTKPuppetModulePath = "/usr/share/dtk/puppet-modules"
15
15
  module MCollective
16
16
  module Agent
17
17
  class Puppet_apply < RPC::Agent
18
+
19
+ NUMBER_OF_RETRIES = 5
20
+
18
21
  def initialize()
19
22
  super()
20
23
  @log = Log.instance
@@ -85,12 +88,18 @@ module MCollective
85
88
 
86
89
  if clean_and_clone
87
90
  begin
91
+ tries ||= NUMBER_OF_RETRIES
88
92
  clean_and_clone_module(puppet_repo_dir, remote_repo,vc[:branch], opts)
89
93
  rescue Exception => e
90
- # TODO: not used now
91
- error_backtrace = backtrace_subset(e)
92
94
  # to achieve idempotent behavior; fully remove directory if any problems
93
95
  FileUtils.rm_rf puppet_repo_dir
96
+ unless (tries -= 1).zero?
97
+ @log.info("Re-trying last command becuase of error: #{e.message}, retries left: #{tries}")
98
+ sleep(1)
99
+ retry
100
+ end
101
+ # TODO: not used now
102
+ error_backtrace = backtrace_subset(e)
94
103
  raise e
95
104
  end
96
105
  end
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.7.4.1
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  version: '0'
271
271
  requirements: []
272
272
  rubyforge_project:
273
- rubygems_version: 2.4.6
273
+ rubygems_version: 2.4.1
274
274
  signing_key:
275
275
  specification_version: 4
276
276
  summary: DTK Node Agent gem.