danarchy_deploy 0.2.6 → 0.2.7
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/danarchy_deploy/system.rb +14 -7
- data/lib/danarchy_deploy/templater.rb +25 -7
- data/lib/danarchy_deploy/version.rb +1 -1
- data/templates/deploy_template.json +71 -44
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e103704d84bcb50319a7f6dae091e4655159c1ee83e0b28ae599280ab1c325d
|
4
|
+
data.tar.gz: '084b77c73e50c58af4f38d8cd81be5cdbbcd6923a046b944f3b1c3eafaacb248'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b24d195152bfd8ce9e63e946d393f6699c56914e6880b431e5ab93b4c557a292b73f3c6a5c6d21fa35fd3cf70f531daced888e1192bea86f0bcef6947e571b9e
|
7
|
+
data.tar.gz: bcf97212adde19fbb712efb9b9864e1f8f26e22370ed5fd0ff435ea1a04cd065d78b9530ee1b2989afd2aadc4c72eeecbdfc67f52b698dd08af0d7ee5d1be930
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
patch_0.2.7
|
2
|
+
- Patch Templater ERB.new for Ruby versions higher than 2.6
|
3
|
+
- Allow builtin:: templates in Templater
|
4
|
+
- System: allow :system:updates in template to control what to install/update
|
5
|
+
- System: do not return if :system is not defined in template
|
6
|
+
|
1
7
|
patch_0.2.6
|
2
8
|
- DanarchyDeploy: gem install --bindir
|
3
9
|
- DanarchyDeploy: return from each class if not defined in a deployment
|
@@ -10,27 +10,34 @@ module DanarchyDeploy
|
|
10
10
|
module System
|
11
11
|
def self.new(deployment, options)
|
12
12
|
abort('Operating System not defined! Exiting!') if !deployment[:os]
|
13
|
-
return deployment if ! deployment[:system]
|
14
13
|
puts "\n" + self.name
|
15
14
|
|
16
15
|
installer, updater, cleaner = prep_operating_system(deployment, options)
|
17
16
|
install_result = nil
|
18
|
-
|
17
|
+
|
18
|
+
puts "\n > Package Installation"
|
19
|
+
if deployment[:packages].any? && ['all', 'packages', nil].include?(deployment[:system][:update])
|
19
20
|
packages = deployment[:packages].join(' ')
|
20
|
-
puts "\
|
21
|
+
puts "\n - Installing packages..."
|
21
22
|
install_result = DanarchyDeploy::Helpers.run_command("#{installer} #{packages}", options)
|
22
23
|
puts install_result[:stdout] if install_result[:stdout]
|
23
24
|
else
|
24
|
-
puts "\
|
25
|
+
puts "\n - Not installing packages."
|
26
|
+
puts " |_ Packages selected: #{deployment[:packages].count}"
|
27
|
+
puts " |_ Updates selected: #{deployment[:system][:update]}"
|
25
28
|
end
|
26
29
|
|
27
|
-
|
28
|
-
|
30
|
+
puts "\n > #{deployment[:os].capitalize} System Updates"
|
31
|
+
if ['all', 'system', nil].include?(deployment[:system][:update])
|
32
|
+
puts "\n - Running system updates..."
|
29
33
|
updater_result = DanarchyDeploy::Helpers.run_command(updater, options)
|
30
34
|
puts updater_result[:stdout] if updater_result[:stdout]
|
31
|
-
puts "\
|
35
|
+
puts "\n - Cleaning up unused packages..."
|
32
36
|
cleanup_result = DanarchyDeploy::Helpers.run_command(cleaner, options)
|
33
37
|
puts cleanup_result[:stdout] if cleanup_result[:stdout]
|
38
|
+
else
|
39
|
+
puts "\n - Not running #{deployment[:os].capitalize} system updates."
|
40
|
+
puts " |_ Updates selected: #{deployment[:system][:update]}"
|
34
41
|
end
|
35
42
|
|
36
43
|
deployment
|
@@ -3,6 +3,15 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module DanarchyDeploy
|
5
5
|
class Templater
|
6
|
+
def self.load_source(source)
|
7
|
+
if source =~ /^builtin::/
|
8
|
+
source = File.expand_path('../../', __dir__) + '/templates/' + source.split('::').last
|
9
|
+
end
|
10
|
+
|
11
|
+
abort("Source file does not exist at: #{source}") if ! File.exist?(source)
|
12
|
+
source
|
13
|
+
end
|
14
|
+
|
6
15
|
def self.new(templates, options)
|
7
16
|
puts "\n" + self.name
|
8
17
|
|
@@ -13,12 +22,17 @@ module DanarchyDeploy
|
|
13
22
|
|
14
23
|
templates.each do |template|
|
15
24
|
next if template[:remove]
|
16
|
-
|
17
|
-
|
18
|
-
|
25
|
+
source = if !template[:target]
|
26
|
+
abort("No target destination set for template: #{template[:source]}!")
|
27
|
+
elsif template[:source].nil? && template[:data].nil?
|
28
|
+
abort("No source or data for template: #{template[:target]}")
|
29
|
+
elsif template[:data]
|
30
|
+
'-- encoded data --'
|
31
|
+
else
|
32
|
+
load_source(template[:source])
|
33
|
+
end
|
19
34
|
|
20
35
|
target = template[:target]
|
21
|
-
source = template[:source] || '-- encoded data --'
|
22
36
|
dir_perms = template[:dir_perms]
|
23
37
|
file_perms = template[:file_perms]
|
24
38
|
@variables = template[:variables] || nil
|
@@ -43,7 +57,11 @@ module DanarchyDeploy
|
|
43
57
|
end
|
44
58
|
|
45
59
|
File.open(tmpfile, 'w') do |f|
|
46
|
-
result =
|
60
|
+
result = if RUBY_VERSION >= '2.6'
|
61
|
+
ERB.new(File.read(source), trim_mode: '-').result(binding)
|
62
|
+
else
|
63
|
+
ERB.new(File.read(source), nil, '-').result(binding)
|
64
|
+
end
|
47
65
|
f.write(result)
|
48
66
|
f.close
|
49
67
|
end
|
@@ -54,7 +72,7 @@ module DanarchyDeploy
|
|
54
72
|
puts "\n - Fake Run: Not changing '#{target}'."
|
55
73
|
result[:verify_permissions][File.dirname(tmpfile)] = verify_permissions(File.dirname(tmpfile), dir_perms, options)
|
56
74
|
result[:verify_permissions][tmpfile] = verify_permissions(tmpfile, file_perms, options)
|
57
|
-
elsif
|
75
|
+
elsif files_identical?(target,tmpfile)
|
58
76
|
puts "\n - No change in '#{target}': Nothing to update here."
|
59
77
|
result[:verify_permissions][File.dirname(target)] = verify_permissions(File.dirname(target), dir_perms, options)
|
60
78
|
result[:verify_permissions][target] = verify_permissions(target, file_perms, options)
|
@@ -141,7 +159,7 @@ module DanarchyDeploy
|
|
141
159
|
[owner, uid, group, gid]
|
142
160
|
end
|
143
161
|
|
144
|
-
def self.
|
162
|
+
def self.files_identical?(target, tmpfile)
|
145
163
|
if File.exist?(target) && File.exist?(tmpfile)
|
146
164
|
FileUtils.identical?(target, tmpfile)
|
147
165
|
elsif File.exist?(target) && !File.exist?(tmpfile)
|
@@ -1,13 +1,41 @@
|
|
1
1
|
{
|
2
2
|
"hostname": "hostname",
|
3
|
-
"os": "gentoo
|
4
|
-
"ipv4": "IPv4 to use for deployment",
|
5
|
-
"ssh_user": "
|
6
|
-
"ssh_key": "/home/path/to/
|
3
|
+
"os": "gentoo || debian || fedora || ubuntu || opensuse",
|
4
|
+
"ipv4": "IPv4 to use for remote deployment",
|
5
|
+
"ssh_user": "ssh-user",
|
6
|
+
"ssh_key": "/home/path/to/ssh-user/ssh_key.",
|
7
7
|
"packages": [
|
8
8
|
"package1",
|
9
9
|
"package2"
|
10
10
|
],
|
11
|
+
"system": {
|
12
|
+
"update": "all || system || packages || none",
|
13
|
+
"fstab": {
|
14
|
+
"source": "builtin::system/fstab_gentoo_client.erb",
|
15
|
+
"mounts": [
|
16
|
+
{
|
17
|
+
"filesystem": "/",
|
18
|
+
"mountpoint": "/dev/sda3",
|
19
|
+
"type": "ext4",
|
20
|
+
"opts": "defaults,noatime",
|
21
|
+
"dump/pass": "0 0"
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"portage": {
|
27
|
+
"sync": false,
|
28
|
+
"templates": [
|
29
|
+
{
|
30
|
+
"target": "/etc/portage/make.conf",
|
31
|
+
"source": "builtin::portage/make.conf.erb",
|
32
|
+
"variables": {
|
33
|
+
"use": "bindist logrotate",
|
34
|
+
"features": "distcc"
|
35
|
+
}
|
36
|
+
}
|
37
|
+
]
|
38
|
+
},
|
11
39
|
"users": [
|
12
40
|
{
|
13
41
|
"username": "username",
|
@@ -16,22 +44,21 @@
|
|
16
44
|
"gid": int,
|
17
45
|
"sudoer": "username ALL = NOPASSWD: ALL",
|
18
46
|
"ssh-authorized_keys": [
|
19
|
-
|
20
|
-
|
47
|
+
"ssh-ed25519 it0C5o6GHC8lxqctpexakfdA5o7LeSe+QbMhIl+GYtZ2OCMFliLsODDrrazR+u2y user@hostname",
|
48
|
+
"ssh-rsa K0APeEvotGunpBrl/LvSAG/gLUldCnOrL60v47QYjuqoGJmM3Fk8V29+8jZPp9Dl user@hostname"
|
21
49
|
],
|
22
50
|
"groups": [
|
23
|
-
|
24
|
-
int
|
51
|
+
int
|
25
52
|
],
|
26
53
|
"archives": [
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
54
|
+
{
|
55
|
+
"target": "/path/to/extract/to/",
|
56
|
+
"source": "/path/to/tarball.(tar.{gz,bz2}|zip)"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"target": "/path/to/extract/to/",
|
60
|
+
"data": "couchdb::base64_encoded_data"
|
61
|
+
}
|
35
62
|
]
|
36
63
|
}
|
37
64
|
],
|
@@ -50,48 +77,48 @@
|
|
50
77
|
]
|
51
78
|
},
|
52
79
|
"archives": [
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
80
|
+
{
|
81
|
+
"target": "/path/to/extract/to/",
|
82
|
+
"source": "/path/to/tarball.(tar.{gz,bz2}|zip)"
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"target": "/path/to/extract/to/",
|
86
|
+
"data": "couchdb::base64_encoded_data"
|
87
|
+
}
|
61
88
|
],
|
62
89
|
"templates": [
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
90
|
+
{
|
91
|
+
"target": "/path/to/target/file",
|
92
|
+
"source": "/path/to/source/erb",
|
93
|
+
"dir_perms": {
|
67
94
|
"owner": "username",
|
68
95
|
"group": "groupname",
|
69
96
|
"mode": "0755"
|
70
|
-
|
71
|
-
|
97
|
+
},
|
98
|
+
"file_perms": {
|
72
99
|
"owner": "username",
|
73
100
|
"group": "groupname",
|
74
101
|
"mode": "0644"
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
102
|
+
},
|
103
|
+
"variables": {
|
104
|
+
"var1": "value",
|
105
|
+
"var2": "value"
|
106
|
+
}
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"target": "/path/to/target/file",
|
110
|
+
"data": "couchdb::base64_encoded_erb",
|
111
|
+
"dir_perms": {
|
85
112
|
"owner": "username",
|
86
113
|
"group": "groupname",
|
87
114
|
"mode": "0755"
|
88
|
-
|
89
|
-
|
115
|
+
},
|
116
|
+
"file_perms": {
|
90
117
|
"owner": "username",
|
91
118
|
"group": "groupname",
|
92
119
|
"mode": "0644"
|
93
|
-
|
94
|
-
|
120
|
+
}
|
121
|
+
}
|
95
122
|
]
|
96
123
|
}
|
97
124
|
}
|
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.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan James
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danarchy_couchdb
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
150
|
+
rubygems_version: 3.3.26
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Pushes deployments locally or remotely based on a JSON/YAML/CouchDB template.
|