---
- hosts: localhost
tasks:
- name: Include users.yaml and setup all vars for nexus
include_vars:
file: users.yaml
name: users
- set_fact:
tmp_user:
- username: "{{ item.username }}"
first_name: "{{ item.first_name }}"
last_name: "{{ item.last_name }}"
email: "{{ item.email }}"
password: "{{ lookup('password', 'credentials/' + item.username + '/password.txt length=15 chars=ascii_letters') }}"
roles: "{{ item.roles }}"
loop: "{{ users.nexus_local_users }}"
register: tmp_users
when: "not '{{ playbook_dir }}/credentials/{{ item.username }}/password.txt' is exists"
- set_fact:
tmp_user: "{{ item.ansible_facts.tmp_user | combine(item.item) }}"
with_items: "{{ tmp_users.results }}"
register: tmp_users_sorted
when: "not item is skipped"
- set_fact:
nexus_local_users: "{{ tmp_users_sorted.results | map(attribute='item.ansible_facts.tmp_user') | list | select('defined') | list }}"
- debug:
msg: "{{ nexus_local_users }}"
---
- hosts: localhost
tasks:
- name: Include users.yaml and setup all vars for nexus
include_vars:
file: users.yaml
name: users
- set_fact:
tmp_user:
- username: "{{ item.username }}"
first_name: "{{ item.first_name }}"
last_name: "{{ item.last_name }}"
email: "{{ item.email }}"
password: "{{ lookup('password', 'credentials/' + item.username + '/password.txt length=15 chars=ascii_letters') }}"
roles: "{{ item.roles }}"
loop: "{{ users.nexus_local_users }}"
register: tmp_users
when: "not '{{ playbook_dir }}/credentials/{{ item.username }}/password.txt' is exists"
- set_fact:
tmp_user: "{{ item.ansible_facts.tmp_user | combine(item.item) }}"
with_items: "{{ tmp_users.results }}"
register: tmp_users_sorted
when: "not item is skipped"
- set_fact:
nexus_local_users: "{{ tmp_users_sorted.results | map(attribute='item.ansible_facts.tmp_user') | list | select('defined') | list }}"
- debug:
msg: "{{ nexus_local_users }}"
when: "not '{{ playbook_dir }}/credentials/{{ item.username }}/password.txt' is exists"
nexus_local_users: "{{ tmp_users_sorted.results | map(attribute='item.ansible_facts.tmp_user') | list | select('defined') | list }}"
when: "not '{{ playbook_dir }}/credentials/{{ item.username }}/password.txt' is exists"
nexus_local_users: "{{ tmp_users_sorted.results | map(attribute='item.ansible_facts.tmp_user') | list | select('defined') | list }}"
when: "not item is skipped"
when: "not item is skipped"