refactor ♻️: Refactoring the Ansible playbook to include new tasks for joining an Active Directory domain.
Added tasks to install required packages, configure Kerberos and Samba, and join the domain. This refactoring improves the automation of the setup process.
This commit is contained in:
45
tasks/main.yml
Normal file
45
tasks/main.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name:
|
||||
- samba
|
||||
- krb5-user
|
||||
- winbind
|
||||
- libpam-winbind
|
||||
- libnss-winbind
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- name: Configure Kerberos
|
||||
template:
|
||||
src: krb5.conf.j2
|
||||
dest: /etc/krb5.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Configure Samba
|
||||
template:
|
||||
src: smb.conf.j2
|
||||
dest: /etc/samba/smb.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
- name: Join the domain
|
||||
shell: |
|
||||
echo "{{ ad_admin_password }}" | net ads join -U {{ ad_admin_user }}%{{ ad_admin_password }}
|
||||
args:
|
||||
warn: false
|
||||
register: join_result
|
||||
changed_when: "'Joined domain' in join_result.stdout"
|
||||
|
||||
- name: Enable and start required services
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
loop:
|
||||
- smbd
|
||||
- nmbd
|
||||
- winbind
|
||||
Reference in New Issue
Block a user