caco 0.1.0

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.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +10 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +12 -0
  6. data/Gemfile.lock +227 -0
  7. data/Guardfile +42 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +97 -0
  10. data/Rakefile +10 -0
  11. data/bin/_guard-core +29 -0
  12. data/bin/bundle +114 -0
  13. data/bin/byebug +29 -0
  14. data/bin/caco +29 -0
  15. data/bin/coderay +29 -0
  16. data/bin/console +20 -0
  17. data/bin/eyaml +29 -0
  18. data/bin/guard +29 -0
  19. data/bin/listen +29 -0
  20. data/bin/pry +29 -0
  21. data/bin/rake +29 -0
  22. data/bin/safe_yaml +29 -0
  23. data/bin/setup +8 -0
  24. data/bin/thor +29 -0
  25. data/bin/tilt +29 -0
  26. data/caco.gemspec +43 -0
  27. data/exe/caco +27 -0
  28. data/lib/caco.rb +115 -0
  29. data/lib/caco/barman.rb +10 -0
  30. data/lib/caco/barman/cell/global.rb +4 -0
  31. data/lib/caco/barman/cell/node.rb +15 -0
  32. data/lib/caco/barman/install.rb +25 -0
  33. data/lib/caco/barman/view/global.erb +7 -0
  34. data/lib/caco/barman/view/node.erb +8 -0
  35. data/lib/caco/cell.rb +8 -0
  36. data/lib/caco/config.rb +23 -0
  37. data/lib/caco/debian.rb +28 -0
  38. data/lib/caco/debian/add_user.rb +18 -0
  39. data/lib/caco/debian/apt_key_install.rb +19 -0
  40. data/lib/caco/debian/apt_repo_add.rb +17 -0
  41. data/lib/caco/debian/apt_sources_list.rb +15 -0
  42. data/lib/caco/debian/apt_update.rb +33 -0
  43. data/lib/caco/debian/cell/service.rb +19 -0
  44. data/lib/caco/debian/cell/sources_list.rb +7 -0
  45. data/lib/caco/debian/package_install.rb +21 -0
  46. data/lib/caco/debian/package_installed.rb +17 -0
  47. data/lib/caco/debian/service_enable.rb +26 -0
  48. data/lib/caco/debian/service_install.rb +31 -0
  49. data/lib/caco/debian/user_home.rb +17 -0
  50. data/lib/caco/debian/view/service.erb +18 -0
  51. data/lib/caco/debian/view/sources_list.erb +10 -0
  52. data/lib/caco/downloader.rb +41 -0
  53. data/lib/caco/executer.rb +33 -0
  54. data/lib/caco/facter.rb +41 -0
  55. data/lib/caco/file_link.rb +36 -0
  56. data/lib/caco/file_reader.rb +24 -0
  57. data/lib/caco/file_writer.rb +57 -0
  58. data/lib/caco/finder.rb +13 -0
  59. data/lib/caco/grafana.rb +6 -0
  60. data/lib/caco/grafana/install.rb +26 -0
  61. data/lib/caco/haproxy.rb +12 -0
  62. data/lib/caco/haproxy/cell/conf_postgres.rb +4 -0
  63. data/lib/caco/haproxy/cell/conf_stats.rb +4 -0
  64. data/lib/caco/haproxy/conf_get.rb +15 -0
  65. data/lib/caco/haproxy/conf_set.rb +52 -0
  66. data/lib/caco/haproxy/install.rb +9 -0
  67. data/lib/caco/haproxy/view/conf_postgres.erb +25 -0
  68. data/lib/caco/haproxy/view/conf_stats.erb +6 -0
  69. data/lib/caco/macro.rb +2 -0
  70. data/lib/caco/postgres.rb +44 -0
  71. data/lib/caco/postgres/build_augeas.rb +20 -0
  72. data/lib/caco/postgres/conf_get.rb +37 -0
  73. data/lib/caco/postgres/conf_set.rb +54 -0
  74. data/lib/caco/postgres/database_create.rb +28 -0
  75. data/lib/caco/postgres/extension_create.rb +28 -0
  76. data/lib/caco/postgres/hba_set.rb +65 -0
  77. data/lib/caco/postgres/install.rb +34 -0
  78. data/lib/caco/postgres/shell.rb +13 -0
  79. data/lib/caco/postgres/sql.rb +17 -0
  80. data/lib/caco/postgres/user_change_password.rb +13 -0
  81. data/lib/caco/postgres/user_create.rb +33 -0
  82. data/lib/caco/prometheus.rb +15 -0
  83. data/lib/caco/prometheus/adapter_install_pg.rb +107 -0
  84. data/lib/caco/prometheus/adapter_install_postgresql.rb +47 -0
  85. data/lib/caco/prometheus/cell/alertmanager_conf.rb +4 -0
  86. data/lib/caco/prometheus/cell/alerts.rb +4 -0
  87. data/lib/caco/prometheus/cell/conf.rb +7 -0
  88. data/lib/caco/prometheus/exporter_install.rb +35 -0
  89. data/lib/caco/prometheus/install.rb +50 -0
  90. data/lib/caco/prometheus/install_alert_manager.rb +62 -0
  91. data/lib/caco/prometheus/view/alertmanager_conf.erb +13 -0
  92. data/lib/caco/prometheus/view/alerts.erb +18 -0
  93. data/lib/caco/prometheus/view/conf.erb +34 -0
  94. data/lib/caco/rbenv.rb +8 -0
  95. data/lib/caco/rbenv/cell/profile.rb +4 -0
  96. data/lib/caco/rbenv/install.rb +56 -0
  97. data/lib/caco/rbenv/install_version.rb +17 -0
  98. data/lib/caco/rbenv/view/profile.erb +3 -0
  99. data/lib/caco/repmgr.rb +15 -0
  100. data/lib/caco/repmgr/cell/conf.rb +43 -0
  101. data/lib/caco/repmgr/conf.rb +25 -0
  102. data/lib/caco/repmgr/install.rb +25 -0
  103. data/lib/caco/repmgr/node_register_primary.rb +34 -0
  104. data/lib/caco/repmgr/node_register_standby.rb +25 -0
  105. data/lib/caco/repmgr/node_registered.rb +15 -0
  106. data/lib/caco/repmgr/node_role.rb +18 -0
  107. data/lib/caco/repmgr/view/conf.erb +27 -0
  108. data/lib/caco/settings_loader.rb +67 -0
  109. data/lib/caco/settings_loader_monkeypatch.rb +28 -0
  110. data/lib/caco/ssh.rb +6 -0
  111. data/lib/caco/ssh/authorized_keys_add.rb +82 -0
  112. data/lib/caco/sudo.rb +6 -0
  113. data/lib/caco/sudo/sudoers_add.rb +15 -0
  114. data/lib/caco/timescale.rb +6 -0
  115. data/lib/caco/timescale/install.rb +25 -0
  116. data/lib/caco/unpacker.rb +76 -0
  117. data/lib/caco/version.rb +3 -0
  118. metadata +398 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 215897a5616e86051cdabfb633def0ee1f685e10b86614bbd782afd7f8cd70b9
