{"id":1865,"date":"2020-04-07T21:54:29","date_gmt":"2020-04-07T18:54:29","guid":{"rendered":"https:\/\/artem.services\/?p=1856"},"modified":"2020-04-07T22:27:37","modified_gmt":"2020-04-07T19:27:37","slug":"1865","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1865&lang=en","title":{"rendered":"Ansible &#8212; Launch Playbook with a specific version of Python"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1393\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/08\/ansible-logo.png\" alt=\"\" width=\"1280\" height=\"720\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2019\/08\/ansible-logo.png 1280w, https:\/\/artem.services\/wp-content\/uploads\/2019\/08\/ansible-logo-300x169.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2019\/08\/ansible-logo-768x432.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2019\/08\/ansible-logo-1024x576.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2019\/08\/ansible-logo-954x537.png 954w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>For example, there is an instance on which <strong>Python<\/strong> of the 2nd and 3rd versions is installed, but the default is 2nd, and in order not to change the default version and start the <strong>Playbook<\/strong> using <strong>Python3<\/strong>, you can use the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npython3 $(which ansible-playbook) -i localhost my-playbook.yaml\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>You can also specify the interpreter in the inventory file:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[localhost]\r\nlocalhost ansible_connection=local ansible_python_interpreter=python3\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Make sure Ansible module is installed for the correct version of Python<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo pip3 install --user ansible\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For example, there is an instance on which Python of the 2nd and 3rd versions is installed, but the default is 2nd, and in order not to change the default version and start the Playbook using Python3, you can use the following command: &nbsp; You can also specify the interpreter in the inventory file: &nbsp; &hellip; <a href=\"https:\/\/artem.services\/?p=1865&#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;Ansible &#8212; Launch Playbook with a specific version of Python&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],"tags":[1133,1525,1135,1527,1529],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1865"}],"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=1865"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1865\/revisions"}],"predecessor-version":[{"id":1867,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1865\/revisions\/1867"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}