Outdent your "when:" line. It ("when") is a task parameter, not a "command" parameter.

On 9/26/23 10:54 AM, 'Matthias Denkler' via Ansible Project wrote:
Hi there,
i am pretty at the beginning of my use of ansible.
But I have a woring script to use ansible to put fresh installed ubuntu machines into our AD to use groups to manage user access.
Now this script has to grow for more groups to come.
So I thought multiple choice is a cool thing.
So I placed this in my playbook.
"
    - name: "institute"
      prompt: "Wähle das Institut. \n1- Institute1\n2- Institute2\n"
      private: no
"
and I use this in the role as follows
"
- name: make admins sudo
  ansible.builtin.lineinfile:
          dest: /etc/sudoers
          line: '% Name_of_the_AD-Group ALL=(ALL:ALL) ALL'
          state: present
          insertafter: '%sudo   ALL=(ALL:ALL) ALL'
          when: ( institute == "1" )
"
The Error is as follows:
fatal: [xxx.xxx.xxx.xxx]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "_raw_params": "realm permit --groups 'Name_of_the_AD-Group'",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": false,
            "when": "( institute == \"1\" )"
        }
    }
}

MSG:

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

Anybody a Tip for me?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c08e0222-03c2-4081-9dd6-47b1833d7feen%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c08e0222-03c2-4081-9dd6-47b1833d7feen%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Todd

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/728e08ba-3703-e34e-dabd-c3aaee00b362%40gmail.com.

Reply via email to