Add minimal functional gate
Change-Id: Ibb758b2e5a7f8bccffe307932aa4f472687f7acb Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
774688ca92
commit
68d36dedd0
@ -13,6 +13,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
- name: Restart networkd
|
||||||
|
service:
|
||||||
|
name: systemd-networkd
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
listen: check connection
|
||||||
|
|
||||||
- name: Wait for container connectivity
|
- name: Wait for container connectivity
|
||||||
wait_for_connection:
|
wait_for_connection:
|
||||||
delay: 3
|
delay: 3
|
||||||
|
@ -33,4 +33,5 @@ galaxy_info:
|
|||||||
- python
|
- python
|
||||||
- development
|
- development
|
||||||
- openstack
|
- openstack
|
||||||
dependencies: []
|
dependencies:
|
||||||
|
- plugins
|
||||||
|
@ -99,6 +99,7 @@
|
|||||||
- "/openstack/log/{{ inventory_hostname }}"
|
- "/openstack/log/{{ inventory_hostname }}"
|
||||||
- "/var/lib/machines/{{ inventory_hostname }}/etc/systemd/network"
|
- "/var/lib/machines/{{ inventory_hostname }}/etc/systemd/network"
|
||||||
- "/var/lib/machines/{{ inventory_hostname }}/etc/systemd/nspawn"
|
- "/var/lib/machines/{{ inventory_hostname }}/etc/systemd/nspawn"
|
||||||
|
- "/var/lib/machines/{{ inventory_hostname }}/var/lib/dbus"
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
|
|
||||||
- name: Container RO bind path cleanup
|
- name: Container RO bind path cleanup
|
||||||
@ -263,12 +264,6 @@
|
|||||||
notify:
|
notify:
|
||||||
- check connection
|
- check connection
|
||||||
|
|
||||||
- name: Restart networkd
|
|
||||||
service:
|
|
||||||
name: systemd-networkd
|
|
||||||
state: restarted
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
- name: Create journal directory
|
- name: Create journal directory
|
||||||
file:
|
file:
|
||||||
path: "/var/log/journal"
|
path: "/var/log/journal"
|
||||||
|
@ -23,6 +23,7 @@ RouteMetric=20
|
|||||||
{% for route in item.value.static_routes %}
|
{% for route in item.value.static_routes %}
|
||||||
Source={{ route['cidr'] }}
|
Source={{ route['cidr'] }}
|
||||||
Gateway={{ route['gateway'] }}
|
Gateway={{ route['gateway'] }}
|
||||||
|
Metric={{ 40 + loop.index }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -10,7 +10,11 @@
|
|||||||
src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts
|
src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts
|
||||||
scm: git
|
scm: git
|
||||||
version: master
|
version: master
|
||||||
- name: lxc_hosts
|
- name: nspawn_hosts
|
||||||
src: https://git.openstack.org/openstack/openstack-ansible-lxc_hosts
|
src: https://git.openstack.org/openstack/openstack-ansible-nspawn_hosts
|
||||||
|
scm: git
|
||||||
|
version: master
|
||||||
|
- name: plugins
|
||||||
|
src: https://git.openstack.org/openstack/openstack-ansible-plugins
|
||||||
scm: git
|
scm: git
|
||||||
version: master
|
version: master
|
||||||
|
@ -13,13 +13,19 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
- name: Gather nspawn container host facts
|
container_networks:
|
||||||
hosts: "localhost"
|
management_address:
|
||||||
gather_facts: true
|
address: "{{ ansible_host | default('localhost') }}"
|
||||||
|
bridge: "br-mgmt"
|
||||||
|
interface: "eth1"
|
||||||
|
netmask: "255.255.252.0"
|
||||||
|
type: "veth"
|
||||||
|
static_routes:
|
||||||
|
- cidr: 10.100.100.0/24
|
||||||
|
gateway: 10.100.100.1
|
||||||
|
|
||||||
- name: Create container(s)
|
bridges:
|
||||||
hosts: "{{ container_group|default('all_containers') }}"
|
- name: "br-mgmt"
|
||||||
gather_facts: false
|
ip_addr: "172.29.236.100"
|
||||||
user: root
|
netmask: "255.255.252.0"
|
||||||
roles:
|
- name: "br-vlan"
|
||||||
- role: "nspawn_container_create"
|
|
@ -15,19 +15,8 @@
|
|||||||
|
|
||||||
container_name: "{{ inventory_hostname }}"
|
container_name: "{{ inventory_hostname }}"
|
||||||
|
|
||||||
container_networks:
|
|
||||||
management_address:
|
|
||||||
address: "{{ ansible_host }}"
|
|
||||||
bridge: "br-mgmt"
|
|
||||||
interface: "eth1"
|
|
||||||
netmask: "255.255.252.0"
|
|
||||||
type: "veth"
|
|
||||||
static_routes:
|
|
||||||
- cidr: 10.100.100.0/24
|
|
||||||
gateway: 10.100.100.1
|
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
service_name: "{{ inventory_hostname }}"
|
service_name: "{{ inventory_hostname }}"
|
||||||
|
|
||||||
global_environment_variables:
|
deployment_environment_variables:
|
||||||
foo: "bar"
|
foo: bar
|
||||||
|
@ -4,3 +4,5 @@ ansible_become: True
|
|||||||
ansible_user: root
|
ansible_user: root
|
||||||
|
|
||||||
physical_host: localhost
|
physical_host: localhost
|
||||||
|
|
||||||
|
container_tech: nspawn
|
||||||
|
@ -4,3 +4,5 @@ ansible_become: True
|
|||||||
ansible_user: root
|
ansible_user: root
|
||||||
|
|
||||||
physical_host: localhost
|
physical_host: localhost
|
||||||
|
|
||||||
|
container_tech: nspawn
|
||||||
|
@ -4,3 +4,5 @@ ansible_become: True
|
|||||||
ansible_user: root
|
ansible_user: root
|
||||||
|
|
||||||
physical_host: localhost
|
physical_host: localhost
|
||||||
|
|
||||||
|
container_tech: nspawn
|
||||||
|
@ -17,3 +17,5 @@ bridges:
|
|||||||
- "br-mgmt"
|
- "br-mgmt"
|
||||||
|
|
||||||
ansible_python_interpreter: "/usr/bin/python2"
|
ansible_python_interpreter: "/usr/bin/python2"
|
||||||
|
|
||||||
|
physical_host: localhost
|
||||||
|
48
tests/templates/test-networks.service.j2
Normal file
48
tests/templates/test-networks.service.j2
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=test networks service
|
||||||
|
After=syslog.target
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
User=root
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
{% set seen_start_interfaces = [] %}
|
||||||
|
{% for item in bridges %}
|
||||||
|
{% if item is mapping %}
|
||||||
|
{% if item.name not in seen_start_interfaces %}
|
||||||
|
{% set _ = seen_start_interfaces.append(item.name) %}
|
||||||
|
|
||||||
|
# Interface [{{ item.name }}]
|
||||||
|
ExecStart=-/sbin/ip link add dev "{{ item.name }}" type bridge
|
||||||
|
ExecStart=-/sbin/ip link set dev "{{ item.name }}" up
|
||||||
|
{% if item.address is defined and item.netmask is defined %}
|
||||||
|
ExecStart=-/sbin/ip address add "{{ item.address }}/{{ item.netmask }}" dev "{{ item.bridge }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if item.veth_peer is defined %}
|
||||||
|
ExecStart=-/sbin/ip link add "{{ item.name }}-veth" type veth peer name "{{ item.veth_peer }}"
|
||||||
|
ExecStart=-/sbin/ip link set "{{ item.name }}-veth" up
|
||||||
|
ExecStart=-/sbin/ip link set "{{ item.veth_peer }}-veth" up
|
||||||
|
ExecStart=-/sbin/ip link set dev "{{ item.name }}-veth" master "{{ item.name }}"
|
||||||
|
ExecStop=-/sbin/ip link delete dev "{{ item.veth_peer }}-veth"
|
||||||
|
ExecStop=-/sbin/ip link delete dev "{{ item.name }}-veth"
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
ExecStop=-/sbin/ip link delete dev "{{ item }}"
|
||||||
|
{% else %}
|
||||||
|
{% if item not in seen_start_interfaces %}
|
||||||
|
{% set _ = seen_start_interfaces.append(item) %}
|
||||||
|
|
||||||
|
# Interface [{{ item }}]
|
||||||
|
ExecStart=-/sbin/ip link add dev "{{ item }}" type bridge
|
||||||
|
ExecStart=-/sbin/ip link set dev "{{ item }}" up
|
||||||
|
ExecStop=-/sbin/ip link delete dev "{{ item }}"
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
242
tests/test.yml
242
tests/test.yml
@ -13,11 +13,241 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# Prepare the user ssh keys
|
- name: Playbook for role testing
|
||||||
- include: common/test-prepare-keys.yml
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
become: true
|
||||||
|
pre_tasks:
|
||||||
|
- name: Show host facts
|
||||||
|
debug:
|
||||||
|
var: hostvars
|
||||||
|
|
||||||
# Prepare the host
|
- name: Create test network service
|
||||||
- include: common/test-prepare-host.yml
|
template:
|
||||||
|
src: "templates/test-networks.service.j2"
|
||||||
|
dest: "/etc/systemd/system/test-networks.service"
|
||||||
|
|
||||||
# Test container creation
|
- name: Enable test network service
|
||||||
- include: test-containers-create.yml
|
systemd:
|
||||||
|
name: "test-networks.service"
|
||||||
|
state: "restarted"
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- 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:
|
||||||
|
nspawn_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}"
|
||||||
|
|
||||||
|
# This is a very dirty hack due to images.linuxcontainers.org
|
||||||
|
# constantly failing to resolve in openstack-infra.
|
||||||
|
- name: Implement hard-coded hosts entries for consistently failing name
|
||||||
|
lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
line: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- "91.189.91.21 images.linuxcontainers.org us.images.linuxcontainers.org"
|
||||||
|
- "91.189.88.37 images.linuxcontainers.org uk.images.linuxcontainers.org"
|
||||||
|
|
||||||
|
# This is a temporary hack to override the nspawn image source to
|
||||||
|
# the reverse proxy if the test is run in OpenStack-Infra.
|
||||||
|
- name: Check if this is an OpenStack-CI nodepool instance
|
||||||
|
stat:
|
||||||
|
path: /etc/nodepool/provider
|
||||||
|
register: nodepool
|
||||||
|
|
||||||
|
- name: Discover the nspawn_image_cache_server value when in nodepool
|
||||||
|
shell: |
|
||||||
|
source /etc/ci/mirror_info.sh
|
||||||
|
echo "${NODEPOOL_MIRROR_HOST}:8080/images.linuxcontainers"
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
register: nspawn_reverse_proxy
|
||||||
|
when:
|
||||||
|
- nodepool.stat.exists | bool
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Set a fact to override nspawn_image_cache_server value when in nodepool
|
||||||
|
set_fact:
|
||||||
|
nspawn_image_cache_server_mirrors: ["http://{{ nspawn_reverse_proxy.stdout.strip('/') }}"]
|
||||||
|
when:
|
||||||
|
- nodepool.stat.exists | bool
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: "nspawn_hosts"
|
||||||
|
|
||||||
|
- name: Create container(s)
|
||||||
|
hosts: all_containers
|
||||||
|
gather_facts: false
|
||||||
|
become: true
|
||||||
|
pre_tasks:
|
||||||
|
- name: Poweroff container
|
||||||
|
command: "machinectl poweroff {{ inventory_hostname }}"
|
||||||
|
delegate_to: "{{ physical_host }}"
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Remove container
|
||||||
|
command: "machinectl remove {{ inventory_hostname }}"
|
||||||
|
delegate_to: "{{ physical_host }}"
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Container cleanup
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: "absent"
|
||||||
|
with_items:
|
||||||
|
- "/openstack/log/{{ inventory_hostname }}"
|
||||||
|
- "/openstack/{{ inventory_hostname }}"
|
||||||
|
delegate_to: "{{ physical_host }}"
|
||||||
|
roles:
|
||||||
|
- role: "nspawn_container_create"
|
||||||
|
post_tasks:
|
||||||
|
- name: force all notified handlers to run at this point
|
||||||
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Test connectivity to external address
|
||||||
|
command: ping -i 5 -c 6 8.8.8.8
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Test containers
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: Stop container3
|
||||||
|
command: "machinectl poweroff container3"
|
||||||
|
register: container_stop
|
||||||
|
changed_when: container_stop.rc == 0
|
||||||
|
failed_when: not container_stop.rc in [0, 2]
|
||||||
|
until: container_stop.rc in [0, 2]
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Start container3
|
||||||
|
command: "machinectl start container3"
|
||||||
|
register: container_start
|
||||||
|
changed_when: container_start.rc == 0
|
||||||
|
until: container_start | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Status check container1
|
||||||
|
command: "machinectl status container1"
|
||||||
|
register: container_status
|
||||||
|
changed_when: container_status.rc == 0
|
||||||
|
until: container_status | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Clone container2
|
||||||
|
command: "machinectl clone container2 test1-container2"
|
||||||
|
register: container_clone
|
||||||
|
changed_when: container_clone.rc == 0
|
||||||
|
until: container_clone | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Show image test1-container2
|
||||||
|
command: "machinectl show-image test1-container2"
|
||||||
|
register: container_show
|
||||||
|
changed_when: container_show.rc == 0
|
||||||
|
until: container_show | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Rename image test1-container2
|
||||||
|
command: "machinectl rename test1-container2 test1"
|
||||||
|
register: container_rename
|
||||||
|
changed_when: container_rename.rc == 0
|
||||||
|
until: container_rename | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Check Status of test1 image
|
||||||
|
command: "machinectl image-status test1"
|
||||||
|
register: container_status
|
||||||
|
changed_when: container_status.rc == 0
|
||||||
|
until: container_status | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Start test1 container
|
||||||
|
command: "machinectl start test1"
|
||||||
|
register: container_start
|
||||||
|
changed_when: container_start.rc == 0
|
||||||
|
until: container_start | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Status test1 container
|
||||||
|
command: "machinectl status test1"
|
||||||
|
register: container_status
|
||||||
|
changed_when: container_status.rc == 0
|
||||||
|
until: container_status | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Poweroff test1 container
|
||||||
|
command: "machinectl poweroff test1"
|
||||||
|
register: container_poweroff
|
||||||
|
changed_when: container_poweroff.rc == 0
|
||||||
|
until: container_poweroff | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Remove test container images
|
||||||
|
command: "machinectl remove {{ item }}"
|
||||||
|
with_items:
|
||||||
|
- test1
|
||||||
|
register: container_poweroff
|
||||||
|
changed_when: container_poweroff.rc == 0
|
||||||
|
until: container_poweroff | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Poweroff all containers
|
||||||
|
command: "machinectl poweroff {{ item }}"
|
||||||
|
with_items: "{{ groups['all_containers'] }}"
|
||||||
|
register: container_poweroff
|
||||||
|
changed_when: container_poweroff.rc == 0
|
||||||
|
until: container_poweroff | success
|
||||||
|
retries: 3
|
||||||
|
delay: 2
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
29
zuul.d/jobs.yaml
Normal file
29
zuul.d/jobs.yaml
Normal file
@ -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.
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-ansible-nspawn-ubuntu-xenial
|
||||||
|
parent: openstack-ansible-functional
|
||||||
|
nodeset: ubuntu-xenial
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: openstack-ansible-nspawn-centos-7
|
||||||
|
parent: openstack-ansible-functional
|
||||||
|
nodeset: centos-7
|
||||||
|
|
||||||
|
# - job:
|
||||||
|
# name: openstack-ansible-nspawn-opensuse-423
|
||||||
|
# parent: openstack-ansible-functional
|
||||||
|
# nodeset: opensuse-423
|
30
zuul.d/project.yaml
Normal file
30
zuul.d/project.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
- project:
|
||||||
|
check:
|
||||||
|
jobs:
|
||||||
|
- openstack-ansible-linters
|
||||||
|
- openstack-ansible-nspawn-ubuntu-xenial
|
||||||
|
- openstack-ansible-nspawn-centos-7
|
||||||
|
# - openstack-ansible-nspawn-opensuse-423
|
||||||
|
experimental:
|
||||||
|
jobs:
|
||||||
|
- openstack-ansible-integrated-deploy-aio
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- openstack-ansible-linters
|
||||||
|
- openstack-ansible-nspawn-ubuntu-xenial
|
||||||
|
- openstack-ansible-nspawn-centos-7
|
||||||
|
# - openstack-ansible-nspawn-opensuse-423
|
Loading…
Reference in New Issue
Block a user