Browse Source

Create ansible virtualenv on bastion

Change-Id: I7b925ae283d25d42b2079d9ee5789b9fef97aab6
Depends-On: https://review.openstack.org/638208
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
changes/19/638219/22
Paul Belanger 3 years ago
parent
commit
609e460994
  1. 20
      inventory/testing/group_vars/bastion.yaml
  2. 1
      requirements.txt
  3. 27
      tests/playbooks/pre.yaml
  4. 2
      tests/playbooks/run-post.yaml
  5. 8
      tests/playbooks/run-pre.yaml
  6. 4
      tests/playbooks/run.yaml

20
inventory/testing/group_vars/bastion.yaml

@ -0,0 +1,20 @@
# Copyright 2019 Red Hat, 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.
---
ansible_pip_name:
- ansible
- ara
- netaddr
ansible_pip_virtualenv_python: python3
ansible_pip_virtualenv: /opt/venv/ansible

1
requirements.txt

@ -1,2 +1 @@
ansible>=2.4.0
netaddr

27
tests/playbooks/pre.yaml

@ -16,16 +16,27 @@
state: absent
when: ansible_os_family == 'RedHat'
- name: Symlink ansible configuration file
file:
- name: Install ansible configuration file
template:
dest: ~/.ansible.cfg
src: "{{ ansible_user_dir}}/{{ windmill_src_dir }}/inventory/testing/ansible.cfg"
state: link
src: "{{ zuul.executor.work_root }}/{{ windmill_src_dir }}/inventory/testing/ansible.cfg"
- name: Bootstrap bindep environment
args:
chdir: "{{ windmill_src_dir }}"
command: tox -ebindep
- name: Set ARA fact for Debian
set_fact:
ara_path: /opt/venv/ansible/lib/python3.6/site-packages/ara/plugins/callbacks
when: ansible_os_family == 'Debian'
- name: Set ARA fact for RedHat
set_fact:
ara_path: /opt/venv/ansible/lib/python3.7/site-packages/ara/plugins/callbacks
when: ansible_os_family == 'RedHat'
- name: Enable ARA callback plugin
ini_file:
path: ~/.ansible.cfg
section: defaults
option: callback_plugins
value: "{{ ara_path }}"
- name: Bootstrap tox environment
args:

2
tests/playbooks/run-post.yaml

@ -4,4 +4,4 @@
- name: Run ansible-playbook for prove.yaml
args:
chdir: "{{ windmill_src_dir }}"
shell: "tox -evenv -- ansible-playbook -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/prove.yaml"
shell: "/opt/venv/ansible/bin/ansible-playbook -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/prove.yaml"

8
tests/playbooks/run-pre.yaml

@ -5,3 +5,11 @@
args:
chdir: "{{ windmill_src_dir }}"
shell: "tox -evenv -- ansible-playbook -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts tests/playbooks/bastion/site.yaml"
# TODO(pabelanger): Because we use ansible, to install ansible, we first
# need to run windmill-ops, like we do with the current launch-node.py
# script. However, limit it to only the bastion host.
- name: Bootstrap bastion node using windmill-ops
args:
chdir: "{{ zuul.projects['git.openstack.org/openstack/windmill-ops'].src_dir }}"
shell: "tox -evenv -- ansible-playbook -v -f1 -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/bootstrap/site.yaml --limit bastion"

4
tests/playbooks/run.yaml

@ -4,9 +4,9 @@
- name: Bootstrap all nodes using windmill-ops
args:
chdir: "{{ zuul.projects['git.openstack.org/openstack/windmill-ops'].src_dir }}"
shell: "tox -evenv -- ansible-playbook -v -f1 -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/bootstrap/site.yaml"
shell: "/opt/venv/ansible/bin/ansible-playbook -v -f1 -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/bootstrap/site.yaml"
- name: Run ansible-playbook for site.yaml
args:
chdir: "{{ windmill_src_dir }}"
shell: "tox -evenv -- ansible-playbook -v -f1 -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/site.yaml -e @{{ windmill_extra_vars_file }}"
shell: "/opt/venv/ansible/bin/ansible-playbook -v -f1 -i {{ ansible_user_dir }}/{{ windmill_src_dir }}/inventory/testing/hosts playbooks/site.yaml -e @{{ windmill_extra_vars_file }}"

Loading…
Cancel
Save