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,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