Skip to content

Instantly share code, notes, and snippets.

@mpdehaan
Last active November 22, 2018 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpdehaan/87d0ea05ed11a9b723d555a566d27ee3 to your computer and use it in GitHub Desktop.
Save mpdehaan/87d0ea05ed11a9b723d555a566d27ee3 to your computer and use it in GitHub Desktop.
# I don't know about this?
# most people should prefer the Python DSL
# but what if some teams don't want to learn Python?
# here's an OPTIONAL idea for a new capability
# ==================
class FooRole(Foo):
def set_bundles(self):
return [ "ext/foo.yml" ]
def set_resources(self):
# you can still add resources the normal way, they will come before before bundle
def set_handlers(self):
# same
=============
# ext/foo.yml
search_path:
- opsmop.core.types
resources:
- Set:
mode: 0770
x: 4567
- File:
name: "/etc/motd"
from_template: "templates/motd.j2"
mode__eval: "mode" # just to show we can load variables, but we still need to be explicit.
signals: "spork"
- Echo:
msg: "hello {{ x }}, sometimes"
when__eval: "Chaos.random() > 2.5"
handlers:
- Echo:
msg: "foo"
handles: "spork"
=========
if I do this, this would clearly be a second class citizen to the main behaviors
limitations: when always results in an Eval()
if you want any variables you need to Eval()
implementation: reads YAML file, dynamically returns resources from it.
you could still mix bundle files with regular python resources, even in the same role.
@mpdehaan
Copy link
Author

A good TOML alternative idea from the Forum thread - https://talk.vespene.io/t/are-there-some-folks-that-do-think-yaml-might-be-useful-as-an-option/73/11?u=mpdehaan - this is currently winning in my mind at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment