{"id":256,"date":"2016-03-14T21:54:48","date_gmt":"2016-03-14T20:54:48","guid":{"rendered":"http:\/\/bemused.org\/blog\/?p=256"},"modified":"2016-03-22T15:08:29","modified_gmt":"2016-03-22T14:08:29","slug":"debugging-ansible","status":"publish","type":"post","link":"https:\/\/bemused.org\/blog\/2016\/03\/14\/debugging-ansible\/","title":{"rendered":"debugging ansible"},"content":{"rendered":"<p>I&#8217;ve been playing with <a href=\"https:\/\/www.ansible.com\/\">Ansible<\/a> recently, and enjoying automating my server installs, after years of relying on home-made scripts (or worse).<\/p>\n<p>From time to time I need to find out why Ansible isn&#8217;t doing what I think it should be, and after using -vvvv verbose flag, my next step is running the generated ansible installation script manually on the server. I didn&#8217;t find this explained anywhere, so I&#8217;m documenting it here for future reference.<!--more--><\/p>\n<p>First, run your ansible-playbook command on your local machine, setting the ANSIBLE_KEEP_REMOTE_FILES variable :<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ ANSIBLE_KEEP_REMOTE_FILES=1 ansible-playbook playbook.yml --ask-sudo-pass -vvvv\r\n<\/pre>\n<p>Make a note of the name of the file ansible copied to your server (it should be in your home directory, in .ansible\/tmp\/ansible-tmp-XXXXXXXXXXXX\/ ) , then on the target machine (you should be doing this in your test environment or in a vagrant virtual machine), run the command using the python debugger :<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ pdb ~\/.ansible\/tmp\/ansible-tmp-XXXXXXXXXXXX\/command\r\n<\/pre>\n<p>You can step through the command file to see what Ansible is really doing. First step is to break at main() : <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n(Pdb) b main\r\n<\/pre>\n<p>then step through the code until it breaks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been playing with Ansible recently, and enjoying automating my server installs, after years of relying on home-made scripts (or worse). From time to time I need to find out why Ansible isn&#8217;t doing what I think it should be, and after using -vvvv verbose flag, my next step is running the generated ansible installation [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-geeky-stuff"],"_links":{"self":[{"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":10,"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":271,"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/posts\/256\/revisions\/271"}],"wp:attachment":[{"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bemused.org\/blog\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}