How to use Multiple choice

69 views
Skip to first unread message

Matthias Denkler

unread,
Sep 26, 2023, 11:00:14 AM9/26/23
to Ansible Project
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?

Todd Lewis

unread,
Sep 26, 2023, 11:03:28 AM9/26/23
to ansible...@googlegroups.com, uto...@gmail.com
Outdent your "when:" line. It ("when") is a task parameter, not a "command" parameter.
--
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-proje...@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.

-- 
Todd
Reply all
Reply to author
Forward
0 new messages