Enable fact caching in ansible

Bug #1498111 reported by Bjoern
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Fix Released
Wishlist
Kevin Carter
Kilo
Fix Released
Wishlist
Kevin Carter
Trunk
Fix Released
Wishlist
Kevin Carter

Bug Description

It might be beneficial to enable fact caching in ansible, especially on a hundred of nodes cluster, especially when the node facts are usually static. It can be enabled pretty easy doing :

apt-get install redis

diff --git a/playbooks/ansible.cfg b/playbooks/ansible.cfg
index 5c36952..8794e68 100644
--- a/playbooks/ansible.cfg
+++ b/playbooks/ansible.cfg
@@ -6,6 +6,9 @@ filter_plugins = plugins/filters
 gathering = smart
 hostfile = inventory
 host_key_checking = False
+fact_caching = redis
+fact_caching_timeout = 86400

you can verify if it is working using :

redis-cli : get ansible_facts+<hostname>

like

127.0.0.1:6379> get ansible_factsaio1_keystone_container-8bfd8abe
"{\"ansible_all_ipv4_addresses\": [\"10.0.3.129\", \"172.29.239.104\"],... output orbmitted....

Revision history for this message
Bjoern (bjoern-t) wrote :

Proposed change for master : https://review.openstack.org/#/c/225967/

Changed in openstack-ansible:
importance: Undecided → Wishlist
Revision history for this message
Bjoern (bjoern-t) wrote :

I disabled the caching by default but left information inside the ansible.cfg so that is can be enabled on request.
It serves also as documentation for all interested / stressed ops folks.

Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

Can you please give a better outline regarding why this is useful? What problem does it solve and how is it beneficial?

Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

Marking it incomplete - please provide the details requested and switch the status back to new for discussion in the bug triage.

Changed in openstack-ansible:
status: New → Incomplete
Revision history for this message
Bjoern (bjoern-t) wrote :

Fact caching is self explanatory. Why would you over and over collect possibly same data without caching ...

Changed in openstack-ansible:
status: Incomplete → In Progress
assignee: nobody → Bjoern Teipel (bjoern-teipel)
milestone: none → 12.0.0
Revision history for this message
Kevin Carter (kevin-carter) wrote :

Tested this the other day when adding 150 compute nodes to an environment. The performance gains are noticeable and quite valuable. I've updated the patch that implements this change and modified it to use the "jsonfile" implementation of fact caching. In this way we add no new dependencies and still receive similar performance gains.

A deployer can choose to use redis but I don't think that it should be the default because the current implementation within Ansible does not allow for the use of user credentials or access to an external redis cluster. If that changes in future releases of Ansible I'd be happy to revisit the default settings.

Changed in openstack-ansible:
status: In Progress → Triaged
assignee: Bjoern Teipel (bjoern-teipel) → Kevin Carter (kevin-carter)
Changed in openstack-ansible:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible (kilo)

Fix proposed to branch: kilo
Review: https://review.openstack.org/228645

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible (master)

Reviewed: https://review.openstack.org/225967
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible/commit/?id=1f07924cd2f619d0c0b3c0bf21e3d9cd5a1541b7
Submitter: Jenkins
Branch: master

commit 1f07924cd2f619d0c0b3c0bf21e3d9cd5a1541b7
Author: Bjoern Teipel <email address hidden>
Date: Mon Sep 21 12:50:31 2015 -0500

    Implement fact caching

    Fact caching will improve general Ansible performance by default.
    This has the biggest performance gain on very large environments.
    This implementation will use the JSONfile configuration because
    it has no new dependencies and will provide a similar performance
    gain as noted through the use of Redis.

    Notes:
    * The facts can purged or read by interacting with the default
      JSON file.
    * The caching behavior can be turned off by removing the parameter
      fact_caching from the playbook/ansible.cfg file.

    DocImpact
    UpgradeImpact

    Co-Authored-By: Kevin Carter <email address hidden>

    Implements: blueprint build-facts-archive
    Closes-Bug: 1498111

    Change-Id: I95ab1c2f8567d6af68feb53d7c14b8997eef5c89

Changed in openstack-ansible:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible (kilo)

Reviewed: https://review.openstack.org/228645
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible/commit/?id=591b3c2cf37ca6570f74f07073ed14e7bf858fde
Submitter: Jenkins
Branch: kilo

commit 591b3c2cf37ca6570f74f07073ed14e7bf858fde
Author: Bjoern Teipel <email address hidden>
Date: Mon Sep 21 12:50:31 2015 -0500

    Implement fact caching

    Fact caching will improve general Ansible performance by default.
    This has the biggest performance gain on very large environments.
    This implementation will use the JSONfile configuration because
    it has no new dependencies and will provide a similar performance
    gain as noted through the use of Redis.

    Notes:
    * The facts can purged or read by interacting with the default
      JSON file.
    * The caching behavior can be turned off by removing the parameter
      fact_caching from the playbook/ansible.cfg file.

    DocImpact
    UpgradeImpact

    Co-Authored-By: Kevin Carter <email address hidden>

    Implements: blueprint build-facts-archive
    Closes-Bug: 1498111

    Change-Id: I95ab1c2f8567d6af68feb53d7c14b8997eef5c89
    (cherry picked from commit 1f07924cd2f619d0c0b3c0bf21e3d9cd5a1541b7)

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/openstack-ansible 11.2.11

This issue was fixed in the openstack/openstack-ansible 11.2.11 release.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/openstack-ansible 11.2.12

This issue was fixed in the openstack/openstack-ansible 11.2.12 release.

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/openstack-ansible 11.2.14

This issue was fixed in the openstack/openstack-ansible 11.2.14 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.