I need to add group and user without password (nologin user) using Ansible script.
I execute the following command:
$ansible-playbook deploy_nagios_client.yml -i hosts -e hosts=qa1-jetty -v
Below is main.yml
---
# Create Nagios User and Group
- name: Add group "nagios"
group: name=nagios
become: true
- name: Add user "nagios"
user: name=nagios groups=nagios password="" shell=/bin/bash append=yes comment="Nagios nologin User" state=present
become: true
If you want to create a nologin user, you should specify that to the shell
argument like this:
- name: Add user "nagios"
user:
name: nagios
groups: nagios
shell: /sbin/nologin
append: yes
comment: "Nagios nologin User"
state: present
become: true