From b470d74da058b9ed15737a93ea2c865fe1c97581 Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Sun, 17 Nov 2024 09:46:25 -0500 Subject: [PATCH] setup nfs on media server for media consumers --- inventory/inventory | 2 ++ playbooks/common/nfs.yml | 27 +++++++++++++++++++++++++++ templates/exports.conf.j2 | 1 + 3 files changed, 30 insertions(+) create mode 100644 playbooks/common/nfs.yml create mode 100644 templates/exports.conf.j2 diff --git a/inventory/inventory b/inventory/inventory index a042282..7f0dc26 100644 --- a/inventory/inventory +++ b/inventory/inventory @@ -35,6 +35,8 @@ foremanAlma ansible_user=ansible [windows] bane ansible_user=ansible ansible_connection=winrm ansible_winrm_transport=basic ansible_port=5985 ansible_winrm_server_cert_validation=ignore +baxter + [servers:children] doc aws diff --git a/playbooks/common/nfs.yml b/playbooks/common/nfs.yml new file mode 100644 index 0000000..adff803 --- /dev/null +++ b/playbooks/common/nfs.yml @@ -0,0 +1,27 @@ +--- +- name: installs nfs and makes common folders available to the network + hosts: baxter + become: true + vars_files: + - ../../vars/secrets.yml + tasks: + - name: install nfs core packages + ansible.builtin.apt: + name: nfs-kernel-server + state: present + + - name: write config to /etc/exports + ansible.builtin.template: + src: ../../templates/exports.conf.j2 + dest: /etc/exports + mode: '0644' + + - name: export the configuration(being safe) + ansible.builtin.shell: | + exportfs -ra + + - name: start the nfs service + ansible.builtin.service: + name: nfs-kernel-server + state: started + enabled: true diff --git a/templates/exports.conf.j2 b/templates/exports.conf.j2 new file mode 100644 index 0000000..3bec685 --- /dev/null +++ b/templates/exports.conf.j2 @@ -0,0 +1 @@ +{{nfs_dir}} {{nfs_server_ip}}(rw,sync,no_root_squash,no_subtree_check)