diff options
| -rw-r--r-- | gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.md | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.md b/gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.md index 37b6eb3a..ac8620d7 100644 --- a/gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.md +++ b/gemfeed/2026-03-02-rcm-ruby-configuration-management-dsl.md @@ -21,6 +21,16 @@ RCM is a tiny configuration management system written in Ruby. It gives me a sma * [⇢ ⇢ Cutting RCM 0.1.0](#cutting-rcm-010) * [⇢ ⇢ What's next](#what-s-next) * [⇢ ⇢ Feature overview (selected)](#feature-overview-selected) +* [⇢ ⇢ ⇢ Template rendering into a file](#template-rendering-into-a-file) +* [⇢ ⇢ ⇢ Ensuring a line is absent from a file](#ensuring-a-line-is-absent-from-a-file) +* [⇢ ⇢ ⇢ Guarding a configuration run on the current hostname](#guarding-a-configuration-run-on-the-current-hostname) +* [⇢ Creating and deleting directories, and purging a directory tree](#creating-and-deleting-directories-and-purging-a-directory-tree) +* [⇢ ⇢ ⇢ Managing file and directory modes and ownership](#managing-file-and-directory-modes-and-ownership) +* [⇢ ⇢ ⇢ Using a chained, more natural language style for notifications](#using-a-chained-more-natural-language-style-for-notifications) +* [⇢ ⇢ ⇢ Touching files and updating their timestamps](#touching-files-and-updating-their-timestamps) +* [⇢ ⇢ ⇢ Expressing dependencies between notifications](#expressing-dependencies-between-notifications) +* [⇢ ⇢ ⇢ Creating and updating symbolic links](#creating-and-updating-symbolic-links) +* [⇢ ⇢ ⇢ Detecting duplicate resource definitions at configure time](#detecting-duplicate-resource-definitions-at-configure-time) ## Why I built RCM @@ -41,7 +51,7 @@ configure do given { hostname is :earth } file '/tmp/test/wg0.conf' do - requires '/etc/hosts.test' + requires file '/etc/hosts.test' manage directory from template 'content with <%= 1 + 2 %>' @@ -53,6 +63,19 @@ configure do end ``` +Which would look like this when run: + +```sh +% sudo ruby example.rb +INFO 20260301-213817 dsl(0) => Configuring... +INFO 20260301-213817 file('/tmp/test/wg0.conf') => Registered dependency on file('/etc/hosts.test') +INFO 20260301-213817 file('/tmp/test/wg0.conf') => Evaluating... +INFO 20260301-213817 file('/etc/hosts.test') => Evaluating... +INFO 20260301-213817 file('/etc/hosts.test') => Writing file /etc/hosts.test +INFO 20260301-213817 file('/tmp/test/wg0.conf') => Creating parent directory /tmp/test +INFO 20260301-213817 file('/tmp/test/wg0.conf') => Writing file /tmp/test/wg0.conf +``` + The idea is that you describe the desired state and RCM worries about the steps. The `given` block can short‑circuit the whole run (for example, only run on a specific hostname). Each `file` resource can either manage a complete file (from a template) or just make sure individual lines are present. ### Keywords and resources @@ -192,7 +215,7 @@ Here is a quick overview of what RCM can do today, grouped by area: Some small examples adapted from RCM's own tests: -Template rendering into a file: +### Template rendering into a file ```ruby configure do @@ -203,7 +226,7 @@ configure do end ``` -Ensuring a line is absent from a file: +### Ensuring a line is absent from a file ```ruby configure do @@ -214,34 +237,16 @@ configure do end ``` -Keeping a backup of the original content when a file changes: - -```ruby -configure do - file original do - path './.dir_example.rcmtmp/foo/backup-me.txt' - manage directory - 'original_content' - end - - file new do - path './.dir_example.rcmtmp/foo/backup-me.txt' - manage directory - requires file original - 'new_content' - end -end -``` - -Guarding a configuration run on the current hostname: +### Guarding a configuration run on the current hostname ```ruby configure do given { hostname Socket.gethostname } + ... end ``` -Creating and deleting directories, and purging a directory tree: +# Creating and deleting directories, and purging a directory tree ```ruby configure do @@ -256,7 +261,7 @@ configure do end ``` -Managing file and directory modes and ownership: +### Managing file and directory modes and ownership ```ruby configure do @@ -270,7 +275,9 @@ configure do end ``` -Using a chained, more natural language style for notifications: +### Using a chained, more natural language style for notifications + +This will just print out something, not changing anything: ```ruby configure do @@ -280,7 +287,7 @@ configure do end ``` -Touching files and updating their timestamps: +### Touching files and updating their timestamps ```ruby configure do @@ -288,7 +295,7 @@ configure do end ``` -Expressing dependencies between notifications: +### Expressing dependencies between notifications ```ruby configure do @@ -306,7 +313,7 @@ configure do end ``` -Creating and updating symbolic links: +### Creating and updating symbolic links ```ruby configure do @@ -317,7 +324,7 @@ configure do end ``` -Detecting duplicate resource definitions at configure time: +### Detecting duplicate resource definitions at configure time ```ruby configure do |
