refs #8142: Refactor hosts file moved to the beginning.

This commit is contained in:
Xavi Lleó 2025-01-16 11:53:07 +01:00
parent 40c1e21e93
commit 375cb1c1cc
1 changed files with 17 additions and 17 deletions

View File

@ -14,6 +14,16 @@
# apt install ldb-tools
#
# samba-tool domain provision --use-rfc2307 --interactive
#
# If we want to go 4.21
# - name: Add Debian backports repository
# apt_repository:
# repo: "deb http://deb.debian.org/debian {{ ansible_distribution_release | lower }}-backports main"
# state: present
# - name: Update apt cache
# apt:
# update_cache: yes
- name: Gather installed packages
package_facts:
@ -24,6 +34,13 @@
# default_release: bookworm-backports # If we want to go 4.21
state: latest
- name: Add adsamba host to hosts file
blockinfile:
path: /etc/hosts
marker: "# {mark} ANSIBLE-MANAGED SAMBA DC ENTRY"
block: |
{{ ip_serverad | default(ansible_default_ipv4.address) }} {{ ansible_facts['hostname'] }}.{{ domain }}.{{ resolv_domain }} {{ realm }}
- name: Check if metadata.tdb exists and is not empty
stat:
path: /var/lib/samba/private/sam.ldb.d/metadata.tdb
@ -38,26 +55,9 @@
(metadata_tdb.stat.exists and metadata_tdb.stat.size > 0)
}}
# If we want to go 4.21
#- name: Add Debian backports repository
# apt_repository:
# repo: "deb http://deb.debian.org/debian {{ ansible_distribution_release | lower }}-backports main"
# state: present
#- name: Update apt cache
# apt:
# update_cache: yes
- when: "not domain_exists"
block:
- name: Add adsamba host to hosts file
blockinfile:
path: /etc/hosts
marker: "# {mark} ANSIBLE-MANAGED SAMBA DC ENTRY"
block: |
{{ ip_serverad | default(ansible_default_ipv4.address) }} {{ ansible_facts['hostname'] }}.{{ domain }}.{{ resolv_domain }} {{ realm }}
- name: Force remove smb.conf file
file:
path: /etc/samba/smb.conf