From a7066a8115f54cb7bff730a33e236a36c36c7ef4 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Mon, 24 Aug 2020 01:34:51 +0200 Subject: [PATCH] move user --- tasks/main.yml | 3 +++ tasks/move.yaml | 13 +++++++++++++ tasks/users.yml | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 tasks/move.yaml 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