Add RH subscription manager support to role testing Vagrantfile

This also fixes some lessero tobiko-inventory things

Change-Id: I0b5080ad210e86e772940170c70972f3ecf93e81
This commit is contained in:
Federico Ressi 2020-05-07 14:57:25 +02:00
parent 92248c8506
commit 92a2183d75
5 changed files with 34 additions and 14 deletions

View File

@ -14,10 +14,11 @@ MEMORY = ENV.fetch("VM_SIZE", "1024").to_i
# boxes at https://vagrantcloud.com/search.
BOX = ENV.fetch("VM_BOX", "generic/centos8")
TOX_INI_DIR = '../..'
TEST_DIR = File.dirname(__FILE__)
TOBIKO_SRC_DIR = File.realpath(ENV.fetch(
'TOBIKO_SRC_DIR', TEST_DIR + '/../..'))
UPPER_CONSTRAINTS_FILE = ENV.fetch(
"UPPER_CONSTRAINTS_FILE",
"https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt")
@ -32,6 +33,8 @@ NODES = {
SSH_KEY_FILE = File.join([TEST_DIR, 'ssh_id'])
RH_USERNAME = ENV.fetch("RH_USERNAME", "")
RH_PASSWORD = ENV.fetch("RH_PASSWORD", "")
# All Vagrant configuration is done below. The "2" in Vagrant.configure
@ -104,10 +107,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
node.vm.hostname = NODES['primary']['hostname']
node.vm.network "private_network", ip: NODES['primary']['ip']
# No need to copy .tox/ dir to node to execute test cases
node.vm.synced_folder TOX_INI_DIR, "/vagrant", type: "rsync",
rsync__exclude: [".tox/"]
# Prepare VMs using ansible playbook
node.vm.provision "ansible" do |ansible|
ansible.playbook = "provision.yaml"
@ -115,6 +114,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
ansible.extra_vars = {
'vagrant_nodes' => NODES,
'ssh_key_file' => SSH_KEY_FILE,
'rh_username' => RH_USERNAME,
'rh_password' => RH_PASSWORD,
'tobiko_src_dir' => TOBIKO_SRC_DIR,
}
end

View File

@ -1,5 +1,19 @@
---
- hosts: all
tasks:
- name: Register as user '{{ rh_username }}' and auto-subscribe to available content
become: yes
redhat_subscription:
state: present
username: '{{ rh_username }}'
password: '{{ rh_password }}'
auto_attach: yes
when:
- rh_username is defined
- rh_username != ''
- hosts: primary
tasks:
- name: "copy /etc/resolv.conf"
@ -106,5 +120,4 @@
- hosts: primary
roles:
- role: tobiko-inventory
vars:
test_inventory_file: /vagrant/ansible_hosts
- role: tobiko-deploy

View File

@ -2,8 +2,8 @@
- hosts: primary
vars:
test_src_dir: /vagrant
test_collect_dir: '{{ test_src_dir }}/test_results'
test_collect_dir: '{{ test_dir }}/test_results'
roles:
- tobiko-ensure-tox
- tobiko-ensure-git
@ -21,7 +21,7 @@
'{{ tox_executable }}' -e infrared --
--host secondary
--collect-dir '{{ test_collect_dir }}'
chdir: /vagrant
chdir: '{{ test_dir }}'
environment:
UPPER_CONSTRAINTS_FILE: '{{ remote_constraints_file }}'
ignore_errors: yes
@ -38,7 +38,6 @@
- hosts: primary
vars:
test_src_dir: /vagrant
test_collect_dir: '{{ test_src_dir }}/test_results'
test_collect_dir: '{{ test_dir }}/test_results'
roles:
- tobiko-check-collected-files

View File

@ -2,4 +2,4 @@
test_inventory_user: '{{ ansible_user }}'
test_inventory_hostvars: {}
test_inventory_file: '{{ test_src_dir | realpath }}/ansible_hosts'
test_inventory_file: '{{ test_dir | realpath }}/ansible_hosts'

View File

@ -49,6 +49,12 @@
- debug: var=test_inventory_hostvars
- name: "ensures inventory directory exists"
file:
path: '{{ test_inventory_file | dirname }}'
state: directory
- name: "writes inventory file to: '{{ test_inventory_file }}'"
template:
src: 'test_inventory.j2'