Handle different service names across OSs

This commit is contained in:
Ian Young 2016-01-02 01:16:08 -08:00
parent 1dfadb6011
commit 751a9694d9
5 changed files with 22 additions and 4 deletions

View File

@ -2,10 +2,10 @@
--- ---
- name: Restart Samba - name: Restart Samba
service: service:
name: smb name: "{{ samba_service }}"
state: restarted state: restarted
- name: Restart WinBind - name: Restart WinBind
service: service:
name: nmb name: "{{ winbind_service }}"
state: restarted state: restarted

View File

@ -1,6 +1,12 @@
# File: roles/samba/tasks/main.yml # File: roles/samba/tasks/main.yml
--- ---
- include_vars: "{{ item }}"
with_first_found:
- "os_{{ ansible_distribution }}.yml"
- "os_{{ ansible_os_family }}.yml"
- "default.yml"
- name: Install Samba packages - name: Install Samba packages
action: "{{ ansible_pkg_mgr }} pkg={{ item }} state=installed" action: "{{ ansible_pkg_mgr }} pkg={{ item }} state=installed"
with_items: with_items:
@ -72,14 +78,14 @@
- name: Start Samba service - name: Start Samba service
service: service:
name: smb name: "{{ samba_service }}"
state: started state: started
enabled: yes enabled: yes
tags: samba tags: samba
- name: Start WindBind service - name: Start WindBind service
service: service:
name: nmb name: "{{ winbind_service }}"
state: started state: started
enabled: yes enabled: yes
tags: samba tags: samba

4
vars/default.yml Normal file
View File

@ -0,0 +1,4 @@
---
samba_service: smbd
winbind_service: nmbd

4
vars/os_CentOS.yml Normal file
View File

@ -0,0 +1,4 @@
---
samba_service: smb
winbind_service: nmb

4
vars/os_Debian.yml Normal file
View File

@ -0,0 +1,4 @@
---
samba_service: smbd
winbind_service: nmbd