Running a realbook
In order to run a realbook, you must do four things. It's probably a good idea to wrap all of these steps in a single Task, and place that task in a supervision tree.
Specify the realbook directory. This is global, and can be set at compile time using the
Config.config/2
directive in yourconfig.exs
or child configuration files.Application.put_env(:realbook, :script_dir, realbook_script_dir)
If you're going to release your app to prod, it's recommended to keep these scripts in the
priv
directory.Connect to the target. The following example shows how to connect with passwordless ssh. For other options, see
SSH.connect/2
:Realbook.connect!(:ssh, host: "my_host", user: "admin")
Note that the
:local
connect target is also provided.Set required variables. If you forget any, the realbook won't execute.
Realbook.set(foo: "bar", baz: "quux")
Launch the realbook.
Realbook.exec("my_realbook_script.exs")