Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a user without .bashrc in Ansible?

Tags:

linux

ansible

I would like to create a user with a clean home directory, but when using the user module, I get by default the files .bashrc, .bash_logout and .profile (these are the defaults in /etc/skel/)

How do I create a user without them?

Relevant part of playbook:

- name: Create user
  become: true
  user:
    name: johndoe
    state: present
    shell: /bin/bash
    system: no
    createhome: yes
    home: /data/johndoe
like image 725
Richard de Wit Avatar asked Nov 25 '25 10:11

Richard de Wit


1 Answers

You have to set skeleton to /dev/null, like this:

- name: Create user
  become: true
  user:
    name: johndoe
    state: present
    shell: /bin/bash
    system: no
    createhome: yes
    home: /data/johndoe
    skeleton: /dev/null      # <- add this line
like image 66
Richard de Wit Avatar answered Nov 27 '25 00:11

Richard de Wit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!