danarchy_deploy 0.2.12 → 0.2.13

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
  SHA256:
3
- metadata.gz: d983a99ae7625895008802d7aefb21d055f45e3b70dfd365ca2881d2349a29d6
4
- data.tar.gz: 55d5b7477a5d2b43bcffe6d86d11977add6739e49336cd963fde8141b374f13a
3
+ metadata.gz: 61637129e8f6974c029b38504bfc513e3284d4d5eef6dc54fa5e24cdf45709d1
4
+ data.tar.gz: 80ea5ff429b1ae44d3eb6aef9d7dea0cecac5fc717fcd3cd8bc0125c8e54788a
5
5
  SHA512:
6
- metadata.gz: 4b42720a0e7433080ff22b9104bde15f347ba6fea32e405a37dc122c46527c27a0e022da4242ff4f44d3e810c82834aa745eb0df9673c4642901da7c726a5e4b
7
- data.tar.gz: 8f0aab58a7132063b3383f9a4a7b310f2dc5fb026f15f0b7850325864098bac55900c1c6e0aacd8e628e620efcc593fdb4e3b26f25ad1741803f38bca41507eb
6
+ metadata.gz: 337fde118724af946077e866fce15a6892cde02f99d46bcfaa9d1535d6ddca450cc2aefb54e2275d71e0b848cf8b562012d5ef1b03be903abfc5483f8159576c
7
+ data.tar.gz: '0868e979870026c5525318b5ccf06dadde9a3ae2b1e52fb2cbba238b1b18d56c5e7e84418abe2ef0bc617f0ff77e52aa4c5744142b9fde4f104345b1f2c592f4'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ patch_0.2.13
2
+ - Pid class to return LocalDeploy if already running
3
+ - remote_LocalDeploy parse options dynamically
4
+ - portage_sync: log eclean output
5
+ - fix @runlevel in init/openrc.rb
6
+ - update builtin::portage/make.conf.erb with variable parsing
7
+
1
8
  patch_0.2.12
2
9
  - Rename bin/console
3
10
  - Change emerge --sync cron to /etc/cron.daily/
