blob: 03a5ee211def8b40dd4d9899f1eb8ab2ecd1398d (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# rcm
Ruby configuration management system (rcm) - KISS and for my personal use.
## Run tests
```
bundle install
rake test
```
## Invokation
```sh
cd playground
rake wireguard -- --debug
```
## Examples
Here are some examples of how to use the DSL.
### Create a file with content
```ruby
configure do
file '/tmp/hello_world.txt' do
'Hello World!'
end
end
```
### Create a file from a template
```ruby
configure do
file '/tmp/calc.txt' do
from template
'One plus two is <%= 1 + 2 %>!'
end
end
```
### Add a line to a file
```ruby
configure do
file '/tmp/notes.txt' do
line 'Remember to buy milk'
end
end
```
### Conditional execution
```ruby
configure do
given { hostname 'myserver' }
file '/etc/myserver.conf' do
'config'
end
end
```
### Dependency management
```ruby
configure do
notify 'service_restart' do
requires file '/etc/config.conf'
# ... logic to restart service
end
file '/etc/config.conf' do
'configuration settings'
end
end
```
For more examples, check out the [tests](./test/lib/dslkeywords).
|