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
This commit is contained in:
Jesse Pretorius 2016-07-25 17:26:35 +01:00 committed by Jesse Pretorius (odyssey4me)
parent 5a8ce375c7
commit b8b149130c

View File

@ -19,16 +19,24 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: 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: file:
path: "/openstack/log/{{ inventory_hostname }}-lxc" path: "/openstack/log/{{ inventory_hostname }}-lxc"
state: directory state: directory
- name: Create log aggregation links - name: Create the LXC service log aggregation link
file: file:
src: "/openstack/log/{{ inventory_hostname }}-lxc" src: "/openstack/log/{{ inventory_hostname }}-lxc"
dest: "/var/log/lxc" dest: "/var/log/lxc"
state: "link" state: "link"
force: "yes"
roles: roles:
- { role: "lxc_hosts", tags: [ "lxc-host", "host-setup" ] } - { role: "lxc_hosts", tags: [ "lxc-host", "host-setup" ] }
- role: "rsyslog_client" - role: "rsyslog_client"