Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roles/devscripts/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ cifmw_devscripts_dry_run: false
cifmw_devscripts_enable_ocp_nodes_host_routing: false
cifmw_devscripts_enable_iscsi_on_ocp_nodes: false
cifmw_devscripts_enable_multipath_on_ocp_nodes: false
cifmw_devscripts_enable_disk_discard: false
cifmw_devscripts_remove_libvirt_net_default: false
cifmw_devscripts_use_static_ip_addr: false

Expand Down
12 changes: 12 additions & 0 deletions roles/devscripts/tasks/300_post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@
tags:
- devscripts_deploy
ansible.builtin.include_tasks: 310_prepare_overlay.yml

- name: Enable discard on OCP master VM disks
when:
- cifmw_devscripts_enable_disk_discard | bool
- not cifmw_devscripts_ocp_comply | bool
- not cifmw_devscripts_ocp_online | bool
tags:
- devscripts_deploy
ansible.builtin.include_tasks: 350_disk_discard.yml
loop: "{{ range(0, cifmw_devscripts_config.num_masters | int) | list }}"
loop_control:
loop_var: _cifmw_devscripts_master_idx
63 changes: 63 additions & 0 deletions roles/devscripts/tasks/350_disk_discard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# 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.

# Called once per master index via include_tasks loop in 300_post.yml.
# Loop variable: _cifmw_devscripts_master_idx

- name: Set master VM name fact
ansible.builtin.set_fact:
_cifmw_devscripts_master_vm: >-
{{ cifmw_devscripts_config.cluster_name }}-master-{{ _cifmw_devscripts_master_idx }}

- name: Add discard=unmap to master-{{ _cifmw_devscripts_master_idx }} persistent disk config
# virt-xml updates the persistent domain XML without requiring the VM to be shut down.
# device=disk filters to storage disks only, excluding cdrom/ISO devices.
# The change takes effect on next boot.
ansible.builtin.command:
cmd: >-
virt-xml {{ _cifmw_devscripts_master_vm }}
--edit device=disk
--disk discard=unmap
--define

- name: Reboot master-{{ _cifmw_devscripts_master_idx }} to apply disk config change
ansible.builtin.command:
cmd: virsh reboot {{ _cifmw_devscripts_master_vm }}

- name: Wait for master-{{ _cifmw_devscripts_master_idx }} to return to Ready
vars:
_kubeconfig: >-
{{
(
cifmw_devscripts_repo_dir,
'ocp',
cifmw_devscripts_config.cluster_name,
'auth',
'kubeconfig'
) | ansible.builtin.path_join
}}
# OCP node names are master-N, not <cluster_name>-master-N.
ansible.builtin.command:
cmd: >-
oc wait node/master-{{ _cifmw_devscripts_master_idx }}
--for=condition=Ready
--timeout=300s
environment:
KUBECONFIG: "{{ _kubeconfig }}"
retries: 3
delay: 10
register: _cifmw_devscripts_node_wait
until: _cifmw_devscripts_node_wait.rc == 0
Loading