Search code examples
ansiblezenity

Is it possible to run script in foreground via Ansible


I use Ansible to push something to nodes and I wanted to use Zenity to warn the user who is using a node that I am doing something but I am unable to figure out how to run script displaying on nodes foreground. It is possible to run a script via Ansible but to display it on the node instead of the Control Machine?


Solution

  • I figure out all I needed to do is to use script module to run my local script on the nodes.

    ---
    - hosts: targets
    
      tasks:   
      - name: Notify of imminent upgrade
        script: /home/hero/loading.sh
    

    The script being something like this.

    #!/bin/bash
    DISPLAY=:0 zenity --warning