diff options
| author | Paul Buetow <paul@buetow.org> | 2024-12-06 22:26:38 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-12-06 22:26:38 +0200 |
| commit | 4a3629e42cb3e1fbca4356cf789a8e79043cdc51 (patch) | |
| tree | e4f6b1099ee3319bcc2f018fdb8937b2eb362ce4 | |
| parent | 9abea6c57e018f6033dfa8ffc6cdcdfc86ece969 (diff) | |
initial config support
| -rw-r--r-- | Gemfile | 3 | ||||
| -rw-r--r-- | Gemfile.lock | 16 | ||||
| -rw-r--r-- | Rakefile | 1 | ||||
| -rw-r--r-- | config.toml | 3 | ||||
| -rw-r--r-- | rcm/config.rb | 18 | ||||
| -rw-r--r-- | rcm/rcm.rb | 2 |
6 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'toml' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..540a42c --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,16 @@ +GEM + remote: https://rubygems.org/ + specs: + parslet (2.0.0) + toml (0.3.0) + parslet (>= 1.8.0, < 3.0.0) + +PLATFORMS + ruby + x86_64-linux + +DEPENDENCIES + toml + +BUNDLED WITH + 2.5.22 @@ -4,6 +4,7 @@ desc 'Set up wireguard mesh' task :wireguard do make_it_so do p option :verbose + dump_config only_when { hostname is :earth } file '/etc/wg/wg0.conf' do diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..9aea7f2 --- /dev/null +++ b/config.toml @@ -0,0 +1,3 @@ +[hostgroups] + +frontends = ["blowfish.buetow.org", "fishfinger.buetow.org"] diff --git a/rcm/config.rb b/rcm/config.rb new file mode 100644 index 0000000..b9dc5ac --- /dev/null +++ b/rcm/config.rb @@ -0,0 +1,18 @@ +require 'toml' + +module RCM + # Configuration + module Config + @@config = File.exist?('config.toml') ? TOML.load_file('config.toml') : {} + + def config(key) + raise "No such config key: #{key}" unless @@config.key?(key) + + @@config[key] + end + + def dump_config + p @@config + end + end +end @@ -1,3 +1,4 @@ +require_relative 'config' require_relative 'options' require_relative 'only_when' require_relative 'file' @@ -6,6 +7,7 @@ require_relative 'file' module RCM # Here all starts class RCM + include Config include Options def initialize |
