staypuft 0.5.3 → 0.5.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGUyNWNiM2M0NjZkMTZiMDRiN2ExNjdmNTEzYTU3MDQwY2EzYThlZQ==
4
+ YWI4ZTliYmU2MjdjNjk0ZDg1Yzk5Yzk3NDg4YjVmMjE1MjYxNjI2OA==
5
5
  data.tar.gz: !binary |-
6
- NzI0ZTY4Y2UzZGM3MzI2MTU3OTkzMjE0NTU5MmVlMmM5YzU5MTYyMw==
6
+ NjQ4Y2U3OTJhNmRkZGQ5ZmRhYzg0NzVhMDM5NzAyYzAxZDczYmRmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTEzNjU2YzIyY2JiNDc1MTYzNGZhYzBlNjFkZGI4ZGI5YmY1YTc3MTdjMDBj
10
- MTJmZTExNjMwZjZkNGRkMWUzZTM1NzJkZDZkMmRmMWQzZjIxNTI2MWJhZTlk
11
- ODU4MWJlYjk5ODEyZTZkM2IzNTBlZGE2ZDc5ZGJhNmMwMTgyYjY=
9
+ NGU3Y2Q4ODIxMWY5ZWU5NDRkNmRjYjNiMTQwMWNjZGNjY2U0OTg1OGQ2YjI5
10
+ YTZjMGI3NTc2YzkxMTM5Njk0NDQzYTI0OTA4YTU4ZWQ1ZGY5ODkwZGM4M2Jm
11
+ MDVlYjgwMzkxZjY3ZDdhZWVhZTgwOWQxZTEyMzQ5NTgzZTYwMGM=
12
12
  data.tar.gz: !binary |-
