- name: sysprep for debian/ubuntu systems gather_facts: yes hosts: servers become: "{{become}}" tasks: # that works only when inventory_hostname is a true hostname - not with just an IP as with terraform - name: hostname matches inventory hostname: name: "{{inventory_hostname}}" - name: debian sysprep incl. connecting user ansible.builtin.script: cmd: scripts/debian-sysprep.bash {{timezone}} {{ansible_user}} chdir: /root register: script_output changed_when: >- "changed - all done" in script_output.stdout when: > ansible_facts['os_family'] == "Debian" and ansible_user is defined - name: debian sysprep w/o additional user ansible.builtin.script: cmd: scripts/debian-sysprep.bash {{timezone}} chdir: /root register: script_output changed_when: >- "changed - all done" in script_output.stdout when: > ansible_facts['os_family'] == "Debian" and ansible_user is not defined - name: display script stdout debug: var=script_output.stdout_lines when: script_output.stdout is defined - name: display script stderr debug: var=script_output.sterr_lines when: script_output.sterr is defined