From b8b149130c2b7ac378e1c5539c12c7357a927732 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 25 Jul 2016 17:26:35 +0100 Subject: [PATCH] If /var/log/lxc exists, move it to the log aggregation parent In https://review.openstack.org/344721 the log aggregation link was added for lxc logs to ensure that the logs are collected in a central place. This patch ensures that any pre-existing folder (which may exist due to the playbook being run when upgrading) is moved to the right place. This ensures that previous logs are kept and that upgrades execute without failure. Change-Id: I35a9b3176a79caf9cee177442fa6b3d79e057ea9 --- playbooks/lxc-hosts-setup.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/playbooks/lxc-hosts-setup.yml b/playbooks/lxc-hosts-setup.yml index e7706d4afe..8cc0e857ee 100644 --- a/playbooks/lxc-hosts-setup.yml +++ b/playbooks/lxc-hosts-setup.yml @@ -19,16 +19,24 @@ max_fail_percentage: 20 user: root pre_tasks: - - name: Create log dir + - name: Check the state of the default LXC service log directory + stat: + path: "/var/log/lxc" + register: _lxc_log_dir + - name: Move the existing folder to the log aggregation parent + command: "mv /var/log/lxc /openstack/log/{{ inventory_hostname }}-lxc" + when: + - _lxc_log_dir.stat.isdir is defined + - _lxc_log_dir.stat.isdir | bool + - name: Create the new LXC service log directory file: path: "/openstack/log/{{ inventory_hostname }}-lxc" state: directory - - name: Create log aggregation links + - name: Create the LXC service log aggregation link file: src: "/openstack/log/{{ inventory_hostname }}-lxc" dest: "/var/log/lxc" state: "link" - force: "yes" roles: - { role: "lxc_hosts", tags: [ "lxc-host", "host-setup" ] } - role: "rsyslog_client"