[PATCH v3 29/36] ltp: Replace /opt with a symlink to data partition

Chuck Lever <[email protected]>
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Chuck Lever <[email protected]>

The size of some cloud OS images is too small for the ltp
installation (eg, the RHEL 8 OS image on Azure is about 10GB). This
causes the ltp workflow to fail 100% of the time during the test
build step.

A simple solution is to replace /opt with a symlink to /data/opt, as
kdevops can make /data large enough to hold the ltp install.

Reviewed-by: Luis Chamberlain <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
---
 playbooks/roles/ltp/tasks/main.yml | 45 +++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/playbooks/roles/ltp/tasks/main.yml b/playbooks/roles/ltp/tasks/main.yml
index 830ec30515f0..1b966771f757 100644
--- a/playbooks/roles/ltp/tasks/main.yml
+++ b/playbooks/roles/ltp/tasks/main.yml
@@ -162,15 +162,52 @@
     target: all
     jobs: "{{ ansible_processor_nproc }}"
 
-- name: Ensure /opt has correct permissions
-  tags: ["ltp"]
+- name: Set the pathname of the install directory
+  tags: ["build", "ltp"]
+  ansible.builtin.set_fact:
+    ltp_install_dir: "{{ data_path }}/opt"
+
+- name: Remove existing ltp install directory
+  tags: ["build", "ltp"]
   become: true
   become_flags: "su - -c"
   become_method: ansible.builtin.sudo
   ansible.builtin.file:
-    state: directory
-    path: "/opt"
+    path: "{{ ltp_install_dir }}"
+    state: absent
+
+- name: Create a fresh ltp install directory
+  tags: ["build", "ltp"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.file:
+    path: "{{ ltp_install_dir }}"
+    owner: "root"
+    group: "root"
     mode: "u=rwx,g=rwx,o=rwxt"
+    state: directory
+
+- name: Remove /opt
+  tags: ["build", "ltp"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.file:
+    path: "/opt"
+    state: absent
+
+- name: Replace /opt with a symlink
+  tags: ["build", "ltp"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.file:
+    src: "{{ ltp_install_dir }}"
+    dest: "/opt"
+    owner: "root"
+    group: "root"
+    state: link
 
 - name: Install ltp on the test systems
   tags: ["ltp"]
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.