f1132fcc47
All references to Gentoo, SUSE, Debian stretch and Centos-7 are removed. Conditional tasks, ternary operators and variables are simplified where possible OS specific variables files are generalised where possible Change-Id: I55037805e59cb6d727593f467e98568a4c030e74
84 lines
2.2 KiB
YAML
84 lines
2.2 KiB
YAML
---
|
|
# Copyright 2017, BBC R&D
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Create an NFS backing store
|
|
hosts: localhost
|
|
user: root
|
|
become: true
|
|
connection: local
|
|
tasks:
|
|
- name: Install NFS packages
|
|
package:
|
|
name: "{{ nfs_package[ansible_facts['distribution'].split()[0] | lower] }}"
|
|
state: present
|
|
|
|
- name: create the system group for nfs
|
|
group:
|
|
name: "nfs-user"
|
|
gid: "10000"
|
|
state: "present"
|
|
system: "yes"
|
|
|
|
- name: Create the system user for nfs
|
|
user:
|
|
name: "nfs-user"
|
|
uid: "10000"
|
|
group: "nfs-user"
|
|
comment: "nfs-user"
|
|
shell: "/bin/false"
|
|
system: "yes"
|
|
createhome: "yes"
|
|
home: "/srv/nfs"
|
|
|
|
- name: Create base directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: "directory"
|
|
owner: "nfs-user"
|
|
group: "nfs-user"
|
|
with_items:
|
|
- "/srv/nfs/test"
|
|
|
|
- name: Create exports file
|
|
lineinfile:
|
|
path: /etc/exports
|
|
line: '{{ item }} 127.0.0.1/255.0.0.0(rw,sync,no_subtree_check,insecure,all_squash,anonuid=10000,anongid=10000)'
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
create: yes
|
|
with_items:
|
|
- "/srv/nfs/test"
|
|
register: nfs_exportfs
|
|
|
|
- name: Restart nfs-server
|
|
systemd:
|
|
daemon_reload: yes
|
|
name: "nfs-server"
|
|
enabled: "yes"
|
|
state: "restarted"
|
|
when:
|
|
- nfs_exportfs is changed
|
|
|
|
- name: Export NFS
|
|
command: exportfs -rav
|
|
tags:
|
|
- skip_ansible_lint
|
|
vars:
|
|
nfs_package:
|
|
ubuntu: "nfs-kernel-server"
|
|
debian: "nfs-kernel-server"
|
|
centos: "nfs-utils"
|