Create devstack-tobiko Vagrantfile
Change-Id: I59810fd352b196f3fb08b265cfb3962efb88f326
This commit is contained in:
parent
1af98dca8e
commit
1758142b29
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
# Tox files
|
# Tox files
|
||||||
.tox
|
.tox
|
||||||
|
.vagrant
|
||||||
|
126
Vagrantfile
vendored
Normal file
126
Vagrantfile
vendored
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# -*- mode: ruby -*-
|
||||||
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||||
|
VAGRANTFILE_API_VERSION = "2"
|
||||||
|
|
||||||
|
# Customize the count of CPU cores on the VM
|
||||||
|
CPUS = 4
|
||||||
|
|
||||||
|
# Customize the amount of memory on the VM
|
||||||
|
MEMORY = ENV.fetch("VM_SIZE", "4096").to_i
|
||||||
|
|
||||||
|
# Every Vagrant development environment requires a box. You can search for
|
||||||
|
# boxes at https://vagrantcloud.com/search.
|
||||||
|
BOX = ENV.fetch("VM_BOX", "generic/centos8")
|
||||||
|
|
||||||
|
# Machine host name
|
||||||
|
HOSTNAME = "tobiko"
|
||||||
|
|
||||||
|
# Top vagrantfile dir
|
||||||
|
VAGRANTFILE_DIR = File.dirname(__FILE__)
|
||||||
|
|
||||||
|
# Source provision playbook
|
||||||
|
PROVISION_PLAYBOOK = ENV.fetch(
|
||||||
|
"PROVISION_PLAYBOOK", "#{VAGRANTFILE_DIR}/playbooks/vagrant/provision.yaml")
|
||||||
|
|
||||||
|
# Host IP address to be assigned to OpenStack in DevStack
|
||||||
|
HOST_IP = "192.168.33.10"
|
||||||
|
|
||||||
|
# Local directory from where look for required projects files
|
||||||
|
PROJECTS_DIR = File.dirname(ENV.fetch('PROJECTS_DIR', VAGRANTFILE_DIR))
|
||||||
|
|
||||||
|
GIT_BASE = ENV.fetch('GIT_BASE', 'https://opendev.org')
|
||||||
|
|
||||||
|
# Local project directories to be copied
|
||||||
|
DEVSTACK_PROJECTS = {
|
||||||
|
# Local directory from where look for devstack project files
|
||||||
|
'devstack' => {
|
||||||
|
'src_dir' => ENV.fetch("DEVSTACK_DIR", "#{PROJECTS_DIR}/devstack"),
|
||||||
|
},
|
||||||
|
|
||||||
|
# Local directory from where look for devstack tobiko plugin project files
|
||||||
|
'devstack-plugin-tobiko' => {
|
||||||
|
'src_dir' => ENV.fetch("DEVSTACK_PLUGIN_TOBIKO_SRC_DIR", VAGRANTFILE_DIR),
|
||||||
|
},
|
||||||
|
|
||||||
|
# Local directory from where looking for Tobiko project files
|
||||||
|
'tobiko' => {
|
||||||
|
'src_dir' => ENV.fetch("TOBIKO_SRC_DIR", "#{PROJECTS_DIR}/tobiko"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||||
|
# configures the configuration version (we support older styles for
|
||||||
|
# backwards compatibility). Please don't change it unless you know what
|
||||||
|
# you're doing.
|
||||||
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
|
# The most common configuration options are documented and commented below.
|
||||||
|
# For a complete reference, please see the online documentation at
|
||||||
|
# https://docs.vagrantup.com.
|
||||||
|
|
||||||
|
# Every Vagrant development environment requires a box. You can search for
|
||||||
|
# boxes at https://vagrantcloud.com/search.
|
||||||
|
config.vm.box = BOX
|
||||||
|
# config.vm.box_version = "< 3.0"
|
||||||
|
config.vm.hostname = HOSTNAME
|
||||||
|
|
||||||
|
# Disable automatic box update checking. If you disable this, then
|
||||||
|
# boxes will only be checked for updates when the user runs
|
||||||
|
# `vagrant box outdated`. This is not recommended.
|
||||||
|
# config.vm.box_check_update = false
|
||||||
|
|
||||||
|
# Create a forwarded port mapping which allows access to a specific port
|
||||||
|
# within the machine from a port on the host machine. In the example below,
|
||||||
|
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||||
|
# NOTE: This will enable public access to the opened port
|
||||||
|
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||||
|
|
||||||
|
# Create a forwarded port mapping which allows access to a specific port
|
||||||
|
# within the machine from a port on the host machine and only allow access
|
||||||
|
# via 127.0.0.1 to disable public access
|
||||||
|
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
|
||||||
|
|
||||||
|
# Create a private network, which allows host-only access to the machine
|
||||||
|
# using a specific IP.
|
||||||
|
config.vm.network "private_network", ip: HOST_IP
|
||||||
|
|
||||||
|
# Create a public network, which generally matched to bridged network.
|
||||||
|
# Bridged networks make the machine appear as another physical device on
|
||||||
|
# your network.
|
||||||
|
# config.vm.network "public_network"
|
||||||
|
|
||||||
|
# Share an additional folder to the guest VM. The first argument is
|
||||||
|
# the path on the host to the actual folder. The second argument is
|
||||||
|
# the path on the guest to mount the folder. And the optional third
|
||||||
|
# argument is a set of non-required options.
|
||||||
|
# config.vm.synced_folder "../data", "/vagrant_data"
|
||||||
|
|
||||||
|
# Provider-specific configuration so you can fine-tune various
|
||||||
|
# backing providers for Vagrant. These expose provider-specific options.
|
||||||
|
# Example for VirtualBox:
|
||||||
|
#
|
||||||
|
config.vm.provider "virtualbox" do |vb|
|
||||||
|
# Display the VirtualBox GUI when booting the machine
|
||||||
|
vb.gui = false
|
||||||
|
|
||||||
|
vb.cpus = CPUS
|
||||||
|
vb.memory = MEMORY
|
||||||
|
end
|
||||||
|
|
||||||
|
config.vm.provider "libvirt" do |libvirt|
|
||||||
|
libvirt.cpus = CPUS
|
||||||
|
libvirt.memory = MEMORY
|
||||||
|
end
|
||||||
|
|
||||||
|
# Run provision playbook
|
||||||
|
config.vm.provision "ansible" do |ansible|
|
||||||
|
ansible.limit = 'all'
|
||||||
|
ansible.playbook = PROVISION_PLAYBOOK
|
||||||
|
ansible.extra_vars = ansible.extra_vars = {
|
||||||
|
'devstack_projects' => DEVSTACK_PROJECTS,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
12
ansible.cfg
Normal file
12
ansible.cfg
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[defaults]
|
||||||
|
host_key_checking = False
|
||||||
|
forks = 500
|
||||||
|
timeout = 30
|
||||||
|
force_color = 0
|
||||||
|
interpreter_python = auto
|
||||||
|
|
||||||
|
roles_path = roles/
|
||||||
|
|
||||||
|
[ssh_connection]
|
||||||
|
pipelining = True
|
||||||
|
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
|
1
playbooks/vagrant/.gitignore
vendored
Normal file
1
playbooks/vagrant/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
roles/
|
30
playbooks/vagrant/local.conf
Normal file
30
playbooks/vagrant/local.conf
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
[[local|localrc]]
|
||||||
|
ADMIN_PASSWORD=secret
|
||||||
|
DATABASE_PASSWORD=$ADMIN_PASSWORD
|
||||||
|
RABBIT_PASSWORD=$ADMIN_PASSWORD
|
||||||
|
SERVICE_PASSWORD=$ADMIN_PASSWORD
|
||||||
|
|
||||||
|
LOGFILE=/opt/stack/devstack/stack.log
|
||||||
|
LOG_COLOR=False
|
||||||
|
|
||||||
|
|
||||||
|
# Disable unrequired services -------------------------------------------------
|
||||||
|
|
||||||
|
disable_service horizon
|
||||||
|
disable_service tempest
|
||||||
|
|
||||||
|
|
||||||
|
# Configure Neutron -----------------------------------------------------------
|
||||||
|
|
||||||
|
HOST_IP=192.168.33.10
|
||||||
|
IP_VERSION=4
|
||||||
|
|
||||||
|
|
||||||
|
# Configure Heat --------------------------------------------------------------
|
||||||
|
|
||||||
|
enable_plugin heat https://opendev.org/openstack/heat.git
|
||||||
|
|
||||||
|
|
||||||
|
# Configure Tobiko ------------------------------------------------------------
|
||||||
|
|
||||||
|
enable_plugin devstack-tobiko-plugin https://opendev.org/x/devstack-plugin-tobiko.git
|
29
playbooks/vagrant/provision.yaml
Normal file
29
playbooks/vagrant/provision.yaml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
resolv_conf_file: /etc/resolv.conf
|
||||||
|
dest_dir: /opt/stack
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
|
||||||
|
- name: copy '{{ resolv_conf_file}}' file
|
||||||
|
become: yes
|
||||||
|
copy:
|
||||||
|
src: '{{ resolv_conf_file }}'
|
||||||
|
dest: /etc/resolv.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: update APT database
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 3600
|
||||||
|
become: yes
|
||||||
|
when:
|
||||||
|
- ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- devstack-tobiko-deploy
|
||||||
|
- devstack-tobiko-run-tests
|
24
roles/devstack-tobiko-common/defaults/main.yaml
Normal file
24
roles/devstack-tobiko-common/defaults/main.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
devstack_restack: true
|
||||||
|
|
||||||
|
devstack_dest_dir: /opt/stack
|
||||||
|
devstack_local_conf_file: '{{ playbook_dir }}/local.conf'
|
||||||
|
|
||||||
|
devstack_projects_dir: '{{ playbook_dir | dirname }}'
|
||||||
|
|
||||||
|
devstack_projects_base:
|
||||||
|
devstack:
|
||||||
|
git_repo: 'https://opendev.org/openstack/devstack.git'
|
||||||
|
devstack-plugin-tobiko:
|
||||||
|
git_repo: 'https://opendev.org/x/devstack-plugin-tobiko.git'
|
||||||
|
tobiko:
|
||||||
|
git_repo: 'https://opendev.org/x/tobiko.git'
|
||||||
|
|
||||||
|
devstack_projects: {}
|
||||||
|
|
||||||
|
devstack_dir: '{{ devstack_dest_dir }}/devstack'
|
||||||
|
|
||||||
|
sudo_secure_path: ''
|
||||||
|
|
||||||
|
tobiko_dir: '{{ devstack_dest_dir }}/tobiko'
|
4
roles/devstack-tobiko-deploy/meta/main.yaml
Normal file
4
roles/devstack-tobiko-deploy/meta/main.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- devstack-tobiko-common
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: copy local.conf file
|
||||||
|
become: yes
|
||||||
|
copy:
|
||||||
|
owner: stack
|
||||||
|
group: stack
|
||||||
|
src: '{{ devstack_local_conf_file }}'
|
||||||
|
dest: '{{ devstack_dir }}/local.conf'
|
54
roles/devstack-tobiko-deploy/tasks/deploy-project.yaml
Normal file
54
roles/devstack-tobiko-deploy/tasks/deploy-project.yaml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: "ensure '{{ project_dest_dir }}' exists"
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
file:
|
||||||
|
path: '{{ project_dest_dir | realpath }}'
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: stack
|
||||||
|
group: stack
|
||||||
|
recurse: yes
|
||||||
|
when: >-
|
||||||
|
( project_src_dir | length) > 0 or
|
||||||
|
( project_git_repo | length) > 0
|
||||||
|
|
||||||
|
|
||||||
|
- name: "check '{{ project_src_dir }}' exists"
|
||||||
|
stat:
|
||||||
|
path: '{{ project_src_dir }}'
|
||||||
|
delegate_to: localhost
|
||||||
|
register: check_project_src_dir_exists
|
||||||
|
when: ( project_src_dir | length) > 0
|
||||||
|
failed_when: no
|
||||||
|
|
||||||
|
|
||||||
|
- become: yes
|
||||||
|
become_user: stack
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: copy '{{ project_src_dir }}' to '{{ project_dest_dir }}'
|
||||||
|
synchronize:
|
||||||
|
group: no
|
||||||
|
owner: no
|
||||||
|
src: "{{ project_src_dir | realpath }}/."
|
||||||
|
dest: "{{ project_dest_dir | realpath }}"
|
||||||
|
use_ssh_args: yes
|
||||||
|
recursive: yes
|
||||||
|
rsync_opts:
|
||||||
|
- '--exclude-from={{ project_src_dir | realpath }}/.gitignore'
|
||||||
|
register: copy_project_src_dir
|
||||||
|
when: check_project_src_dir_exists.stat.isdir | default(False)
|
||||||
|
|
||||||
|
- name: >-
|
||||||
|
fetch project sources from '{{ project_git_repo }}' to
|
||||||
|
'{{ project_dest_dir }}'
|
||||||
|
git:
|
||||||
|
repo: '{{ project_git_repo }}'
|
||||||
|
dest: '{{ project_dest_dir }}'
|
||||||
|
version: '{{ project_git_version }}'
|
||||||
|
force: true
|
||||||
|
when:
|
||||||
|
- copy_project_src_dir is skipped
|
||||||
|
- ( project_git_repo | length) > 0
|
21
roles/devstack-tobiko-deploy/tasks/deploy-projects.yaml
Normal file
21
roles/devstack-tobiko-deploy/tasks/deploy-projects.yaml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: combine DevStack projects
|
||||||
|
set_fact:
|
||||||
|
devstack_projects_combined: >-
|
||||||
|
{{ [devstack_projects_base, devstack_projects] |
|
||||||
|
combine(recursive=True) }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: show resulting DevStack projects
|
||||||
|
debug: var=devstack_projects_combined
|
||||||
|
|
||||||
|
|
||||||
|
- name: deploy projects
|
||||||
|
include_tasks: deploy-project.yaml
|
||||||
|
with_dict: '{{ devstack_projects_combined }}'
|
||||||
|
vars:
|
||||||
|
project_dest_dir: '{{ devstack_dest_dir }}/{{ item.key }}'
|
||||||
|
project_src_dir: '{{ item.value.src_dir | default("") }}'
|
||||||
|
project_git_repo: '{{ item.value.git_repo | default("") }}'
|
||||||
|
project_git_version: '{{ item.value.git_version | default("HEAD") }}'
|
37
roles/devstack-tobiko-deploy/tasks/ensure-stack-user.yaml
Normal file
37
roles/devstack-tobiko-deploy/tasks/ensure-stack-user.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
- name: ensure stack group exists
|
||||||
|
become: yes
|
||||||
|
group:
|
||||||
|
name: stack
|
||||||
|
state: present
|
||||||
|
|
||||||
|
|
||||||
|
- name: ensure stack user exists
|
||||||
|
become: yes
|
||||||
|
user:
|
||||||
|
name: stack
|
||||||
|
home: '{{ devstack_dest_dir }}'
|
||||||
|
comment: DevStack user
|
||||||
|
group: stack
|
||||||
|
shell: /bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
- name: ensure stack user has sudo privileges
|
||||||
|
become: yes
|
||||||
|
copy:
|
||||||
|
dest: /etc/sudoers.d/stack
|
||||||
|
content: |
|
||||||
|
stack ALL=(ALL) NOPASSWD: ALL
|
||||||
|
|
||||||
|
|
||||||
|
- name: ensure stack user home exists
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
file:
|
||||||
|
path: '{{ devstack_dest_dir | realpath }}'
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: stack
|
||||||
|
group: stack
|
13
roles/devstack-tobiko-deploy/tasks/install-bindeps.yaml
Normal file
13
roles/devstack-tobiko-deploy/tasks/install-bindeps.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: "ensure DevStack bindeps are installed"
|
||||||
|
become: true
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- git
|
||||||
|
- iptables
|
||||||
|
- python3
|
||||||
|
- python3-pip
|
||||||
|
- python3-systemd
|
||||||
|
- rsync
|
||||||
|
- sudo
|
8
roles/devstack-tobiko-deploy/tasks/main.yaml
Normal file
8
roles/devstack-tobiko-deploy/tasks/main.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- include_tasks: install-bindeps.yaml
|
||||||
|
- include_tasks: ensure-stack-user.yaml
|
||||||
|
- include_tasks: run-unstack.yaml
|
||||||
|
- include_tasks: deploy-projects.yaml
|
||||||
|
- include_tasks: deploy-local-conf.yaml
|
||||||
|
- include_tasks: run-stack.yaml
|
19
roles/devstack-tobiko-deploy/tasks/run-stack.yaml
Normal file
19
roles/devstack-tobiko-deploy/tasks/run-stack.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: run stack.sh
|
||||||
|
become: true
|
||||||
|
become_user: stack
|
||||||
|
shell:
|
||||||
|
cmd: |
|
||||||
|
sudo su -l stack -c "cd '{{ devstack_dir }}' && ./stack.sh" 2>&1
|
||||||
|
rc=$?
|
||||||
|
echo "*** FINISHED ***"
|
||||||
|
exit $rc
|
||||||
|
chdir: '{{ devstack_dir }}'
|
||||||
|
register: run_stack
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
|
||||||
|
- name: show stack.sh output
|
||||||
|
debug: var=run_stack.stdout_lines
|
||||||
|
failed_when: run_stack is failed
|
26
roles/devstack-tobiko-deploy/tasks/run-unstack.yaml
Normal file
26
roles/devstack-tobiko-deploy/tasks/run-unstack.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: check '{{ devstack_dir }}/local.conf' exists
|
||||||
|
stat:
|
||||||
|
path: '{{ devstack_dir }}/local.conf'
|
||||||
|
register: check_devstack_local_conf_file_exists
|
||||||
|
failed_when: no
|
||||||
|
|
||||||
|
|
||||||
|
- name: run unstack.sh
|
||||||
|
become: yes
|
||||||
|
become_user: stack
|
||||||
|
shell:
|
||||||
|
cmd: |
|
||||||
|
sudo su -l stack -c "cd '{{ devstack_dir }}' && ./unstack.sh" 2>&1
|
||||||
|
rc=$?
|
||||||
|
echo "*** FINISHED ***"
|
||||||
|
exit $rc
|
||||||
|
register: run_unstack
|
||||||
|
ignore_errors: yes
|
||||||
|
when:
|
||||||
|
check_devstack_local_conf_file_exists.stat.exists | default(False)
|
||||||
|
|
||||||
|
|
||||||
|
- debug: var=run_unstack.stdout_lines
|
||||||
|
when: run_unstack is failed
|
4
roles/devstack-tobiko-run-tests/meta/main.yaml
Normal file
4
roles/devstack-tobiko-run-tests/meta/main.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- devstack-tobiko-common
|
3
roles/devstack-tobiko-run-tests/tasks/main.yaml
Normal file
3
roles/devstack-tobiko-run-tests/tasks/main.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- include_tasks: run-tests.yaml
|
7
roles/devstack-tobiko-run-tests/tasks/run-tests.yaml
Normal file
7
roles/devstack-tobiko-run-tests/tasks/run-tests.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: run tobiko test cases
|
||||||
|
command:
|
||||||
|
cmd: >
|
||||||
|
tox -e {{ tox_envlist }}
|
||||||
|
chdir: '{{ tobiko_dir }}'
|
Loading…
Reference in New Issue
Block a user