Removed default lxc profile on container create

Having the lxc container create role drop the lxc-openstack apparmor
profile on all containers anytime its executed leads to the possibility
of the lxc container create task overwriting the running profile on a given
container. If this happens its likley to cause service interruption until the
correct profile is loaded for all containers its effected by the action.

To fix this issue the default "lxc-openstack" profile has been removed from the
lxc contianer create task and added to all plays that are known to be executed
within an lxc container. This will ensure that the profile is untouched on
subsequent runs of the lxc-container-create.yml play.

Change-Id: Ifa4640be60c18f1232cc7c8b281fb1dfc0119e56
Closes-Bug: 1487130
This commit is contained in:
kevin 2015-08-24 16:24:02 +01:00 committed by Jesse Pretorius
parent f7edf6d4a9
commit ffb701f8a3
16 changed files with 171 additions and 40 deletions

View File

@ -67,6 +67,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Galera extra lxc config - name: Galera extra lxc config
lxc_container: lxc_container:
name: "{{ container_name }}" name: "{{ container_name }}"
@ -75,7 +84,7 @@
container_config: container_config:
- "lxc.mount.entry=/openstack/{{ container_name }} var/lib/mysql none bind 0 0" - "lxc.mount.entry=/openstack/{{ container_name }} var/lib/mysql none bind 0 0"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: is_metal == false or is_metal == "False" when: not is_metal | bool
tags: tags:
- galera-mysql-dir - galera-mysql-dir
- name: Flush net cache - name: Flush net cache

View File

@ -17,6 +17,16 @@
hosts: memcached hosts: memcached
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
roles: roles:
- { role: "memcached_server", tags: [ "memcached-server" ] } - { role: "memcached_server", tags: [ "memcached-server" ] }
- role: "system_crontab_coordination" - role: "system_crontab_coordination"

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Flush net cache - name: Flush net cache
command: /usr/local/bin/lxc-system-manage flush-net-cache command: /usr/local/bin/lxc-system-manage flush-net-cache
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
@ -47,7 +56,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-ceilometer" } - { path: "/openstack/log/{{ inventory_hostname }}-ceilometer" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- ceilometer-logs - ceilometer-logs
- ceilometer-log-dirs - ceilometer-log-dirs
@ -59,7 +68,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-ceilometer", dest: "/var/log/ceilometer", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-ceilometer", dest: "/var/log/ceilometer", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- ceilometer-logs - ceilometer-logs
roles: roles:

View File

@ -18,6 +18,17 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=unconfined"
delegate_to: "{{ physical_host }}"
when: >
not is_metal | bool and
inventory_hostname in groups['cinder_volume']
tags:
- lxc-aa-profile
- name: Add volume group block device to cinder - name: Add volume group block device to cinder
shell: | shell: |
{% if item.1.volume_group is defined %} {% if item.1.volume_group is defined %}
@ -36,27 +47,16 @@
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
tags: tags:
- cinder-lxc-devices - cinder-lxc-devices
- name: Cinder extra lxc config
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=unconfined"
- "lxc.cgroup.devices.allow=a *:* rmw"
delegate_to: "{{ physical_host }}"
when: (is_metal == false or is_metal == "False") and inventory_hostname not in groups['cinder_volume']
tags:
- cinder-container-setup
- name: Cinder volume extra lxc config - name: Cinder volume extra lxc config
lxc_container: lxc_container:
name: "{{ container_name }}" name: "{{ container_name }}"
container_config: container_config:
- "lxc.autodev=0" - "lxc.autodev=0"
- "lxc.aa_profile=unconfined"
- "lxc.cgroup.devices.allow=a *:* rmw" - "lxc.cgroup.devices.allow=a *:* rmw"
- "lxc.mount.entry=udev dev devtmpfs defaults 0 0" - "lxc.mount.entry=udev dev devtmpfs defaults 0 0"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: > when: >
(is_metal == false or is_metal == "False") and not is_metal | bool and
inventory_hostname in groups['cinder_volume'] and inventory_hostname in groups['cinder_volume'] and
cinder_backend_lvm_inuse cinder_backend_lvm_inuse
tags: tags:
@ -97,7 +97,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-cinder" } - { path: "/openstack/log/{{ inventory_hostname }}-cinder" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- cinder-logs - cinder-logs
- cinder-log-dirs - cinder-log-dirs
@ -109,7 +109,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-cinder", dest: "/var/log/cinder", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-cinder", dest: "/var/log/cinder", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- cinder-logs - cinder-logs
roles: roles:

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Glance extra lxc config - name: Glance extra lxc config
lxc_container: lxc_container:
name: "{{ container_name }}" name: "{{ container_name }}"
@ -26,7 +35,7 @@
container_config: container_config:
- "lxc.mount.entry=/openstack/{{ container_name }} var/lib/glance/images none bind 0 0" - "lxc.mount.entry=/openstack/{{ container_name }} var/lib/glance/images none bind 0 0"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: is_metal == false or is_metal == "False" when: not is_metal | bool
tags: tags:
- glance-cache-dir - glance-cache-dir
- name: Flush net cache - name: Flush net cache
@ -58,7 +67,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-glance" } - { path: "/openstack/log/{{ inventory_hostname }}-glance" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- glance-logs - glance-logs
- glance-log-dirs - glance-log-dirs
@ -70,7 +79,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-glance", dest: "/var/log/glance", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-glance", dest: "/var/log/glance", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- glance-logs - glance-logs
roles: roles:

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Sort the rabbitmq servers - name: Sort the rabbitmq servers
dist_sort: dist_sort:
value_to_lookup: "{{ container_name }}" value_to_lookup: "{{ container_name }}"
@ -33,7 +42,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-heat" } - { path: "/openstack/log/{{ inventory_hostname }}-heat" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- heat-logs - heat-logs
- heat-log-dirs - heat-log-dirs
@ -45,7 +54,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-heat", dest: "/var/log/heat", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-heat", dest: "/var/log/heat", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- heat-logs - heat-logs
roles: roles:

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Sort the rabbitmq servers - name: Sort the rabbitmq servers
dist_sort: dist_sort:
value_to_lookup: "{{ container_name }}" value_to_lookup: "{{ container_name }}"
@ -33,7 +42,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-horizon" } - { path: "/openstack/log/{{ inventory_hostname }}-horizon" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- horizon-logs - horizon-logs
- horizon-log-dirs - horizon-log-dirs
@ -45,7 +54,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-horizon", dest: "/var/log/horizon", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-horizon", dest: "/var/log/horizon", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- horizon-logs - horizon-logs
roles: roles:

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Sort the rabbitmq servers - name: Sort the rabbitmq servers
dist_sort: dist_sort:
value_to_lookup: "{{ container_name }}" value_to_lookup: "{{ container_name }}"
@ -33,7 +42,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-keystone" } - { path: "/openstack/log/{{ inventory_hostname }}-keystone" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- keystone-logs - keystone-logs
- keystone-log-dirs - keystone-log-dirs
@ -45,7 +54,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-keystone", dest: "/var/log/keystone", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-keystone", dest: "/var/log/keystone", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- keystone-logs - keystone-logs
roles: roles:

View File

@ -18,17 +18,29 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=unconfined"
delegate_to: "{{ physical_host }}"
when: >
not is_metal | bool and
inventory_hostname in groups['neutron_agent']
tags:
- lxc-aa-profile
- name: Neutron extra lxc config - name: Neutron extra lxc config
lxc_container: lxc_container:
name: "{{ container_name }}" name: "{{ container_name }}"
container_command: | container_command: |
[[ ! -d "/lib/modules" ]] && mkdir -p "/lib/modules" [[ ! -d "/lib/modules" ]] && mkdir -p "/lib/modules"
container_config: container_config:
- "lxc.aa_profile=unconfined"
- "lxc.cgroup.devices.allow=a *:* rmw" - "lxc.cgroup.devices.allow=a *:* rmw"
- "lxc.mount.entry=/lib/modules lib/modules none bind 0 0" - "lxc.mount.entry=/lib/modules lib/modules none bind 0 0"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: is_metal == false or is_metal == "False" when: >
not is_metal | bool and
inventory_hostname in groups['neutron_agent']
tags: tags:
- neutron-container-setup - neutron-container-setup
- name: Flush net cache - name: Flush net cache
@ -60,7 +72,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-neutron" } - { path: "/openstack/log/{{ inventory_hostname }}-neutron" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- neutron-logs - neutron-logs
- neutron-log-dirs - neutron-log-dirs
@ -72,7 +84,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-neutron", dest: "/var/log/neutron", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-neutron", dest: "/var/log/neutron", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- neutron-logs - neutron-logs
- name: Create the neutron provider networks facts - name: Create the neutron provider networks facts

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Sort the rabbitmq servers - name: Sort the rabbitmq servers
dist_sort: dist_sort:
value_to_lookup: "{{ container_name }}" value_to_lookup: "{{ container_name }}"
@ -49,7 +58,7 @@
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: > when: >
inventory_hostname in groups['nova_compute'] and inventory_hostname in groups['nova_compute'] and
(is_metal == false or is_metal == "False") not is_metal | bool
tags: tags:
- nova-kvm - nova-kvm
- nova-kvm-container-devices - nova-kvm-container-devices
@ -63,7 +72,7 @@
'added' in device_add.stdout.lower() 'added' in device_add.stdout.lower()
when: > when: >
inventory_hostname in groups['nova_compute'] and inventory_hostname in groups['nova_compute'] and
(is_metal == false or is_metal == "False") and not is_metal | bool and
nova_virt_type == 'kvm' nova_virt_type == 'kvm'
tags: tags:
- nova-kvm - nova-kvm
@ -74,7 +83,7 @@
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-nova" } - { path: "/openstack/log/{{ inventory_hostname }}-nova" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- nova-logs - nova-logs
- nova-log-dirs - nova-log-dirs
@ -86,7 +95,7 @@
force: "yes" force: "yes"
with_items: with_items:
- { src: "/openstack/log/{{ inventory_hostname }}-nova", dest: "/var/log/nova", state: "link" } - { src: "/openstack/log/{{ inventory_hostname }}-nova", dest: "/var/log/nova", state: "link" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- nova-logs - nova-logs
roles: roles:

View File

@ -20,13 +20,22 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Create log dir - name: Create log dir
file: file:
path: "{{ item.path }}" path: "{{ item.path }}"
state: directory state: directory
with_items: with_items:
- { path: "/openstack/log/{{ inventory_hostname }}-swift" } - { path: "/openstack/log/{{ inventory_hostname }}-swift" }
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- swift-logs - swift-logs
- swift-log-dirs - swift-log-dirs
@ -44,7 +53,7 @@
owner: "syslog" owner: "syslog"
group: "syslog" group: "syslog"
state: "link" state: "link"
when: is_metal == true or is_metal == "True" when: is_metal | bool
tags: tags:
- swift-logs - swift-logs
roles: roles:

View File

@ -17,6 +17,16 @@
hosts: rabbitmq_all hosts: rabbitmq_all
max_fail_percentage: 0 max_fail_percentage: 0
user: root user: root
pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
roles: roles:
- role: "rabbitmq_server" - role: "rabbitmq_server"
tags: tags:

View File

@ -18,6 +18,15 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Package repo extra lxc config - name: Package repo extra lxc config
lxc_container: lxc_container:
name: "{{ container_name }}" name: "{{ container_name }}"
@ -26,7 +35,7 @@
container_config: container_config:
- "lxc.mount.entry=/openstack/{{ container_name }} var/www none bind 0 0" - "lxc.mount.entry=/openstack/{{ container_name }} var/www none bind 0 0"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: is_metal == false or is_metal == "False" when: not is_metal | bool
tags: tags:
- repo-dirs - repo-dirs
- name: Flush net cache - name: Flush net cache

View File

@ -101,7 +101,6 @@
container_config: container_config:
- "lxc.mount.entry=/openstack/backup/{{ inventory_hostname }} var/backup none defaults,bind,rw 0 0" - "lxc.mount.entry=/openstack/backup/{{ inventory_hostname }} var/backup none defaults,bind,rw 0 0"
- "lxc.mount.entry=/openstack/log/{{ inventory_hostname }} var/log/{{ properties.log_directory | default(properties.service_name) }} none defaults,bind,rw 0 0" - "lxc.mount.entry=/openstack/log/{{ inventory_hostname }} var/log/{{ properties.log_directory | default(properties.service_name) }} none defaults,bind,rw 0 0"
- "lxc.aa_profile=lxc-openstack"
when: properties.service_name is defined when: properties.service_name is defined
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
tags: tags:

View File

@ -18,12 +18,21 @@
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks: pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
- name: Ensure log stroage directory exists - name: Ensure log stroage directory exists
file: file:
path: "/openstack/{{ container_name }}/log-storage" path: "/openstack/{{ container_name }}/log-storage"
state: "directory" state: "directory"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: is_metal == false or is_metal == "False" when: not is_metal | bool
tags: tags:
- rsyslog-storage-dirs - rsyslog-storage-dirs
- name: Rsyslog server extra lxc config - name: Rsyslog server extra lxc config
@ -34,7 +43,7 @@
container_config: container_config:
- "lxc.mount.entry=/openstack/{{ container_name }}/log-storage {{ storage_directory.lstrip('/') }} none bind 0 0" - "lxc.mount.entry=/openstack/{{ container_name }}/log-storage {{ storage_directory.lstrip('/') }} none bind 0 0"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
when: is_metal == false or is_metal == "False" when: not is_metal | bool
tags: tags:
- rsyslog-storage-dirs - rsyslog-storage-dirs
- name: Flush net cache - name: Flush net cache

View File

@ -17,6 +17,16 @@
hosts: utility_all hosts: utility_all
max_fail_percentage: 20 max_fail_percentage: 20
user: root user: root
pre_tasks:
- name: Use the lxc-openstack aa profile
lxc_container:
name: "{{ container_name }}"
container_config:
- "lxc.aa_profile=lxc-openstack"
delegate_to: "{{ physical_host }}"
when: not is_metal | bool
tags:
- lxc-aa-profile
roles: roles:
- { role: "galera_client", tags: [ "utility-galera-client" ] } - { role: "galera_client", tags: [ "utility-galera-client" ] }
- { role: "pip_lock_down", tags: [ "utility-pip-lock-down" ] } - { role: "pip_lock_down", tags: [ "utility-pip-lock-down" ] }