summaryrefslogtreecommitdiff
path: root/examples/gem
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gem')
-rw-r--r--examples/gem/Gemfile4
-rw-r--r--examples/gem/Rakefile27
2 files changed, 31 insertions, 0 deletions
diff --git a/examples/gem/Gemfile b/examples/gem/Gemfile
new file mode 100644
index 0000000..b1f79ad
--- /dev/null
+++ b/examples/gem/Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Point at the local rcm checkout; change to gem 'rcm' once published.
+gem 'rcm', path: '../../'
diff --git a/examples/gem/Rakefile b/examples/gem/Rakefile
new file mode 100644
index 0000000..81a66d4
--- /dev/null
+++ b/examples/gem/Rakefile
@@ -0,0 +1,27 @@
+# Example: Using RCM as a gem inside a Bundler-managed project.
+#
+# Run with:
+# bundle install
+# bundle exec rake setup -- --dry # dry run, no changes made
+# bundle exec rake setup -- --debug # verbose output
+# bundle exec rake setup # apply configuration
+require 'rcm'
+
+desc 'Apply system configuration'
+task :setup do
+ configure do
+ # Only run on the host named 'earth'
+ given { hostname is :earth }
+
+ # Write a WireGuard config rendered from an inline ERB template.
+ file '/tmp/example/wg0.conf' do
+ from template
+
+ <<~TEMPLATE
+ [Interface]
+ Address = <%= "10.0.0.1/24" %>
+ ListenPort = 51820
+ TEMPLATE
+ end
+ end
+end