๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ansible-playbooks/roles/smb/tasks/main.yml

81 lines
1.7 KiB

- name: set smb_cfg
set_fact:
smb_cfg: "{{ smb_default_config | d({}) | combine(smb_config | d({}), recursive=true) }}"
- name: install samba
include_tasks: tasks/install_packages.yml
vars:
package:
- samba-server
- alpine: samba-server-openrc
- name: ensure nmbd is disabled in conf file
lineinfile:
path: /etc/conf.d/samba
regexp: '^daemon_list='
line: 'daemon_list="smbd"'
notify: restart samba
- name: ensure syslog logging is enabled in conf file
lineinfile:
path: /etc/conf.d/samba
regexp: '^smbd_options='
line: 'smbd_options="-D --option=logging=syslog"'
notify: restart samba
- name: create user and group
include_tasks: tasks/create_user.yml
vars:
user:
name: "{{ smb_guest_user }}"
group: "{{ smb_guest_group }}"
dir: "{{ smb_storage_dir }}"
create_home: no
- name: ensure storage dir has adequate permissions
file:
path: "{{ smb_storage_dir }}"
mode: "2750"
owner: "{{ smb_guest_user }}"
group: "{{ smb_guest_group }}"
notify: restart samba
- name: ensure share directories exist
file:
path: "{{ smb_storage_dir }}/{{ item.name }}"
state: directory
mode: "2750"
owner: "{{ smb_guest_user }}"
group: "{{ smb_guest_group }}"
loop: "{{ smb_shares }}"
notify: restart samba
- name: template config file
template:
src: smb.j2
dest: /etc/samba/smb.conf
force: yes
mode: 0640
notify: restart samba
- name: flush handlers
meta: flush_handlers
- name: generate scripts
include_tasks: script_generate.yml
- name: start samba and set it to start on boot
service:
name: samba
enabled: yes
state: started