4
+ data.tar.gz: b88d372eaba6606c00cf08fc4a13e64bd06e66ceb3d3dd6887fe253a0ae1eeeb
5
+ SHA512:
6
+ metadata.gz: 8208484d7b2b07fbb703deb5b2745ac6fcb25723dcedb6081c68424f272884d7c9b35c42651451f61a8680e94d84202d9347923fd133d26389c0d1c27d508513
7
+ data.tar.gz: 37538d5659a6d9abfcd1dee40634926a4c1a58d5b47f2ddad33178c5bd21f78dc2ce1c1594141bca70ec667ddc59f26c19a5700036309477181d64afb58dbf80
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /data
10
+ /keys
11
+ /.byebug_history
12
+ /test/tmp
@@ -0,0 +1,10 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install:
8
+ - sudo adduser --disabled-password --quiet --gecos "" fernandes
9
+ - gem install bundler -v 2.1.4
10
+ - sudo apt-get -y install libaugeas-dev
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at celso.fernandes@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in caco.gemspec
4
+ gemspec
5
+
6
+ # gem "rails"
7
+ group :development do
8
+ gem 'guard' # NOTE: this is necessary in newer versions
9
+ gem 'guard-minitest'
10
+ gem 'pry'
11
+ gem 'pry-byebug'
12
+ end
@@ -0,0 +1,227 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ caco (0.1.0)
5
+ cells (~> 4.1)
6
+ cells-erb (~> 0.1)
7
+ config
8
+ down (~> 5.0)
9
+ hiera-eyaml
10
+ http (~> 4.0)
11
+ marcel
12
+ ruby-augeas
13
+ trailblazer (~> 2.1)
14
+ trailblazer-cells
15
+
16
+ GEM
17
+ remote: https://rubygems.org/
18
+ specs:
19
+ activesupport (6.0.1)
20
+ concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ i18n (>= 0.7, < 2)
22
+ minitest (~> 5.1)
23
+ tzinfo (~> 1.1)
24
+ zeitwerk (~> 2.2)
25
+ addressable (2.7.0)
26
+ public_suffix (>= 2.0.2, < 5.0)
27
+ ansi (1.5.0)
28
+ builder (3.2.3)
29
+ byebug (11.0.1)
30
+ cells (4.1.7)
31
+ declarative-builder (< 0.2.0)
32
+ declarative-option (< 0.2.0)
33
+ tilt (>= 1.4, < 3)
34
+ uber (< 0.2.0)
35
+ cells-erb (0.1.0)
36
+ cells (~> 4.0)
37
+ erbse (>= 0.1.1)
38
+ coderay (1.1.2)
39
+ concurrent-ruby (1.1.5)
40
+ config (2.0.0)
41
+ activesupport (>= 4.2)
42
+ deep_merge (~> 1.2, >= 1.2.1)
43
+ dry-schema (~> 1.0)
44
+ crack (0.4.3)
45
+ safe_yaml (~> 1.0.0)
46
+ declarative (0.0.10)
47
+ declarative-builder (0.1.0)
48
+ declarative-option (< 0.2.0)
49
+ declarative-option (0.1.0)
50
+ deep_merge (1.2.1)
51
+ disposable (0.4.6)
52
+ declarative (>= 0.0.9, < 1.0.0)
53
+ declarative-builder (< 0.2.0)
54
+ declarative-option (< 0.2.0)
55
+ representable (>= 2.4.0, <= 3.1.0)
56
+ uber (< 0.2.0)
57
+ domain_name (0.5.20190701)
58
+ unf (>= 0.0.5, < 1.0.0)
59
+ down (5.0.0)
60
+ addressable (~> 2.5)
61
+ dry-configurable (0.9.0)
62
+ concurrent-ruby (~> 1.0)
63
+ dry-core (~> 0.4, >= 0.4.7)
64
+ dry-container (0.7.2)
65
+ concurrent-ruby (~> 1.0)
66
+ dry-configurable (~> 0.1, >= 0.1.3)
67
+ dry-core (0.4.9)
68
+ concurrent-ruby (~> 1.0)
69
+ dry-equalizer (0.3.0)
70
+ dry-inflector (0.2.0)
71
+ dry-initializer (3.0.2)
72
+ dry-logic (1.0.5)
73
+ concurrent-ruby (~> 1.0)
74
+ dry-core (~> 0.2)
75
+ dry-equalizer (~> 0.2)
76
+ dry-schema (1.4.1)
77
+ concurrent-ruby (~> 1.0)
78
+ dry-configurable (~> 0.8, >= 0.8.3)
79
+ dry-core (~> 0.4)
80
+ dry-equalizer (~> 0.2)
81
+ dry-initializer (~> 3.0)
82
+ dry-logic (~> 1.0)
83
+ dry-types (~> 1.2)
84
+ dry-types (1.2.1)
85
+ concurrent-ruby (~> 1.0)
86
+ dry-container (~> 0.3)
87
+ dry-core (~> 0.4, >= 0.4.4)
88
+ dry-equalizer (~> 0.2, >= 0.2.2)
89
+ dry-inflector (~> 0.1, >= 0.1.2)
90
+ dry-logic (~> 1.0, >= 1.0.2)
91
+ erbse (0.1.3)
92
+ temple
93
+ fakefs (0.20.1)
94
+ ffi (1.11.2)
95
+ ffi-compiler (1.0.1)
96
+ ffi (>= 1.0.0)
97
+ rake
98
+ formatador (0.2.5)
99
+ guard (2.16.1)
100
+ formatador (>= 0.2.4)
101
+ listen (>= 2.7, < 4.0)
102
+ lumberjack (>= 1.0.12, < 2.0)
103
+ nenv (~> 0.1)
104
+ notiffany (~> 0.0)
105
+ pry (>= 0.9.12)
106
+ shellany (~> 0.0)
107
+ thor (>= 0.18.1)
108
+ guard-compat (1.2.1)
109
+ guard-minitest (2.4.6)
110
+ guard-compat (~> 1.2)
111
+ minitest (>= 3.0)
112
+ hashdiff (1.0.0)
113
+ hiera-eyaml (3.1.1)
114
+ highline (~> 1.6.19)
115
+ optimist
116
+ highline (1.6.21)
117
+ http (4.2.0)
118
+ addressable (~> 2.3)
119
+ http-cookie (~> 1.0)
120
+ http-form_data (~> 2.0)
121
+ http-parser (~> 1.2.0)
122
+ http-cookie (1.0.3)
123
+ domain_name (~> 0.5)
124
+ http-form_data (2.1.1)
125
+ http-parser (1.2.1)
126
+ ffi-compiler (>= 1.0, < 2.0)
127
+ i18n (1.7.0)
128
+ concurrent-ruby (~> 1.0)
129
+ listen (3.2.0)
130
+ rb-fsevent (~> 0.10, >= 0.10.3)
131
+ rb-inotify (~> 0.9, >= 0.9.10)
132
+ lumberjack (1.0.13)
133
+ marcel (0.3.3)
134
+ mimemagic (~> 0.3.2)
135
+ method_source (0.9.2)
136
+ mimemagic (0.3.3)
137
+ minitest (5.13.0)
138
+ minitest-reporters (1.4.2)
139
+ ansi
140
+ builder
141
+ minitest (>= 5.0)
142
+ ruby-progressbar
143
+ nenv (0.3.0)
144
+ notiffany (0.1.3)
145
+ nenv (~> 0.1)
146
+ shellany (~> 0.0)
147
+ optimist (3.0.0)
148
+ pry (0.12.2)
149
+ coderay (~> 1.1.0)
150
+ method_source (~> 0.9.0)
151
+ pry-byebug (3.7.0)
152
+ byebug (~> 11.0)
153
+ pry (~> 0.10)
154
+ public_suffix (4.0.1)
155
+ rake (13.0.1)
156
+ rb-fsevent (0.10.3)
157
+ rb-inotify (0.10.0)
158
+ ffi (~> 1.0)
159
+ reform (2.2.4)
160
+ disposable (>= 0.4.1)
161
+ representable (>= 2.4.0, < 3.1.0)
162
+ representable (3.0.4)
163
+ declarative (< 0.1.0)
164
+ declarative-option (< 0.2.0)
165
+ uber (< 0.2.0)
166
+ ruby-augeas (0.5.0)
167
+ ruby-progressbar (1.10.1)
168
+ safe_yaml (1.0.5)
169
+ shellany (0.0.1)
170
+ temple (0.8.2)
171
+ thor (0.20.3)
172
+ thread_safe (0.3.6)
173
+ tilt (2.0.10)
174
+ trailblazer (2.1.0)
175
+ trailblazer-macro (>= 2.1.0, < 2.2.0)
176
+ trailblazer-macro-contract (>= 2.1.0, < 2.2.0)
177
+ trailblazer-operation
178
+ trailblazer-activity (0.10.0)
179
+ trailblazer-context (>= 0.2.0, < 0.3.0)
180
+ trailblazer-activity-dsl-linear (0.2.1)
181
+ trailblazer-activity (>= 0.9.1, < 1.0.0)
182
+ trailblazer-cells (0.0.3)
183
+ cells (>= 4.1.0.rc1, < 5.0.0)
184
+ trailblazer-context (0.2.0)
185
+ trailblazer-developer (0.0.9)
186
+ representable
187
+ trailblazer-activity (>= 0.10.0, < 1.0.0)
188
+ trailblazer-activity-dsl-linear
189
+ trailblazer-macro (2.1.0)
190
+ trailblazer-operation (>= 0.6.0)
191
+ trailblazer-macro-contract (2.1.0)
192
+ reform (>= 2.2.0, < 3.0.0)
193
+ trailblazer-operation (0.6.0)
194
+ trailblazer-activity (>= 0.10.0, < 1.0.0)
195
+ trailblazer-activity-dsl-linear (>= 0.2.1, < 1.0.0)
196
+ trailblazer-developer (>= 0.0.8)
197
+ tzinfo (1.2.5)
198
+ thread_safe (~> 0.1)
199
+ uber (0.1.0)
200
+ unf (0.1.4)
201
+ unf_ext
202
+ unf_ext (0.0.7.6)
203
+ webmock (3.7.6)
204
+ addressable (>= 2.3.6)
205
+ crack (>= 0.3.2)
206
+ hashdiff (>= 0.4.0, < 2.0.0)
207
+ zeitwerk (2.2.1)
208
+
209
+ PLATFORMS
210
+ ruby
211
+
212
+ DEPENDENCIES
213
+ bundler (~> 2.0)
214
+ caco!
215
+ fakefs
216
+ guard
217
+ guard-minitest
218
+ minitest (~> 5.0)
219
+ minitest-reporters
220
+ pry
221
+ pry-byebug
222
+ rake (~> 13.0)
223
+ trailblazer-developer
224
+ webmock
225
+
226
+ BUNDLED WITH
227
+ 2.1.4
@@ -0,0 +1,42 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest do
19
+ # with Minitest::Unit
20
+ watch(%r{^test/(.*)\/?(.*)_test\.rb$})
21
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
22
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+
24
+ # with Minitest::Spec
25
+ # watch(%r{^spec/(.*)_spec\.rb$})
26
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
28
+
29
+ # Rails 4
30
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
31
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
32
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
33
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
34
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
35
+ # watch(%r{^test/.+_test\.rb$})
36
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
37
+
38
+ # Rails < 4
39
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
40
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
41
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
42
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Celso Fernandes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,97 @@
1
+ # Caco
2
+
3
+ Configure your machines like you develop your web apps
4
+
5
+ ## Usage aka Control Repo
6
+
7
+ To start using `Caco`, you need a control repo, that is where you add your node config files, keys, certs, whatever makes sense to you.
8
+
9
+ Create a new `Gemfile` with `bundle init` and add to it:
10
+
11
+ ```ruby
12
+ gem 'caco'
13
+ ```
14
+
15
+ After you can add your config files under `nodes` folder, with each file being the hostname of your machines:
16
+
17
+ ```
18
+ nodes/
19
+ web.example.com.rb
20
+ db.example.com.rb
21
+ ```
22
+
23
+ This is the minimum you need to start using Caco, a hello world example would be, in `nodes/<hostname>.rb` add
24
+
25
+ ```ruby
26
+ class HelloWorld < Trailblazer::Operation
27
+ step Subprocess(Caco::FileWriter),
28
+ input: ->(_ctx, **) {{
29
+ path: "/root/caco.txt",
30
+ content: 'Hello World From Caco :)'
31
+ }}
32
+ end
33
+
34
+ HelloWorld.()
35
+ ```
36
+
37
+ Sync your control repo to your remote machine and run `./bin/caco` inside its folder, it will create the `/root/caco.txt` file with `Hello World From Caco :)` content
38
+
39
+ ## Data
40
+
41
+ It's useful to share data between your nodes, you can do this on the `data` folder, you can add yaml files and access inside your config files.
42
+
43
+ It also has a hierarchy, most specific values overwrite more generic value, files from common to specific are:
44
+
45
+ - data/common.yaml
46
+ - data/<os_name>.yaml
47
+ - data/<os_name>/<distro_name>.yaml
48
+ - data/nodes/<hostname>.yaml
49
+
50
+ You can also encrypt values with your keys, for the first time you can create them with `eyaml createkeys` command, you add the files:
51
+
52
+ - keys/private_key.pkcs7.pem
53
+ - keys/public_key.pkcs7.pem
54
+
55
+ After that you can edit your yaml files with the command `eyaml edit path/to/file.yaml`
56
+
57
+ It's safe to commit your encrypted yaml files, but remember to never commit your keys, the `keys` folder is also on gitignore.
58
+
59
+ On your server you also need to sync the `keys` folder to be able to read the values when configuring the nodes.
60
+
61
+ To read the values, as they are organized as yaml files, considering the structure:
62
+
63
+ ```yaml
64
+ # common.yaml
65
+ ---
66
+ prefix:
67
+ name: Common
68
+ ```
69
+
70
+ ```yaml
71
+ # nodes/hostname.yaml
72
+ ---
73
+ prefix:
74
+ name: Hostname
75
+ ```
76
+
77
+ (as node file is more specific it overwrites the common.yaml value)
78
+
79
+ ```ruby
80
+ Caco::Facter.("prefix", "name")
81
+ # => 'Hostname'
82
+ ```
83
+
84
+ ## Roadmap
85
+
86
+ - [ ] Bootstrap control repo via CLI
87
+ - [ ] Sync remote control repo
88
+ - [ ] Run automatically from developer machine
89
+ - [ ] Add operations to run as a _health check_ after the config process to ensure it's working as expected (that can also be used as acceptance test in development environment)
90
+
91
+ ## License
92
+
93
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
94
+
95
+ ## Code of Conduct
96
+
97
+ Everyone interacting in the Caco project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fernandes/caco/blob/master/CODE_OF_CONDUCT.md).