{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/14766","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/14766/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/14766/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/14766/events","html_url":"https://github.com/ansible/ansible/issues/14766","id":138074864,"number":14766,"title":"`-meta: refresh_inventory` breaks `hostvars`","user":{"login":"jaddison","id":101148,"avatar_url":"https://avatars.githubusercontent.com/u/101148?v=3","gravatar_id":"","url":"https://api.github.com/users/jaddison","html_url":"https://github.com/jaddison","followers_url":"https://api.github.com/users/jaddison/followers","following_url":"https://api.github.com/users/jaddison/following{/other_user}","gists_url":"https://api.github.com/users/jaddison/gists{/gist_id}","starred_url":"https://api.github.com/users/jaddison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaddison/subscriptions","organizations_url":"https://api.github.com/users/jaddison/orgs","repos_url":"https://api.github.com/users/jaddison/repos","events_url":"https://api.github.com/users/jaddison/events{/privacy}","received_events_url":"https://api.github.com/users/jaddison/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-03T04:49:35Z","updated_at":"2016-03-03T04:49:35Z","closed_at":null,"body":"##### Issue Type:\r\n\r\n - Bug Report\r\n\r\n##### Ansible Version:\r\n\r\n```\r\nansible 2.0.1.0\r\n  config file = /Users/jaddison/projects/jollygood.com-config/aws/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### Ansible Configuration:\r\n\r\nansible.cfg:\r\n```\r\n[defaults]\r\ninventory = inventory/ec2.py\r\n\r\n[ssh_connection]\r\ncontrol_path = /tmp/%%h-%%p-%%r\r\n```\r\n\r\n##### Environment:\r\n\r\nRunning ansible on OSX 10.11.3. Managing Ubuntu 16.04 EC2 instances using ec2.py inventory.\r\n\r\nec2.ini (comments removed for brevity):\r\n```\r\n[ec2]\r\nregions = us-west-2\r\nregions_exclude =\r\ndestination_variable = public_dns_name\r\nvpc_destination_variable = ip_address\r\nroute53 = False\r\nall_instances = True\r\nall_rds_instances = True\r\nall_elasticache_replication_groups = True\r\nall_elasticache_clusters = True\r\nall_elasticache_nodes = True\r\ncache_path = ~/.ansible/tmp\r\ncache_max_age = 0\r\nnested_groups = False\r\nreplace_dash_in_groups = True\r\nexpand_csv_tags = False\r\ngroup_by_instance_id = True\r\ngroup_by_region = True\r\ngroup_by_availability_zone = True\r\ngroup_by_ami_id = True\r\ngroup_by_instance_type = True\r\ngroup_by_key_pair = True\r\ngroup_by_vpc_id = True\r\ngroup_by_security_group = True\r\ngroup_by_tag_keys = True\r\ngroup_by_tag_none = True\r\ngroup_by_route53_names = True\r\ngroup_by_rds_engine = True\r\ngroup_by_rds_parameter_group = True\r\ngroup_by_elasticache_engine = True\r\ngroup_by_elasticache_cluster = True\r\ngroup_by_elasticache_parameter_group = True\r\ngroup_by_elasticache_replication_group = True\r\n```\r\n\r\n##### Summary:\r\n\r\nUsing the `-meta: refresh_inventory` task breaks `hostvars` and thus plays.\r\n\r\n##### Steps To Reproduce:\r\n\r\nRun the sample playbook below. I ran mine against the ec2.py inventory, but I don't think it's platform-specific. Obviously the `hosts` tag group targeting would need to change for reproduction purposes.\r\n\r\nIf I remove the `-meta: refresh_inventory` line, the `ec2_id` variable is output correctly.\r\n\r\n```\r\n# this play does not (debug statement doesn't output anything - see following output)\r\n \r\n- name: Common {{ env }} EC2 server setup/securing\r\n  hosts: \"tag_environment_{{ env }}:&tag_new_True\"\r\n  become: yes\r\n  gather_facts: False\r\n  vars:\r\n    ansible_port: 22\r\n  tasks:\r\n    - meta: refresh_inventory\r\n    - debug: var=ec2_id\r\n```\r\n\r\n##### Expected Results:\r\n\r\nThe debug statement to output the desired value.\r\n\r\n##### Actual Results:\r\n\r\nNo output - it's like the play was never run.\r\n\r\nResulting output:\r\n```\r\n~/project AWS_PROFILE=jollygood ansible-playbook -vvvv test.yml --extra-vars \"env=staging\"\r\nUsing /Users/jaddison/projects/jollygood.com-config/aws/ansible.cfg as config file\r\nLoaded callback default of type stdout, v2.0\r\n1 plays in test.yml\r\n\r\nPLAY [Common staging EC2 server setup/securing] ********************************\r\n\r\nPLAY RECAP *********************************************************************\r\n\r\n```\r\n\r\n@bcoca on IRC stated that there was another issue related to `refresh_inventory` (see #14435, I assume) that covered this case, but I figured I might as well add in more details as its information was quite sparse."}}