{"id":2215,"date":"2018-01-18T23:05:41","date_gmt":"2018-01-19T04:05:41","guid":{"rendered":"http:\/\/blog.domb.net\/?p=2215"},"modified":"2018-01-20T17:48:47","modified_gmt":"2018-01-20T22:48:47","slug":"ansible-container-mysql_config-not-found-issue","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=2215","title":{"rendered":"ansible-container fix mysql_config not found issue"},"content":{"rendered":"<p>It has to be noted that ansible-container is not a supported redhat\u00a0product. So everything you see here is unsupported. If you want to use ansible to package containers look at the Ansible Playbook Bundle in OpenShift.<\/p>\n<p>I thought\u00a0it would be a good idea to see where ansible container is. My goal was to create a wordpress\u00a0 container backed by mariadb. Here is the github\u00a0repo to my files:\u00a0https:\/\/github.com\/ldomb\/ansible-container-wordpress.git<\/p>\n<p>based on the documentation I was supposed to be able to build my project by simply running <strong>ansible-container build.\u00a0<\/strong>This resulted in the following error<\/p>\n<pre class=\"lang:default decode:true\">Collecting mysql-python (from -r \/_ansible\/build\/ansible-requirements.txt (line 3))\r\nDownloading MySQL-python-1.2.5.zip (108kB)\r\nComplete output from command python setup.py egg_info:\r\nsh: mysql_config: command not found\r\nTraceback (most recent call last):\r\nFile \"\", line 1, in \r\nFile \"\/tmp\/pip-build-FeCnAk\/mysql-python\/setup.py\", line 17, in \r\nmetadata, options = get_config()\r\nFile \"setup_posix.py\", line 43, in get_config\r\nlibs = mysql_config(\"libs_r\")\r\nFile \"setup_posix.py\", line 25, in mysql_config\r\nraise EnvironmentError(\"%s not found\" % (mysql_config.path,))\r\nEnvironmentError: mysql_config not found<\/pre>\n<p>This is kind of weird as in my ansible role I am installing MySQL-python. It seems that this doesn&#8217;t matter.<\/p>\n<p>A workaround to get this working is to use &#8211;use-local-python which uses the python you have on the system.<\/p>\n<pre class=\"lang:default decode:true\">[root@host87 wordpress]# ansible-container build --use-local-python<\/pre>\n<p>After this builds correctly you can then run<\/p>\n<pre class=\"lang:default decode:true\">[root@host87 wordpress]# ansible-container run \r\n\r\n<\/pre>\n<p>You can now go to http:\/\/localhost or http:\/\/ipwherethecontainersarerunning and should see the WordPress\u00a0install page<\/p>\n<p>If you want to push this image to OpenShift you can do the following (Be aware that I OpenShift was not able to run the image due to Error: InvalidImageName and Failed to apply default image tag:)<\/p>\n<p>Login to OpenShift and create new project (<strong>be aware the project name has to match your ansible-container project name<\/strong>)<\/p>\n<pre class=\"lang:default decode:true\">oc new-project wordpress<\/pre>\n<p>In OpenShift for ansible container to work the following needs to be done so that the user can access\u00a0the registry:<\/p>\n<pre class=\"lang:default decode:true\">oadm policy add-role-to-user system:registry bob\r\noadm policy add-role-to-user admin bob -n wordpress\r\noadm policy add-role-to-user system:image-builder bob\r\noadm policy add-cluster-role-to-user cluster-admin bob<\/pre>\n<p>Now Bob can push images to openshift<\/p>\n<p>then you can run as bob<\/p>\n<pre class=\"lang:default decode:true\">oc whoami -t<\/pre>\n<p class=\"p1\">now you can push the images to the registry<\/p>\n<pre class=\"lang:default decode:true\">oc login --token $(oc whoami -t) host82.local.redhat-demo.com:8443\r\n\r\n<\/pre>\n<p>Then deploy the container to the OpenShift registry and create the build config<\/p>\n<pre class=\"lang:default decode:true\">[root@host82 wordpress]# ansible-container --engine openshift deploy --push-to docker-registry-default.apps.local.redhat-demo.com --username bob --password $(oc whoami -t) --roles-path .\/roles\r\nParsing conductor CLI args.\r\nEngine integration loaded. Preparing push.\tengine=OpenShift&#x2122;\r\nTagging docker-registry-default.apps.local.redhat-demo.com\/wordpress\/wordpress-db\r\nPushing docker-registry-default.apps.local.redhat-demo.com\/wordpress\/wordpress-db:20180120192555...\r\nThe push refers to a repository [docker-registry-default.apps.local.redhat-demo.com\/wordpress\/wordpress-db]\r\nPreparing\r\nLayer already exists\r\n20180120192555: digest: sha256:faa6707abb3876ecf26e0580f2bd5c416bd45fdb79f39f5984a2d7e04c3d91fc size: 741\r\nTagging docker-registry-default.apps.local.redhat-demo.com\/wordpress\/wordpress-wordpress\r\nPushing docker-registry-default.apps.local.redhat-demo.com\/wordpress\/wordpress-wordpress:20180120192707...\r\nThe push refers to a repository [docker-registry-default.apps.local.redhat-demo.com\/wordpress\/wordpress-wordpress]\r\nPreparing\r\nMounted from wordpress\/wordpress-db\r\nPushing\r\nPushed\r\n20180120192707: digest: sha256:df8486c732a5092b420338dc2f9871d8554b096136b9bc0f3d2a834c05be094a size: 742\r\nConductor terminated. Cleaning up.\tcommand_rc=0 conductor_id=93f470df51e1334d34fe5a18c8a73050beb44c085bfd0b7e934f4b872f14181d save_container=False\r\nParsing conductor CLI args.\r\nEngine integration loaded. Preparing deploy.\tengine=OpenShift&#x2122;\r\nVerifying image for db\r\nVerifying image for wordpress\r\nansible-galaxy 2.5.0\r\n  config file = \/etc\/ansible\/ansible.cfg\r\n  configured module search path = [u'\/root\/.ansible\/plugins\/modules', u'\/usr\/share\/ansible\/plugins\/modules']\r\n  ansible python module location = \/usr\/lib\/python2.7\/site-packages\/ansible\r\n  executable location = \/usr\/bin\/ansible-galaxy\r\n  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]\r\nUsing \/etc\/ansible\/ansible.cfg as config file\r\nOpened \/root\/.ansible_galaxy\r\nProcessing role ansible.kubernetes-modules\r\nOpened \/root\/.ansible_galaxy\r\n- downloading role 'kubernetes-modules', owned by ansible\r\nhttps:\/\/galaxy.ansible.com\/api\/v1\/roles\/?owner__username=ansible&name=kubernetes-modules\r\nhttps:\/\/galaxy.ansible.com\/api\/v1\/roles\/16501\/versions\/?page_size=50\r\n- downloading role from https:\/\/github.com\/ansible\/ansible-kubernetes-modules\/archive\/v0.3.1-6.tar.gz\r\n- extracting ansible.kubernetes-modules to \/root\/ansible-container-wordpress\/wordpress\/ansible_deployment\/roles\/ansible.kubernetes-modules\r\n- ansible.kubernetes-modules (v0.3.1-6) was installed successfully\r\nConductor terminated. Cleaning up.\tcommand_rc=0 conductor_id=7d2ca733add8d6042be3f154af9ef973a8bcb8ea8d33df3da1b23824a0c0212f save_container=False<\/pre>\n<p>If successful\u00a0you should be able to do this:<\/p>\n<pre class=\"lang:default decode:true\">[root@host82 wordpress]# ansible-playbook .\/ansible_deployment\/wordpress.yml --tags start\r\n [WARNING]: Could not match supplied host pattern, ignoring: all\r\n\r\n [WARNING]: provided hosts list is empty, only localhost is available\r\n\r\n\r\nPLAY [Manage the lifecycle of wordpress on OpenShift&#x2122;] *****************************************************************************************\r\n\r\nTASK [Create project wordpress] ****************************************************************************************************************\r\nok: [localhost]\r\n\r\nTASK [Create service] **************************************************************************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [Create service] **************************************************************************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [Create deployment, and scale replicas up] ************************************************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [Create deployment, and scale replicas up] ************************************************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [Create route] ****************************************************************************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [Create route] ****************************************************************************************************************************\r\nchanged: [localhost]\r\n\r\nPLAY RECAP *************************************************************************************************************************************\r\nlocalhost                  : ok=7    changed=6    unreachable=0    failed=0\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It has to be noted that ansible-container is not a supported redhat\u00a0product. So everything you see here is unsupported. If you want to use ansible to package containers look at the Ansible Playbook Bundle in OpenShift. I thought\u00a0it would be a good idea to see where ansible container is. My goal was to create a&#8230;<\/p>\n","protected":false},"author":2,"featured_media":2133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[64],"tags":[133],"class_list":["post-2215","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible","tag-ansible-container"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2215"}],"version-history":[{"count":12,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2215\/revisions"}],"predecessor-version":[{"id":2228,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2215\/revisions\/2228"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/2133"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}