Ansibly the start of fresh logging

Replace start fresh logging bash logic for
start_fresh_logging role

Change-Id: I0177fcce93087b6a7081f6f96ac1fec3fdd9f53f
This commit is contained in:
Ricardo Carrillo Cruz 2016-11-24 15:43:59 +00:00
parent c920f1ad98
commit 161fa62663
3 changed files with 58 additions and 21 deletions

View File

@ -584,27 +584,6 @@ function setup_host {
local xtrace=$(set +o | grep xtrace)
set -o xtrace
# Start with a fresh syslog
if which journalctl ; then
# save timestamp and use journalctl to dump everything since
# then at the end
date +"%Y-%m-%d %H:%M:%S" | sudo tee $BASE/log-start-timestamp.txt
else
# Assume rsyslog, move old logs aside then restart the service.
sudo stop rsyslog
sudo mv /var/log/syslog /var/log/syslog-pre-devstack
sudo mv /var/log/kern.log /var/log/kern_log-pre-devstack
sudo touch /var/log/syslog
sudo chown /var/log/syslog --ref /var/log/syslog-pre-devstack
sudo chmod /var/log/syslog --ref /var/log/syslog-pre-devstack
sudo chmod a+r /var/log/syslog
sudo touch /var/log/kern.log
sudo chown /var/log/kern.log --ref /var/log/kern_log-pre-devstack
sudo chmod /var/log/kern.log --ref /var/log/kern_log-pre-devstack
sudo chmod a+r /var/log/kern.log
sudo start rsyslog
fi
# Create a stack user for devstack to run as, so that we can
# revoke sudo permissions from that user when appropriate.
sudo useradd -U -s /bin/bash -d $BASE/new -m stack

View File

@ -0,0 +1,57 @@
---
- name: Check for /bin/journalctl file
command: which journalctl
changed_when: False
failed_when: False
register: which_out
- block:
- name: Get current date
command: date +"%Y-%m-%d %H:%M:%S"
register: date_out
- name: Copy current date to log-start-timestamp.txt
copy:
dest: "{{ BASE }}/log-start-timestamp.txt"
content: "{{ date_out.stdout }}"
when: which_out.rc == 0
become: yes
- block:
- name: Stop rsyslog
service: name=rsyslog state=stopped
- name: Save syslog file prior to devstack run
command: mv /var/log/syslog /var/log/syslog-pre-devstack
- name: Save kern.log file prior to devstack run
command: mv /var/log/kern.log /var/log/kern_log-pre-devstack
- name: Recreate syslog file
file: name=/var/log/syslog state=touch
- name: Recreate syslog file owner and group
command: chown /var/log/syslog --ref /var/log/syslog-pre-devstack
- name: Recreate syslog file permissions
command: chmod /var/log/syslog --ref /var/log/syslog-pre-devstack
- name: Add read permissions to all on syslog file
file: name=/var/log/syslog mode=a+r
- name: Recreate kern.log file
file: name=/var/log/kern.log state=touch
- name: Recreate kern.log file owner and group
command: chown /var/log/kern.log --ref /var/log/kern_log-pre-devstack
- name: Recreate kern.log file permissions
command: chmod /var/log/kern.log --ref /var/log/kern_log-pre-devstack
- name: Add read permissions to all on kern.log file
file: name=/var/log/kern.log mode=a+r
- name: Start rsyslog
service: name=rsyslog state=started
when: which_out.rc == 1
become: yes

View File

@ -7,3 +7,4 @@
- gather_host_info
- fix_etc_hosts
- create_base_folder
- start_fresh_logging