thx Vladimir this works to, but I already made this:

  
--- 
- hosts: servera 
 tasks: 
   - getent: 
       database: passwd

- name: lock 
     user: 
       name: "{{ item }}" 
       password_lock: yes 
     loop: 
       - uporabnik1 
       - uporabnik2 
       - uporabnik3 
       - uporabnik4 
       - uporabnik5 
       - uporabnik15 
     when: item in my_users 
     vars: 
       my_users: "{{ getent_passwd.keys()|list }}"




On Monday, December 14, 2020 at 4:55:40 PM UTC+1 [email protected] wrote:

> On Mon, 14 Dec 2020 06:37:05 -0800 (PST)
> Jost Rakovec <[email protected]> wrote:
>
> > ... lock list of users on linux only if user exist
>
> Try this
>
> - name: Get passwd 
> getent: 
> database: passwd 
>
> - name: lock 
> user: 
> name: "{{ item }}" 
> password_lock: yes 
> loop: "{{ getent_passwd|intersect(my_users) }}"
> vars:
> my_users:
> - uporabnik1 
> - uporabnik2 
> - uporabnik3 
> - uporabnik4 
> - uporabnik5 
>
> -- 
> Vladimir Botka
>

-- 
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/6ea94937-3ebf-486c-9d49-c8cdc2e8f394n%40googlegroups.com.

Reply via email to