Skip to content

Commit

Permalink
clean log files before snapshot restore
Browse files Browse the repository at this point in the history
Signed-off-by: Florent CARLI <[email protected]>
  • Loading branch information
insatomcat committed Feb 27, 2025
1 parent 927853c commit 793111b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 32 deletions.
4 changes: 2 additions & 2 deletions playbooks/ci_configure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# This playbook call all necessary playbooks to configure the CI and the SEAPATH
# cluster
---
- name: Cleanup syslog-ng files and restore snapshot
- name: Cleanup /var/log folders and restore snapshot
hosts:
- cluster_machines
- standalone_machine
become: true
gather_facts: true
roles:
- ci_cleanup_syslog
- ci_cleanup_varlog
- ci_restore_snapshot

- name: CI configure skip reboot
Expand Down
21 changes: 0 additions & 21 deletions roles/ci_cleanup_syslog/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions roles/ci_cleanup_syslog/tasks/main.yml

This file was deleted.

21 changes: 21 additions & 0 deletions roles/ci_cleanup_varlog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Cleanup /var/log/ Role

This role removes the content of the /var/log/ folder

## Requirements

no requirement.

## Role Variables

no variable.

## Example Playbook

```yaml
- name: Cleanup /var/log/ folder
hosts: cluster_machines
become: true
roles:
- { role: seapath_ansible.ci_cleanup_varlog }
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
galaxy_info:
author: "Seapath"
description: removes syslog-ng logs
description: empty /var/log/ folder
license: Apache-2.0
min_ansible_version: 2.9.10
platforms:
Expand Down
34 changes: 34 additions & 0 deletions roles/ci_cleanup_varlog/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2024 RTE
# SPDX-License-Identifier: Apache-2.0

---
- name: Wipe the /var/log/ directory content
shell: rm -rf /var/log/*
changed_when: true
args:
warn: false

- name: Recreate useful folders (1)
file:
path: "{{ item }}"
state: directory
mode: 0755
loop:
- /var/log/audit
- /var/log/openvswitch
- /var/log/nginx

- name: Check if hacluster user exists
command: getent passwd hacluster
register: hacluster_check
changed_when: false
failed_when: hacluster_check.rc not in [0, 2]

- name: Recreate useful folders /var/log/crmsh/ (2)
file:
path: /var/log/crmsh/
state: directory
mode: 0755
owner: hacluster
group: haclient
when: hacluster_check.rc == 0

0 comments on commit 793111b

Please sign in to comment.