Like what? You aren't looping anything in those tasks you showed. You'll need to use with_items to actually do a loop.
On Mon, Jun 5, 2017 at 8:15 PM Rob Dumas <robdu...@gmail.com> wrote: > So I can't loop over variables like this? > > > On Monday, June 5, 2017 at 5:58:23 PM UTC-5, Matt Martz wrote: > >> default_users is a list, you need to loop over it. Look into with_items >> >> On Mon, Jun 5, 2017 at 5:37 PM Rob Dumas <robd...@gmail.com> wrote: >> > I'm trying to set up a few users on a Linux box using Ansible and I keep >>> running into a weird error. First, here's the playbook: >>> >>> --- >>> - name: common/users | ensure presence, gid of default group >>> group: >>> name: "{{ default_group.name }}" >>> gid: "{{ default_group.gid }}" >>> state: present >>> >>> - name: common/users | ensure presence, sudo privileges of admin users >>> user: >>> name: "{{ default_users.username }}" >>> uid: "{{ default_users.uid }}" >>> group: "{{ default_group.name }}" >>> groups: sudo >>> state: present >>> >>> and here's the `group_vars/all` file: >>> >>> --- >>> default_group: >>> gid: 2000 >>> name: groupname >>> default_users: >>> - username: user1 >>> uid: 2001 >>> - username: user2 >>> uid: 2002 >>> >>> However, when I run the playbook, I get the following error: >>> >>> fatal: [vm-server]: FAILED! => {"failed": true, "msg": "the field 'args' >>> has an invalid value, which appears >>> to include a variable that is undefined. The error was: 'list object' >>> has no attribute 'username' >>> >>> The error appears to have been in >>> '/vagrant/roles/common/tasks/users.yml': line 8, column 3, but may >>> be elsewhere in the file depending on the exact syntax problem. >>> >>> The offending line appears to be: >>> >>> - name: common/users | ensure presence, sudo privileges of admin users >>> ^ here"} >>> >>> My list object "default_users" is supposed to set up two users and each >>> one definitely contains the attribute "username", so why is it refusing to >>> create the users and giving me this error? My YAML seems to follow the >>> syntax and it passes YAMLlint <http://www.yamllint.com/> with no >>> problem. >>> >>> -- >>> 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 post to this group, send email to ansible...@googlegroups.com. >> >> >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/09b3b7b9-763f-40f4-8fb3-6c005c51aee2%40googlegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/09b3b7b9-763f-40f4-8fb3-6c005c51aee2%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> Matt Martz >> @sivel >> sivel.net >> > -- > 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 post to this group, send email to ansible-project@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/05523441-576b-4a7a-a23e-c791c6539271%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/05523441-576b-4a7a-a23e-c791c6539271%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- 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 post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v-PDrTe8kh2yg5YO7g%3DQDPEAsRBDOuan1gZK%3DOmuW1_%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.