an Ansible noobie here.
The issue i'm having is the when I used "command" module to execute a command, it will fail. Tried this on a remote host and localhost as well.
BASIC INFO:
Version: ansible 2.0.0 (devel 2c9d1257ba)
Core: (detached HEAD 5983d64d77) last updated 2015/05/30 07:22:33 (GMT +800)
Extras: (detached HEAD 1276420a3a) last updated 2015/05/30 07:22:41 (GMT +800)
Ansible Host file
local ansible_ssh_host=127.0.0.1 ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=a
Command
ansible -i ansible_hosts -m command -a "/usr/bin/ls" local
Actual Result
local | FAILED! => {u'msg': u'Traceback (most recent call last):\r\n
File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 2139, in <module>\r\n main()\r\n File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 158, in main\r\n module =
CommandModule(argument_spec=dict())\r\n File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 606, in __init__\r\n self._check_for_check_mode()\r\n File
"/root/.ansible/tmp/ansible-tmp-1436165888.5-23845581569171/command",
line 1142, in _check_for_check_mode\r\n for (k,v) in
self.params.iteritems():\r\nAttributeError: \'tuple\' object has no
attribute \'iteritems\'\r\n', u'failed': True, u'changed': False,
u'parsed': False, u'invocation': {u'module_name': u'command',
u'module_args': {u'_raw_params': u'/usr/bin/ls'}}}
Was there something wrong in my config?
You can change and specify the directory path where you want to run the command using the chdir parameter. This parameter is available for both command and shell module. You can also change the default shell by specifying the absolute path of the require shell in the executable parameter.
You can use ignore_errors to continue on in spite of the failure. The ignore_errors directive only works when the task is able to run and returns a value of 'failed'. It does not make Ansible ignore undefined variable errors, connection failures, execution issues (for example, missing packages), or syntax errors.
Ansible changed_when property or parameters is defined to deal with the output of the specific task once a task is triggered on the remote node and based on the return code or the output, we can determine whether the task should be reported in the ansible statistic or need to use the trigger to handle the condition and ...
It sounds like this question was resolved by running git submodule update --init --recursive
in the checkout of Ansible that was being used.
If others run into the same problem, the easiest fix would be to install Ansible from the system package manager of the host from which it's being run, or pip install Ansible
in a virtualenv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With