Skip to content

Commit

Permalink
Configure logrotate for API + portal logs during Ansible provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-li committed Nov 9, 2023
1 parent be6da5f commit 8d6d1ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions bootstrap/ansible/logrotate.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ log_path }}/{{ api_log_file }} {{ log_path }}/{{ portal_log_file }} {
weekly
rotate 8
dateext
dateformat -%Y%m%d-%H%s
copytruncate
missingok
notifempty
compress
delaycompress
su {{ djangooperator }} apache
}
1 change: 1 addition & 0 deletions bootstrap/ansible/main.copyme
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ redis_host: localhost
log_path: /var/log/user_portals/cf_mybrc
portal_log_file: cf_mybrc_portal.log
api_log_file: cf_mybrc_api.log
logrotate_entry_name: cf_mybrc

# Apache settings.
# The name of the copy of the generated WSGI template in the Apache directory.
Expand Down
9 changes: 7 additions & 2 deletions bootstrap/ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
state: started
enabled: true

# Create Django application log files.
# Create Django application log files and set up log rotation.

- name: Create a parent directory for storing Django application logs
file:
Expand Down Expand Up @@ -234,6 +234,11 @@
owner: "{{ djangooperator }}"
group: apache

- name: Configure logrotate to rotate the Django API and portal logs
template:
src: "{{ git_prefix }}/{{ reponame }}/bootstrap/ansible/logrotate.tmpl"
dest: /etc/logrotate.d/{{ logrotate_entry_name }}

# Prepare the Python virtual environment for the Django application.

- name: Create Python virtual environment directory
Expand All @@ -252,7 +257,7 @@
register: venv_register
become_user: "{{ djangooperator }}"
changed_when: venv_register.stdout == "created"

- name: Upgrade pip
pip:
name: pip
Expand Down

0 comments on commit 8d6d1ff

Please sign in to comment.