data/README.md CHANGED
@@ -40,8 +40,7 @@ Usage: sudo bin/danarchy_deploy (local|remote) --json /path/to/deployment.json [
40
40
  --dev-gem Build dAnarchy_deploy gem locally and push to target host in RemoteDeploy.
41
41
  --ssh-verbose Verbose SSH stdout/stderr output.
42
42
  --vars-verbose Verbose template variable output.
43
+ --skip-install Skip package installation and updates.
43
44
  --version Print bin/danarchy_deploy version.
44
45
  -h, --help Print this help info.
45
46
  ```
46
-
47
- More documentation incoming...
@@ -0,0 +1,38 @@
1
+ module DanarchyDeploy
2
+ class Pid
3
+ attr_reader :pid
4
+ attr_reader :locked
5
+ attr_reader :message
6
+
7
+ def initialize
8
+ @pidfile = '/var/run/danarchy_deploy.pid'
9
+ @pid = File.exist?(@pidfile) ? File.read(@pidfile).chomp.to_i : nil
10
+ @locked = false
11
+
12
+ if @pid
13
+ begin
14
+ Process.getpgid(@pid)
15
+ @locked = true
16
+ @message = "dAnarchy Deploy is already running as PID: #{@pid}"
17
+ rescue Errno::ESRCH => e
18
+ @locked = false
19
+ @message = "dAnarchy Deploy is not currently running."
20
+ end
21
+ end
22
+
23
+ if @locked == false
24
+ @pid = Process.pid
25
+ @locked = false
26
+ @message = "dAnarchy Deploy has started as PID: #{@pid}"
27
+ File.write(@pidfile, @pid)
28
+ end
29
+ end
30
+
31
+ def cleanup
32
+ File.delete(@pidfile)
33
+ @pid = nil
34
+ @locked = false
35
+ @message = "dAnarchy Deploy has completed. Cleaning up PID"
36
+ end
37
+ end
38
+ end
@@ -65,7 +65,7 @@ module DanarchyDeploy
65
65
  end
66
66
 
67
67
  def disable
68
- cmd = "rc-update del #{@service} #{runlevel}"
68
+ cmd = "rc-update del #{@service} #{@runlevel}"
69
69
  DanarchyDeploy::Helpers.run_command(cmd, @options)
70
70
  end
71
71
 
@@ -1,3 +1,3 @@
1
1
  module DanarchyDeploy
2
- VERSION = "0.2.12"
2
+ VERSION = "0.2.13"
3
3
  end
@@ -4,6 +4,7 @@ module DanarchyDeploy
4
4
  require_relative 'danarchy_deploy/groups'
5
5
  require_relative 'danarchy_deploy/hash_deep_merge'
6
6
  require_relative 'danarchy_deploy/helpers'
7
+ require_relative 'danarchy_deploy/pid'
7
8
  require_relative 'danarchy_deploy/services'
8
9
  require_relative 'danarchy_deploy/system'
9
10
  require_relative 'danarchy_deploy/templater'
@@ -14,8 +15,15 @@ module DanarchyDeploy
14
15
  class LocalDeploy
15
16
  def self.new(deployment, options)
16
17
  puts "\n" + self.name
18
+
19
+ pid = Pid.new
20
+ puts pid.message
21
+ if pid.locked
22
+ return deployment
23
+ end
24
+
17
25
  puts "Pretend run! Not making any changes." if options[:pretend]
18
-
26
+
19
27
  puts 'Begining Deployment:'
20
28
  printf("%12s %0s\n", 'Hostname:', deployment[:hostname])
21
29
  printf("%12s %0s\n", 'OS:', deployment[:os])
@@ -36,6 +44,8 @@ module DanarchyDeploy
36
44
  File.write(options[:deploy_file], deployment.to_yaml)
37
45
  end
38
46
 
47
+ pid.cleanup
48
+ puts pid.message
39
49
  deployment
40
50
  end
41
51
  end
@@ -159,7 +169,7 @@ module DanarchyDeploy
159
169
  gem_dir = File.expand_path('../../', __FILE__)
160
170
 
161
171
  abort('ERROR: Need to be in development gem directory for --dev-gem!') if Dir.pwd != gem_dir
162
-
172
+
163
173
  gem_path = "#{gem_dir}/pkg/#{gem}"
164
174
  build_cmd = "cd #{gem_dir} && git add . && rake build"
165
175
  build_result = DanarchyDeploy::Helpers.run_command(build_cmd, options)
@@ -183,7 +193,7 @@ module DanarchyDeploy
183
193
  else
184
194
  puts ' |+ Gem pushed!'
185
195
  end
186
-
196
+
187
197
  puts "\n > Installing gem: #{gem} on #{connector[:hostname]}"
188
198
  install_cmd = _ssh_command(connector, "sudo -i gem install --bindir /usr/local/bin -f #{options[:deploy_dir]}/#{File.basename(gem)}")
189
199
  install_result = DanarchyDeploy::Helpers.run_command(install_cmd, options)
@@ -204,14 +214,16 @@ module DanarchyDeploy
204
214
 
205
215
  def self.push_templates(connector, options)
206
216
  template_dir = options[:deploy_dir] + '/templates'
207
- puts "\n > Pushing templates: #{template_dir}"
208
- push_cmd = _rsync_push(connector, template_dir, template_dir)
209
- push_result = DanarchyDeploy::Helpers.run_command(push_cmd, options)
210
-
211
- if push_result[:stderr]
212
- abort(' ! Templates push failed!')
213
- else
214
- puts " |+ Templates pushed to '#{template_dir}'!"
217
+ if Dir.exist?(template_dir)
218
+ puts "\n > Pushing templates: #{template_dir}"
219
+ push_cmd = _rsync_push(connector, template_dir, template_dir)
220
+ push_result = DanarchyDeploy::Helpers.run_command(push_cmd, options)
221
+
222
+ if push_result[:stderr]
223
+ abort(' ! Templates push failed!')
224
+ else
225
+ puts " |+ Templates pushed to '#{template_dir}'!"
226
+ end
215
227
  end
216
228
  end
217
229
 
@@ -231,15 +243,23 @@ module DanarchyDeploy
231
243
  puts "\n > Running LocalDeploy on #{connector[:hostname]}.\n\n"
232
244
 
233
245
  deploy_cmd = "sudo -i #{gem_binary} local "
234
- deploy_cmd += '--first-run ' if options[:first_run]
235
- deploy_cmd += '--ssh-verbose ' if options[:ssh_verbose]
236
- deploy_cmd += '--vars-verbose ' if options[:vars_verbose]
237
- deploy_cmd += '--pretend ' if options[:pretend]
238
- deploy_cmd += '--json ' if options[:deploy_file].end_with?('.json')
239
- deploy_cmd += '--yaml ' if options[:deploy_file].end_with?('.yaml')
240
- deploy_cmd += options[:deploy_file]
241
-
242
- deploy_command = _ssh_command(connector, deploy_cmd)
246
+ opts = Array.new
247
+ options.each do |k,v|
248
+ next if [:couchdb, :dev_gem, :deploy_dir].include?(k)
249
+ if k == :deploy_file
250
+ if v.end_with?('.json')
251
+ opts.insert(-1, '--json ' + v)
252
+ elsif v.end_with?('.yaml')
253
+ opts.insert(-1, '--yaml ' + v)
254
+ else
255
+ abort(" ! Unknown deploy_file type: #{v}")
256
+ end
257
+ elsif v == true
258
+ opts.insert(0, '--' + k.to_s.gsub('_', '-'))
259
+ end
260
+ end
261
+
262
+ deploy_command = _ssh_command(connector, deploy_cmd + opts.join(' '))
243
263
  system(deploy_command)
244
264
  end
245
265
 
@@ -247,7 +267,7 @@ module DanarchyDeploy
247
267
  puts "\n > Pulling deployment: #{options[:deploy_file]}"
248
268
  pull_cmd = _scp_pull(connector, options[:deploy_file], options[:deploy_file])
249
269
  pull_result = DanarchyDeploy::Helpers.run_command(pull_cmd, options)
250
-
270
+
251
271
  if pull_result[:stderr]
252
272
  abort(' ! Deployment pull failed!')
253
273
  else
@@ -5,20 +5,19 @@ CXXFLAGS="${COMMON_FLAGS}"
5
5
  FCFLAGS="${COMMON_FLAGS}"
6
6
  FFLAGS="${COMMON_FLAGS}"
7
7
 
8
- MAKEOPTS="-j<%= `nproc`.to_i * 2 + 1 %> -l<%= `nproc`.to_i %>"
8
+ MAKEOPTS="-j<%= @variables[:MAKEOPTS_J] ? @variables[:MAKEOPTS_J] : `nproc`.to_i + 1 %> -l<%= (`nproc`.to_f * 0.85) %>"
9
9
  CPU_FLAGS_X86="<%= `cpuid2cpuflags`.split(': ').last.chomp %>"
10
10
 
11
- <% if !@variables -%>
12
- USE="bindist logrotate"
13
- INPUT_DEVICES="evdev keyboard"
14
- <% else -%>
15
- <%= @variables[:use] ? 'USE=' + "\"bindist logrotate #{@variables[:use]}\"\n" : "USE=\"bindist logrotate\"\n" -%>
16
- <%= @variables[:grub] ? 'GRUB_PLATFORMS=' + "\"#{@variables[:grub]}\"\n" : '' -%>
17
- <%= @variables[:ruby] ? 'RUBY_TARGETS=' + "\"#{@variables[:ruby]}\"\n" : '' -%>
18
- <%= @variables[:php] ? 'PHP_TARGETS=' + "\"#{@variables[:php]}\"\n" : '' -%>
19
- <%= @variables[:features] ? 'FEATURES=' + "\"#{@variables[:features]}\"\n" : '' -%>
20
- <%= @variables[:videocards] ? 'VIDEO_CARDS=' + "\"#{@variables[:videocards]}\"\n" : '' -%>
21
- <%= @variables[:input] ? 'INPUT_DEVICES=' + "\"#{@variables[:input]}\"\n" : "INPUT_DEVICES=\"evdev keyboard\"\n" -%>
11
+ <%
12
+ defaults = {
13
+ :USE => "bindist logrotate",
14
+ :INPUT_DEVICES => "evdev keyboard"
15
+ }
16
+
17
+ variables = defaults.merge(@variables) if @variables.any?
18
+
19
+ variables.each do |k, v| -%>
20
+ <%= k.to_s + "=\"#{v}\"" %>
22
21
  <% end -%>
23
22
 
24
23
  # This sets the language of build output to English.
@@ -1,5 +1,5 @@
1
1
  #!/bin/bash
2
2
 
3
- /usr/bin/emerge --sync &> /var/log/emerge-sync.log
4
- /usr/bin/eclean-dist
5
- /usr/bin/eclean-pkg
3
+ /usr/bin/emerge --sync &> /var/log/emerge-sync.log
4
+ /usr/bin/eclean-dist &> /var/log/emerge-clean.log
5
+ /usr/bin/eclean-pkg &>> /var/log/emerge-clean.log
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danarchy_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan James
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-07 00:00:00.000000000 Z
11
+ date: 2025-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,6 +114,7 @@ files:
114
114
  - lib/danarchy_deploy/hash_deep_merge.rb
115
115
  - lib/danarchy_deploy/helpers.rb
116
116
  - lib/danarchy_deploy/installer.rb
117
+ - lib/danarchy_deploy/pid.rb
117
118
  - lib/danarchy_deploy/services.rb
118
119
  - lib/danarchy_deploy/services/init.rb
119
120
  - lib/danarchy_deploy/services/init/openrc.rb