{"id":1776,"date":"2020-03-31T15:53:00","date_gmt":"2020-03-31T12:53:00","guid":{"rendered":"https:\/\/artem.services\/?p=1765"},"modified":"2020-03-31T16:34:52","modified_gmt":"2020-03-31T13:34:52","slug":"1776","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1776&lang=en","title":{"rendered":"FIX ERROR &#8212; Ansible AWS SSM: AnsibleError: An unhandled exception occurred while templating"},"content":{"rendered":"<p>When trying to get a value from <strong>AWS SSM<\/strong>,<strong> Ansible Playbook<\/strong> using <strong>Python3<\/strong> as an interpreter generates the following error:<\/p>\n<blockquote><p>fatal: [localhost-py3]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;AnsibleError: An unhandled exception occurred while templating &#39;{{ lookup(&#39;aws_ssm&#39;, &#39;server_listeners&#39;, decrypt=false, region=&#8217;eu-west-1&#8242;) }}&#39;. Error was a &lt;class &#39;ansible.errors.AnsibleError&#39;&gt;, original message: An unhandled exception occurred while running the lookup plugin &#39;aws_ssm&#39;. Error was a &lt;class &#39;ansible.errors.AnsibleError&#39;&gt;, original message: botocore and boto3 are required for aws_ssm lookup.&quot;}<\/p><\/blockquote>\n<p>The <strong>Ansible<\/strong> <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/plugins\/lookup\/aws_ssm.html\" target=\"_blank\" rel=\"noopener noreferrer\">documentation<\/a> says that dependencies are needed for <strong>PIP<\/strong>:<\/p>\n<ul>\n<li>boto3<\/li>\n<li>botocore<\/li>\n<\/ul>\n<p>But the error was still present until the &quot;<strong>ansible<\/strong>&quot; module was added to the <strong>PIP<\/strong> dependency<\/p>\n<h3>Solution:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n---\r\n- name: Ensure boto3, botocore and ansible modules are installed\r\n  pip:\r\n    name: \r\n      - boto3\r\n      - botocore\r\n      - ansible\r\n    executable: \/usr\/bin\/pip3\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When trying to get a value from AWS SSM, Ansible Playbook using Python3 as an interpreter generates the following error: fatal: [localhost-py3]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;AnsibleError: An unhandled exception occurred while templating &#39;{{ lookup(&#39;aws_ssm&#39;, &#39;server_listeners&#39;, decrypt=false, region=&#8217;eu-west-1&#8242;) }}&#39;. Error was a &lt;class &#39;ansible.errors.AnsibleError&#39;&gt;, original message: An unhandled exception occurred while running the lookup &hellip; <a href=\"https:\/\/artem.services\/?p=1776&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;FIX ERROR &#8212; Ansible AWS SSM: AnsibleError: An unhandled exception occurred while templating&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1131,599,357],"tags":[1133,543,1437,1439,1441,361,365,1443,1135,883],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1776"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1776"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1776\/revisions"}],"predecessor-version":[{"id":1778,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1776\/revisions\/1778"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}