e_scape
e_scape

Reputation: 99

Ansible cant run any command or shell

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.

Upvotes: 3

Views: 9878

Answers (2)

Steve Dowling
Steve Dowling

Reputation: 1999

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.

Upvotes: 0

larsks
larsks

Reputation: 312790

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

Upvotes: 6

Related Questions