All,

I have a playbook that reads in a vars_file and creates new users and then
runs the chage command to force them to change their password on first/next
login.  Here is the playbook.

+++++++++++++++++++++++++++
---
- hosts: my-test-centos
  become: yes
  vars_files:
    - /home/rkruck/ansible-playbooks/users.yml
  tasks:
    - name:  Adding users from user.yml file
      user:
        name: "{{ item.name }}"
        state: present
        comment: "{{ item.comment }}"
        uid: "{{ item.uid }}"
        password:
$6$QAnwjCYOtTaLJkHE$k3tKqKT0B/mFugYNBjuhY7RCVU/AwvW00wTg6p/66Gp/MoWdN2QfveJxGmsdho5Hn.xduUVCuLiXHPeZDod/o1
        update_password: on_create
        createhome: yes
      with_items: "{{ users }}"

    - name: Force password change for user test-user
        command: "chage -d 0 {{ item.name }}"
      with_items: "{{ users }}"

+++++++++++++++++++++++++++++++
The first task works fine and creates the users in the user.yml file.
However, when it gets to the password force change I get the following
error:

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed in this context

The error appears to have been in
'/home/rkruck/ansible-playbooks/test.yml': line 19, column 16, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    - name: Force password change for user test-user
        command: "chage -d 0 {{ item.name }}"
               ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes.  Always quote template expression brackets when they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"

I'm confused as to what I am doing wrong.

Any help is appreciated

--Robert

-- 
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/CAJLEWMcvhcS8DHoXR%3Dmg7wdbJC%2BJg%3DmJev9YCcLxVibW8S1hxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to