Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Human-readable Ansible diagnostic messages? #1655

Closed
iainhouston opened this issue Jan 13, 2018 · 9 comments
Closed

Human-readable Ansible diagnostic messages? #1655

iainhouston opened this issue Jan 13, 2018 · 9 comments

Comments

@iainhouston
Copy link
Contributor

iainhouston commented Jan 13, 2018

Issue Type

  • Feature Idea

Your Environment

python --version #==> Python 2.7.14
ansible --version #==> ansible 2.4.2.0
vagrant --version #==> Vagrant 2.0.1
VBoxManage --version #==> Virtual Box 5.2.4r119785
composer --version  #==> ... 1.6.2 2018-01-05 15:28:4

Your OS

  • macOS (high Sierra)

Summary

Human-readable Ansible diagnostics would make life a lot easier.
Debugging failing Ansible tasks is made much more difficult by unformatted (html strings) diagnostics which take a lot of deciphering.

For example, adding to ansible.cfg the following (according to ansible-human_log) should make life a lot easier.

[defaults]
callback_plugins = path/to/callback_plugins/
@oxyc
Copy link
Collaborator

oxyc commented Jan 16, 2018

Do you happen to have any before/after examples?

@iainhouston
Copy link
Contributor Author

Haven't got a suitable "after" to hand right here, but here's what was bugging me "before":

TASK [Run configured post-provision ansible task files.] ***********************
fatal: [local-BAPC]: FAILED! => {"reason": "no action detected in task. This often indicates a misspelled module n
ame, or incorrect module path.\n\nThe error appears to have been in '/Users/iainhouston/bradford-abbas.uk/vm/local
_tasks/local_directories.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax p
roblem.\n\nThe offending line appears to be:\n\n---\n- name: Ensure Dev sql-dump directory is present\n  ^ here\n\
n\nThe error appears to have been in '/Users/iainhouston/bradford-abbas.uk/vm/local_tasks/local_directories.yml':
line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line a
ppears to be:\n\n---\n- name: Ensure Dev sql-dump directory is present\n  ^ here\n\nexception type: <class 'ansibl

e.errors.AnsibleParserError'>\nexception: no action detected in task. This often indicates a misspelled module nam
e, or incorrect module path.\n\nThe error appears to have been in '/Users/iainhouston/bradford-abbas.uk/vm/local_t
asks/local_directories.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax pro
blem.\n\nThe offending line appears to be:\n\n---\n- name: Ensure Dev sql-dump directory is present\n  ^ here\n"}
        to retry, use: --limit @/Users/iainhouston/bradford-abbas.uk/vendor/geerlingguy/drupal-vm/provisioning/pla
ybook.retry

@geerlingguy
Copy link
Owner

Could this just be a documentation thing? e.g. if you want to have easier to read debug output, download x and place it in y, then add line z to Drupal VM's ansible.cfg file... something like that?

@iainhouston
Copy link
Contributor Author

iainhouston commented Jan 17, 2018

Yes, a documentation thing, sure that would suffice. Trouble is I've tried all sorts of suggestions for ansible-playbook's ansible.cfg including:

[defaults]
roles_path = ./
stdout_callback = skippy
callback_plugins = /usr/local/lib/python2.7/site-packages/ansible/plugins/callback/
...

but none of the plugins seem to have any effect on the readability of something like:

TASK [geerlingguy.firewall : Check if ufw package is installed (on Ubuntu).] ***
fatal: [local-BAPC]: FAILED! => {"changed": false, "cmd": "service ufw status", "delta":   "0:00:00.007012", "end": "2018-01-17 22:24:38.367020", "msg": "non-zero return code", "rc": 3,    "start": "2018-01-17 22:24:38.360008", "stderr": "", "stderr_lines": [], "stdout": "* ufw.service -    Uncomplicated firewall\n   Loaded: loaded (/lib/systemd/system/ufw.service; disabled; vendor preset:    enabled)\n   Active: inactive (dead)", "stdout_lines": ["* ufw.service - Uncomplicated firewall", "      Loaded: loaded (/lib/systemd/system/ufw.service; disabled; vendor preset: enabled)", "   Active:    inactive (dead)"]}   
...ignoring   

where newlines are not interpreted (on MacOS Terminal anyway. And there again GitHub Markdown gives yet another slant!)

@oxyc
Copy link
Collaborator

oxyc commented Jan 18, 2018

When I was working on #1563 I noticed that the ansible.cfg wasn't picked up by Drupal VM at all. It had to reside next to the Vagrantfile to get picked up (PR solves it).

@iainhouston
Copy link
Contributor Author

iainhouston commented Jan 19, 2018

What’s the journey between @oxyc update and me doing composer update geerlingguy/drupal-vm —with-dependencies to try with an ansible.cfg whose contents are picked up? I tried placing it next to my (delegating) Vagrantfile with no joy. My drupal-vm was cloned about three or four weeks ago.

@geerlingguy
Copy link
Owner

See also: Use Ansible's YAML callback plugin for a better CLI experience—but note that would require Ansible 2.5.0+ and I'm not yet ready to bump from 2.4 to 2.5 as a minimum requirement :)

I like @oxyc's PR, and have one follow-up docs question, but otherwise I'm happy to merge that in so we can get a little better Ansible output by default!

@geerlingguy
Copy link
Owner

I am closing issues more than 6 months old which are not approved feature requests or definitively reproducible bugs affecting most users of Drupal VM; if you feel like this is still a reproducible issue with Drupal VM or something that should still be worked on, please open a new issue in the Drupal VM issue queue. I am trying to clean up some older issues which were hard or impossible to reproduce and debug.

Thank you!

@geerlingguy
Copy link
Owner

(But note that I may switch the callback plugin to YAML at some point, as I've been doing that on a number of projects. It just doesn't show debug output properly in all cases, so I've been cautious about switching it on.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants