5078d478fb
Previously, we only executed the AppArmor configuration when the inventory_hostname matched one of the hosts in the neutron_appamor_hosts list. However, there are cases were a multiple LXC hosts share the same physical host. In that case, since we only record one container per physical host, that container may not be part of the running inventory, so the AppArmor configuration is never executed. We fix that by simply iterating the neutron_all group which should contain all the hosts which participate in the neutron deployment. Change-Id: Ib523de857a5de9adc86bd90fe6919af17704192f
105 lines
3.5 KiB
YAML
105 lines
3.5 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.
|
|
|
|
- name: Record the installation method
|
|
ini_file:
|
|
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
|
section: "neutron"
|
|
option: "install_method"
|
|
value: "{{ neutron_install_method }}"
|
|
|
|
- name: Refresh local facts to ensure the neutron section is present
|
|
setup:
|
|
filter: ansible_local
|
|
gather_subset: "!all"
|
|
|
|
- name: Install neutron role packages
|
|
package:
|
|
name: "{{ neutron_package_list }}"
|
|
state: "{{ neutron_package_state }}"
|
|
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
|
|
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
|
|
register: install_packages
|
|
until: install_packages is success
|
|
retries: 5
|
|
delay: 2
|
|
|
|
- name: Remove known problem packages
|
|
package:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
register: remove_packages
|
|
until: remove_packages is success
|
|
retries: 5
|
|
delay: 2
|
|
with_items: "{{ neutron_remove_distro_packages }}"
|
|
|
|
- name: Install neutron packages from PIP
|
|
include_tasks: neutron_install_source.yml
|
|
when: neutron_install_method == 'source'
|
|
|
|
- name: Initialise the upgrade facts
|
|
ini_file:
|
|
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
|
section: neutron
|
|
option: "{{ item.name }}"
|
|
value: "{{ item.state }}"
|
|
with_items:
|
|
- name: "need_db_expand"
|
|
state: "True"
|
|
- name: "need_db_contract"
|
|
state: "True"
|
|
when: (install_packages | changed) or
|
|
(ansible_local is not defined) or
|
|
('openstack_ansible' not in ansible_local) or
|
|
('neutron' not in ansible_local['openstack_ansible']) or
|
|
('need_db_expand' not in ansible_local['openstack_ansible']['neutron']) or
|
|
('need_db_contract' not in ansible_local['openstack_ansible']['neutron'])
|
|
|
|
- name: Ensure Open vSwitch service is started and enabled
|
|
service:
|
|
name: "{{ neutron_ovs_service_name }}"
|
|
state: started
|
|
enabled: yes
|
|
when: neutron_needs_openvswitch | bool
|
|
|
|
# NOTE(hwoarang) contains may share the same physical host so we only
|
|
# need to execute the apparmor configuration once per physical host.
|
|
- name: Record the first container on each physical host
|
|
delegate_to: 'localhost'
|
|
run_once: True
|
|
set_fact:
|
|
neutron_apparmor_hosts: |
|
|
{%- set apparmor_hosts = [] -%}
|
|
{%- set physical_hosts = [] -%}
|
|
{%- for host in groups[neutron_role_project_group] -%}
|
|
{%- if hostvars[host]['physical_host'] is defined -%}
|
|
{%- set phost = hostvars[host]['physical_host'] -%}
|
|
{%- if phost not in physical_hosts -%}
|
|
{%- set _ = apparmor_hosts.append(host) -%}
|
|
{%- set _ = physical_hosts.append(phost) -%}
|
|
{%- endif -%}
|
|
{%- else -%}
|
|
{%- set _ = apparmor_hosts.append('localhost') -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{{ apparmor_hosts | unique }}
|
|
when: ansible_pkg_mgr in ['apt', 'zypper']
|
|
|
|
- include_tasks: neutron_apparmor.yml
|
|
when:
|
|
- ansible_pkg_mgr in ['apt', 'zypper']
|
|
- inventory_hostname in neutron_apparmor_hosts
|