diff --git a/rpc_deployment/playbooks/setup/build-containers.yml b/rpc_deployment/playbooks/setup/build-containers.yml index 571e60f4e5..2ce3815db7 100644 --- a/rpc_deployment/playbooks/setup/build-containers.yml +++ b/rpc_deployment/playbooks/setup/build-containers.yml @@ -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 diff --git a/rpc_deployment/roles/container_create/tasks/container_create.yml b/rpc_deployment/roles/container_create/tasks/container_create.yml index 6dd0257269..d0caae593c 100644 --- a/rpc_deployment/roles/container_create/tasks/container_create.yml +++ b/rpc_deployment/roles/container_create/tasks/container_create.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 }}" diff --git a/rpc_deployment/roles/host_common/tasks/check_container_bridge.yml b/rpc_deployment/roles/host_common/tasks/check_container_bridge.yml new file mode 100644 index 0000000000..473f529fa3 --- /dev/null +++ b/rpc_deployment/roles/host_common/tasks/check_container_bridge.yml @@ -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" diff --git a/rpc_deployment/roles/host_common/tasks/main.yml b/rpc_deployment/roles/host_common/tasks/main.yml index 1d1e087006..b251de48ca 100644 --- a/rpc_deployment/roles/host_common/tasks/main.yml +++ b/rpc_deployment/roles/host_common/tasks/main.yml @@ -18,3 +18,4 @@ - include: authorized_keys.yml - include: kernel_modules.yml - include: irqbalance.yml +- include: check_container_bridge.yml