|
|
@ -31,6 +31,7 @@ from ansible.playbook.base import Base
|
|
|
|
from ansible.playbook.become import Become
|
|
|
|
from ansible.playbook.become import Become
|
|
|
|
from ansible.playbook.conditional import Conditional
|
|
|
|
from ansible.playbook.conditional import Conditional
|
|
|
|
from ansible.playbook.taggable import Taggable
|
|
|
|
from ansible.playbook.taggable import Taggable
|
|
|
|
|
|
|
|
from ansible.template import Templar
|
|
|
|
from ansible.utils.path import unfrackpath
|
|
|
|
from ansible.utils.path import unfrackpath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,7 +42,11 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
|
|
|
|
|
|
|
|
|
|
|
|
_role = FieldAttribute(isa='string')
|
|
|
|
_role = FieldAttribute(isa='string')
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, role_basedir=None):
|
|
|
|
def __init__(self, play=None, role_basedir=None, variable_manager=None, loader=None):
|
|
|
|
|
|
|
|
self._play = play
|
|
|
|
|
|
|
|
self._variable_manager = variable_manager
|
|
|
|
|
|
|
|
self._loader = loader
|
|
|
|
|
|
|
|
|
|
|
|
self._role_path = None
|
|
|
|
self._role_path = None
|
|
|
|
self._role_basedir = role_basedir
|
|
|
|
self._role_basedir = role_basedir
|
|
|
|
self._role_params = dict()
|
|
|
|
self._role_params = dict()
|
|
|
@ -112,6 +117,14 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
|
|
|
|
if not role_name or not isinstance(role_name, string_types):
|
|
|
|
if not role_name or not isinstance(role_name, string_types):
|
|
|
|
raise AnsibleError('role definitions must contain a role name', obj=ds)
|
|
|
|
raise AnsibleError('role definitions must contain a role name', obj=ds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if we have the required datastructures, and if the role_name
|
|
|
|
|
|
|
|
# contains a variable, try and template it now
|
|
|
|
|
|
|
|
if self._play and self._variable_manager:
|
|
|
|
|
|
|
|
all_vars = self._variable_manager.get_vars(loader=self._loader, play=self._play)
|
|
|
|
|
|
|
|
templar = Templar(loader=self._loader, variables=all_vars)
|
|
|
|
|
|
|
|
if templar._contains_vars(role_name):
|
|
|
|
|
|
|
|
role_name = templar.template(role_name)
|
|
|
|
|
|
|
|
|
|
|
|
return role_name
|
|
|
|
return role_name
|
|
|
|
|
|
|
|
|
|
|
|
def _load_role_path(self, role_name):
|
|
|
|
def _load_role_path(self, role_name):
|
|
|
|