.the fyr place.

ansible woes

I think it's time to call it a night because I keep going in circles with ansible:

I get the whole dict when I do this:

  hosts: myhost
  vars_files:
    - .vault
  gather_facts: true
  tasks:
    - name: Test a task and see the output
      ansible.builtin.find:
        paths:
          - /mypath
        patterns:
          - '*txt'
      register: command_output
    - name: show what I got
      ansible.builtin.debug:
        msg: " {{ command_output }}"
    - name: set fact
      ansible.builtin.set_fact:
        msg_text: "{{ command_output }}"
    - import_tasks: telegram.playbook

side note: telegram.playbook looks something like this:

  - name: Telegram send
    community.general.telegram:
      token: "{{ vault_telegram_bot_id }}"
      api_args:
        chat_id: "{{ vault_telegram_bot_chat }}"
        parse_mode: "plain"
        text: "{{ msg_text }}"
        disable_web_page_preview: true
        disable_notification: false
    delegate_to: localhost

But I get the last item in the dict when I do this:

- name: Testing task includes
  hosts: myhost
  vars_files:
    - .vault
  gather_facts: true
  tasks:
    - name: Test a task and see the output
      ansible.builtin.find:
        paths:
          - /mypath
        patterns:
          - '*txt'
      register: command_output
      changed_when: 'command_output.failed == false'
      notify: Telegram send
    - name: show what I got
      ansible.builtin.debug:
        msg: " {{ command_output }}"
    - name: set fact
      ansible.builtin.set_fact:
        msg_text: "{{ item.path }}"
      with_items: "{{ command_output.files }}"
  handlers:
    - import_tasks: telegram.playbook

Dammit ... I just want the paths not the whole damn dict!


I give up. Time for sleep ... or at least some Sudoku or Diable Immortal. This is making my headache worse.