openstack-ansible-openstack.../tests/test.yml

76 lines
2.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
pre_tasks:
- name: First ensure apt cache is always refreshed
apt:
update_cache: yes
roles:
- role: "{{ rolename | basename }}"
openstack_host_kernel_modules:
- dm_multipath
openstack_kernel_options:
- { key: 'vm.swappiness', value: 5 }
global_environment_variables:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
post_tasks:
- name: Open modules file
slurp:
src: /etc/modules
register: modules_file
- name: Open sysctl file
slurp:
src: /etc/sysctl.conf
register: sysctl_file
- name: Open hosts file
slurp:
src: /etc/hosts
register: hosts_file
- name: Read files
set_fact:
modules_content: "{{ modules_file.content | b64decode }}"
sysctl_content: "{{ sysctl_file.content | b64decode }}"
hosts_content: "{{ hosts_file.content | b64decode }}"
- name: Check for release file
stat:
path: /etc/openstack-release
register: release_file
- name: Check for systat file
stat:
path: /etc/default/sysstat
register: systat_file
- name: Check for environment file
stat:
path: /etc/environment
register: environment_file
- name: Check for ssh dir
stat:
path: "{{ ansible_env.HOME}}/.ssh"
register: ssh_dir
- name: Check role functions
assert:
that:
- "'dm_multipath' in modules_content"
- "'vm.swappiness' in sysctl_content"
- "'127.111.111.101 test1' in hosts_content"
- "'127.111.111.102 test2' in hosts_content"
- "release_file.stat.exists"
- "systat_file.stat.exists"
- "environment_file.stat.exists"
- "ssh_dir.stat.isdir"