feat: Introduce an Ansible common role for base system configuration, including packages, users, and Netplan networking, alongside Semaphore playbooks for system bootstrapping and Proxmox management.
This commit is contained in:
10
ansible/roles/common/tasks/main.yml
Normal file
10
ansible/roles/common/tasks/main.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
- name: Install common packages
|
||||
import_tasks: packages.yml
|
||||
|
||||
- name: Configure users and SSH keys
|
||||
import_tasks: users.yml
|
||||
|
||||
- name: Configure networking
|
||||
import_tasks: networking.yml
|
||||
when: common_configure_static_ip | bool
|
||||
23
ansible/roles/common/tasks/networking.yml
Normal file
23
ansible/roles/common/tasks/networking.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: Verify required variables for static IP
|
||||
fail:
|
||||
msg: "common_ip_address and common_interface_name must be defined when common_configure_static_ip is true."
|
||||
when:
|
||||
- common_configure_static_ip | bool
|
||||
- (common_ip_address is not defined or common_ip_address | length == 0 or common_interface_name is not defined)
|
||||
|
||||
- name: Install netplan.io
|
||||
apt:
|
||||
name: netplan.io
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Configure Netplan
|
||||
template:
|
||||
src: netplan_config.yaml.j2
|
||||
dest: /etc/netplan/01-netcfg.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
notify: Apply Netplan
|
||||
when: common_configure_static_ip | bool
|
||||
12
ansible/roles/common/tasks/packages.yml
Normal file
12
ansible/roles/common/tasks/packages.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Install common packages
|
||||
apt:
|
||||
name: "{{ common_packages }}"
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
18
ansible/roles/common/tasks/users.yml
Normal file
18
ansible/roles/common/tasks/users.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Ensure users exist
|
||||
user:
|
||||
name: "{{ item.name }}"
|
||||
shell: /bin/bash
|
||||
groups: sudo
|
||||
append: yes
|
||||
state: present
|
||||
loop: "{{ common_ssh_users }}"
|
||||
when: item.create_user | default(false)
|
||||
|
||||
- name: Add SSH keys
|
||||
authorized_key:
|
||||
user: "{{ item.0.name }}"
|
||||
key: "{{ item.1 }}"
|
||||
loop: "{{ common_ssh_users | subelements('keys', skip_missing=True) }}"
|
||||
loop_control:
|
||||
label: "{{ item.0.name }}"
|
||||
Reference in New Issue
Block a user