On 24.10.2019 19:22, R-JRI wrote:
> Thanks for the reply, Kai
>
> After I changed the host to local host name in hosts field of yml file. I
> ran it without error but I don't see it get logs from remote servers to
> local /tmp directory. If I ran UNIX script, it takes logs to local /tmp/
> directory from remote server.
>
> Here is my yml file content:
>
> ---
> - name: grab log
> hosts: ansidev (this is the host name of ansible server)
>
> tasks:
> - name: get log
> command: /usr/local/bin/failed_log_analysys.sh
That is most likely because your script assume some environment variables is set that is not set when using ssh with non-interactive shell.
Since you are using ansidev instead of localhost Ansible most likely is login in to the server with ssh(depending on you inventory).
If using ssh then you are running it under an non-interactive shell that has very few environment variables set.
--
Kai Stian Olstad