From 9ede6f7f494d83cf95b11bb46a8eb4a8234c0a48 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 26 Mar 2014 12:01:15 -0500 Subject: [PATCH] Convert gather_facts to a boolean value if it is not None Fixes #5618 --- lib/ansible/playbook/play.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 2da555bd0f..68c5dbf9ae 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -117,7 +117,6 @@ class Play(object): self.sudo = ds.get('sudo', self.playbook.sudo) self.sudo_user = ds.get('sudo_user', self.playbook.sudo_user) self.transport = ds.get('connection', self.playbook.transport) - self.gather_facts = ds.get('gather_facts', None) self.remote_port = self.remote_port self.any_errors_fatal = utils.boolean(ds.get('any_errors_fatal', 'false')) self.accelerate = utils.boolean(ds.get('accelerate', 'false')) @@ -128,6 +127,13 @@ class Play(object): self.su_user = ds.get('su_user', self.playbook.su_user) #self.vault_password = vault_password + # gather_facts is not a simple boolean, as None means that a 'smart' + # fact gathering mode will be used, so we need to be careful here as + # calling utils.boolean(None) returns False + self.gather_facts = ds.get('gather_facts', None) + if self.gather_facts: + self.gather_facts = utils.boolean(self.gather_facts) + # Fail out if user specifies a sudo param with a su param in a given play if (ds.get('sudo') or ds.get('sudo_user')) and (ds.get('su') or ds.get('su_user')): raise errors.AnsibleError('sudo params ("sudo", "sudo_user") and su params '