Using Ansible to get the tor offline key expiry date

I am trying to run a very simple Ansible script to get the offline key expiration date:

  • name: Execute a script.
    hosts: myhosts
    become: True
    gather_facts: false
    tasks:
    • name: execute the script
      script:
      cmd: /home/torix/ansible/ansible_quickstart/chkkey2.sh > {{ inventory_hostname }}.exp

chkkey2.sh is:
/usr/sbin/tor -f /etc/tor/instances/*9000/torrc --key-expiration sign --format iso8601 --quiet

When I run this, I get a 0 size xxxx.exp file.
When I change chkkey2.sh to:
/usr/sbin/tor --version
I get the right results in the xxxx.exp file.
When I run: sudo /usr/sbin/tor -f /etc/tor/instances/*9000/torrc --key-expiration sign --format iso8601 --quiet
on the server, I get the expiration date I want.
My Ansible.cfg defines become as sudo to root.
The server is running debian 11(bullseye)

And I’m stumped.