diff --git a/dnaclab_linux/prestage_users.yaml b/dnaclab_linux/prestage_users.yaml index 9ea61f8..80e5f5d 100644 --- a/dnaclab_linux/prestage_users.yaml +++ b/dnaclab_linux/prestage_users.yaml @@ -9,7 +9,23 @@ tasks: - - name: Configure NCA Automation team users for server access + - name: Check if OS is RHEL or other + ansible.builtin.stat: + path: "/etc/redhat-release" + register: outcome + + - name: Configure NCA Automation team users for server access (RHEL only) + ansible.builtin.user: + name: "{{ item.key }}" + comment: "Added via Ansible" + home: "/home/{{ item.key }}" + shell: "/bin/bash" + group: "wheel" + password: "{{ item.value }}" + loop: "{{ lookup('dict', users) }}" + when: outcome.stat.exists + + - name: Configure NCA Automation team users for server access (non-RHEL) ansible.builtin.user: name: "{{ item.key }}" comment: "Added via Ansible" @@ -18,3 +34,4 @@ group: "sudo" password: "{{ item.value }}" loop: "{{ lookup('dict', users) }}" + when: not outcome.stat.exists