Ensure that lxc_container starts/stops are logged
This patch ensures that all lxc_container starts/stops are logged in the container debug log. Change-Id: I494ab938f18adc42a0e11781434228642acb5930
This commit is contained in:
parent
9eb6f66cb4
commit
93c5b5f9f9
|
@ -13,17 +13,25 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
|
||||
# this uses the LXC CLI tools to ensure that we get logging.
|
||||
# TODO(odyssey4me): revisit this once the bug is fixed and released
|
||||
- name: Lxc container restart
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
state: "stopped"
|
||||
command: >
|
||||
lxc-stop --name {{ inventory_hostname }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
notify:
|
||||
- Start Container
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when: lxc_container_allow_restarts | bool
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
|
||||
# this uses the LXC CLI tools to ensure that we get logging.
|
||||
# TODO(odyssey4me): revisit this once the bug is fixed and released
|
||||
- name: Start Container
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
state: "started"
|
||||
command: >
|
||||
lxc-start --daemon --name {{ inventory_hostname }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
- name: Create container
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
container_log: "true"
|
||||
container_log: true
|
||||
container_log_level: "{{ (debug | bool) | ternary('DEBUG', 'INFO') }}"
|
||||
config: "{{ lxc_container_config }}"
|
||||
template: "{{ lxc_container_template }}"
|
||||
|
@ -103,6 +103,23 @@
|
|||
tags:
|
||||
- lxc-container-create
|
||||
|
||||
- name: Check container state
|
||||
command: "lxc-info -n {{ inventory_hostname }} --state"
|
||||
failed_when: false
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: _lxc_container_state
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
|
||||
# this uses the LXC CLI tools to ensure that we get logging.
|
||||
# TODO(odyssey4me): revisit this once the bug is fixed and released
|
||||
- name: Start the container if it is not already running
|
||||
command: >
|
||||
lxc-start --daemon --name {{ inventory_hostname }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when: _lxc_container_state.stdout.find('STOPPED') != -1
|
||||
|
||||
- name: Execute container commands
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
---
|
||||
# Copyright 2016, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Note this is a used in an iterable and requires the <item.value.interface> variable
|
||||
# The container interface variable is a a default object that assume the
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
---
|
||||
# Copyright 2016, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Note this is a used in an iterable and requires the <item.value.interface> variable
|
||||
# The container interface variable is a a default object that assume the
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
---
|
||||
# Copyright 2016, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Note this is a used in an iterable and requires the <item.value.interface> variable
|
||||
# The container interface variable is a a default object that assume the
|
||||
|
|
Loading…
Reference in New Issue