In your first example, you can't stick a "when:" twice in a single task.
You can feed it a list of multiple conditionals, but I think your problem is you are missing a "-" to seperate two different tasks. However, in the text below, there are other questions and problems, such as "username" vs "user", which I suspect selects a module, and other duplicated fields, like "groups". Another problem is the when is indented and not at "task" level, though the module should yell to you about being sent a parameter it doesn't know about. On Tue, Sep 2, 2014 at 11:52 PM, John Ross Tasipit <[email protected]> wrote: > Sorry for the mistype, on 2nd highlighted code syntax, below is the > correct one: > > > On Wednesday, September 3, 2014 11:45:32 AM UTC+8, John Ross Tasipit wrote: >> >> # The default shell for a user if none is specified >> users_default_shell: /bin/bash >> # Create home dirs for new users? Set this to false if you manage home >> # directories in some other way. >> users_create_homedirs: true >> >> # Lists of users to create and delete >> users: >> - username: username >> name: full_name_of_user >> groups: ['sudo'] >> *when: ansible_os_family == "Debian"* >> groups: ['wheel'] >> *when: ansible_os_family == "RedHat"* >> uid: 2001 >> ssh_key: >> - "ssh-dss AAAAB3N...Enter code here... >> >> When conditionals not skipping "RedHat" tasks using the above >> roles/users/default/main.yml syntax, which is for an ubuntu system >> >> I also tried doing this: >> >> > # The default shell for a user if none is specified >> users_default_shell: /bin/bash >> # Create home dirs for new users? Set this to false if you manage home >> # directories in some other way. >> users_create_homedirs: true >> >> # Lists of users to create and delete >> users: >> - username: username >> name: full_name_of_user >> groups: ['sudo'] >> >> uid: 1001 >> *when: ansible_os_family == "Debian"* >> ssh_key: >> >> - "ssh-dss AAAAB3N...Enter code here... >> >> - username: same_as_above_username >> name: full_name_of_user >> groups: ['wheel'] >> uid: 1001 >> *when: ansible_os_family == "RedHat"* >> ssh_key: >> - "ssh-dss AAAAB3N... >> >> >> ... but still not skipping "redhat" tasks >> >> Hope someone can help. TIA >> > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/076420b3-8abc-40e7-9d1e-0c5c186cd650%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/076420b3-8abc-40e7-9d1e-0c5c186cd650%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxdm_xiOTuTc1VsRjzLeRYsN4GnOf3PNdLPH9sKEX4hZQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
