diff --git a/tasks/main.yml b/tasks/main.yml index 97871b8..8b7beba 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,9 @@ - import_tasks: user_groups.yml when: user_groups is defined +- import_tasks: move.yml + when: users is defined + - import_tasks: users.yml when: users is defined diff --git a/tasks/move.yaml b/tasks/move.yaml new file mode 100644 index 0000000..6392512 --- /dev/null +++ b/tasks/move.yaml @@ -0,0 +1,13 @@ +--- + +- name: move group + command: "groupmod --login {{ item }} {{ users[item].old_name }}" + loop: "{{ users.keys() | list }}" + when: users[item].old_name is defined + failed_when: false + +- name: move account + command: "usermod --login {{ item }} {{ users[item].old_name }}" + loop: "{{ users.keys() | list }}" + when: users[item].old_name is defined + failed_when: false diff --git a/tasks/users.yml b/tasks/users.yml index cdbba00..cc51052 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -15,6 +15,8 @@ uid: "{{ users[item].uid }}" home: "{{ users[item].home | default('/home/'+item) }}" shell: "{{ users[item].shell | default('/usr/bin/fish') }}" + create_home: true + move_home: true loop: "{{ users.keys() | list }}" notify: restart systemd-logind.service