Hello working on a ansible script to create a ssh user and on the first login to be forced to changed the password. The idea is ok, but seems like handler is not ok for the ansible 2.7.7 with python version 3.7.3. Here is the actual script and actual syntax
- name: Add {{ user }} user
user:
name: "{{ user }}"
state: present
groups: "rebel"
shell: /bin/bash
password: $1$Somesdfs$AVJ/Zl.pfCejORtGpE4p..
update_password: on_create
notify: force change password
handlers:
- name: force change password
command: "chage -d 0 {{ user }}"
when: user.changed
Here is the error
fatal: [192.168.12.147]: FAILED! => {"reason": "Syntax Error while loading YAML.\n did not find expected '-' indicator\n\nThe error appears to have been in '/home/klevin/Rebel/ansible-user-sync/edit_users/internal_add_users.yml': line 57, column 1, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\nhandlers:\n^ here\n"}
Line 57 is where the handler line start
There seems to be issue with the yam file you posted, with the syntax, specifically with spaces and "-" symbol.
I updated the yaml, since complete yaml is not provided, as below, and it ran successfully without any syntax errors.
Make sure "hosts", "tasks" and "handlers" are having correct format/spacing along with line below them for "- name:"