From 4dc4d713e8427a34c21ac6078683455ab01bce28 Mon Sep 17 00:00:00 2001 From: Maciej Wereski Date: Wed, 28 Jul 2021 09:48:17 +0000 Subject: noheat deployment: setup NFS server and clients Issue-ID: INT-1601 Signed-off-by: Maciej Wereski Change-Id: I8de10257f75e662e8e8809061ec818def0d3f048 --- deployment/noheat/cluster-rke/ansible/create.yml | 5 ++ .../ansible/roles/setup_nfs/defaults/main.yml | 2 + .../ansible/roles/setup_nfs/tasks/main.yml | 53 ++++++++++++++++++++++ .../ansible/roles/setup_nfs/templates/exports.j2 | 1 + 4 files changed, 61 insertions(+) create mode 100644 deployment/noheat/cluster-rke/ansible/roles/setup_nfs/defaults/main.yml create mode 100644 deployment/noheat/cluster-rke/ansible/roles/setup_nfs/tasks/main.yml create mode 100644 deployment/noheat/cluster-rke/ansible/roles/setup_nfs/templates/exports.j2 (limited to 'deployment/noheat') diff --git a/deployment/noheat/cluster-rke/ansible/create.yml b/deployment/noheat/cluster-rke/ansible/create.yml index fa24fb1d6..7304dbb6c 100644 --- a/deployment/noheat/cluster-rke/ansible/create.yml +++ b/deployment/noheat/cluster-rke/ansible/create.yml @@ -1,4 +1,9 @@ --- +- name: Install NFS + hosts: all + become: yes + roles: + - role: setup_nfs - name: Set up bastion node for ONAP Docker registry hosts: "control0" become: yes diff --git a/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/defaults/main.yml b/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/defaults/main.yml new file mode 100644 index 000000000..da66bfb38 --- /dev/null +++ b/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/defaults/main.yml @@ -0,0 +1,2 @@ +--- +nfs_mountpoint: "/dockerdata-nfs" diff --git a/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/tasks/main.yml b/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/tasks/main.yml new file mode 100644 index 000000000..398b56317 --- /dev/null +++ b/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/tasks/main.yml @@ -0,0 +1,53 @@ +- name: Install NFS common + apt: + name: nfs-common + state: present + when: nfs_role is defined + +- name: Install NFS server + apt: + name: nfs-kernel-server + state: present + when: nfs_role is defined and nfs_role == "server" + +- name: Remove leftovers + file: + path: "{{ nfs_mountpoint }}" + state: absent + when: nfs_role is defined + +- name: Create dockerdata directory + file: + path: "{{ nfs_mountpoint }}" + state: directory + mode: '0777' + owner: nobody + group: nogroup + when: nfs_role is defined + +- name: Configure NFS server + template: + src: "exports.j2" + dest: "/etc/exports" + owner: root + group: root + mode: '0644' + when: nfs_role is defined and nfs_role == "server" + +- name: Restart NFS server + service: + name: nfs-kernel-server + state: restarted + enabled: yes + when: nfs_role is defined and nfs_role == "server" + +- name: Configure NFS clients + mount: + path: "{{ nfs_mountpoint }}" + src: "{{ hostvars[groups['nfs'][0]]['ansible_default_ipv4']['address'] }}:{{ nfs_mountpoint }}" + fstype: nfs + opts: auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 + dump: 0 + passno: 0 + state: mounted + when: nfs_role is defined and nfs_role == "client" diff --git a/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/templates/exports.j2 b/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/templates/exports.j2 new file mode 100644 index 000000000..edadcb9bd --- /dev/null +++ b/deployment/noheat/cluster-rke/ansible/roles/setup_nfs/templates/exports.j2 @@ -0,0 +1 @@ +{{ nfs_mountpoint }} {% for host in (groups['control'] | union(groups['workers'])) %} {{ hostvars[host]['ansible_default_ipv4']['address'] }}{% endfor %}(rw,sync,no_root_squash,no_subtree_check) -- cgit 1.2.3-korg