3

I have troubles running any command or shell on my RPi.

When I use the following code:

- name: Example command
  ansible.builtin.command:
    cmd: "cat /etc/motd"

I get this error:

Unsupported parameters for (ansible.builtin.command) module: cmd Supported parameters include: _raw_params, _uses_shell, argv, chdir, creates, executable, removes, stdin, stdin_add_newline, strip_empty_ends, warn"}

When i try this:

- name: Example command
  ansible.builtin.command: cat /etc/motd

I get this error:

ERROR! this task 'ansible.builtin.command' has extra params, which is only allowed in the following modules: import_tasks, raw, include, include_tasks, include_vars, include_role, script, set_fact, win_command, add_host, shell, import_role, group_by, command, win_shell, meta

I get the same errors when I try to use ansible.builtin.shell. I tried several other commands but without any luck. It seems I cant run ANY command without these 2 errors.

I use ansible 2.9.6. I tried to upgrade it but apt said its the newest available.

Any help would be appreciated.

e_scape
  • 89
  • 1
  • 3
  • 8

2 Answers2

6

Replace ansible.builtin.command with command. Your version of Ansible is too old for the newer syntax. This works with Ansible 2.9.6:

- hosts: localhost
  gather_facts: false
  tasks:
    - command: cat /etc/motd
larsks
  • 277,717
  • 41
  • 399
  • 399
  • thank you, that works. I dont understand why in ansible documentation for 2.9 version is written to use ansible.builtin.command. – e_scape Mar 02 '21 at 08:32
  • 1
    I think the problem is that later version of 2.9 *do* support the new syntax, and Ansible doesn't make available docs for minor versions (i.e. you won't find docs for 2.9.x and 2.9.y, but just 2.9). If you were to just grab the sources for 2.9.6, you could build your own local version of the docs that would be correct. – larsks Mar 02 '21 at 11:55
0

I fixed this by removing the version of Ansible that was installed by apt and then installing it again via pip by following the install instructions on the Ansible docs website.

Steve Dowling
  • 1,919
  • 1
  • 13
  • 18