5 ms·
I use m4 to generate my ssh config files. Otherwise managing the complexity of hundreds of servers over multiple subdomains all with different requirements for
by enasterosophes 4y ago
I use m4 to generate my ssh config files. Otherwise managing the complexity of hundreds of servers over multiple subdomains all with different requirements for access and authentication would be prohibitive, especially given that openssh's config format only has a cursory understanding of how to define patterns with regex or cidr.
- e40 4y agoI considered that just the other day. Ended up using cpp instead.
- imglorp 4y agoAnother simple option is envsubst which does one thing well.
- nick__m 4y agoI used envsubst when I can but as far as I know you cannot do loop using envsubst. When you use the c preprocessor or php, m4, etc..., you can.
- imglorp 4y agoNah, that's what I meant. It does $-expansion and that's it. If you need conditionals and loop you need templates and macros like others are saying: m4, cpp, handlebars, whatever. I use it as a low-brain template engine to do only that.
- morelisp 4y agoI use envsubst a lot, but without - and + forms it's hard to say it does it well.
- harshreality 4y agoThey have different design philosophies, but dhall[1] will generally do that sort of thing, and anyone who has dabbled with functional programming and hates baroque syntax common to many languages from the early days of computing may prefer dhall over something like m4. [1] https://dhall-lang.org/ https://dhall-lang.org/
- hdjjhhvvhga 4y agoOf course you are right and hundreds of such tools exist. The only reason we are talking about m4 here is that is basically everywhere for legacy reasons.
- enasterosophes 4y agoCorrect. I was motivated to use m4 to solve the problem I had, because m4 is ubiquitous. I wanted to know more about it, and I wanted my config files to be generatable on any machine where I spend some time.
- deleted 4y ago[deleted]
- perfecthjrjth 4y agoCan you please share a sample m4 script to generate ssh config? Just curious how you have solved complicated stuff, patterns, etc.