summaryrefslogtreecommitdiff
path: root/examples/cli/config.rb
blob: 2828d7cb014383cb8e6d543808173c32cf22f19c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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
#
# rcm is already loaded by the bin/rcm CLI tool before this file is executed.

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