{"action":"created","issue":{"url":"https://api.github.com/repos/philpep/testinfra/issues/385","repository_url":"https://api.github.com/repos/philpep/testinfra","labels_url":"https://api.github.com/repos/philpep/testinfra/issues/385/labels{/name}","comments_url":"https://api.github.com/repos/philpep/testinfra/issues/385/comments","events_url":"https://api.github.com/repos/philpep/testinfra/issues/385/events","html_url":"https://github.com/philpep/testinfra/issues/385","id":378427511,"node_id":"MDU6SXNzdWUzNzg0Mjc1MTE=","number":385,"title":"How to use the Ansible template properly?","user":{"login":"DamnedNForsaken","id":6027892,"node_id":"MDQ6VXNlcjYwMjc4OTI=","avatar_url":"https://avatars0.githubusercontent.com/u/6027892?v=4","gravatar_id":"","url":"https://api.github.com/users/DamnedNForsaken","html_url":"https://github.com/DamnedNForsaken","followers_url":"https://api.github.com/users/DamnedNForsaken/followers","following_url":"https://api.github.com/users/DamnedNForsaken/following{/other_user}","gists_url":"https://api.github.com/users/DamnedNForsaken/gists{/gist_id}","starred_url":"https://api.github.com/users/DamnedNForsaken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DamnedNForsaken/subscriptions","organizations_url":"https://api.github.com/users/DamnedNForsaken/orgs","repos_url":"https://api.github.com/users/DamnedNForsaken/repos","events_url":"https://api.github.com/users/DamnedNForsaken/events{/privacy}","received_events_url":"https://api.github.com/users/DamnedNForsaken/received_events","type":"User","site_admin":false},"labels":[{"id":187660505,"node_id":"MDU6TGFiZWwxODc2NjA1MDU=","url":"https://api.github.com/repos/philpep/testinfra/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-07T19:06:56Z","updated_at":"2018-11-12T13:18:41Z","closed_at":null,"author_association":"NONE","body":"Hi all, I am trying to figure out how to use the templates via testinfra via ansible backend, and the documentation is lacking on this very specific kind of thing.\r\n\r\nI have a SO open up too that may shed alittle more light on the subject as well. \r\nhttps://stackoverflow.com/questions/52860896/what-is-the-correct-way-to-pass-variables-to-an-ansible-template-with-testinfra\r\n\r\nEssentially I am at a loss at how to pass in variables into a template, and right now all i am really able to do is to push files to the remote (files that are not templated) using the template command.\r\n\r\nAnyone have any ideas on this?"},"comment":{"url":"https://api.github.com/repos/philpep/testinfra/issues/comments/437876585","html_url":"https://github.com/philpep/testinfra/issues/385#issuecomment-437876585","issue_url":"https://api.github.com/repos/philpep/testinfra/issues/385","id":437876585,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzg3NjU4NQ==","user":{"login":"philpep","id":387511,"node_id":"MDQ6VXNlcjM4NzUxMQ==","avatar_url":"https://avatars3.githubusercontent.com/u/387511?v=4","gravatar_id":"","url":"https://api.github.com/users/philpep","html_url":"https://github.com/philpep","followers_url":"https://api.github.com/users/philpep/followers","following_url":"https://api.github.com/users/philpep/following{/other_user}","gists_url":"https://api.github.com/users/philpep/gists{/gist_id}","starred_url":"https://api.github.com/users/philpep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philpep/subscriptions","organizations_url":"https://api.github.com/users/philpep/orgs","repos_url":"https://api.github.com/users/philpep/repos","events_url":"https://api.github.com/users/philpep/events{/privacy}","received_events_url":"https://api.github.com/users/philpep/received_events","type":"User","site_admin":false},"created_at":"2018-11-12T13:18:41Z","updated_at":"2018-11-12T13:18:41Z","author_association":"OWNER","body":"Hi, I don't think it's currently possible because we have no way to set vars directly through the `host.ansible()`.\r\n\r\nHowever, host vars from ansible inventory or ./host_vars/<ansible_host> and group vars should be loaded and available within the jinja rendering.\r\n\r\nExample:\r\n\r\n```\r\n>>> open('t.yaml', 'wb').write(b'host = {{ansible_host}}\\n')\r\n>>> import testinfra\r\n>>> host = testinfra.get_host('ansible://localhost')\r\n>>> host.ansible('template', 'src=t.yaml dest=/tmp/t.txt', check=False)\r\n>>> open('/tmp/t.txt').read()\r\n'host = 127.0.0.1\\n'\r\n```\r\n\r\nI think we might have a way to add variables by using the `variable_manager` from testinfra/utils/ansible_runner.py"}}
{"actor":{"display_login":"philpep"}}