ClusterAPI.imageBuilder/ansible/roles/sysprep/tasks/redhat.yml
Danny Bessems f2b0a5e7c7
Some checks failed
continuous-integration/drone Build is failing
Test dependencies
2023-02-22 21:24:42 +01:00

80 lines
2.3 KiB
YAML

# Copyright 2019 The Kubernetes Authors.
# 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.
---
- name: Define file modes
set_fact:
last_log_mode: "0644"
machine_id_mode: "0444"
- name: Get installed packages
package_facts:
- name: create the package list
set_fact:
package_list: "{{ ansible_facts.packages.keys() | join(' ') }}"
- name: exclude the packages from upgrades
lineinfile:
path: /etc/yum.conf
regexp: '^exclude='
line: exclude={{ package_list }}
- import_tasks: rpm_repos.yml
# Oracle Linux does not have temp-disk-swapfile service
- name: Disable swap service and ensure it is masked
systemd:
name: temp-disk-swapfile
enabled: no
masked: yes
when: ansible_memory_mb.swap.total != 0 and ansible_distribution_major_version|int <= 7
- name: Disable swap service and ensure it is masked on RHEL 8
systemd:
name: swap.target
enabled: no
masked: yes
when: ansible_memory_mb.swap.total != 0 and ansible_distribution_major_version|int == 8
- name: Remove RHEL subscription
block:
- name: enable repo mgmt with subscription-manager
command: subscription-manager config --rhsm.manage_repos=1
- name: Remove subscriptions
rhsm_repository:
name: '*'
state: absent
- name: Unregister system
redhat_subscription:
state: absent
- name: clean local subscription data
command: subscription-manager clean
when: ansible_distribution == "RedHat"
- name: Remove yum package caches
yum:
autoremove: yes
lock_timeout: 60
- name: Remove yum package lists
command: /usr/bin/yum -y clean all
- name: Reset network interface IDs
shell: sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-*
- name: Remove the kickstart log
file:
state: absent
path: /root/anaconda-ks.cfg