summaryrefslogtreecommitdiffstats
path: root/vagrant/ansible/roles/samba-glusterfs.setup/tasks/main.yml
blob: dfd6fdf3a7a16c0238060ac3f9b3f1b9d0c3f70c (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
- name: Install samba and samba-vfs-glusterfs packages
  yum:
    name:
      - samba
      - samba-vfs-glusterfs
    state: present

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

- name: Install libsemanage-python. This is needed for the seboolean ansible command
  yum: name=libsemanage-python state=present

- name: Selinux - Allow Samba to access glusterfs services
  seboolean:
    name: samba_load_libgfapi
    state: yes
    persistent: yes

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

- name: Set volume options
  gluster_volume:
    state: present
    name: "{{ gluster_cluster_volume }}"
    options:
      {
        features.cache-invalidation: 'on',
        features.cache-invalidation-timeout: '600',
        performance.cache-samba-metadata: 'on',
        performance.stat-prefetch: 'on',
        performance.cache-invalidation: 'on',
        performance.md-cache-timeout: '600',
        network.inode-lru-limit: '200000',
        performance.nl-cache: 'on',
        performance.nl-cache-timeout: '600',
        performance.readdir-ahead: 'on',
        performance.parallel-readdir: 'on',
      }
  run_once: true

- name: Mount glusterfs using fuse mount and set world writable permissions
  block:
    - name: Mount gluster volume using glusterfs
      mount:
        path: /mnt-fuse
        src: 'localhost:/vol'
        fstype: glusterfs
        state: mounted

    - name: Set permission of share root to 0777
      file:
        path: /mnt-fuse
        mode: '0777'

    - name: Unmount mounted fuse glusterfs mount
      mount:
        path: /mnt-fuse
        state: absent
  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