0

could somebody please help, I am trying to create an Ansible playbook for our VMWare virtual hosts but the playbook will not work. If I run the same command on its own, it succeeds.

Single command which works

ansible vhosts -vvv -k -m shell -a "vmkfstools -Ph -v 1 /vmfs/volumes/VMFS_01 | grep Mode"

Playbook

---
- hosts: vhosts
  remote_user: root

  tasks:
    - name: Get VMFS 01
      shell: vmkfstools -Ph -v 1 /vmfs/volumes/VMFS_01 | grep Mode

Playbook Error

fatal: [10.10.10.3]: FAILED! => {"msg": "/bin/sh: sudo: not found
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: auto-mux: Trying existing master
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 = 1810
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 127
Shared connection to 10.10.10.3 closed.
", "failed": true, "changed": false, "parsed": false, "invocation": {"module_name": "setup", "module_args": {}}}

ansible 2.0.0

Infact I have tried some basic modules inside the playbook and they all seem to give the same error.

  • Do you need "sudo: yes"? Remote user is already root. Seems to be failing on executing sudo. – Joe Jan 14 '16 at 13:48
  • I have tried with and without the sudo option – Arturski Jan 14 '16 at 13:54
  • I have alsobtried it with both /bin and /usr/bin – Arturski Jan 14 '16 at 14:02
  • In your oneliner you are using the shell module, in the playbook you're using the command module. Your playbook error still contains an error related to sudo which most likely isn't present on an esxi server. Can you update the question so that you use the shell module in the playbook without sudo and the error? – Joe Jan 14 '16 at 14:06
  • I have made the suggested chages, however the sudo: not found is still there for some reason – Arturski Jan 14 '16 at 14:33
2

I managed to get a successful answer on the Google Group for Ansible.

The resolution was to explicitly say "no" to sudo as well as turn off gathering facts.

--- 
- hosts: vhosts 
  gather_facts: false 
  sudo: no 
  remote_user: root 

Thanks to user Brian Coca at https://groups.google.com/forum/#!topic/ansible-project/7KybtGyckHk

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.