13
- MmRlYTkyMDkyOTY1MWViYzgyNDliNzM5ZTdhODYxMmU5NzYwMTE2NGIxYWI2
14
- M2JlNGNlZjRhOWI4MTY5MWMwN2ZkMzcwODdlNmJlZTQwYmQxOTA5MjRjZTdh
15
- Y2UxNmZiYzZhNzlhYWQ3NWQxN2YwMmIzMjI1YWI4ZTg0YWZiMWQ=
13
+ NjEyMTlhMDQ5MjgwNjcyZGJiNTU5ZjdhZmU0OWNlZTExY2YwMDYyODM3ODhk
14
+ ZmZiYjcxMTlhN2IwNzk0ODQ5OGQxODA3YTFjZThmN2M4ZTk3ZjdjOTI0Yzdm
15
+ MmI4YTljZDllM2JhZjViOWE2MDQwMmZhNGNhZGNkZDFiZTcxNTc=
@@ -214,3 +214,7 @@ h3[data-toggle="collapse"] {
214
214
  .single_password.inset_form {
215
215
  margin-left: 192px;
216
216
  }
217
+
218
+ .ui-draggable-dragging {
219
+ z-index: 1000;
220
+ }
@@ -0,0 +1,49 @@
1
+ module Actions
2
+ module Staypuft
3
+ module Host
4
+ class AssertReportSuccess < Dynflow::Action
5
+
6
+ middleware.use Actions::Staypuft::Middleware::AsCurrentUser
7
+
8
+ def plan(host_id)
9
+ plan_self host_id: host_id
10
+ end
11
+
12
+ def run(event = nil)
13
+ case event
14
+ when Dynflow::Action::Skip
15
+ output[:status] = true
16
+ else
17
+ output[:status] = assert_latest_report_success(input[:host_id])
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def assert_latest_report_success(host_id)
24
+ host = ::Host.find(host_id)
25
+ report = host.reports.order('reported_at DESC').first
26
+
27
+ unless report
28
+ fail(::Staypuft::Exception, "No Puppet report found for host: #{host_id}")
29
+ end
30
+
31
+ check_for_failures(report, host_id)
32
+ report_change?(report)
33
+ end
34
+
35
+ def report_change?(report)
36
+ report.status['applied'] > 0
37
+ end
38
+
39
+ def check_for_failures(report, host_id)
40
+ if report.status['failed'] > 0
41
+ output[:report_id] = report.id
42
+ fail(::Staypuft::Exception, "Latest Puppet run contains failures for host: #{host_id}")
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -15,20 +15,22 @@ module Actions
15
15
  module Host
16
16
  class Deploy < Dynflow::Action
17
17
 
18
- def plan(host)
18
+ def plan(host, check_success = true)
19
19
  Type! host, ::Host::Base
20
20
 
21
21
  input.update host: { id: host.id, name: host.name }
22
22
 
23
23
  sequence do
24
- plan_action Actions::Staypuft::Host::Update, host, :environment => nil
25
24
  puppet_run = plan_action Host::PuppetRun, host
26
- plan_action Host::ReportCheck, host.id, puppet_run.output[:executed_at]
25
+ plan_action Host::ReportWait, host.id, puppet_run.output[:executed_at]
26
+ if check_success
27
+ plan_action Host::AssertReportSuccess, host.id
28
+ end
27
29
  end
28
30
  end
29
31
 
30
32
  def task_output
31
- steps = planned_actions(Host::ReportCheck).inject([]) { |s, a| s + a.steps[1..2] }.compact
33
+ steps = planned_actions(Host::ReportWait).inject([]) { |s, a| s + a.steps[1..2] }.compact
32
34
  progress = if steps.empty?
33
35
  1
34
36
  else
@@ -14,7 +14,7 @@ module Actions
14
14
  module Staypuft
15
15
  module Host
16
16
 
17
- class ReportCheck < Actions::Base
17
+ class ReportWait < Actions::Base
18
18
 
19
19
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
20
20
  include Dynflow::Action::Polling
@@ -69,21 +69,7 @@ module Actions
69
69
  def host_ready?(host_id, after)
70
70
  host = ::Host.find(host_id)
71
71
  report = host.reports.where('reported_at > ?', after).first
72
- return false unless report
73
-
74
- check_for_failures(report, host.id)
75
- report_change?(report)
76
- end
77
-
78
- def report_change?(report)
79
- report.status['applied'] > 0
80
- end
81
-
82
- def check_for_failures(report, id)
83
- if report.status['failed'] > 0
84
- output[:report_id] = report.id
85
- fail(::Staypuft::Exception, "Latest Puppet Run Contains Failures for Host: #{id}")
86
- end
72
+ return !!report
87
73
  end
88
74
 
89
75
  end
@@ -41,18 +41,34 @@ module Actions
41
41
 
42
42
  input.update hostgroups: {}
43
43
  hostgroups.each do |hostgroup|
44
- concurrence do
45
- input[:hostgroups].update hostgroup.id => { name: hostgroup.name, hosts: {} }
44
+ input[:hostgroups].update hostgroup.id => { name: hostgroup.name, hosts: {} }
45
+ hostgroup_hosts = (hostgroup.hosts & hosts_to_deploy_filter)
46
46
 
47
- (hostgroup.hosts & hosts_to_deploy_filter).each do |host|
47
+ # wait till all hosts are ready
48
+ concurrence do
49
+ hostgroup_hosts.each do |host|
48
50
  input[:hostgroups][hostgroup.id][:hosts].update host.id => host.name
49
51
 
50
- sequence do
51
- plan_action Host::WaitUntilReady, host
52
- plan_action Host::Deploy, host
52
+ plan_action Host::WaitUntilReady, host
53
+ plan_action Host::Update, host, :environment => nil
54
+ end
55
+ end
56
+
57
+ # run puppet twice without checking for puppet success
58
+ 2.times do
59
+ concurrence do
60
+ hostgroup_hosts.each do |host|
61
+ plan_action Host::Deploy, host, false
53
62
  end
54
63
  end
55
64
  end
65
+
66
+ # run puppet once and check it succeeded
67
+ concurrence do
68
+ hostgroup_hosts.each do |host|
69
+ plan_action Host::Deploy, host
70
+ end
71
+ end
56
72
  end
57
73
 
58
74
  enable_puppet_agent hosts_to_deploy
@@ -87,7 +103,10 @@ module Actions
87
103
 
88
104
  concurrence do
89
105
  hosts.zip(puppet_runs).each do |host, puppet_run|
90
- plan_action Actions::Staypuft::Host::ReportCheck, host.id, puppet_run.output[:executed_at]
106
+ sequence do
107
+ plan_action Actions::Staypuft::Host::ReportWait, host.id, puppet_run.output[:executed_at]
108
+ plan_action Actions::Staypuft::Host::AssertReportSuccess, host.id
109
+ end
91
110
  end
92
111
  end
93
112
  end
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staypuft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Staypuft team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks
@@ -126,10 +126,11 @@ files:
126
126
  - app/helpers/staypuft/hosts_helper.rb
127
127
  - app/lib/actions/staypuft/deployment/deploy.rb
128
128
  - app/lib/actions/staypuft/deployment/populate.rb
129
+ - app/lib/actions/staypuft/host/assert_report_success.rb
129
130
  - app/lib/actions/staypuft/host/create.rb
130
131
  - app/lib/actions/staypuft/host/deploy.rb
131
132
  - app/lib/actions/staypuft/host/puppet_run.rb
132
- - app/lib/actions/staypuft/host/report_check.rb
133
+ - app/lib/actions/staypuft/host/report_wait.rb
133
134
  - app/lib/actions/staypuft/host/trigger_provisioning.rb
134
135
  - app/lib/actions/staypuft/host/update.rb
135
136
  - app/lib/actions/staypuft/host/wait_until_provisioned.rb