From 876a5959cedd3699b2c3eccc71ed78badc3bad55 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 1 Mar 2026 20:15:44 +0200 Subject: add quickstart examples directory and link from README --- examples/rake/Rakefile | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/rake/Rakefile (limited to 'examples/rake/Rakefile') diff --git a/examples/rake/Rakefile b/examples/rake/Rakefile new file mode 100644 index 0000000..27b7e7a --- /dev/null +++ b/examples/rake/Rakefile @@ -0,0 +1,36 @@ +# Example: Using RCM with Rake (from a project directory). +# +# Run with: +# rake setup -- --dry # dry run, no changes made +# rake setup -- --debug # verbose output +# rake setup # apply configuration +# +# This example assumes rcm is available via bundler (see Gemfile), +# or you can swap the require for: require_relative '../../lib/dsl' +require 'rcm' + +desc 'Apply system configuration' +task :setup do + configure do + # Only run on host named 'earth' + given { hostname is :earth } + + # Create a WireGuard config from an inline ERB template. + # The 'manage directory' directive creates /tmp/example/wg/ if it is missing. + file '/tmp/example/wg/wg0.conf' do + manage directory + from template + + <<~TEMPLATE + [Interface] + Address = <%= "10.0.0.1/24" %> + ListenPort = 51820 + TEMPLATE + end + + # Ensure a specific line is present in a hosts file (idempotent). + file '/tmp/example/hosts.txt' do + line '192.168.1.101 earth.local' + end + end +end -- cgit v1.2.3