Hi
I would like to lock list of users on linux only if user exist, but have
some problems:
lock-user1.yml
---
- name: lock users
hosts: webservers
tasks:
- name: Check if user exists
getent:
database: passwd
key: "{{ item }}"
register: user_exists
ignore_errors: true
loop:
- uporabnik1
- uporabnik2
- uporabnik3
- uporabnik4
- uporabnik5
- uporabnik15
- name: lock
user:
name: "{{ item }}"
password_lock: yes
when: user_exists.rc == 0
loop:
- uporabnik1
- uporabnik2
- uporabnik3
- uporabnik4
- uporabnik5
- uporabnik15
error:
fatal: [serverb]: FAILED! => {"msg": "The conditional check 'user_exists.rc
== 0' failed. The error was: error while evaluating conditi
onal (user_exists.rc == 0): 'dict object' has no attribute 'rc'\n\nThe
error appears to be in '/home/student/acer/lock-user1.yml': line
20, column 7, but may\nbe elsewhere in the file depending on the exact
syntax problem.\n\nThe offending line appears to be:\n\n\n -
name: lock\n ^ here\n"}
question is, how can I get list of users to put them in play * - name:
lock*
thanks
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f0ae5aff-2b46-46a2-9c59-06fa033fbd24n%40googlegroups.com.