{"id":275,"date":"2019-07-17T15:41:09","date_gmt":"2019-07-17T03:41:09","guid":{"rendered":"http:\/\/www.herbert.org.nz\/?p=275"},"modified":"2019-07-17T16:01:38","modified_gmt":"2019-07-17T04:01:38","slug":"ovirt-ansible-module-and-osx-delegate_to-localhost","status":"publish","type":"post","link":"https:\/\/www.herbert.org.nz\/?p=275","title":{"rendered":"ovirt ansible module and osx delegate_to: localhost"},"content":{"rendered":"<p>When running an ansible playbook using the<a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/modules\/ovirt_module.html\"> ovirt module<\/a> on os x (and maybe any os) and using <code>delegate_to: localhost<\/code>\u00a0I kept getting the following error:<\/p>\n<p><code>ovirtsdk4 version 4.2.4 or higher is required for this module<\/code><\/p>\n<p>That&#8217;s even after I had installed ovirtsdk using pip3 (my ansible runs using python3). Turns out when ansible runs under delegate_to: localhost it doesn&#8217;t use the normal python path, using the\u00a0<a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/modules\/python_requirements_facts_module.html\">python_requirements_facts module<\/a>\u00a0you can check what the actual path to python ansible was using when running under delegate_to: localhost, here is the output from my python requirement facts:<\/p>\n<pre style=\"padding-left: 30px;\">\"python\": \"\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/bin\/python3.7\",\r\n\"python_system_path\": [\r\n\"\/tmp\/ansible_python_requirements_facts_payload_bt3it94z\/ansible_python_requirements_facts_payload.zip\",\r\n\"\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/lib\/python37.zip\",\r\n\"\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/lib\/python3.7\",\r\n\"\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/lib\/python3.7\/lib-dynload\",\r\n\"\/usr\/local\/opt\/python\/Frameworks\/Python.framework\/Versions\/3.7\/lib\/python3.7\",\r\n\"\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/lib\/python3.7\/site-packages\"<\/pre>\n<p>So checking if ovirt module was installed in this path showed it wasn&#8217;t<\/p>\n<p><code>\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/bin\/pip3 list | grep ovirt<\/code><\/p>\n<p>So I had to install ovirtsdk into the &#8216;local&#8217; ansible path (making sure it could access the libxml2 header files):<\/p>\n<p><code>\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/bin\/pip3 install --global-option=build_ext --global-option=\"-I\/usr\/local\/Cellar\/libxml2\/2.9.7\/include\/libxml2\" ovirt-engine-sdk-python<\/code><\/p>\n<p>I then tested to make sure it could run the ovirtSDK, I created the following script to test:<\/p>\n<pre>#!\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/bin\/python3\r\n\r\nfrom distutils.version import LooseVersion\r\nfrom enum import Enum\r\nimport ovirtsdk4 as sdk\r\nimport ovirtsdk4.version as sdk_version\r\nHAS_SDK = (LooseVersion(sdk_version.VERSION) &gt;= LooseVersion('4.2.4'))\r\nif HAS_SDK:\r\n  print(\"Version OK\")\r\nelse:\r\n  print(\"Version FAIL\")<\/pre>\n<p>I ran this and got:<\/p>\n<pre>ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none\/other)<\/pre>\n<p>OK, so my pycurl module needs to be built with openssl support:<\/p>\n<pre>\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/bin\/pip3 uninstall pycurl\r\nexport CPPFLAGS=-I\/usr\/local\/opt\/openssl\/include\r\nexport LDFLAGS=-L\/usr\/local\/opt\/openssl\/lib\r\n\/usr\/local\/Cellar\/ansible\/2.7.10\/libexec\/bin\/pip3 install pycurl --global-option=\"--with-openssl\"<\/pre>\n<p>After this running my test script was successful and I am able to use the ovirt ansible module using delegate_to: localhost!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When running an ansible playbook using the ovirt module on os x (and maybe any os) and using delegate_to: localhost\u00a0I kept getting the following error: ovirtsdk4 version 4.2.4 or higher is required for this module That&#8217;s even after I had &hellip; <a href=\"https:\/\/www.herbert.org.nz\/?p=275\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-275","post","type-post","status-publish","format-standard","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=\/wp\/v2\/posts\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=275"}],"version-history":[{"count":8,"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=\/wp\/v2\/posts\/275\/revisions"}],"predecessor-version":[{"id":283,"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=\/wp\/v2\/posts\/275\/revisions\/283"}],"wp:attachment":[{"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.herbert.org.nz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}