Combined backport to support LXC container storage options
The LXC container create role has not been updated to use some of our more well throughout patterns and layouts. This change updates the role so that its following our normal role conventions and simplifying task execution. New tags have been added to follow the basic tag pattern found in all other roles. The two tags now supported are lxc-config, and lxc-create. The creation backends have been seperated out into dynamically included files. This will reduce our "skips" which will improve execution time and assist developers in understanding what is happening when a container is created. Stubbs for BTRFS and ZFS container types have been added so future work can continue on those two store options without impacting our normal workflow. All task files have been updated to use the "lxc_" prefix which follows the pattern found in everyone of our roles. This change modifies the lxc container create role to consume the machinectl template when the `lxc_container_backing_store` is set to "machinectl". This new container store type will allow us to better manage containers and the images we use to run systems. As mentioned in the release note within the lxc_hosts role, this change has no upgrade impact as existing containers will continue to use the storage they already have. This change adds several tox functional sections to support our different backend storage options. This change will allow us to create jenkens jobs specific to the various backends to validate they work as we expect them to. (cherry picked from commit I8e140a4c820e7f2b19c472ed1bc72191cd284f06) (cherry picked from commit I852b7a3e1ef82a40b58d10af1a72291b421ae2f8) (cherry picked from commit I1deb4633059567b43ed4d2c9ee85bf9e163ea659) (cherry picked from commit I73576f4ca00985cefba788eba560a71be5d57b57) (cherry picked from commit I258ac6496775233cad8e07db13e80df3d578d63c) (cherry picked from commit I8fa1676b26c0007f88a8cca1583c2e8d4fdaf7bf) Signed-off-by: Kevin Carter <kevin.carter@rackspace.com> Depends-On: Ia022a9e8bc7eefa4dcdc1c83c75cd4ad454a78ee Change-Id: I8e140a4c820e7f2b19c472ed1bc72191cd284f06
This commit is contained in:
parent
6f19ef944f
commit
05b84528d1
14
bindep.txt
14
bindep.txt
|
@ -2,7 +2,7 @@
|
|||
# before the execution of any tests.
|
||||
#
|
||||
# See the following for details:
|
||||
# - http://docs.openstack.org/infra/bindep/
|
||||
# - https://docs.openstack.org/infra/bindep/
|
||||
# - https://git.openstack.org/cgit/openstack-infra/bindep
|
||||
#
|
||||
# Even if the role does not make use of this facility, it
|
||||
|
@ -49,17 +49,5 @@ python2-dnf [platform:fedora]
|
|||
libselinux-python [platform:redhat]
|
||||
libsemanage-python [platform:redhat]
|
||||
|
||||
# For SSL SNI support
|
||||
python-pyasn1 [platform:dpkg platform:suse]
|
||||
python-openssl [platform:dpkg]
|
||||
python-ndg-httpsclient [platform:ubuntu !platform:ubuntu-14]
|
||||
python2-pyasn1 [platform:redhat]
|
||||
pyOpenSSL [platform:redhat]
|
||||
python-pyOpenSSL [platform:opensuseproject-42]
|
||||
python2-pyOpenSSL [platform:suse !platform:opensuseproject-42]
|
||||
python-ndg_httpsclient [platform:redhat !platform:fedora]
|
||||
python2-ndg_httpsclient [platform:fedora]
|
||||
python-ndg-httpsclient [platform:suse]
|
||||
|
||||
# Required for compressing collected log files in CI
|
||||
gzip
|
||||
|
|
|
@ -58,6 +58,7 @@ lxc_architecture_mapping:
|
|||
x86_64: amd64
|
||||
ppc64le: ppc64el
|
||||
s390x: s390x
|
||||
armv7l: armhf
|
||||
|
||||
# lxc container rootfs directory and cache path
|
||||
lxc_container_directory: "/var/lib/lxc"
|
||||
|
@ -69,11 +70,18 @@ lxc_container_rootfs_directory: "{{ lxc_container_directory }}/{{ container_name
|
|||
lxc_container_fs_size: 5G
|
||||
lxc_container_fs_type: ext4
|
||||
|
||||
# The container creation process now allows ``copy-on-write`` to be set as
|
||||
# the ``lxc_container_backing_method`` when the
|
||||
# ``lxc_container_backing_store`` is set to ``lvm``. When this is set it
|
||||
# will use a snapshot of the base container to build the containers.
|
||||
lxc_container_backing_method: null
|
||||
|
||||
# The container backing store can be set to 'overlayfs' to use overlayfs
|
||||
# This should only be done for production use with a linux kernel > 3.14
|
||||
# which is when overlayfs was merged into the mainline kernel.
|
||||
# lxc_container_backing_store: overlayfs
|
||||
# Other store options are "dir" and "lvm".
|
||||
# Other store options are: ["machinectl", "btrfs", "dir", "zfs", "lvm"].
|
||||
lxc_container_backing_store: dir
|
||||
|
||||
# If the container backing store is LVM, the automatic detection will
|
||||
# require the presence of the lxc_container_vg_name volume group. If
|
||||
|
@ -118,6 +126,21 @@ lxc_container_download_template_options: >-
|
|||
--variant={{ properties['lxc_container_variant'] | default(lxc_container_variant) }}
|
||||
{{ lxc_container_download_template_extra_options }}
|
||||
|
||||
## Default machinectl template options
|
||||
## This can be customized to use a local build server and options.
|
||||
## By default these options will be fulfilled by the distro specific
|
||||
## variable files found in vars/
|
||||
# lxc_container_download_template_options: >
|
||||
# --dist NAME_OF_DISTRO
|
||||
# --release DISTRO_RELEASE
|
||||
# --arch CONTAINER_ARCH
|
||||
lxc_container_machinectl_template_options: >-
|
||||
--dist {{ lxc_container_map.distro }}
|
||||
--release {{ lxc_container_map.release }}
|
||||
--arch {{ lxc_container_map.arch }}
|
||||
--variant={{ properties['lxc_container_variant'] | default(lxc_container_variant) }}
|
||||
{{ lxc_container_download_template_extra_options }}
|
||||
|
||||
# Toggle the restart of containers via the handler.
|
||||
lxc_container_allow_restarts: yes
|
||||
|
||||
|
|
|
@ -69,7 +69,9 @@ target_name = 'openstack-ansible-' + role_name
|
|||
title = 'OpenStack-Ansible Documentation: ' + role_name + 'role'
|
||||
|
||||
# The link to the browsable source code (for the left hand menu)
|
||||
oslosphinx_cgit_link = 'https://git.openstack.org/cgit/openstack/' + target_name
|
||||
oslosphinx_cgit_link = (
|
||||
"https://git.openstack.org/cgit/openstack/{}".format(target_name)
|
||||
)
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
|
|
|
@ -16,16 +16,11 @@
|
|||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
|
||||
# this uses the LXC CLI tools to ensure that we get logging.
|
||||
# TODO(odyssey4me): revisit this once the bug is fixed and released
|
||||
# NOTE(hwoarang): We pass the timeout (-t) option on openSUSE due to
|
||||
# https://bugzilla.opensuse.org/show_bug.cgi?id=1054609. Feel free to
|
||||
# remove this workaround when the bug is closed or lxc-2.X.X becomes the
|
||||
# default on openSUSE.
|
||||
- name: Lxc container restart
|
||||
command: >
|
||||
lxc-stop --name {{ inventory_hostname }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
"{{ (hostvars[physical_host]['ansible_pkg_mgr'] == 'zypper') | ternary('-t 10', '') }}"
|
||||
notify:
|
||||
- Start Container
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
# Copyright 2017, 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.
|
||||
#
|
||||
# (c) 2017, Jean-Philippe Evrard <jean-philippe.evrard@rackspace.co.uk>
|
||||
|
||||
maturity_info:
|
||||
status: complete
|
||||
created_during: mitaka
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
features:
|
||||
- The tag options when creating an LXC container have been simplified. The two
|
||||
tags now supported by the `lxc_container_create` role are
|
||||
**lxc-{create,config}**.
|
||||
upgrade:
|
||||
- The LXC container create option `lxc_container_backing_store` is now defined
|
||||
by default and has a value of "dir". Prior to this release the backend store
|
||||
option was using several auto-detection methods to try and guess the store
|
||||
type based on facts fed into the role and derived from the physical host.
|
||||
While the auto-detection methods worked, they created a cumbersome set of
|
||||
conditionals and limited our ability to leverage additional container
|
||||
stores. Having this option be a default allows deployers to mix and match
|
||||
container stores to suit the needs of the deployment. Existing deployments
|
||||
should set this option within group or user variables to ensure
|
||||
there's no change in the backend store when new container be provisioned.
|
||||
other:
|
||||
- The LXC container create role will now check for the LXC volume group if
|
||||
the option `lxc_container_backing_store` is set to "lvm". If this volume
|
||||
group is not found, the role will halt and instruct the deployer to update
|
||||
their configuration options and inspect their host setup.
|
|
@ -65,7 +65,9 @@ target_name = 'openstack-ansible-' + role_name
|
|||
title = 'OpenStack-Ansible Release Notes: ' + role_name + 'role'
|
||||
|
||||
# The link to the browsable source code (for the left hand menu)
|
||||
oslosphinx_cgit_link = 'https://git.openstack.org/cgit/openstack/' + target_name
|
||||
oslosphinx_cgit_link = (
|
||||
"https://git.openstack.org/cgit/openstack/{}".format(target_name)
|
||||
)
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
mitaka
|
||||
newton
|
||||
unreleased
|
||||
pike
|
||||
ocata
|
||||
newton
|
||||
mitaka
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
===================================
|
||||
Pike Series Release Notes
|
||||
===================================
|
||||
|
||||
.. release-notes::
|
||||
:branch: stable/pike
|
|
@ -40,8 +40,7 @@ install_pkg_deps() {
|
|||
|
||||
case ${ID,,} in
|
||||
*suse*) pkg_mgr_cmd="zypper -n in" ;;
|
||||
centos|rhel) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
|
||||
fedora) pkg_mgr_cmd="dnf -y install" ;;
|
||||
centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
|
||||
ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
|
||||
*) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
|
||||
esac
|
||||
|
|
|
@ -13,171 +13,22 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Read custom facts from previous runs
|
||||
setup:
|
||||
filter: ansible_local
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Check for lxc volume group
|
||||
shell: "(which vgs > /dev/null && vgs | grep -o '{{ lxc_container_vg_name }}') || false"
|
||||
register: vg_result
|
||||
failed_when: false
|
||||
changed_when: vg_result.rc != 0
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when: lxc_container_backing_store is not defined or lxc_container_backing_store == "lvm"
|
||||
tags:
|
||||
- lxc_container_create-vg-detect
|
||||
|
||||
- name: Set container backend to "dir" or "lvm" based on whether the lxc VG was found
|
||||
set_fact:
|
||||
lxc_container_backing_store: "{{ (vg_result.rc != 0) | ternary('dir', 'lvm') }}"
|
||||
when: vg_result.rc is defined
|
||||
tags:
|
||||
- lxc_container_create-vg-detect
|
||||
|
||||
- name: Container service directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: "directory"
|
||||
with_items:
|
||||
- "/openstack/{{ inventory_hostname }}"
|
||||
- "/openstack/backup/{{ inventory_hostname }}"
|
||||
- "/openstack/log/{{ inventory_hostname }}"
|
||||
- "{{ lxc_container_directory }}/{{ inventory_hostname }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-directories
|
||||
|
||||
- name: LXC autodev setup
|
||||
template:
|
||||
src: "autodev.j2"
|
||||
dest: "/var/lib/lxc/{{ inventory_hostname }}/autodev"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0755"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-autodev
|
||||
|
||||
- name: Create container
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
container_log: true
|
||||
container_log_level: "{{ (debug | bool) | ternary('DEBUG', 'INFO') }}"
|
||||
config: "{{ lxc_container_config }}"
|
||||
template: "{{ lxc_container_template }}"
|
||||
state: started
|
||||
backing_store: "{{ lxc_container_backing_store }}"
|
||||
directory: "{{ lxc_container_rootfs_directory }}"
|
||||
fs_size: "{{ properties.container_fs_size | default(lxc_container_fs_size) }}"
|
||||
fs_type: "{{ lxc_container_fs_type }}"
|
||||
vg_name: "{{ lxc_container_vg_name }}"
|
||||
template_options: "{{ lxc_container_download_template_options }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when: >
|
||||
lxc_container_backing_store != "overlayfs" or
|
||||
(lxc_container_backing_store == 'lvm' and not
|
||||
(lxc_container_backing_method is defined
|
||||
and lxc_container_backing_method == 'copy-on-write'))
|
||||
tags:
|
||||
- lxc_container_create-create
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2577 the
|
||||
# next two tasks do not use the lxc_container module.
|
||||
# TODO(odyssey4me): Revisit this once a fix has merged
|
||||
- name: Check if container exists (copy-on-write backing store)
|
||||
command: "lxc-info -n {{ inventory_hostname }}"
|
||||
failed_when: false
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: lxc_container_info
|
||||
when: >
|
||||
lxc_container_backing_store == "overlayfs" or
|
||||
(lxc_container_backing_store == 'lvm' and
|
||||
lxc_container_backing_method is defined and
|
||||
lxc_container_backing_method == 'copy-on-write')
|
||||
|
||||
# Due to https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1591510
|
||||
# the '-B' option is used, instead of the more understandable
|
||||
# '--backingstore'.
|
||||
# TODO(odyssey4me): Revisit this once a fix has merged
|
||||
# NOTE(hwoarang) lxc-copy is only available since lxc-2.0.0 so emulate
|
||||
# its behavior using the old lxc-clone command. This is only a problem
|
||||
# on openSUSE so it's safe to remove it when lxc-2.X becomes the default
|
||||
# option for openSUSE in the openstack-ansible-lxc_hosts role.
|
||||
- block:
|
||||
- name: Create container (copy-on-write backing store)
|
||||
command: >
|
||||
lxc-copy --snapshot -B {{ lxc_container_backing_store }}
|
||||
--name {{ lxc_container_base_name }}
|
||||
--newname {{ inventory_hostname }}
|
||||
-L {{ properties.container_fs_size | default(lxc_container_fs_size) }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
rescue:
|
||||
# NOTE(hwoarang) lxc-clone does not support the common
|
||||
# --logfile/logpriority options so we just redirect everything to the log
|
||||
# which is probably the best we can do.
|
||||
- name: Create container (copy-on-write backing store) (fallback)
|
||||
shell: >
|
||||
lxc-clone -s -B {{ lxc_container_backing_store }} -L {{ properties.container_fs_size | default(lxc_container_fs_size) }}
|
||||
{{ lxc_container_base_name }} {{ inventory_hostname }} &>>
|
||||
{{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
||||
when: >
|
||||
(lxc_container_backing_store == "overlayfs" or
|
||||
(lxc_container_backing_store == 'lvm' and
|
||||
lxc_container_backing_method is defined and
|
||||
lxc_container_backing_method == 'copy-on-write')) and
|
||||
lxc_container_info.rc != 0
|
||||
tags:
|
||||
- lxc_container_create-create
|
||||
|
||||
- name: Check container state
|
||||
command: "lxc-info -n {{ inventory_hostname }} --state"
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: _lxc_container_state
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
|
||||
# this uses the LXC CLI tools to ensure that we get logging.
|
||||
# TODO(odyssey4me): revisit this once the bug is fixed and released
|
||||
- name: Start the container if it is not already running
|
||||
command: >
|
||||
lxc-start --daemon --name {{ inventory_hostname }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: _lxc_container_create
|
||||
until: _lxc_container_create | success
|
||||
retries: 3
|
||||
delay: 5
|
||||
when: _lxc_container_state.stdout.find('STOPPED') != -1
|
||||
|
||||
- name: Execute container commands
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
container_command: |
|
||||
{{ lxc_container_commands }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-commands
|
||||
|
||||
- name: Write default container config
|
||||
lineinfile:
|
||||
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
|
||||
line: "{{ item | replace('=', ' = ') | regex_replace('\\s+', ' ') }}"
|
||||
line: "{{ item | replace('=', ' = ', 1) | regex_replace('\\s+', ' ') }}"
|
||||
backup: "true"
|
||||
with_items: "{{ lxc_container_default_config_list | union(lxc_container_config_list) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
notify:
|
||||
- Lxc container restart
|
||||
tags:
|
||||
- lxc_container_create-config
|
||||
|
||||
- name: Ensure bind mount host directories exists
|
||||
file:
|
||||
|
@ -190,126 +41,64 @@
|
|||
- name: Add bind mount configuration to container
|
||||
lineinfile:
|
||||
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
|
||||
line: "lxc.mount.entry = {{ item['host_directory'] }} {{ item['container_directory'].lstrip('/') }} none bind 0 0"
|
||||
line: "lxc.mount.entry = {{ item['host_directory'] }} {{ item['container_directory'].lstrip('/') }} none bind,create=dir 0 0"
|
||||
backup: "true"
|
||||
with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
notify:
|
||||
- Lxc container restart
|
||||
tags:
|
||||
- lxc_container_create-config
|
||||
|
||||
# NOTE(cloudnull): Should a container already be up and running with a defined container interface
|
||||
# the shell command will use the MAC address already set within the container as
|
||||
# it's value. This allows the tasks to remain idempotent while ensuring that a
|
||||
# container restart isn't required to set a static mac.
|
||||
- name: Set define static mac address from an existing interface
|
||||
shell: |
|
||||
if lxc-attach -n {{ inventory_hostname }} -- cat /sys/class/net/{{ item.value.interface }}/address; then
|
||||
lxc-attach -n {{ inventory_hostname }} -- cat /sys/class/net/{{ item.value.interface }}/address > /var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: "/var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr"
|
||||
with_dict: "{{ container_networks | default({}) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
failed_when: false
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# NOTE(cloudnull): This task is being done to allow a container to have a static mac address.
|
||||
# This task is being done to allow a container to have a static mac address.
|
||||
# before this task a container had a dynamic mac address which would
|
||||
# change when a container was restarted. This restart process causes terrible
|
||||
# issues in several network intensive systems (RabbitMQ, Neutron, etc). To
|
||||
# resolve the rotating mac address issue this task is setting the mac in a hwaddr
|
||||
# file and a lookup is being used in the container-interface.ini template to render
|
||||
# the static hardware address as expected.
|
||||
- name: Set unique interface mac address (when no facts exist)
|
||||
environment:
|
||||
hexchars: "0123456789abcdef"
|
||||
- name: Set define static mac address from an existing interface
|
||||
shell: |
|
||||
C_PID="$(lxc-info --name {{ inventory_hostname }} --pid | awk '/PID:/ {print $2}')"
|
||||
C_ADDR="/proc/${C_PID}/root/sys/class/net/{{ item.value.interface }}/address"
|
||||
HARDWARE_ADDR="/var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr"
|
||||
HEXCHARS="0123456789abcdef"
|
||||
if ! cat "${C_ADDR}" > "${HARDWARE_ADDR}"; then
|
||||
echo "00:16:3e$(
|
||||
for i in {1..6}; do
|
||||
echo -n ${hexchars:$(( $RANDOM % 16 )):1}
|
||||
echo -n "${HEXCHARS:$(( $RANDOM % 16 )):1}"
|
||||
done | sed -e 's/\(..\)/:\1/g'
|
||||
)" > /var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr
|
||||
)" > "${HARDWARE_ADDR}"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: "/var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr"
|
||||
with_dict: "{{ container_networks | default({}) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
- (ansible_local is not defined or
|
||||
'mac' not in ansible_local or
|
||||
inventory_hostname not in ansible_local['mac'])
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# NOTE(palendae): If we have saved MACs, write those out instead of generating new ones.
|
||||
# Parentheses on the mac in ansible_local check to make the YAML parser happy.
|
||||
- name: Reuse saved interface mac address from host facts
|
||||
shell: |
|
||||
echo {{ item.value }} > /var/lib/lxc/{{ inventory_hostname }}/{{ item.key }}.hwaddr
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: "/var/lib/lxc/{{ inventory_hostname }}/{{ item.key }}.hwaddr"
|
||||
with_dict: "{{ ansible_local['mac'][inventory_hostname] | default({}) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
- ansible_local is defined
|
||||
- ('mac' in ansible_local)
|
||||
- inventory_hostname in ansible_local['mac']
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Gather hardware addresses to be used as facts
|
||||
command: cat /var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr
|
||||
slurp:
|
||||
src: "/var/lib/lxc/{{ inventory_hostname }}/{{ item.value.interface }}.hwaddr"
|
||||
changed_when: false
|
||||
register: macs
|
||||
with_dict: "{{ container_networks | default({}) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# NOTE(cloudnull): To dynamically set the the mac address "facts" Ansible line format is being used
|
||||
- name: Set fixed hardware address fact
|
||||
set_fact: "{{item.item.value.interface }}_mac_address={{ item.stdout }}"
|
||||
set_fact: "{{item.item.value.interface }}_mac_address={{ item.content | b64decode }}"
|
||||
with_items:
|
||||
- "{{ macs.results }}"
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# NOTE(palendae): If a unique identifier (like the hostname) is not provided as the marker, only one block will be written.
|
||||
# Each host will be written once, and whichever one came last will be the only one in the file.
|
||||
- name: Ensure MAC address fact cache is up-to-date
|
||||
blockinfile:
|
||||
dest: /etc/ansible/facts.d/mac.fact
|
||||
marker: "# {mark} Managed by OpenStack-Ansible {{ inventory_hostname }}"
|
||||
block: "{{ lookup('template', 'macs.fact.j2') }}"
|
||||
create: yes
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# NOTE(palendae): This is necessary to read any local facts in to the 'ansible_local' dict.
|
||||
- name: Read local facts in for use
|
||||
setup:
|
||||
filter: ansible_local
|
||||
when:
|
||||
- lxc_container_fixed_mac | bool
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: LXC host config for container networks
|
||||
template:
|
||||
|
@ -320,16 +109,12 @@
|
|||
mode: "0644"
|
||||
with_dict: "{{ container_networks | default({}) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Create start
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
state: started
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-create
|
||||
|
||||
- name: Drop container network file (interfaces)
|
||||
template:
|
||||
|
@ -339,8 +124,6 @@
|
|||
group: "root"
|
||||
mode: "0644"
|
||||
with_dict: "{{ container_networks | default({}) }}"
|
||||
tags:
|
||||
- lxc_container_create-setup
|
||||
|
||||
- name: Drop container network file (routes)
|
||||
template:
|
||||
|
@ -355,8 +138,6 @@
|
|||
- item.value.static_routes is defined or
|
||||
(item.value.gateway is defined and ansible_pkg_mgr == "zypper")
|
||||
with_dict: "{{ container_networks | default({}) }}"
|
||||
tags:
|
||||
- lxc_container_create-setup
|
||||
|
||||
- name: Drop container setup script
|
||||
template:
|
||||
|
@ -365,16 +146,12 @@
|
|||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0755"
|
||||
tags:
|
||||
- lxc_container_create-setup
|
||||
|
||||
- name: Run container setup script
|
||||
command: /opt/container-setup.sh
|
||||
register: container_setup
|
||||
changed_when: false
|
||||
failed_when: container_setup.rc != 0
|
||||
tags:
|
||||
- lxc_container_create-setup
|
||||
|
||||
# NOTE(major): the lxc.network.veth.pair line must appear *immediately* after
|
||||
# the lxc.network.name congfiguration line or it will be ignored. That's why
|
||||
|
@ -386,8 +163,6 @@
|
|||
insertafter: "^lxc.network.name"
|
||||
backup: "true"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Container network includes
|
||||
lineinfile:
|
||||
|
@ -397,8 +172,6 @@
|
|||
with_dict: "{{ container_networks | default({}) }}"
|
||||
when: item.value.interface is defined
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Create wiring script
|
||||
copy:
|
||||
|
@ -408,8 +181,6 @@
|
|||
group: "root"
|
||||
mode: "0755"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Run container veth wiring script
|
||||
command: >
|
||||
|
@ -426,8 +197,6 @@
|
|||
failed_when: wiring_script.rc not in [3, 0]
|
||||
changed_when: wiring_script.rc == 3
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# Adds post-down and pre-start hooks
|
||||
- name: Drop veth cleanup script
|
||||
|
@ -438,8 +207,6 @@
|
|||
group: "root"
|
||||
mode: "0755"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# This is being defined due to an issue with dangling veth pairs.
|
||||
# TODO(someone) This should be removed once an upstream patch has
|
||||
|
@ -454,8 +221,6 @@
|
|||
- "lxc.hook.pre-start = /var/lib/lxc/{{ inventory_hostname }}/veth-cleanup.sh"
|
||||
- "lxc.hook.post-stop = /var/lib/lxc/{{ inventory_hostname }}/veth-cleanup.sh"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
# Flush the handlers to ensure the container and networking is online.
|
||||
- meta: flush_handlers
|
||||
|
@ -466,8 +231,6 @@
|
|||
delay: "{{ lxc_container_wait_params.delay | default(omit) }}"
|
||||
sleep: "{{ lxc_container_wait_params.sleep | default(omit) }}"
|
||||
timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}"
|
||||
tags:
|
||||
- lxc_container_create-networks
|
||||
|
||||
- name: Add global_environment_variables to environment file
|
||||
blockinfile:
|
||||
|
@ -477,8 +240,6 @@
|
|||
insertbefore: EOF
|
||||
block: "{{ lookup('template', 'environment.j2') }}"
|
||||
remote_user: root
|
||||
tags:
|
||||
- lxc_container_create-proxy
|
||||
|
||||
- name: Create localhost config
|
||||
lineinfile:
|
||||
|
@ -489,8 +250,6 @@
|
|||
group: "root"
|
||||
mode: "0644"
|
||||
remote_user: root
|
||||
tags:
|
||||
- lxc_container_create-hostname
|
||||
|
||||
- name: Create domain config
|
||||
lineinfile:
|
||||
|
@ -501,8 +260,6 @@
|
|||
group: "root"
|
||||
mode: "0644"
|
||||
remote_user: root
|
||||
tags:
|
||||
- lxc_container_create-hostname
|
||||
|
||||
- name: Create hostname
|
||||
copy:
|
||||
|
@ -512,15 +269,11 @@
|
|||
group: "root"
|
||||
mode: "0644"
|
||||
remote_user: root
|
||||
tags:
|
||||
- lxc_container_create-hostname
|
||||
|
||||
- name: Setup hostname
|
||||
command: hostname -F /etc/hostname
|
||||
changed_when: false
|
||||
remote_user: root
|
||||
tags:
|
||||
- lxc_container_create-hostname
|
||||
|
||||
- name: Ensure sysctl can be applied
|
||||
template:
|
||||
|
@ -530,8 +283,6 @@
|
|||
owner: "root"
|
||||
group: "root"
|
||||
remote_user: root
|
||||
tags:
|
||||
- lxc_container_create-sysctl
|
||||
|
||||
# NOTE(hwoarang) openSUSE randomly fails to start the service
|
||||
# with an error like the following one
|
||||
|
@ -551,15 +302,13 @@
|
|||
until: _sysctl_service_started|success
|
||||
retries: 5
|
||||
delay: 5
|
||||
tags:
|
||||
- lxc_container_create-sysctl
|
||||
|
||||
- name: Allow the usage of local facts
|
||||
file:
|
||||
path: /etc/ansible/facts.d/
|
||||
state: directory
|
||||
tags:
|
||||
- lxc_container_create-install
|
||||
- always
|
||||
|
||||
- name: Record the container variant deployed
|
||||
ini_file:
|
||||
|
@ -567,3 +316,5 @@
|
|||
section: lxc
|
||||
option: variant
|
||||
value: "{{ properties['lxc_container_variant'] | default(lxc_container_variant) }}"
|
||||
tags:
|
||||
- always
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
# 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: Container service directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: "directory"
|
||||
with_items:
|
||||
- "/openstack/{{ inventory_hostname }}"
|
||||
- "/openstack/backup/{{ inventory_hostname }}"
|
||||
- "/openstack/log/{{ inventory_hostname }}"
|
||||
- "{{ lxc_container_directory }}/{{ inventory_hostname }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
||||
- name: LXC autodev setup
|
||||
template:
|
||||
src: "autodev.j2"
|
||||
dest: "/var/lib/lxc/{{ inventory_hostname }}/autodev"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0755"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
||||
# Run the lxc container creation process based on the backend store type
|
||||
- include: "lxc_container_create_{{ lxc_container_backing_store }}.yml"
|
||||
|
||||
- name: Check container state
|
||||
command: "lxc-info -n {{ inventory_hostname }} --state"
|
||||
changed_when: false
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: _lxc_container_state
|
||||
until: _lxc_container_state | success
|
||||
retries: 3
|
||||
delay: 5
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2691
|
||||
# this uses the LXC CLI tools to ensure that we get logging.
|
||||
# TODO(odyssey4me): revisit this once the bug is fixed and released
|
||||
- name: Start the container if it is not already running
|
||||
command: >
|
||||
lxc-start
|
||||
--daemon
|
||||
--name {{ inventory_hostname }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: _lxc_container_create
|
||||
until: _lxc_container_create | success
|
||||
retries: 3
|
||||
delay: 5
|
||||
when:
|
||||
- _lxc_container_state.stdout.find('STOPPED') != -1
|
|
@ -0,0 +1 @@
|
|||
lxc_container_create_cow.yml
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
# Copyright 2017, 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.
|
||||
|
||||
# Due to https://github.com/ansible/ansible-modules-extras/issues/2577 the
|
||||
# next two tasks do not use the lxc_container module.
|
||||
# TODO(odyssey4me): Revisit this once a fix has merged
|
||||
- name: Check if container exists
|
||||
command: "lxc-info -n {{ inventory_hostname }}"
|
||||
failed_when: false
|
||||
delegate_to: "{{ physical_host }}"
|
||||
register: lxc_container_info
|
||||
|
||||
# Due to https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1591510
|
||||
# the '-B' option is used, instead of the more understandable
|
||||
# '--backingstore'.
|
||||
# TODO(odyssey4me): Revisit this once a fix has merged
|
||||
- name: Create container (cow)
|
||||
command: >
|
||||
lxc-copy --snapshot -B {{ lxc_container_backing_store }}
|
||||
--name {{ lxc_container_base_name }}
|
||||
--newname {{ inventory_hostname }}
|
||||
-L {{ properties.container_fs_size | default(lxc_container_fs_size) }}
|
||||
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
|
||||
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when:
|
||||
- lxc_container_info.rc != 0
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
# Copyright 2017, 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: Create container (dir)
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
container_log: true
|
||||
container_log_level: "{{ (debug | bool) | ternary('DEBUG', 'INFO') }}"
|
||||
config: "{{ lxc_container_config }}"
|
||||
template: "{{ lxc_container_template }}"
|
||||
state: started
|
||||
backing_store: "{{ lxc_container_backing_store }}"
|
||||
directory: "{{ lxc_container_rootfs_directory }}"
|
||||
template_options: "{{ lxc_container_download_template_options }}"
|
||||
delegate_to: "{{ physical_host }}"
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
# Copyright 2017, 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: Create container (lvm)
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
container_log: true
|
||||
container_log_level: "{{ (debug | bool) | ternary('DEBUG', 'INFO') }}"
|
||||
config: "{{ lxc_container_config }}"
|
||||
template: "{{ lxc_container_template }}"
|
||||
state: started
|
||||
backing_store: "{{ lxc_container_backing_store }}"
|
||||
fs_size: "{{ properties.container_fs_size | default(lxc_container_fs_size) }}"
|
||||
fs_type: "{{ lxc_container_fs_type }}"
|
||||
vg_name: "{{ lxc_container_vg_name }}"
|
||||
template_options: "{{ lxc_container_download_template_options }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
when:
|
||||
- lxc_container_backing_store == 'lvm'
|
||||
- lxc_container_backing_method != 'copy-on-write'
|
||||
|
||||
- include: lxc_container_create_cow.yml
|
||||
when:
|
||||
- lxc_container_backing_method == 'copy-on-write'
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
# Copyright 2017, 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.
|
||||
|
||||
# NOTE(cloudnull): When the machinectl backend is set the container create
|
||||
# module will use the "machinectl" container template which
|
||||
# will build and store all containers using a copy-on-write
|
||||
# snapshot from the base image stored withine machinectl.
|
||||
- name: Create container (machinectl)
|
||||
lxc_container:
|
||||
name: "{{ inventory_hostname }}"
|
||||
container_log: true
|
||||
container_log_level: "{{ (debug | bool) | ternary('DEBUG', 'INFO') }}"
|
||||
config: "{{ lxc_container_config }}"
|
||||
template: "machinectl"
|
||||
state: started
|
||||
template_options: "{{ lxc_container_machinectl_template_options }}"
|
||||
delegate_to: "{{ physical_host }}"
|
|
@ -0,0 +1 @@
|
|||
lxc_container_create_cow.yml
|
|
@ -0,0 +1 @@
|
|||
lxc_container_create_cow.yml
|
|
@ -19,23 +19,24 @@
|
|||
state: directory
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc_container_create-install
|
||||
- always
|
||||
|
||||
- name: Ansible version and LXC backing store check
|
||||
- name: Check the physical_host variable is set
|
||||
fail:
|
||||
msg: "Using overlayfs is not supported when using Ansible version < 2"
|
||||
msg: "The physical_host variable is not defined."
|
||||
when:
|
||||
- lxc_container_backing_store is defined
|
||||
- lxc_container_backing_store == "overlayfs"
|
||||
- ansible_version.major < 2
|
||||
- physical_host is undefined
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Kernel version and LXC backing store check
|
||||
debug:
|
||||
msg: "Using overlayfs is not recommended when using Kernel version < 3.18"
|
||||
when:
|
||||
- lxc_container_backing_store is defined
|
||||
- lxc_container_backing_store == "overlayfs"
|
||||
- hostvars[physical_host]['ansible_kernel'] | version_compare('3.18.0-0-generic', '<')
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Gather variables for each operating system
|
||||
include_vars: "{{ item }}"
|
||||
|
@ -48,16 +49,48 @@
|
|||
tags:
|
||||
- always
|
||||
|
||||
- include: container_destroy.yml
|
||||
when:
|
||||
- lxc_container_recreate | bool
|
||||
- name: Read custom facts from previous runs
|
||||
setup:
|
||||
filter: ansible_local
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- lxc-container-recreate
|
||||
- always
|
||||
|
||||
- include: container_create.yml
|
||||
# NOTE(cloudnull): Check for the LXC volume group when creating LVM backed
|
||||
# containers.
|
||||
- block:
|
||||
- name: Check for lxc volume group
|
||||
shell: "(which vgs > /dev/null && vgs | grep -o '{{ lxc_container_vg_name }}') || false"
|
||||
register: vg_result
|
||||
failed_when: false
|
||||
changed_when: vg_result.rc != 0
|
||||
delegate_to: "{{ physical_host }}"
|
||||
- name: LXC VG check
|
||||
fail:
|
||||
msg: >-
|
||||
The "lxc_container_backing_store" option was set to "lvm" but no LXC
|
||||
volume group was found on the physical host. Please check your settings
|
||||
and host setup.
|
||||
when:
|
||||
- vg_result.rc != 0
|
||||
when:
|
||||
- lxc_container_backing_store == 'lvm'
|
||||
tags:
|
||||
- always
|
||||
|
||||
- include: lxc_container_destroy.yml
|
||||
when:
|
||||
- physical_host != inventory_hostname
|
||||
- lxc_container_recreate | bool
|
||||
|
||||
- include: lxc_container_create.yml
|
||||
when:
|
||||
- physical_host is defined
|
||||
- inventory_hostname is defined
|
||||
- physical_host != inventory_hostname
|
||||
tags:
|
||||
- lxc_container_create
|
||||
- lxc-create
|
||||
|
||||
- include: lxc_container_config.yml
|
||||
when:
|
||||
- physical_host != inventory_hostname
|
||||
tags:
|
||||
- lxc-config
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
bashate>=0.2 # Apache-2.0
|
||||
bashate>=0.5.1 # Apache-2.0
|
||||
flake8<2.6.0,>=2.5.4 # MIT
|
||||
pyasn1!=0.2.3 # BSD
|
||||
pyOpenSSL>=0.14 # Apache-2.0
|
||||
pyasn1!=0.2.3,>=0.1.8 # BSD
|
||||
pyOpenSSL>=16.2.0 # Apache-2.0
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
ndg-httpsclient>=0.4.2;python_version<'3.0' # BSD
|
||||
|
||||
# this is required for the docs build jobs
|
||||
sphinx>=1.6.2 # BSD
|
||||
openstackdocstheme>=1.16.0 # Apache-2.0
|
||||
doc8 # Apache-2.0
|
||||
reno!=2.3.1,>=1.8.0 # Apache-2.0
|
||||
openstackdocstheme>=1.17.0 # Apache-2.0
|
||||
doc8>=0.6.0 # Apache-2.0
|
||||
reno>=2.5.0 # Apache-2.0
|
||||
sphinxmark>=0.1.14 # Apache-2.0
|
||||
|
|
|
@ -4,7 +4,7 @@ ansible_become: True
|
|||
ansible_user: root
|
||||
lxc_container_config_list:
|
||||
- "lxc.aa_profile=lxc-openstack"
|
||||
- "lxc.mount.entry=/openstack/{{ inventory_hostname }} opt/test1 none bind 0 0"
|
||||
- "lxc.mount.entry=/openstack/{{ inventory_hostname }} opt/test1 none bind,create=dir 0 0"
|
||||
|
||||
lxc_container_commands: |
|
||||
if [[ ! -d "/opt/test1" ]]; then
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Copyright 2015, 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.
|
||||
|
||||
lxc_container_backing_store: btrfs
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Copyright 2015, 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.
|
||||
|
||||
lxc_container_backing_store: dir
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Copyright 2015, 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.
|
||||
|
||||
lxc_container_backing_store: machinectl
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Copyright 2015, 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.
|
||||
|
||||
lxc_container_backing_store: overlayfs
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
# Copyright 2015, 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.
|
||||
|
||||
# At this time we're only testing ZFS on linux when the OS is Ubuntu.
|
||||
# If ZFS get support across more distros we can revist this.
|
||||
lxc_container_backing_store: zfs
|
||||
lxc_container_zfs_root_name: "pool/lxc"
|
|
@ -50,10 +50,10 @@
|
|||
failed_when: container3_profile.rc == 0
|
||||
|
||||
- name: Check for the presence of the right bound mount for container1
|
||||
command: grep "lxc.mount.entry = /openstack/container1 opt/test1 none bind 0 0" /var/lib/lxc/container1/config
|
||||
command: grep "lxc.mount.entry = /openstack/container1 opt/test1 none bind,create=dir 0 0" /var/lib/lxc/container1/config
|
||||
|
||||
- name: Check for the presence of the right bound mount for container2
|
||||
command: grep "lxc.mount.entry = {{ development_repo_directory }} {{ development_repo_directory | relpath('/') }} none bind 0 0" /var/lib/lxc/container2/config
|
||||
command: grep "lxc.mount.entry = {{ development_repo_directory }} {{ development_repo_directory | relpath('/') }} none bind,create=dir 0 0" /var/lib/lxc/container2/config
|
||||
|
||||
- name: Check for the presence of the default bound mount for container3
|
||||
command: grep "lxc.mount.entry = /openstack/backup/container3" /var/lib/lxc/container3/config
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
# Copyright 2017, BBC R&D
|
||||
#
|
||||
# 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: Configure BTRFS backing storage
|
||||
hosts: localhost
|
||||
user: root
|
||||
become: true
|
||||
connection: local
|
||||
tasks:
|
||||
- block:
|
||||
- name: Install BTRFS packages
|
||||
package:
|
||||
name: "{{ btrfs_package[ansible_distribution | lower] }}"
|
||||
state: present
|
||||
|
||||
- name: Create base directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: "directory"
|
||||
with_items:
|
||||
- /openstack
|
||||
- /var/lib/lxc
|
||||
|
||||
- name: Create sparse lxc-btrfs file
|
||||
command: "truncate -s 1024G /openstack/lxc-btrfs.img"
|
||||
args:
|
||||
creates: /openstack/lxc-btrfs.img
|
||||
register: lxc_btrfs_create
|
||||
|
||||
- name: Format the lxc-btrfs file
|
||||
filesystem:
|
||||
fstype: btrfs
|
||||
dev: /openstack/lxc-btrfs.img
|
||||
when: lxc_btrfs_create | changed
|
||||
|
||||
- name: Create the mount points, fstab entries and mount the file systems
|
||||
mount:
|
||||
name: /var/lib/lxc
|
||||
src: /openstack/lxc-btrfs.img
|
||||
fstype: btrfs
|
||||
state: mounted
|
||||
when:
|
||||
- lxc_container_backing_store == 'btrfs'
|
||||
vars:
|
||||
btrfs_package:
|
||||
ubuntu: "btrfs-tools"
|
||||
redhat: "btrfs-progs"
|
||||
suse: "btrfsprogs"
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
# Copyright 2017, BBC R&D
|
||||
#
|
||||
# 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: Configure ZFS backing storage
|
||||
hosts: localhost
|
||||
user: root
|
||||
become: true
|
||||
connection: local
|
||||
tasks:
|
||||
- block:
|
||||
- name: Install ZFS packages
|
||||
package:
|
||||
name: "{{ zfs_package[ansible_distribution | lower] }}"
|
||||
state: present
|
||||
|
||||
- name: Create base directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: "directory"
|
||||
with_items:
|
||||
- /openstack
|
||||
- /var/lib/lxc
|
||||
|
||||
- name: Create sparse ZFS backing file
|
||||
command: "truncate -s 1024G /openstack/lxc-zfs.img"
|
||||
args:
|
||||
creates: /openstack/lxc-zfs.img
|
||||
register: lxc_zfs_create
|
||||
|
||||
- name: Create the ZFS pool
|
||||
command: zpool create pool /openstack/lxc-zfs.img
|
||||
args:
|
||||
creates: /pool
|
||||
|
||||
- name: Create the ZFS pool/lxc volume
|
||||
shell: "(zfs list | grep lxc) || zfs create -o mountpoint=/var/lib/lxc pool/lxc"
|
||||
when:
|
||||
- lxc_container_backing_store == 'zfs'
|
||||
vars:
|
||||
zfs_package:
|
||||
ubuntu: "zfsutils-linux"
|
|
@ -13,6 +13,12 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Create a zfs backend
|
||||
- include: test-create-zfs-dev.yml
|
||||
|
||||
# Create a btrfs backend
|
||||
- include: test-create-btrfs-dev.yml
|
||||
|
||||
# Setup the host
|
||||
- include: common/test-setup-host.yml
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ fi
|
|||
# tests repo are not supported.
|
||||
if [[ "${CLONE_UPGRADE_TESTS}" == "yes" ]]; then
|
||||
if [[ ! -d "${WORKING_DIR}/tests/common/previous" ]]; then
|
||||
git clone -b stable/ocata \
|
||||
git clone -b stable/pike \
|
||||
https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||
${WORKING_DIR}/tests/common/previous
|
||||
fi
|
||||
|
|
63
tox.ini
63
tox.ini
|
@ -95,14 +95,75 @@ commands =
|
|||
bash -c "{toxinidir}/tests/common/test-ansible-lint.sh"
|
||||
|
||||
|
||||
[testenv:functional]
|
||||
# Functional testing for BTRFS backed containers
|
||||
[testenv:btrfs]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-btrfs.yml
|
||||
commands =
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
||||
|
||||
|
||||
# Functional testing for Directory backed containers
|
||||
[testenv:dir]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-dir.yml
|
||||
commands =
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
||||
|
||||
|
||||
# Functional testing for machinectl backed containers
|
||||
[testenv:mnctl]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-machinectl.yml
|
||||
commands =
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
||||
|
||||
|
||||
# Functional testing for OverlayFS backed containers
|
||||
[testenv:ofs]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-overlayfs.yml
|
||||
commands =
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
||||
|
||||
|
||||
# Functional testing for ZFS backed containers
|
||||
[testenv:zfs]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-zfs.yml
|
||||
commands =
|
||||
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
|
||||
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
|
||||
|
||||
|
||||
[testenv:functional]
|
||||
deps =
|
||||
{[testenv:dir]deps}
|
||||
setenv =
|
||||
{[testenv:dir]setenv}
|
||||
commands =
|
||||
{[testenv:dir]commands}
|
||||
|
||||
|
||||
[testenv:linters]
|
||||
deps =
|
||||
{[testenv:ansible]deps}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
# Copyright 2017, 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.
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-dir-ubuntu-xenial
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: ubuntu-xenial
|
||||
vars:
|
||||
tox_env: dir
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-dir-centos-7
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: centos-7
|
||||
vars:
|
||||
tox_env: dir
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-dir-opensuse-423
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: opensuse-423
|
||||
vars:
|
||||
tox_env: dir
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-btrfs-ubuntu-xenial
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: ubuntu-xenial
|
||||
voting: false
|
||||
vars:
|
||||
tox_env: btrfs
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-machinectl-ubuntu-xenial
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: ubuntu-xenial
|
||||
voting: false
|
||||
vars:
|
||||
tox_env: mnctl
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-overlayfs-ubuntu-xenial
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: ubuntu-xenial
|
||||
voting: false
|
||||
vars:
|
||||
tox_env: ofs
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-zfs-ubuntu-xenial
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: ubuntu-xenial
|
||||
voting: false
|
||||
vars:
|
||||
tox_env: zfs
|
|
@ -18,12 +18,16 @@
|
|||
check:
|
||||
jobs:
|
||||
- openstack-ansible-linters
|
||||
- openstack-ansible-functional-centos-7
|
||||
- openstack-ansible-functional-opensuse-423
|
||||
- openstack-ansible-functional-ubuntu-xenial
|
||||
- openstack-ansible-dir-ubuntu-xenial
|
||||
- openstack-ansible-dir-centos-7
|
||||
- openstack-ansible-dir-opensuse-423
|
||||
- openstack-ansible-btrfs-ubuntu-xenial
|
||||
- openstack-ansible-machinectl-ubuntu-xenial
|
||||
- openstack-ansible-overlayfs-ubuntu-xenial
|
||||
- openstack-ansible-zfs-ubuntu-xenial
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-ansible-linters
|
||||
- openstack-ansible-functional-centos-7
|
||||
- openstack-ansible-functional-opensuse-423
|
||||
- openstack-ansible-functional-ubuntu-xenial
|
||||
- openstack-ansible-dir-ubuntu-xenial
|
||||
- openstack-ansible-dir-centos-7
|
||||
- openstack-ansible-dir-opensuse-423
|
||||
|
|
Loading…
Reference in New Issue