1

I'm trying to run a script on my Ansible localhost. What I have now is:

    - name: "Cherrytree - execute build.sh"
      ansible.builtin.shell: "./build.sh"
      args:
        chdir: /opt/Build/cherrytree

When I run this I get the error:

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

I'm just trying to run a script that will install cherrytree using Ansible. Any help would be appreciated.

2
  • I'm guessing you're running an old version of ansible with the new style namespaced modules; since shell: still works fine both ways, you'll be better off using the old style shell: since it will work for the foreseeable future. Pedantically, you don't need shell: for that, either, since you're not using any "shell" features, the command: task is designed for things one can exec Commented Oct 27, 2021 at 14:45
  • I just did an upgrade to Ansible and changed the task to the below and it's still not working. - name: "Cherrytree - execute build.sh" ansible.builtin.command: /opt/Build/cherrytree/build.sh Commented Oct 27, 2021 at 15:40

1 Answer 1

2

You should use the chdir argument of shell module, instead of trying to pass it with args.

- name: "Cherrytree - execute build.sh"
  ansible.builtin.shell: 
     cmd: "./build.sh"
     chdir: /opt/Build/cherrytree
Sign up to request clarification or add additional context in comments.

2 Comments

I thought that was the problem, too, but the examples show the syntax used by OP, which is why I strongly suspect it's the ansible.bulitin. part that's causing them trouble
Yes that's more likely. I originally wanted to post as comment but I have no rep points yet ..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.