{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/15502","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/15502/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/15502/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/15502/events","html_url":"https://github.com/ansible/ansible/pull/15502","id":149782418,"number":15502,"title":"Add 'refresh' mode to fact gathering","user":{"login":"electrofelix","id":912324,"avatar_url":"https://avatars.githubusercontent.com/u/912324?v=3","gravatar_id":"","url":"https://api.github.com/users/electrofelix","html_url":"https://github.com/electrofelix","followers_url":"https://api.github.com/users/electrofelix/followers","following_url":"https://api.github.com/users/electrofelix/following{/other_user}","gists_url":"https://api.github.com/users/electrofelix/gists{/gist_id}","starred_url":"https://api.github.com/users/electrofelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/electrofelix/subscriptions","organizations_url":"https://api.github.com/users/electrofelix/orgs","repos_url":"https://api.github.com/users/electrofelix/repos","events_url":"https://api.github.com/users/electrofelix/events{/privacy}","received_events_url":"https://api.github.com/users/electrofelix/received_events","type":"User","site_admin":false},"labels":[{"id":454885231,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.3","name":"affects_2.3","color":"5319e7","default":false},{"id":48464763,"url":"https://api.github.com/repos/ansible/ansible/labels/docs_pull_request","name":"docs_pull_request","color":"0052cc","default":false},{"id":48457821,"url":"https://api.github.com/repos/ansible/ansible/labels/feature_pull_request","name":"feature_pull_request","color":"006b75","default":false},{"id":231201931,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_rebase","name":"needs_rebase","color":"eb6420","default":false},{"id":61436281,"url":"https://api.github.com/repos/ansible/ansible/labels/needs_revision","name":"needs_revision","color":"eb6450","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-04-20T14:22:44Z","updated_at":"2016-12-19T17:19:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/15502","html_url":"https://github.com/ansible/ansible/pull/15502","diff_url":"https://github.com/ansible/ansible/pull/15502.diff","patch_url":"https://github.com/ansible/ansible/pull/15502.patch"},"body":"##### ISSUE TYPE\n- Feature Pull Request\n##### ANSIBLE VERSION\n\n```\nansible 2.1.0 (refresh-facts 3ec116da5a) last updated 2016/04/20 13:49:46 (GMT +100)\n  lib/ansible/modules/core: (detached HEAD 98322a777f) last updated 2016/04/20 13:49:52 (GMT +100)\n  lib/ansible/modules/extras: (detached HEAD 1aecfc1e19) last updated 2016/04/20 13:49:52 (GMT +100)\n  config file = /home/baileybd/.ansible.cfg\n  configured module search path = Default w/o overrides\n```\n##### SUMMARY\n\nEnsures that gathered facts are refreshed at the start of play\nexecution, still using the cache for all remaining plays same as\n'smart'.\n\nMost useful when combined with a persistent fact cache store such as\n'jsonfile' or 'redis', where you may wish to persist custom facts\nstored in addition that you don't wish to flush or expire as quickly as\nsystem facts gathered.\n\nThis allows for refreshing system facts at the start of a playbook,\nand then continuing to benefit from the 'smart' behaviour during the\nsubsequent plays executed as part of that play.\n\ntest-gathering.yml\n\n```\n- hosts: localhost\n  tasks:\n    - ping:\n      register: ping_status\n\n- hosts: localhost\n  tasks:\n    - debug:\n        var: ping_status\n```\n\nansible.cfg\n\n```\n[defaults]\ngathering = smart\nfact_caching = jsonfile\nfact_caching_connection = ~/.ansible_fact_cache\nfact_caching_timeout = 86400\n```\n\nRun 1\n\n```\nansible-playbook test-gathering.yml \n\nPLAY [localhost] ***************************************************************\n\nTASK [setup] *******************************************************************\nok: [localhost]\n\nTASK [ping] ********************************************************************\nok: [localhost]\n\nPLAY [localhost] ***************************************************************\n\nTASK [debug] *******************************************************************\nok: [localhost] => {\n    \"ping_status\": {\n        \"changed\": false, \n        \"ping\": \"pong\"\n    }\n}\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=3    changed=0    unreachable=0    failed=0\n```\n\nRun 2\n\n```\nansible-playbook test-gathering.yml \n\nPLAY [localhost] ***************************************************************\n\nTASK [ping] ********************************************************************\nok: [localhost]\n\nPLAY [localhost] ***************************************************************\n\nTASK [debug] *******************************************************************\nok: [localhost] => {\n    \"ping_status\": {\n        \"changed\": false, \n        \"ping\": \"pong\"\n    }\n}\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=2    changed=0    unreachable=0    failed=0\n```\n\nNotice that for the second run in addition to skipping gather on the second play, it also skipped it on the first as well.\n\nansible.cfg\n\n```\n[defaults]\ngathering = refresh\nfact_caching = jsonfile\nfact_caching_connection = ~/.ansible_fact_cache\nfact_caching_timeout = 86400\n```\n\nRun 1\n\n```\nansible-playbook test-gathering.yml \n\nPLAY [localhost] ***************************************************************\n\nTASK [setup] *******************************************************************\nok: [localhost]\n\nTASK [ping] ********************************************************************\nok: [localhost]\n\nPLAY [localhost] ***************************************************************\n\nTASK [debug] *******************************************************************\nok: [localhost] => {\n    \"ping_status\": {\n        \"changed\": false, \n        \"ping\": \"pong\"\n    }\n}\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=3    changed=0    unreachable=0    failed=0\n```\n\nRun 2\n\n```\nansible-playbook test-gathering.yml \n\nPLAY [localhost] ***************************************************************\n\nTASK [setup] *******************************************************************\nok: [localhost]\n\nTASK [ping] ********************************************************************\nok: [localhost]\n\nPLAY [localhost] ***************************************************************\n\nTASK [debug] *******************************************************************\nok: [localhost] => {\n    \"ping_status\": {\n        \"changed\": false, \n        \"ping\": \"pong\"\n    }\n}\n\nPLAY RECAP *********************************************************************\nlocalhost                  : ok=3    changed=0    unreachable=0    failed=0\n```\n\nWith _refresh_, it will re-gather for the first play in each run, but then use the fact cache for all remaining plays. This allows us to avoid needing to add in regathering capabilities for other custom facts returned during previous plays, while ensuring we always have a consistent view of basic system state at the start of a playbook run.\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/268023139","html_url":"https://github.com/ansible/ansible/pull/15502#issuecomment-268023139","issue_url":"https://api.github.com/repos/ansible/ansible/issues/15502","id":268023139,"user":{"login":"ansibot","id":6585283,"avatar_url":"https://avatars.githubusercontent.com/u/6585283?v=3","gravatar_id":"","url":"https://api.github.com/users/ansibot","html_url":"https://github.com/ansibot","followers_url":"https://api.github.com/users/ansibot/followers","following_url":"https://api.github.com/users/ansibot/following{/other_user}","gists_url":"https://api.github.com/users/ansibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ansibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansibot/subscriptions","organizations_url":"https://api.github.com/users/ansibot/orgs","repos_url":"https://api.github.com/users/ansibot/repos","events_url":"https://api.github.com/users/ansibot/events{/privacy}","received_events_url":"https://api.github.com/users/ansibot/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T17:19:49Z","updated_at":"2016-12-19T17:19:49Z","body":"cc @dharmabumstead\n[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)\n<!--- boilerplate: notify --->"}}
{"actor":{"display_login":"ansibot"}}