From 84e471264a0d398acf1f4458efb2c0f030b6ac65 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 22 Feb 2018 16:43:19 -0600 Subject: [PATCH] Add minimal functional gate Change-Id: Ibb758b2e5a7f8bccffe307932aa4f472687f7acb Signed-off-by: Kevin Carter --- meta/main.yml | 3 +- tests/ansible-role-requirements.yml | 8 +- .../all.yml} | 20 ++--- tests/group_vars/all_containers.yml | 11 --- tests/host_vars/localhost.yml | 2 + tests/test.yml | 80 +++++++++++++++++-- zuul.d/jobs.yaml | 29 +++++++ zuul.d/project.yaml | 30 +++++++ 8 files changed, 153 insertions(+), 30 deletions(-) rename tests/{test-containers-create.yml => group_vars/all.yml} (68%) create mode 100644 zuul.d/jobs.yaml create mode 100644 zuul.d/project.yaml diff --git a/meta/main.yml b/meta/main.yml index da313ca..00f4da5 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -33,4 +33,5 @@ galaxy_info: - python - development - openstack -dependencies: [] +dependencies: + - plugins diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index ac87a1c..4dd225b 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -10,7 +10,11 @@ src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts scm: git version: master -- name: lxc_hosts - src: https://git.openstack.org/openstack/openstack-ansible-lxc_hosts +- name: nspawn_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 version: master diff --git a/tests/test-containers-create.yml b/tests/group_vars/all.yml similarity index 68% rename from tests/test-containers-create.yml rename to tests/group_vars/all.yml index a770ad8..5bef675 100644 --- a/tests/test-containers-create.yml +++ b/tests/group_vars/all.yml @@ -13,13 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Gather nspawn container host facts - hosts: "localhost" - gather_facts: true - -- name: Create container(s) - hosts: "{{ container_group|default('all_containers') }}" - gather_facts: false - user: root - roles: - - role: "nspawn_container_create" +container_networks: + management_address: + 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 diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml index 7349858..545f686 100644 --- a/tests/group_vars/all_containers.yml +++ b/tests/group_vars/all_containers.yml @@ -15,17 +15,6 @@ 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: service_name: "{{ inventory_hostname }}" diff --git a/tests/host_vars/localhost.yml b/tests/host_vars/localhost.yml index 65ddeaa..0829028 100644 --- a/tests/host_vars/localhost.yml +++ b/tests/host_vars/localhost.yml @@ -17,3 +17,5 @@ bridges: - "br-mgmt" ansible_python_interpreter: "/usr/bin/python2" + +physical_host: localhost diff --git a/tests/test.yml b/tests/test.yml index 9db1f68..85d6345 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -13,11 +13,79 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Prepare the user ssh keys -- include: common/test-prepare-keys.yml +- name: Playbook for role testing + hosts: localhost + connection: local + become: true + pre_tasks: + - name: Show host facts + debug: + var: hostvars -# Prepare the host -- include: common/test-prepare-host.yml + - name: First ensure apt cache is always refreshed + apt: + update_cache: yes + when: + - ansible_pkg_mgr == 'apt' -# Test container creation -- include: test-containers-create.yml + - 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 + user: root + roles: + - role: "nspawn_container_create" diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 0000000..c82090c --- /dev/null +++ b/zuul.d/jobs.yaml @@ -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 diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml new file mode 100644 index 0000000..db546c8 --- /dev/null +++ b/zuul.d/project.yaml @@ -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