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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# openshift_storage_nfs_lvm
This role is useful to create and export nfs disks for openshift persistent volumes.
It does so by creating lvm partitions on an already setup pv/vg, creating xfs
filesystem on each partition, mounting the partitions, exporting the mounts via NFS
and creating a json file for each mount that an openshift master can use to
create persistent volumes.
## Requirements
* Ansible 2.2
* NFS server with NFS, iptables, and everything setup
* A lvm volume group created on the nfs server (default: openshiftvg)
* The lvm volume needs to have as much free space as you are allocating
## Role Variables
```
# Options of NFS exports.
osnl_nfs_export_options: "*(rw,sync,all_squash)"
# Directory, where the created partitions should be mounted. They will be
# mounted as <osnl_mount_dir>/<lvm volume name>
osnl_mount_dir: /exports/openshift
# Volume Group to use.
# This role always assumes that there is enough free space on the volume
# group for all the partitions you will be making
osnl_volume_group: openshiftvg
# volume names
# volume names are {{osnl_volume_prefix}}{{osnl_volume_size}}g{{volume number}}
# example: stg5g0004
# osnl_volume_prefix
# Useful if you are using the nfs server for more than one cluster
osnl_volume_prefix: "stg"
# osnl_volume_size
# Size of the volumes/partitions in Gigabytes.
osnl_volume_size: 5
# osnl_volume_num_start
# Where to start the volume number numbering.
osnl_volume_num_start: 3
# osnl_number_of_volumes
# How many volumes/partitions to build, with the size we stated.
osnl_number_of_volumes: 2
```
## Dependencies
None
## Example Playbook
With this playbook, 2 5Gig lvm partitions are created, named stg5g0003 and stg5g0004
Both of them are mounted into `/exports/openshift` directory. Both directories are
exported via NFS. json files are created in /root.
- hosts: nfsservers
become: no
remote_user: root
gather_facts: no
roles:
- role: openshift_storage_nfs_lvm
osnl_mount_dir: /exports/openshift
osnl_volume_prefix: "stg"
osnl_volume_size: 5
osnl_volume_num_start: 3
osnl_number_of_volumes: 2
## Full example
* Create an `inventory` file:
```
[nfsservers]
10.0.0.1
10.0.0.2
```
* Create an ansible playbook, say `setupnfs.yaml`:
```
- hosts: nfsservers
become: no
remote_user: root
gather_facts: no
roles:
- role: openshift_storage_nfs_lvm
osnl_mount_dir: /exports/stg
osnl_volume_prefix: "stg"
osnl_volume_size: 5
osnl_volume_num_start: 3
osnl_number_of_volumes: 2
* Run the playbook:
```
ansible-playbook -i inventory setupnfs.yml
```
## License
Apache 2.0
|