Files
Maison/Migration/Ansible/roles/system/tasks/main.yml
2026-02-10 12:12:11 +01:00

84 lines
2.5 KiB
YAML

---
# System Role - Main Tasks (Simplified for compatibility)
- name: Check if server has static IP configuration
block:
- name: Get network interface configuration
shell: |
# Check for static IP in netplan configuration
if [ -d /etc/netplan ]; then
grep -r "dhcp4.*false\|addresses:" /etc/netplan/ 2>/dev/null && echo "static_found" || echo "no_static"
# Check for static IP in network interfaces (older systems)
elif [ -f /etc/network/interfaces ]; then
grep -E "^iface.*static" /etc/network/interfaces 2>/dev/null && echo "static_found" || echo "no_static"
# Check for static IP in NetworkManager
elif [ -d /etc/NetworkManager/system-connections ]; then
grep -r "method=manual\|method=static" /etc/NetworkManager/system-connections/ 2>/dev/null && echo "static_found" || echo "no_static"
else
echo "no_config_found"
fi
register: static_ip_check
changed_when: false
- name: Verify static IP configuration exists
fail:
msg: |
ERROR: No static IP configuration detected!
A Samba4 Domain Controller requires a static IP address.
Please configure a static IP before proceeding.
Current network configuration method appears to be DHCP.
To configure static IP:
- For netplan: Edit /etc/netplan/*.yaml files
- For interfaces: Edit /etc/network/interfaces
- For NetworkManager: Use nmcli or edit connection files
when: static_ip_check.stdout == "no_static" or static_ip_check.stdout == "no_config_found"
- name: Display static IP confirmation
debug:
msg: "✓ Static IP configuration detected - proceeding with installation"
when: static_ip_check.stdout == "static_found"
- name: Update package cache
apt:
update_cache: yes
cache_valid_time: 3600
- name: Install base system packages
apt:
name:
- curl
- wget
- vim
- htop
- tree
- unzip
- software-properties-common
- apt-transport-https
- ca-certificates
- gnupg
- lsb-release
- rsyslog
- mc
- sudo
- nfs-common
state: present
- name: Cloud init is not wanted on DCs - remove if present
apt:
name:
- cloudinit
state: absent
- name: Configure timezone
timezone:
name: Europe/Paris
- name: Include bash configuration tasks
include_tasks: bash_config.yml
- name: Validate hostname configuration
include_tasks: hostname.yml