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:
parent
92248c8506
commit
92a2183d75
14
roles/tests/Vagrantfile
vendored
14
roles/tests/Vagrantfile
vendored
@ -14,10 +14,11 @@ MEMORY = ENV.fetch("VM_SIZE", "1024").to_i
|
|||||||
# boxes at https://vagrantcloud.com/search.
|
# boxes at https://vagrantcloud.com/search.
|
||||||
BOX = ENV.fetch("VM_BOX", "generic/centos8")
|
BOX = ENV.fetch("VM_BOX", "generic/centos8")
|
||||||
|
|
||||||
TOX_INI_DIR = '../..'
|
|
||||||
|
|
||||||
TEST_DIR = File.dirname(__FILE__)
|
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 = ENV.fetch(
|
||||||
"UPPER_CONSTRAINTS_FILE",
|
"UPPER_CONSTRAINTS_FILE",
|
||||||
"https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt")
|
"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'])
|
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
|
# 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.hostname = NODES['primary']['hostname']
|
||||||
node.vm.network "private_network", ip: NODES['primary']['ip']
|
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
|
# Prepare VMs using ansible playbook
|
||||||
node.vm.provision "ansible" do |ansible|
|
node.vm.provision "ansible" do |ansible|
|
||||||
ansible.playbook = "provision.yaml"
|
ansible.playbook = "provision.yaml"
|
||||||
@ -115,6 +114,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||||||
ansible.extra_vars = {
|
ansible.extra_vars = {
|
||||||
'vagrant_nodes' => NODES,
|
'vagrant_nodes' => NODES,
|
||||||
'ssh_key_file' => SSH_KEY_FILE,
|
'ssh_key_file' => SSH_KEY_FILE,
|
||||||
|
'rh_username' => RH_USERNAME,
|
||||||
|
'rh_password' => RH_PASSWORD,
|
||||||
|
'tobiko_src_dir' => TOBIKO_SRC_DIR,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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
|
- hosts: primary
|
||||||
tasks:
|
tasks:
|
||||||
- name: "copy /etc/resolv.conf"
|
- name: "copy /etc/resolv.conf"
|
||||||
@ -106,5 +120,4 @@
|
|||||||
- hosts: primary
|
- hosts: primary
|
||||||
roles:
|
roles:
|
||||||
- role: tobiko-inventory
|
- role: tobiko-inventory
|
||||||
vars:
|
- role: tobiko-deploy
|
||||||
test_inventory_file: /vagrant/ansible_hosts
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
- hosts: primary
|
- hosts: primary
|
||||||
vars:
|
vars:
|
||||||
test_src_dir: /vagrant
|
test_collect_dir: '{{ test_dir }}/test_results'
|
||||||
test_collect_dir: '{{ test_src_dir }}/test_results'
|
|
||||||
roles:
|
roles:
|
||||||
- tobiko-ensure-tox
|
- tobiko-ensure-tox
|
||||||
- tobiko-ensure-git
|
- tobiko-ensure-git
|
||||||
@ -21,7 +21,7 @@
|
|||||||
'{{ tox_executable }}' -e infrared --
|
'{{ tox_executable }}' -e infrared --
|
||||||
--host secondary
|
--host secondary
|
||||||
--collect-dir '{{ test_collect_dir }}'
|
--collect-dir '{{ test_collect_dir }}'
|
||||||
chdir: /vagrant
|
chdir: '{{ test_dir }}'
|
||||||
environment:
|
environment:
|
||||||
UPPER_CONSTRAINTS_FILE: '{{ remote_constraints_file }}'
|
UPPER_CONSTRAINTS_FILE: '{{ remote_constraints_file }}'
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
- hosts: primary
|
- hosts: primary
|
||||||
vars:
|
vars:
|
||||||
test_src_dir: /vagrant
|
test_collect_dir: '{{ test_dir }}/test_results'
|
||||||
test_collect_dir: '{{ test_src_dir }}/test_results'
|
|
||||||
roles:
|
roles:
|
||||||
- tobiko-check-collected-files
|
- tobiko-check-collected-files
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
test_inventory_user: '{{ ansible_user }}'
|
test_inventory_user: '{{ ansible_user }}'
|
||||||
test_inventory_hostvars: {}
|
test_inventory_hostvars: {}
|
||||||
test_inventory_file: '{{ test_src_dir | realpath }}/ansible_hosts'
|
test_inventory_file: '{{ test_dir | realpath }}/ansible_hosts'
|
||||||
|
@ -49,6 +49,12 @@
|
|||||||
- debug: var=test_inventory_hostvars
|
- 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 }}'"
|
- name: "writes inventory file to: '{{ test_inventory_file }}'"
|
||||||
template:
|
template:
|
||||||
src: 'test_inventory.j2'
|
src: 'test_inventory.j2'
|
||||||
|
Loading…
Reference in New Issue
Block a user