Merge "delegate container_create to physical hosts"
This commit is contained in:
commit
023a652242
@ -13,12 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- hosts: "{{ host_group|default('hosts') }}"
|
||||
- hosts: "{{ host_group|default('all_containers') }}"
|
||||
gather_facts: False
|
||||
user: root
|
||||
roles:
|
||||
- container_create
|
||||
vars:
|
||||
default_container_groups: "{{ hostvars[inventory_hostname]['container_types'] }}"
|
||||
container_groups: "{{ groups[container_group|default(default_container_groups)] | default('') }}"
|
||||
|
||||
- include: containers-setup.yml
|
||||
|
@ -16,43 +16,35 @@
|
||||
# Create an LXC container.
|
||||
|
||||
- name: Check for lxc volume group
|
||||
shell: >
|
||||
(which vgs > /dev/null && vgs | grep -o "lxc") || false
|
||||
shell: "vgs | grep -o '{{ container_vg|default('lxc') }}'"
|
||||
register: vg_result
|
||||
ignore_errors: True
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
||||
- name: Create Container Local
|
||||
lxc: >
|
||||
name={{ hostvars[item]['container_name'] }}
|
||||
template={{ container_template }}
|
||||
config={{ hostvars[item]['container_config'] }}
|
||||
command=create
|
||||
state=running
|
||||
template_options="
|
||||
--release {{ container_release }}
|
||||
"
|
||||
lxc:
|
||||
name: "{{ container_name }}"
|
||||
template: "{{ container_template }}"
|
||||
config: "{{ container_config }}"
|
||||
command: create
|
||||
state: running
|
||||
template_options: "--release {{ container_release }}"
|
||||
when: vg_result.rc == 1
|
||||
with_items: container_groups
|
||||
|
||||
- name: Check Container Bridge exists
|
||||
file: >
|
||||
state=file
|
||||
path="/sys/class/net/{{ management_bridge }}/bridge/bridge_id"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
||||
- name: Create Container LVM
|
||||
lxc: >
|
||||
name={{ hostvars[item]['container_name'] }}
|
||||
template={{ container_template }}
|
||||
config={{ hostvars[item]['container_config'] }}
|
||||
command=create
|
||||
state=running
|
||||
bdev=lvm
|
||||
lvname={{ hostvars[item]['container_name'] }}
|
||||
vgname=lxc
|
||||
fstype={{ hostvars[item]['container_lvm_fstype'] }}
|
||||
fssize={{ hostvars[item]['container_lvm_fssize'] }}
|
||||
template_options="
|
||||
--release {{ container_release }}
|
||||
"
|
||||
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
|
||||
with_items: container_groups
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
@ -0,0 +1,19 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
- name: Fail if Container Bridge doesnt exist
|
||||
file:
|
||||
state: file
|
||||
path: "/sys/class/net/{{ management_bridge }}/bridge/bridge_id"
|
@ -18,3 +18,4 @@
|
||||
- include: authorized_keys.yml
|
||||
- include: kernel_modules.yml
|
||||
- include: irqbalance.yml
|
||||
- include: check_container_bridge.yml
|
||||
|
Loading…
x
Reference in New Issue
Block a user