Playbook #7

/home/zuul/src/opendev.org/opendev/system-config/playbooks/service-gitea.yaml

Report Status CLI Date Duration Controller User Versions Hosts Plays Tasks Results Files Records
18 Jul 2025 20:49:11 +0000 00:02:01.40 bridge99.opendev.org root Ansible 2.15.13 ara 1.7.2 (client), 1.7.2 (server) Python 3.10.12 1 1 94 92 21 0

File: /home/zuul/src/opendev.org/opendev/system-config/playbooks/roles/logrotate/tasks/main.yaml

- name: Check for filename
  fail:
    msg: Must set logrotate_file_name for logfile to rotate
  when: logrotate_file_name is not defined

- assert:
    that:
      - logrotate_frequency in ('hourly', 'daily', 'weekly', 'monthly', 'yearly', 'size')
    fail_msg: Invalid logrotate_frequency

- assert:
    that:
      - logrotate_size
    fail_msg: Must specify size for rotation
  when: logrotate_frequency == 'size'

# Hash the full path to avoid any conflicts but remain idempotent.
- name: Create a unique config name
  set_fact:
    # NOTE(ianw) 2023-02-13 : we missed that this makes files with
    # names like "*.1234.conf" when using wild-cards.  Below we have
    # dropped using the file-name component.  After we've removed them
    # we can drop this.
    _old_logrotate_generated_config_file_name: "{{ logrotate_file_name | basename }}.{{ (logrotate_file_name|hash('sha1'))[0:5] }}.conf"
    logrotate_generated_config_file_name:  "{{ (logrotate_file_name | hash('sha1'))[0:6] }}.conf"

- name: Clear out potentially confusing config files
  file:
    state: absent
    path: '/etc/logrotate.d/{{ _old_logrotate_generated_config_file_name }}'

- name: 'Install {{ logrotate_file_name }} rotatation config file'
  template:
    src: logrotate.conf.j2
    dest: '/etc/logrotate.d/{{ logrotate_config_file_name|default(logrotate_generated_config_file_name) }}'
    owner: root
    group: root
    mode: 0644