Your files are not in YAML- Syntax. Ansible should give you an error if you 
start the playbook. You dont event need it at all.

Use with_lines! Like this:

  tasks:
    - name: Create groups
      group:
        name: "{{ item }}"
        state: present
      with_lines: cat groups.yml

    - name: Create users
      user:
        name: "{{ item }}"
        state: present
      with_lines: cat users.yml


Am Freitag, 7. Juli 2017 02:34:09 UTC+2 schrieb Anfield:
>
> Trying to create groups and then users using with files and its not 
> working..How should the lists be represented in the groups vars file and 
> the users vars file?
>
> It doesnt like it just as text below..how am I supposed to list the values 
> out? How do people normally create a few users and groups like this?
>
> groups.yml
> devops
> dbadmin
> business
>
> users.yml
> tom 
> dave
> joe
>
>
> Playbook 
> --- # Users and Groups
> - hosts: localhost
>   vars_files:
>     - groups.yml
>     - users.yml
>   tasks:
>     - name: Create groups
>       group:
>         name: "{{ item }}"
>         state: present
>       with_file:
>         - groups.yml
>     - name: Create users
>       user:
>         name: "{{ item }}"
>         state: present
>       with_file:
>         - users.yml
>
>

-- 
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/487cdf37-93db-4a90-b9d0-6f62e25c94a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to