summaryrefslogtreecommitdiff
path: root/examples/plain_ruby/example.rb
blob: 45c9fb360e70e2391d3cf2c03929c3320bd621de (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
28
29
30
#!/usr/bin/env ruby
# Example: Plain Ruby script — no Rake, no bundler required.
#
# Run with:
#   ruby config.rb --dry      # dry run, no changes made
#   ruby config.rb --debug    # verbose output
#   ruby config.rb            # apply configuration
#
# Requires rcm to be installed as a gem, or adjust the path below:
#   require_relative '../../lib/dsl'
begin
  require 'rcm'
rescue LoadError
  require_relative '../../lib/dsl'
end

configure do
  given { hostname is :earth }

  file '/tmp/test/wg0.conf' do
    requires file '/etc/hosts.test'
    manage directory
    from template
    'content with <%= 1 + 2 %>'
  end

  file '/etc/hosts.test' do
    line '192.168.1.101 earth'
  end
end