Skip to content

Add Playbook Templates #1764

@janithcooray

Description

@janithcooray

Pretty Surprised that this feature is missing and not even considered, i think it would be extremely useful.

We have task templates, that can run a single playbook with multiple variables. Pretty Good. But what about Playbook templates.
It's pretty common to have multiple playbooks with the same roles but with different variables.

For example, we can have the playbook template similar to task template. We can define the playbook yml like this..

# predefined arrays and nested vars
array_templates:
   - example_array:
       field_1: @required @string
       feild_2: @required @string
       nested_field: 
         some_more: @required @string

roles:
 - role-1
 - role-2
vars:
    service_name: @required @string
    service_port: @required @number
    image: @required @string
    some_unneeded_var:  @string
    some_array: @required @array example_array
# .... your required variables on how you made your playbook

Playbook instance 1 from template

#populated
roles:
 - role-1
 - role-2
vars:
    service_name: "test"
    service_port: 31000
    image: "some-registry/something/image"
    some_unneeded_var:  "valid-string"
    some_array: 
       - sample:
              field_1: "test"
              field_2: "test"
              nested_field: 
                 some_more: "test2"
# .... your required variables on how you made your playbook

Then we should make it register as a task template.

WHY?

While a single playbooks can run with multiple vars, some would often have multiple playbooks for the same roles. For example, say we have a role(s) that can provision a new k8 deployments and its requirements such as Volume claims , repository variables , service accounts etc. we would generally prefer to have deployment_1.yml ,deployment_2.yml deployment_n.yml ...

I think such a feature would extend the audience of semaphore.

While I prefer CLI all the way for doing this, my colleagues prefer something visual/UI as they aren't very well versed with CLI. And i'm pretty sure most of semaphore's audience out there would prefer UI.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions