From 66e8d1fc0303879c0d0c2fabe4746d9b2a50931b Mon Sep 17 00:00:00 2001 From: Vlad R Date: Wed, 2 Aug 2023 08:33:03 +0000 Subject: [PATCH] Improved the prestage_users playbook --- dnaclab_linux/prestage_users.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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