From: Michael Jeanson Date: Mon, 5 Jun 2023 19:01:50 +0000 (-0400) Subject: ansible: common: move root user logic to users.yml X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=170dfe8d8b13575376af75b3bc14cfb783b265c0;p=lttng-ci.git ansible: common: move root user logic to users.yml Change-Id: I3d723d81fe25993a18736b5eea619987edd7c7e4 Signed-off-by: Michael Jeanson --- diff --git a/automation/ansible/roles/common/tasks/main.yml b/automation/ansible/roles/common/tasks/main.yml index d901cf0..105eb40 100644 --- a/automation/ansible/roles/common/tasks/main.yml +++ b/automation/ansible/roles/common/tasks/main.yml @@ -22,17 +22,11 @@ when: ansible_os_family == 'Suse' - include: setup-Windows.yml - when: ansible_os_family == "Windows" + when: ansible_os_family == 'Windows' -- name: Set up authorized_keys for the root user - authorized_key: - user: 'root' - key: "{% for key in query('fileglob', 'public_keys/*.pub') %}{{ lookup('file', key) ~ '\n'}}{% endfor %}\n{% for key in lookup('vars', 'extra_root_ssh_authorized_keys', default=[]) %}{{ key ~ '\n' }}{% endfor %}" - exclusive: true +# Setup user accounts +- include: users.yml when: ansible_os_family != 'Windows' - include: users-Windows.yml - when: ansible_os_family == "Windows" - -- include: users.yml - when: ansible_os_family != "Windows" + when: ansible_os_family == 'Windows' diff --git a/automation/ansible/roles/common/tasks/users.yml b/automation/ansible/roles/common/tasks/users.yml index f5065bd..d4c05ec 100644 --- a/automation/ansible/roles/common/tasks/users.yml +++ b/automation/ansible/roles/common/tasks/users.yml @@ -1,4 +1,10 @@ --- +- name: Set up authorized_keys for the root user + authorized_key: + user: 'root' + key: "{% for key in query('fileglob', 'public_keys/*.pub') %}{{ lookup('file', key) ~ '\n'}}{% endfor %}\n{% for key in lookup('vars', 'extra_root_ssh_authorized_keys', default=[]) %}{{ key ~ '\n' }}{% endfor %}" + exclusive: true + - name: Remove ubuntu user user: name: ubuntu