From 09699d0cd0790f3398c41aa1e8a4e93e85591dc4 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 14 Mar 2016 21:24:26 -0700 Subject: [PATCH] meta: clear_facts draft implementation --- lib/ansible/plugins/strategy/__init__.py | 3 +++ lib/ansible/vars/__init__.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 3875211402..b5e4e1209b 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -656,6 +656,9 @@ class StrategyBase: self.run_handlers(iterator, play_context) elif meta_action == 'refresh_inventory': self._inventory.refresh_inventory() + elif meta_action == 'clear_facts': + for host in iterator._host_states: + self._variable_manager.clear_facts(host) #elif meta_action == 'reset_connection': # connection_info.connection.close() elif meta_action == 'clear_host_errors': diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index 1405d8736d..e18dfceabd 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -566,6 +566,13 @@ class VariableManager: else: return dict() + def clear_facts(self, hostname): + ''' + Clears the facts for a host + ''' + if hostname in self._fact_cache: + del self._fact_cache[hostname] + def set_host_facts(self, host, facts): ''' Sets or updates the given facts for a host in the fact cache.