raw module inside playbooks

3,677 views
Skip to first unread message

Viktor Tsymbalyuk

unread,
Apr 18, 2015, 10:09:03 PM4/18/15
to ansible...@googlegroups.com
Hi,
according to module description, raw
Executes a low-down and dirty SSH command, not going through the module subsystem.
Everything looks fine using  Ad-Hoc Commands.
But inside playbook
---
- hosts: cisco-test
  tasks
:
 
- name: replay hostname
    raw
: show run | i hostname
it works like command module

vic@ZBook:~$ ansible-playbook -k scripts/ansible/cisco_ping.yml -u test -v
SSH password
:
PLAY
[cisco-test] *************************************************************

GATHERING FACTS
***************************************************************
fatal
: [test] => failed to transfer file to Line has invalid autocommand "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1429366350.06-115305493777139 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1429366350.06-115305493777139 && echo $HOME/.ansible/tmp/ansible-tmp-1429366350.06-115305493777139'"/setup:

Administratively disabled.
Connection to 172.16.1.2 closed by remote host.

TASK
: [replay hostname] *******************************************************
FATAL
: no hosts matched or all hosts have already failed -- aborting

Does it possible to change raw module behavior for ansible-playbook?



Brian Coca

unread,
Apr 18, 2015, 10:47:53 PM4/18/15
to ansible...@googlegroups.com
you might want to add "gather_facts: False" (between hosts and tasks),
otherwise the setup module tries to run before the play even gets to
the raw module




--
Brian Coca

Viktor Tsymbalyuk

unread,
Apr 21, 2015, 6:29:32 AM4/21/15
to ansible...@googlegroups.com
Hi, Brian.
Thank you for explanation, it works.

rrrki...@gmail.com

unread,
Apr 21, 2015, 9:14:02 AM4/21/15
to ansible...@googlegroups.com









Hi,

I have this playbook and getting the same above error

         - raw: /home/rccmadm/AIX_5/nimldr  -r -X  -D CSCLAB  -I 192.168.35.14   -o 48005 -R 10.20.73.128 -U gbevan -S 'N1ms0ft!' -l /home/rccmadm/nimldr.log
           when: ansible_os_family == "AIX"

If I say gathering facts is false then the condition is ansible_os_family check is failing .

How to resolve this ?

Toshio Kuratomi

unread,
Apr 21, 2015, 9:30:24 AM4/21/15
to ansible...@googlegroups.com
On Tue, Apr 21, 2015 at 3:46 AM, <rrrki...@gmail.com> wrote:

> I have this playbook and getting the same above error
>
> - raw: /home/rccmadm/AIX_5/nimldr -r -X -D CSCLAB -I
> 192.168.35.14 -o 48005 -R 10.20.73.128 -U gbevan -S 'N1ms0ft!' -l
> /home/rccmadm/nimldr.log
> when: ansible_os_family == "AIX"
>
> If I say gathering facts is false then the condition is ansible_os_family
> check is failing .
>
> How to resolve this ?
>
You'll have to make a choice. either install python on the remote
machine so that fact gathering can work or keep an explicit list of
hosts that you want to run this task on instead of relying on
conditionals that need gathered facts.

The fact gathering scripts are written in python so you can't have
facts without also having a remote python interpreter.

-Toshio
Reply all
Reply to author
Forward
0 new messages