Stupid Ansible Tricks

The problem with a large collection of not homogeneous servers is that ansible gets all angry when you try to do an “apt-get” on Red Hat/Fedora, or “yum” on a Debian/Ubuntu. And sometimes I just want a quick count of what is what. This info is under “ansible_distribution”, and you can set tasks to run depending on which “OS” it detects. So this little snipplet just spits that info out. I sometimes use something like this instead of “-m ping” since it prints out something useful, but just “ansible -m ping all” is so quick to type. [Maybe this isn’t a great trick, but I was happy to learn this, and use it regularly]

---
- hosts: all
  become: true
  become_user: root
  gather_facts: true

  tasks:

    - name: some debug info
      ansible.builtin.debug:
        msg:
          - "Distrbution = {{ ansible_distribution }}"