50 lines
1.4 KiB
YAML
50 lines
1.4 KiB
YAML
# Copyright 2025 Code Fox
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
---
|
|
|
|
- name: "Setup {{ ubuntu_passwordless_sudo_group }} group"
|
|
ansible.builtin.group:
|
|
state: present
|
|
name: "{{ ubuntu_passwordless_sudo_group }}"
|
|
|
|
- name: "Add {{ ubuntu_passwordless_sudo_group }} group to sudoers"
|
|
lineinfile:
|
|
path: /etc/sudoers
|
|
state: present
|
|
regexp: "^%{{ ubuntu_passwordless_sudo_group }}"
|
|
line: "%{{ ubuntu_passwordless_sudo_group }} ALL=(ALL) NOPASSWD: ALL"
|
|
validate: 'visudo -cf %s'
|
|
|
|
- name: Setup Groups
|
|
ansible.builtin.group:
|
|
state: present
|
|
name: "{{ item }}"
|
|
loop: "{{ ubuntu_groups }}"
|
|
|
|
- name: Setup Users
|
|
ansible.builtin.user:
|
|
state: present
|
|
shell: /bin/bash
|
|
name: "{{ item.name }}"
|
|
groups: "{{ item.groups }}"
|
|
loop: "{{ ubuntu_users }}"
|
|
|
|
- name: Set Authorized ssh key
|
|
ansible.posix.authorized_key:
|
|
state: present
|
|
user: "{{ item.name }}"
|
|
key: "{{ item.ssh_key }}"
|
|
loop: "{{ ubuntu_users }}"
|