Hi All,
I am trying to add a chromeOS test image based DUT to ansible inventory but 
not able to run any script on it using ansible.
But when changed to network OS  in hosts config *ping works fine*. But 
running a bash script doesn't work. I have also tried changing ansible.cfg 
file to reflect remote_temp to /tmp which has right permission and 
remote_user as root but no help.

Below is what I have tried so far. Can anybody help ?

hosts file config:
[duts]
172.25.235.142 ansible_password=test0000 ansible_user=root

Running a playbook:
# ansible-playbook remote_script_dut.yml 

PLAY [Transfer and execute a script.] 
*********************************************************************************************************************************************************************

TASK [Copy and Execute the script] 
************************************************************************************************************************************************************************
fatal: [172.25.235.142]: UNREACHABLE! => {"changed": false, "msg": 
"Authentication or permission failure. In some cases, you may have been 
able to authenticate and did not have permissions on the target directory. 
Consider changing the remote tmp path in ansible.cfg to a path rooted in 
\"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo 
/root/.ansible/tmp/ansible-tmp-1656530218.5656176-121124387873189 `\" && 
echo ansible-tmp-1656530218.5656176-121124387873189=\"` echo 
/root/.ansible/tmp/ansible-tmp-1656530218.5656176-121124387873189 `\" ), 
exited with result 1", "unreachable": true}

PLAY RECAP 
************************************************************************************************************************************************************************************************
172.25.235.142             : ok=0    changed=0    unreachable=1    failed=0 
   skipped=0    rescued=0    ignored=0   


#ansible duts -m ping -vvvv
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg

<172.25.235.142> (0, b'/root\n', b'OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 
1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include 
/etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: 
/etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: 
resolve_canonicalize: hostname 172.25.235.142 is address\r\ndebug1: 
auto-mux: Trying existing master\r\ndebug1: Control socket 
"/home/cssdesk/.ansible/cp/f9610a0af3" does not exist\r\ndebug2: 
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 67343
debug3: mux_client_request_session: session request sent
mkdir: cannot create directory '/root/.ansible': Read-only file system
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
172.25.235.142 | UNREACHABLE! => {
    "changed": false,
    "msg": "Authentication or permission failure. In some cases, you may 
have been able to authenticate and did not have permissions on the target 
directory. Consider changing the remote tmp path in ansible.cfg to a path 
rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo 
/root/.ansible/tmp/ansible-tmp-1656530410.1564126-265903908945916 `\" && 
echo ansible-tmp-1656530410.1564126-265903908945916=\"` echo 
/root/.ansible/tmp/ansible-tmp-1656530410.1564126-265903908945916 `\" ), 
exited with result 1, stderr output: OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, 
OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include 
/etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: 
/etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: 
resolve_canonicalize: hostname 172.25.235.142 is address\r\ndebug1: 
auto-mux: Trying existing master\r\ndebug2: fd 3 setting 
O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 
4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 
remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: 
mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: 
done pid = 67343\r\ndebug3: mux_client_request_session: session request 
sent\r\nmkdir: cannot create directory '/root/.ansible': Read-only file 
system\ndebug3: mux_client_read_packet: read header failed: Broken 
pipe\r\ndebug2: Received exit status from master 1\r\n",
    "unreachable": true
}


############################################################################################################

When changed to network OS ping works. But running a bash script doesn't 
work.

[duts]
172.25.235.142 ansible_password=test0000 ansible_user=root 
ansible_connection=network_cli ansible_network_os=junos

#ansible duts -m ping -vvvv
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
['/home/cssdesk/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its 
verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its 
verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its 
verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading callback plugin minimal of type stdout, v2.0 from 
/usr/lib/python3/dist-packages/ansible/plugins/callback/minimal.py
META: ran handlers
<172.25.235.142> attempting to start connection
<172.25.235.142> using connection plugin network_cli
<172.25.235.142> local domain socket does not exist, starting it
<172.25.235.142> control socket path is /home/cssdesk/.ansible/pc/ee7b4f3509
<172.25.235.142> local domain socket listeners started successfully
<172.25.235.142> loaded cliconf plugin junos from path 
/usr/lib/python3/dist-packages/ansible/plugins/cliconf/junos.py for 
network_os junos
<172.25.235.142> 
<172.25.235.142> local domain socket path is 
/home/cssdesk/.ansible/pc/ee7b4f3509
<172.25.235.142> ESTABLISH LOCAL CONNECTION FOR USER: cssdesk
<172.25.235.142> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492
 
`" && echo ansible-tmp-1656531006.859179-4419420807492="` echo 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492
 
`" ) && sleep 0'
<172.25.235.142> Attempting python interpreter discovery
<172.25.235.142> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command 
-v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v 
'"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v 
'"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v 
'"'"'/usr/libexec/platform-python'"'"'; command -v 
'"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && 
sleep 0'
<172.25.235.142> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Using module file 
/usr/lib/python3/dist-packages/ansible/modules/system/ping.py
<172.25.235.142> PUT 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/tmp7kuf3nfs TO 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492/AnsiballZ_ping.py
<172.25.235.142> EXEC /bin/sh -c 'chmod u+x 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492/
 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492/AnsiballZ_ping.py
 
&& sleep 0'
<172.25.235.142> EXEC /bin/sh -c '/usr/bin/python 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492/AnsiballZ_ping.py
 
&& sleep 0'
<172.25.235.142> EXEC /bin/sh -c 'rm -f -r 
/home/cssdesk/.ansible/tmp/ansible-local-674356wfkewy6/ansible-tmp-1656531006.859179-4419420807492/
 
> /dev/null 2>&1 && sleep 0'
[DEPRECATION WARNING]: Distribution ubuntu 20.04 on host 172.25.235.142 
should use /usr/bin/python3, but is using /usr/bin/python for backward 
compatibility with prior Ansible releases. A future Ansible
 release will default to using the discovered platform python for this 
host. See 
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html
 
for more information. This feature 
will be removed in version 2.12. Deprecation warnings can be disabled by 
setting deprecation_warnings=False in ansible.cfg.
172.25.235.142 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "data": "pong"
        }
    },
    "ping": "pong"
}
META: ran handlers
META: ran handlers

ANSIBLE PLAYBOOK FAILURE
$ ansible-playbook remote_script_dut.yml 

PLAY [Transfer and execute a script.] 
*********************************************************************************************************************************************************************

TASK [Copy and Execute the script] 
************************************************************************************************************************************************************************
changed: [172.25.235.142]

PLAY RECAP 
************************************************************************************************************************************************************************************************
172.25.235.142             : ok=1    changed=1    unreachable=0    failed=0 
   skipped=0    rescued=0    ignored=0   



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a409841c-dd2c-49a5-b9ea-2ea76f59cd80n%40googlegroups.com.

Reply via email to