HomeDevCentral

Allow to filter a list by role

Authored by dereckson on Nov 23 2017, 04:46.

Description

Allow to filter a list by role

Summary:
Currently, content to deploy to /var/wwwroot are split
in mastodon, shellserver and webserver-legacy roles.

Plan is to consolidate all of them in the webserver-content
role, and from webserver-content/init.sls, to include the relevant
states files according the target role.

To use node.has_role with if condition isn't pretty, especially as
a sls file can't only have one unique include entry.

Instead, this change provides a node.filter_by_role method, to be
able to create a pillar like this:

web_content_sls:
  mastodon:
    - .org/nasqueron/social
  shellserver:
    - .com/paysannerebelle
    - .org/eglide
  webserver-legacy:
    - .be/dereckson
    - .org/nasqueron/docs

Then, node.filter_by_role('web_content_sls') called on a node
with the mastodon role will return this list:

- .org/nasqueron/social

Ref T1325

Test Plan: Unit tests have been provided for the new method.

Reviewers: dereckson

Reviewed By: dereckson

Tags: TDD

Maniphest Tasks: T1325

Differential Revision: https://devcentral.nasqueron.org/D1257

Details

Committed
derecksonNov 23 2017, 04:46
Pushed
derecksonNov 23 2017, 04:46
Reviewer
dereckson
Differential Revision
D1257: Allow to filter a list by role
Parents
rOPS6e9a7a7f63dd: Prune /var/www/html on shellserver role
Branches
Unknown
Tags
Unknown
Tasks
T1325: Consolidate webserver roles