refactor ♻️: Refactor logrotate tasks for better readability and consistency - Rename 'logrotate reload' task to 'Logrotate reload' - Refactor task names in subscription.yml for better organization and clarity
This commit refactors the logrotate tasks by renaming them for better readability and consistency, and refactoring task names in `subscription.yml` for improved organization and clarity.
This commit is contained in:
@@ -15,6 +15,6 @@
|
|||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
daemon_reexec: true
|
daemon_reexec: true
|
||||||
|
|
||||||
- name: logrotate reload
|
- name: Logrotate reload
|
||||||
ansible.builtin.command: logrotate /etc/logrotate.conf
|
ansible.builtin.command: logrotate /etc/logrotate.conf
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
@@ -13,98 +13,98 @@
|
|||||||
|
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Check if {{ item }} exists
|
- name: logrotate | Check if {{ item }} exists
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
register: logrotate_file
|
register: logrotate_file
|
||||||
|
|
||||||
- name: Configure {{ item }}
|
- name: logrotate | Configure {{ item }}
|
||||||
|
when: logrotate_file.stat.exists
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Backup {{ item }} once
|
- name: logrotate | Backup {{ item }} once
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "{{ item }}.original"
|
dest: "{{ item }}.original"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
remote_src: true
|
remote_src: true
|
||||||
args:
|
args:
|
||||||
creates: "{{ item }}.original"
|
creates: "{{ item }}.original"
|
||||||
|
|
||||||
- name: Ensure daily rotation
|
- name: logrotate | Ensure daily rotation
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s*weekly'
|
regexp: '^\s*weekly'
|
||||||
replace: 'daily'
|
replace: 'daily'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Set rotate (number of retained logs)
|
- name: logrotate | Set rotate (number of retained logs)
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^(\s*rotate\s+).*'
|
regexp: '^(\s*rotate\s+).*'
|
||||||
line: ' rotate {{ proxmox_logrotate_rotate }}'
|
line: ' rotate {{ proxmox_logrotate_rotate }}'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*daily'
|
insertafter: '^\s*daily'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure maxsize is set
|
- name: logrotate | Ensure maxsize is set
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^(\s*maxsize\s+).*'
|
regexp: '^(\s*maxsize\s+).*'
|
||||||
line: ' maxsize {{ proxmox_logrotate_maxsize }}'
|
line: ' maxsize {{ proxmox_logrotate_maxsize }}'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*rotate'
|
insertafter: '^\s*rotate'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure Compress
|
- name: logrotate | Ensure Compress
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s*compress\b'
|
regexp: '^\s*compress\b'
|
||||||
line: ' compress'
|
line: ' compress'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*maxsize'
|
insertafter: '^\s*maxsize'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure delaycompress
|
- name: logrotate | Ensure delaycompress
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s*delaycompress\b'
|
regexp: '^\s*delaycompress\b'
|
||||||
line: ' delaycompress'
|
line: ' delaycompress'
|
||||||
state: present
|
state: present
|
||||||
insertafter: '^\s*compress'
|
insertafter: '^\s*compress'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
when: logrotate_file.stat.exists
|
|
||||||
|
|
||||||
|
|
||||||
# only for logrotate.conf
|
# only for logrotate.conf
|
||||||
|
|
||||||
- name: Uncomment dateext if commented
|
- name: logrotate | Uncomment dateext if commented
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*#\s*(dateext)\b'
|
regexp: '^\s*#\s*(dateext)\b'
|
||||||
replace: '\1'
|
replace: '\1'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Uncomment compress if commented
|
- name: logrotate | Uncomment compress if commented
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*#\s*(compress)\b'
|
regexp: '^\s*#\s*(compress)\b'
|
||||||
replace: '\1'
|
replace: '\1'
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure missingok is present
|
- name: logrotate | Ensure missingok is present
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*missingok\b'
|
regexp: '^\s*missingok\b'
|
||||||
line: 'missingok'
|
line: 'missingok'
|
||||||
state: present
|
state: present
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|
||||||
- name: Ensure notifempty is present
|
- name: logrotate | Ensure notifempty is present
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/logrotate.conf
|
path: /etc/logrotate.conf
|
||||||
regexp: '^\s*notifempty\b'
|
regexp: '^\s*notifempty\b'
|
||||||
line: 'notifempty'
|
line: 'notifempty'
|
||||||
state: present
|
state: present
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
notify: logrotate reload
|
notify: Logrotate reload
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure /usr/local/bin exists
|
- name: subscription | Ensure /usr/local/bin exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /usr/local/bin
|
path: /usr/local/bin
|
||||||
state: directory
|
state: directory
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
mode: "0755"
|
mode: "0755"
|
||||||
when: proxmoxlib_js.stat.exists
|
when: proxmoxlib_js.stat.exists
|
||||||
|
|
||||||
- name: Install APT post-invoke hook for nag removal
|
- name: subscription | Install APT post-invoke hook for nag removal
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/apt/apt.conf.d/no-nag-script
|
dest: /etc/apt/apt.conf.d/no-nag-script
|
||||||
owner: root
|
owner: root
|
||||||
|
|||||||
Reference in New Issue
Block a user