ansible create user: no default .bashrc created?

I am creating users with these tasks:

- name: ensure home directory
  sudo: yes
  file: path={{item.home}} state=directory
  with_items: users

- name: create user {{}}
  sudo: yes
  user: name={{}} home={{item.home}} shell=/bin/bash group={{}} groups={{item.groups}} password={{item.password}} state=present
  with_items: users

but it seems that a ~/.bashrc per user is not created in their home directory.

Is there a way to create a default basic .bashrc file?



Starting from Ansible 2.0, you can pass along a skeleton option:

Optionally set a home skeleton directory. Requires createhome option!

This works for me:

- name: "Create deployment user"
    name: "foobar"
    groups: "sudo"
    append: yes
    skeleton: "/etc/skel"
    createhome: yes

I used a specific path for the home folders (different than the traditionnal /home/user1 folder): /specific/path/home/user1

Since I had an error that the path /specific/path/home/user1 could not be created when I was creating the user1, I then created the home folders before creating the users. However if the home folder already exists when a user is created, the default .bashrc is not copied.

You have to add append=yes at the end of the user command user:

- name: Add users
    name: '{{}}'
    home: '{{item.home}}'
    shell: /bin/bash
    group: '{{}}'
    groups: '{{item.groups}}'
    password: '{{item.password}}'
    state: present
    append: yes 
with_items: users

Need Your Help

ionic Angularjs vs jquery : $http.jsonp() vs jquery.ajax

javascript jquery ajax json angularjs

I am trying to get some json data from an api it works with jquery but doesn't work with angularjs?

Convert integer matrix to bitstring?

matrix bit-manipulation

I have a 4x4 integer matrix (called tb) which I can create from a int64_t bitstring (called state) as follows: