1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #1613 from dhozac/use-all-vars-for-hosts-template

Use all available vars for hosts:, user: and sudo_user:
This commit is contained in:
Michael DeHaan 2012-11-13 04:47:03 -08:00
commit 6793bcbe4d

View file

@ -57,22 +57,21 @@ class Play(object):
raise errors.AnsibleError('hosts declaration is required') raise errors.AnsibleError('hosts declaration is required')
elif isinstance(hosts, list): elif isinstance(hosts, list):
hosts = ';'.join(hosts) hosts = ';'.join(hosts)
hosts = utils.template(basedir, hosts, playbook.extra_vars)
self._ds = ds self._ds = ds
self.playbook = playbook self.playbook = playbook
self.basedir = basedir self.basedir = basedir
self.hosts = hosts
self.name = ds.get('name', self.hosts)
self.vars = ds.get('vars', {}) self.vars = ds.get('vars', {})
self.vars_files = ds.get('vars_files', []) self.vars_files = ds.get('vars_files', [])
self.vars_prompt = ds.get('vars_prompt', {}) self.vars_prompt = ds.get('vars_prompt', {})
self.vars = self._get_vars() self.vars = self._get_vars()
self.hosts = utils.template(basedir, hosts, self.vars)
self.name = ds.get('name', self.hosts)
self._tasks = ds.get('tasks', []) self._tasks = ds.get('tasks', [])
self._handlers = ds.get('handlers', []) self._handlers = ds.get('handlers', [])
self.remote_user = utils.template(basedir, ds.get('user', self.playbook.remote_user), playbook.extra_vars) self.remote_user = utils.template(basedir, ds.get('user', self.playbook.remote_user), self.vars)
self.remote_port = ds.get('port', self.playbook.remote_port) self.remote_port = ds.get('port', self.playbook.remote_port)
self.sudo = ds.get('sudo', self.playbook.sudo) self.sudo = ds.get('sudo', self.playbook.sudo)
self.sudo_user = utils.template(basedir, ds.get('sudo_user', self.playbook.sudo_user), playbook.extra_vars) self.sudo_user = utils.template(basedir, ds.get('sudo_user', self.playbook.sudo_user), self.vars)
self.transport = ds.get('connection', self.playbook.transport) self.transport = ds.get('connection', self.playbook.transport)
self.tags = ds.get('tags', None) self.tags = ds.get('tags', None)
self.gather_facts = ds.get('gather_facts', None) self.gather_facts = ds.get('gather_facts', None)