
This eliminates the use of hostvars[] in container creation which allows us to use templated variables, necessary for the fix for #1399427 which has already been merged. Notes: * Creates containers in parallel. * Improves flexability in container create as a specific group or container can be targeted on the CLI. * Syntax clean up. * Adds option to specify the container volume group name. * Removes the "ignored" failure note when running in an environment that does not use LVM and have an LXC volume group. Closes-Bug: #1399427 Change-Id: I4270a9d11039b62d631f82d24de7cc87d5f142c9
51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
---
|
|
# Copyright 2014, 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.
|
|
|
|
# Create an LXC container.
|
|
|
|
- name: Check for lxc volume group
|
|
shell: "vgs | grep -o '{{ container_vg|default('lxc') }}'"
|
|
register: vg_result
|
|
failed_when: false
|
|
changed_when: false
|
|
delegate_to: "{{ physical_host }}"
|
|
|
|
- name: Create Container Local
|
|
lxc:
|
|
name: "{{ container_name }}"
|
|
template: "{{ container_template }}"
|
|
config: "{{ container_config }}"
|
|
command: create
|
|
state: running
|
|
template_options: "--release {{ container_release }}"
|
|
when: vg_result.rc == 1
|
|
delegate_to: "{{ physical_host }}"
|
|
|
|
- name: Create Container LVM
|
|
lxc:
|
|
name: "{{ container_name }}"
|
|
template: "{{ container_template }}"
|
|
config: "{{ container_config }}"
|
|
command: "create"
|
|
state: "running"
|
|
bdev: "lvm"
|
|
lvname: "{{ container_name }}"
|
|
vgname: "{{ container_vg|default('lxc') }}"
|
|
fstype: "{{ container_lvm_fstype }}"
|
|
fssize: "{{ container_lvm_fssize }}"
|
|
template_options: " --release {{ container_release }}"
|
|
when: vg_result.rc == 0
|
|
delegate_to: "{{ physical_host }}"
|