Ansible user home directory issue

Hi all,

ansible --version
ansible 2.7.7

I’m not sure if it’s a bug?

I’m creating a system user & group without home directory and --disabled-login but in the /etc/passwd , it’s showing as home directory created but it doesn’t exist.

Playbook:

  • name: Create sonarqube group
    group:
    name: sonarqube
    system: yes
    state: present
  • name: Create sonarqube user account
    user:
    name: sonarqube
    group: sonarqube
    create_home: no
    system: yes
    state: present
    password: ‘!’

cat /etc/passwd

sonarqube:x:998:998::/home/sonarqube:/bin/sh

cat /etc/group

sonarqube:x:998:

cat /etc/shadow

sonarqube:!:18305::::::

ls -l /home/sonarqube
ls: cannot access ‘/home/sonarqube’: No such file or directory

Hi all,

ansible --version
ansible 2.7.7

I'm not sure if it's a bug?

No, why would you think that?

I'm creating a system user & group without home directory and
--disabled-login but in the /etc/passwd , it's showing as home directory
created but it doesn't exist.

Playbook:

- name: Create sonarqube group
  group:
    name: sonarqube
    system: yes
    state: present
- name: Create sonarqube user account
  user:
    name: sonarqube
    group: sonarqube
    create_home: no
    system: yes
    state: present
    password: '!'

cat /etc/passwd
sonarqube:x:998:998::/home/sonarqube:/bin/sh

cat /etc/group
sonarqube:x:998:

cat /etc/shadow
sonarqube:!:18305::::::

ls -l /home/sonarqube
ls: cannot access '/home/sonarqube': No such file or directory

It doesn't show it as created you ls demonstrate that.

Setting HOME dir in /etc/passwd is default behavior (same as useradd/adduser commands) and
has nothing to do with the directory being created or not.

If you want other value, set the home parameter on the user module.

I thought because of the /home/user in the /etc/passwd.

Ok,thanks for the clarification.