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 # apt install ldb-tools
# #
# samba-tool domain provision --use-rfc2307 --interactive # 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 - name: Gather installed packages
package_facts: package_facts:
@ -24,6 +34,13 @@
# default_release: bookworm-backports # If we want to go 4.21 # default_release: bookworm-backports # If we want to go 4.21
state: latest 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 - name: Check if metadata.tdb exists and is not empty
stat: stat:
path: /var/lib/samba/private/sam.ldb.d/metadata.tdb path: /var/lib/samba/private/sam.ldb.d/metadata.tdb
@ -38,26 +55,9 @@
(metadata_tdb.stat.exists and metadata_tdb.stat.size > 0) (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" - when: "not domain_exists"
block: 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 - name: Force remove smb.conf file
file: file:
path: /etc/samba/smb.conf path: /etc/samba/smb.conf