Initialisation depot

This commit is contained in:
Serge NOEL
2026-02-10 12:12:11 +01:00
commit c3176e8d79
818 changed files with 52573 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
---
# Bash Configuration Tasks
- name: Configure bash prompt for installer user
lineinfile:
path: /home/installer/.bashrc
regexp: '^PS1='
line: 'PS1="\033[0;32m[\u@\h]\w\033[m: $ "'
create: yes
owner: installer
group: installer
mode: '0644'
backup: yes
- name: Configure bash prompt for root user
lineinfile:
path: /root/.bashrc
regexp: '^PS1='
line: 'PS1="\033[0;31m[\u@\h]\w\033[m: # "'
create: yes
owner: root
group: root
mode: '0644'
backup: yes
- name: Configure default bash prompt in /etc/skel for new users
lineinfile:
path: /etc/skel/.bashrc
regexp: '^PS1='
line: 'PS1="\033[0;32m[\u@\h]\w\033[m: $ "'
create: yes
owner: root
group: root
mode: '0644'
backup: yes

View File

@@ -0,0 +1,63 @@
---
# Hostname configuration tasks
- name: Get current hostname
command: hostname
register: current_hostname_result
changed_when: false
- name: Validate target hostname is properly configured
fail:
msg: |
ERROR: target_hostname is not properly configured!
Current hostname: {{ current_hostname_result.stdout }}
Target hostname: {{ target_hostname | default('NOT SET') }}
Please update your inventory.yml file with the correct target_hostname.
Example:
all:
hosts:
your-server:
ansible_host: your_server_ip
target_hostname: your-desired-hostname
samba_realm: your.domain.local
The target_hostname must be set in inventory for Samba4 domain controller installation.
when:
- target_hostname is not defined or target_hostname == ""
- name: Display hostname validation status
debug:
msg: |
✅ Hostname validation passed:
Current: {{ current_hostname_result.stdout }}
Target: {{ target_hostname }}
Domain: {{ samba_realm }}
{% if current_hostname_result.stdout == target_hostname %}
✅ Hostname is already correctly set - no change needed.
{% else %}
⚠️ Hostname will be changed from {{ current_hostname_result.stdout }} to {{ target_hostname }}
{% endif %}
- name: Update /etc/hosts with new hostname
lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1\s+.*'
line: "127.0.1.1 {{ target_hostname }}.{{ samba_realm }} {{ target_hostname }}"
state: present
- name: Get current server IP address
shell: |
# Get the IP of the default route interface
ip route get 8.8.8.8 | grep -oP 'src \K\S+' | head -1
register: current_server_ip
changed_when: false
- name: Add domain entry to /etc/hosts
lineinfile:
path: /etc/hosts
regexp: "^{{ current_server_ip.stdout }}\\s+.*"
line: "{{ current_server_ip.stdout }} {{ target_hostname }}.{{ samba_realm }} {{ target_hostname }}"
state: present

View File

@@ -0,0 +1,83 @@
---
# 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