On Wednesday, 21 November 2018 16:19:44 CET Dimitri Yioulos wrote:
> ---
> > - hosts: all
> >   gather_facts: false
> >   any_errors_fatal: true
> >   tasks:
> >      - name: reload DAO
> >        local_action: script /etc/ansible/files/DAO_update.py {{ 
> > inventory_hostname }}
> >        register: dao_output
> >      - debug: var=dao_output.stdout_lines
> 
> 
> Note the use of local_action.  When I tried to simply use the script module 
> (script: /etc/ansible/files/DAO_update.py {{ inventory_hostname }}), I got 
> no errors, but the script didn't execute.  I determined this by running 
> tcpdump, which returned no output.  If I ran the script manually, tcpdump 
> returned expected output.  However, If I ran the playbook with local_action 
> (as above), tcpdump returned the expected output; e.g. the script executed 
> properly.  Why did using the script module not work?  According to the 
> script module documentation, among other things, python isn't required to 
> be installed on the target.  An explanation would be appreciated.

The first line in the documentation is 
"script - Runs a local script on a remote node after transferring it"

So the script module copy the script from ansible controller to the _remote_ 
and execute the script on _remote_ host.

The script module doesn't require python installed, but if you are running a 
Python script on the remote host of course you need Python on the remote host.

So if you are intending to execute this script on the Ansible controller, use 
the command module and "local_action/delegate_to: localhost" or just set the 
"connection: local" in the playbook with the command module.

-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1865249.hVpG87TfFB%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to