openstack-ansible-lxc_hosts/tests/test.yml
Mohammed Naser 1d7fe1e10c redhat: Add the EPEL repository for aria2 and python2-lxc packages
The ARIA2 package is needed from EPEL so we install it inside
the role. Moreover, in order to minimize the potential EPEL vs RDO
package conflicts, we only allow a small subset of packages from the
EPEL repository. This also removes the 'debootstrap' package from
CentOS since it's not needed. Finally, we include the nodepool playbook
from the tests repository in order to populate the necessary CI facts.

Depends-On: https://review.openstack.org/#/c/574801/
Depends-On: https://review.openstack.org/#/c/575059/
Change-Id: Icd4d09a26cd95ecfefec26142723ddffe81aae74
Co-Authored-By: Markos Chandras <mchandras@suse.de>
2018-06-13 13:26:48 +01:00

102 lines
3.4 KiB
YAML

---
# 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.
- name: Playbook for role testing
hosts: localhost
connection: local
become: true
pre_tasks:
- name: Show host facts
debug:
var: hostvars
- name: First ensure apt cache is always refreshed
apt:
update_cache: yes
when:
- ansible_pkg_mgr == 'apt'
- name: Ensure root ssh key
user:
name: "{{ ansible_env.USER | default('root') }}"
generate_ssh_key: "yes"
ssh_key_bits: 2048
ssh_key_file: ".ssh/id_rsa"
- name: Get root ssh key
slurp:
src: '~/.ssh/id_rsa.pub'
register: _root_ssh_key
- name: Prepare container ssh key fact
set_fact:
lxc_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}"
- include_tasks: "common/common-tasks/test-set-nodepool-vars.yml"
roles:
- role: "lxc_hosts"
lxc_net_address: 10.100.100.1
lxc_net_bridge: lxcbr0
lxc_kernel_options:
- { key: 'fs.inotify.max_user_instances', value: 1024 }
lxc_container_cache_files:
- src: files/container-file-copy-test.txt
dest: /tmp/file-copied-from-deployment-host.txt
post_tasks:
- name: Get sysctl content
set_fact:
sysctl_conf: "{{ lookup('file', '/etc/sysctl.conf') }}"
- name: Check for lxc bridge
stat:
path: /sys/class/net/lxcbr0/bridge/bridge_id
register: lxc_bridge_file
- name: Check dnsmasq is running
shell: ps auxfww | grep -w 'dnsmasq -u lxc-dnsmasq'
changed_when: false
- name: DEBIAN - Get deployed interface file contents, without Ansible managed line
set_fact:
interface_file: "{{ lookup('pipe', 'cat /etc/network/interfaces.d/lxc-net-bridge.cfg | tail -n +3') }}"
when: ansible_os_family | lower == "debian"
- name: RHEL - Get deployed interface file contents, without Ansible managed line
set_fact:
interface_file: "{{ lookup('pipe', 'cat /etc/sysconfig/network-scripts/ifcfg-lxcbr0 | tail -n +3') }}"
when: ansible_os_family | lower == "redhat"
- name: SUSE - Get deployed interface file contents, without Ansible managed line
set_fact:
interface_file: "{{ lookup('pipe', 'cat /etc/sysconfig/network/ifcfg-lxcbr0 | tail -n +3') }}"
when: ansible_os_family | lower == "suse"
- name: Get bridge interface facts
setup:
filter: ansible_lxcbr0
register: lxcbr0_facts
- name: Check role functions
assert:
that:
- interface_file | search('.*lxcbr0.*')
- interface_file | search('.*10.100.100.1.*')
- interface_file | search('.*255.255.255.0.*')
- sysctl_conf | search('fs.inotify.max_user_instances.*')
- "lxc_bridge_file.stat.exists"
- "lxcbr0_facts.ansible_facts.ansible_lxcbr0.ipv4.address | match('10.100.100.1')"