summaryrefslogtreecommitdiffstats
path: root/vagrant/ansible/roles/samba-glusterfs.setup/tasks/main.yml
blob: b32e5540dac9c73a58796071ceb49a5f36a23ded (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- name: Run distro specific tasks for samba-glusterfs.setup
  include_tasks:
    file: "{{ distro.actions_file }}"

- name: Enable firewall for samba
  firewalld:
    service: samba
    permanent: yes
    state: enabled

- name: Create fresh directory /etc/samba/smb.shares to contain share definition
  block:
    - file:
        path: /etc/samba/smb.shares/
        state: absent
    - file:
        path: /etc/samba/smb.shares/
        state: directory
        mode: '0755'

- name: Create smb.conf
  template:
    src: smb.conf.j2
    dest: /etc/samba/smb.conf
    owner: root
    group: root
    mode: '0644'

- name: Add share configuration
  block:
    - name: Create share conf file
      template:
        src: smb_share.conf.j2
        dest: "/etc/samba/smb.shares/{{ samba_share }}.conf"
      vars:
        cluster_volume: "{{ item.cluster_volume }}"
        samba_share: "{{ item.share_name }}"
      with_items: "{{ samba_shares }}"
    - name: Include share configuration into smb.conf
      lineinfile:
        path: "/etc/samba/smb.conf"
        line: "include = /etc/samba/smb.shares/{{ item.share_name }}.conf"
        insertafter: EOF
      with_items: "{{ samba_shares }}"

- name: Mount glusterfs using fuse mount and set world writable permissions
  include_tasks:
    file: "fix_share_permissions.yml"
  vars:
    volume: "localhost:/{{ item.cluster_volume }}"
  with_items: "{{ samba_shares }}"
  run_once: true

- name: Create test users
  user:
    name: "{{ item.username }}"
    uid: "{{ item.uid }}"
    state: present
  with_items: "{{ samba_users }}"

- name: Create test users with smbpasswd
  shell: (echo {{ item.password }}; echo {{ item.password }})|smbpasswd -a {{ item.username }}
  with_items: "{{ samba_users }}"
  run_once: yes