diff --git a/.ansible-lint b/.ansible-lint index c4653df5..2220007c 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -4,3 +4,5 @@ warn_list: exclude_paths: - devsetup/standalone/network_data.yaml - devsetup/standalone/deployed_network.yaml +skip_list: + - no-handler diff --git a/devsetup/Makefile b/devsetup/Makefile index 24a3e394..6c6b5b8b 100644 --- a/devsetup/Makefile +++ b/devsetup/Makefile @@ -136,12 +136,16 @@ IPV6_LAB_SNO_OCP_MIRROR_URL ?= https://mirror.openshift.com/pub/openshift- # default number of instances to deploy via edpm_deploy_instance NUMBER_OF_INSTANCES ?=1 +# base directory used for the nfs server +NFS_HOME ?= /home/nfs + STANDALONE_COMPUTE_DRIVER ?= libvirt CLEANUP_DIR_CMD ?= rm -Rf define vars ${1}: export CLEANUP_DIR_CMD=${CLEANUP_DIR_CMD} +${1}: export NFS_HOME=${NFS_HOME} endef ##@ General @@ -168,6 +172,20 @@ download_tools: ## Runs an ansible playbook to install required tools with the v -v -i hosts --tags ${DOWNLOAD_TOOLS_SELECTION} \ download_tools.yaml +##@ Configure nfs server on the host +.PHONY: nfs +nfs: ## Runs an ansible playbook to install nfs rpms, uses per default /home/nfs as the data dir and exports shared for OSP services. + $(eval $(call vars)) + ANSIBLE_FORCE_COLOR=true ansible-playbook \ + -v -i hosts nfs.yaml + +.PHONY: nfs_cleanup +nfs_cleanup: ## removes /etc/exports.d/osp.exports, reloads nfs exports and deletes /home/nfs + $(eval $(call vars)) + sudo rm -f /etc/exports.d/osp.exports + sudo exportfs -ra + sudo ${CLEANUP_DIR_CMD} ${NFS_HOME} + ##@ CRC .PHONY: crc crc: ## Deploys CRC using CRC_URL to download and install CRC, KUBEADMIN_PWD as the password which defaults to 12345678 and PULL_SECRET to specify the file containing the pull secret, defaults to ${PWD}/pull-secret.txt. To change the default memory and/or cpus for the VM use `CPUS=X MEMORY=Y DISK=Z make crc`. diff --git a/devsetup/nfs.yaml b/devsetup/nfs.yaml new file mode 100644 index 00000000..3a8ad25c --- /dev/null +++ b/devsetup/nfs.yaml @@ -0,0 +1,10 @@ +#!/usr/bin/env ansible-playbook +--- +- name: Configure nfs server and exports + become: true + hosts: localhost + gather_facts: true + roles: + - role: nfs_server + vars: + nfs_home: "{{ lookup('ansible.builtin.env', 'NFS_HOME')|default('/home/nfs', True) }}" diff --git a/devsetup/roles/nfs_server/defaults/main.yaml b/devsetup/roles/nfs_server/defaults/main.yaml new file mode 100644 index 00000000..d76207e2 --- /dev/null +++ b/devsetup/roles/nfs_server/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +nfs_home: /home/nfs diff --git a/devsetup/roles/nfs_server/tasks/main.yaml b/devsetup/roles/nfs_server/tasks/main.yaml new file mode 100644 index 00000000..ce3541e9 --- /dev/null +++ b/devsetup/roles/nfs_server/tasks/main.yaml @@ -0,0 +1,54 @@ +--- +- name: Install NFS packages + ansible.builtin.yum: + name: nfs-utils + state: present + +- name: Start and enable NFS services + ansible.builtin.systemd: + name: nfs-server + state: started + enabled: true + +- name: Open nfsv4 port 2049/tcp (running config, non permanent) + ansible.builtin.iptables: + chain: INPUT + destination_port: 2049 + protocol: tcp + ctstate: NEW + syn: match + jump: ACCEPT + comment: Accept new NFS connections. + +- name: Create NFS shares + ansible.builtin.file: + path: "{{ nfs_home }}/{{ item }}" + state: directory + mode: '0777' + group: nobody + owner: nobody + with_items: + - glance + - glance-staging + - nova + - cinder + - cinder_image_conversion + +- name: Configure exports + ansible.builtin.lineinfile: + path: /etc/exports.d/osp.exports + line: "{{ nfs_home }}/{{ item }} *(rw,sync,no_root_squash)" + create: true + mode: '0644' + with_items: + - glance + - glance-staging + - nova + - cinder + - cinder_image_conversion + register: _export_shares + +- name: Export NFS share to the server + when: + - _export_shares.changed + ansible.builtin.command: "exportfs -r"