diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-01 20:15:44 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-01 20:15:44 +0200 |
| commit | 876a5959cedd3699b2c3eccc71ed78badc3bad55 (patch) | |
| tree | 2596099f3061fbabecef5704052db9bda3587ea0 /examples/cli | |
| parent | 84cf996536b62abe91fa881cdf46b72eb44ee24c (diff) | |
add quickstart examples directory and link from README
Diffstat (limited to 'examples/cli')
| -rwxr-xr-x | examples/cli/config.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/cli/config.rb b/examples/cli/config.rb new file mode 100755 index 0000000..84fa8f1 --- /dev/null +++ b/examples/cli/config.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# Example: Using RCM via the rcm CLI tool. +# +# Run with: +# rcm config.rb --dry # dry run, no changes made +# rcm config.rb --debug # verbose output +# rcm config.rb --hosts earth,mars # limit to specific hosts +# rcm config.rb # apply configuration +# +# Requires rcm to be installed as a gem, or adjust the path below: +# require_relative '../../lib/dsl' +require 'rcm' + +configure do + # Only apply the block below when running on host 'earth'. + given { hostname is :earth } + + # Write a simple text file with static content. + file '/tmp/example/hello.txt' do + manage directory + 'Hello from earth!' + end + + # Create a file rendered from an inline ERB template. + file '/tmp/example/info.txt' do + from template + 'Host: <%= `hostname`.strip %>, Date: <%= Time.now.strftime("%Y-%m-%d") %>' + end +end |
