{"id":3555,"date":"2016-12-26T10:06:51","date_gmt":"2016-12-26T09:06:51","guid":{"rendered":"https:\/\/www.devco.net\/?p=3555"},"modified":"2016-12-29T09:42:39","modified_gmt":"2016-12-29T08:42:39","slug":"choria-playbooks","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2016\/12\/26\/choria-playbooks.php","title":{"rendered":"Choria Playbooks"},"content":{"rendered":"

Today I am very pleased to release something I’ve been thinking about for years and actively working on since August.<\/p>\n

After many POCs and thrown away attempts at this over the years I am finally releasing a Playbook system that lets you run work flows on your MCollective network – it can integrate with a near endless set of remote services in addition to your MCollective to create a multi service playbook system.<\/p>\n

This is a early release with only a few integrations but I think it’s already useful and I’m looking for feedback and integrations to build this into something really powerful for the Puppet eco system.<\/p>\n

The full docs can be found on the Choria Website<\/a>, but below you can get some details.<\/p>\n

Overview<\/H3>
\nToday playbooks are basic YAML files. Eventually I envision a Service to execute playbooks on your behalf, but today you just run them in your shell, so they are pure data.<\/p>\n

Playbooks have a basic flow that is more or less like this:<\/p>\n

    \n
  1. Discover named Node Sets<\/li>\n
  2. Validate the named Node Sets meet expectations such as reachability and versions of software available on them<\/li>\n
  3. Run a pre_book<\/em> task list that lets you do prep work<\/li>\n
  4. Run the main tasks<\/em> task list where you do your work, around every task certain hook lists can be run<\/li>\n
  5. Run either the on_success<\/em> or on_fail<\/em> task list for notification of Slacks etc<\/li>\n
  6. Run the post_book<\/em> task list for cleanups etc<\/li>\n<\/ol>\n

    Today a task can be a MCollective request, a shell script or a Slack notification. I imagine this list will grow huge, I am thinking you will want to ping webhooks, or interact with Razor to provision machines and wait for them to finish building, run Terraform or make EC2 API requests. This list of potential integrations is endless and you can use any task in any of the above task lists.<\/p>\n

    A Node Set is simply a named set of nodes, in MCollective that would be certnames of nodes but the playbook system itself is not limited to that. Today Node Sets can be resolved from MCollective Discovery, PQL Queries (PuppetDB), YAML files with groups of nodes in them or a shell command. Again the list of integrations that make sense here is huge. I imagine querying PE or Foreman for node groups, querying etcd or Consul for service members. Talking to random REST services that return node lists or DB queries. Imagine using Terraform outputs as Node Set sources or EC2 API queries. <\/p>\n

    In cases where you wish to manage nodes via MCollective but you are using a cached discovery source you can ask node sets to be tested for reachability over MCollective. And node sets that need certain MCollective agents can express this desire as SemVer version ranges and the valid network state will be asserted before any playbook is run.<\/p>\n

    Playbooks do not have a pseudo programming language in them though I am not against the idea. I do not anticipate YAML to be the end format of playbooks but it’s good enough for today.<\/p>\n

    Example<\/H3>
    \nI’ll show an example here of what I think you will be able to achieve using these Playbooks.<\/p>\n

    <\/center><\/p>\n

    Here we have a web stack and we want to do Blue\/Green deploys against it, sub clusters have a fact cluster<\/em>. The deploy process for a cluster is:<\/p>\n