I use a combination of several plugins - for the main role assignment and resolution I use the Role Strategy Plugin .
When I need to divide some role depending on the parameters (for example, everyone who has a worker can run tasks, but the UUU user user allows to run a deployment task for deployment on machine MMM), I use Python Plugin and define a python script as the first step of the assembly and complete with sys.exit (-1), when the task is forbidden to work with a given combination of parameters.
Creating a plugin for custom Vars provides me with information about the user performing the task as environment variables.
eg:
import os import sys print os.environ["BUILD_USER"], "deploying to", os.environ["target_host"] # only some users are allowed to deploy to servers "MMM" mmm_users = ["UUU"] if os.environ["target_host"] != "MMM" or os.environ["BUILD_USER"] in mmm_users: print "access granted" else: print "access denied" sys.exit(-1)
Rostislav Matl Apr 28 '15 at 18:27 2015-04-28 18:27
source share