-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admin_user: move the user configuration to a dedicated role
This user is not linked to the livemgration user. Therefore, it should not be configured in the same playbook. Signed-off-by: Tanguy Raufflet <[email protected]>
- Loading branch information
1 parent
2656221
commit 1db8bf5
Showing
7 changed files
with
79 additions
and
22 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (C) 2022, RTE (http://www.rte-france.com) | ||
# Copyright (C) 2024 Savoir-faire Linux, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# This playbook adds and configures the livemigration and the admin user. | ||
# The first user is used by libvirt to migrate VM from a host to an other without halting it. | ||
# The second is used by consolevm on Debian/CentOS | ||
|
||
--- | ||
- name: Create livemigration user | ||
hosts: hypervisors:&cluster_machines | ||
gather_facts: true | ||
become: true | ||
roles: | ||
- add_livemigration_user | ||
|
||
- name: Configure admin user | ||
hosts: hypervisors:&cluster_machines | ||
gather_facts: true | ||
become: true | ||
roles: | ||
- configure_admin_user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Configure admin_user Role | ||
This role copy the root ssh key to admin user's. This user is used by Debian when using consolevm. | ||
|
||
## Requirements | ||
|
||
no requirement. | ||
|
||
## Role Variables | ||
|
||
- admin_user | ||
|
||
## Example Playbook | ||
|
||
```yaml | ||
- name: Configure admin user | ||
hosts: hypervisors | ||
gather_facts: true | ||
become: true | ||
roles: | ||
- { role: seapath_ansible.configure_admin_user } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (C) 2024 RTE | ||
# SPDX-License-Identifier: Apache-2.0 | ||
--- | ||
galaxy_info: | ||
author: "Seapath" | ||
description: Configure Admin user | ||
license: Apache-2.0 | ||
min_ansible_version: 2.9.10 | ||
platforms: | ||
- name: Debian | ||
versions: | ||
- all | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (C) 2024 Savoir-faire Linux, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
- block: | ||
- name: Get root user's home directory | ||
shell: getent passwd root | cut -d ':' -f6 | ||
register: root_home_dir | ||
- name: Fetch the root keyfile | ||
fetch: | ||
src: "{{ root_home_dir.stdout }}/.ssh/id_rsa.pub" | ||
dest: "buffer/{{ inventory_hostname }}-id_rsa.pub" | ||
flat: true | ||
- name: Copy the key to admin user's authorized_keys using Ansible module | ||
authorized_key: | ||
user: "{{ admin_user }}" | ||
state: present | ||
key: "{{ lookup('file','buffer/' + item + '-id_rsa.pub') }}" | ||
with_items: "{{ groups['hypervisors'] }}" | ||
when: ansible_distribution | regex_search("CentOS|Debian") |