1

I'm new to Ansible, and yes I know this has already been asked many times, but I already tried to apply advice I saw elsewhere.

I did export ANSIBLE_STDOUT_CALLBACK=debug and then ansible-playbook -vvvvvv arch-upgrade.yaml -l my-host with arch-upgrade.yaml below:

- name: ArchLinux up-to-date
  hosts: all
  tasks:
    - name: full system upgrade
      pacman:
        update_cache: yes
        upgrade: yes
      register: out
    - debug: msg="{{ out }}"

I get a lot of details about how ansible opens it's ssh connections, transfers its python file, runs it remotely, etc. but as far as I can tell, not a single thing about what command the python script actually ran and what it returned (stdout, stderr, return code). That's why I'm not including this very long log here, but I can upon request.

Is someone aware of how I can ask ansible to be more verbose about what it does (and not how it does it) ?

Antoine
  • 281
  • 1
  • 3
  • 12
  • 2
    Ansible can provide you with the output of a module. See [Debugging modules](https://docs.ansible.com/ansible/latest/dev_guide/debugging.html#debugging-modules) if you want to learn more. It's pretty straightforward. You ask Ansible to leave the code at the remote node. See ANSIBLE_KEEP_REMOTE_FILES. Then, at the remote node, you unpack the code and run *pdb*. – Vladimir Botka Aug 31 '21 at 15:21
  • Ok thanks, I guess this is a way to do it. Seems a bit convoluted though. Is there no "native" way to see what's happening from the ansible command line ? I mean things like `run_command` do not interact with some kind of native logging mechanism within ansible ? – Antoine Aug 31 '21 at 15:47
  • 1
    No. It is not. Imagine how Ansible works. First, at the controller, all data and code are compressed into a packet ``AnsiballZ``. Then, this packet is sent to a remote node. At the remote node, the data and code are extracted and executed. When a task completes the output is sent back from the remote node to the controller. Read the link above. – Vladimir Botka Aug 31 '21 at 16:06
  • Yes what you propose is simple from a systems design point of view. It's not so simple from a user's point of view. I'm a bit surprised there is no generic framework within ansible to log the side effects a what modules does (shell commands, system calls, API calls, etc.) without having to run it by hand. Nevertheless thanks for the insights into the internals of ansible ! – Antoine Aug 31 '21 at 16:49
  • You're welcome! It's necessary to understand that the success of Ansible is in providing a comprehensive framework to write custom modules. There is [unified structure of the output](https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#creating-an-info-or-a-facts-module) but, because of the variety of the modules, you get only such output the author of the module provides. There are about 10k modules at the moment, I assume. See [Ansible collections](https://github.com/orgs/ansible-collections/repositories). – Vladimir Botka Aug 31 '21 at 16:59

0 Answers0