Dmitry Tantsur ab69cca0ce Get rid of ci_testing variable in roles
The roles should not change their behavior based on the presence of Zuul.
Use the existing copy_from_local_path variable to copy pre-cached
repositories. Also get rid of the redundant ci_testing_zuul.

Change-Id: Idfdfe2087b020cd8069d1088991e088873783825
2020-07-09 12:14:53 +02:00

156 lines
5.4 KiB
YAML

# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# 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.
---
- name: produce warning when csv file is defined
debug:
msg: >
"WARNING - Variable 'baremetal_csv_file' is deprecated.
For backward compatibility, its value will be used as path for
file to write data for created 'virtual' baremetal nodes,
but the file will be JSON formatted."
when: baremetal_csv_file is defined
- name: override baremetal_json_file with csv file path
set_fact:
baremetal_json_file: "{{ baremetal_csv_file }}"
when: baremetal_csv_file is defined
# NOTE(cinerama) openSUSE Tumbleweed & Leap have different distribution
# IDs which are not currently accounted for in Ansible, so adjust facts
# so we can have shared defaults for the whole SuSE family.
# This change can be removed when the pull request at
# https://github.com/ansible/ansible/pull/17575 lands in a new version.
- name: Ensure openSUSE Tumbleweed has the correct family
set_fact:
ansible_os_family: "Suse"
when: ansible_os_family is search("openSUSE Tumbleweed")
- name: Ensure openSUSE Leap has the correct family
set_fact:
ansible_os_family: "Suse"
when: (ansible_os_family is search("SUSE LINUX")) or
(ansible_os_family is search("openSUSE Leap"))
# NOTE(hwoarang) The 'apt' module needs python-apt installed in the virtualenv
# but it's not possible to do that. See https://github.com/ansible/ansible/issues/14468
# python-apt only works if it's installed on the local system so we need to switch the
# Ansible python interpreter.
- name: "Update apt cache if Ubuntu/Debian"
apt:
update_cache: yes
when: ansible_os_family == "Debian"
vars:
ansible_python_interpreter: '/usr/bin/python3'
- name: "Load distribution defaults"
include_vars: "{{ item }}"
with_first_found:
- "../defaults/required_defaults_{{ ansible_distribution }}.yml"
- "../defaults/required_defaults_{{ ansible_os_family }}.yml"
- name: "Include OS version-specific defaults"
include_vars: "{{ item }}"
with_first_found:
- "../defaults/required_defaults_{{ ansible_distribution }}_{{ ansible_distribution_release }}.yml"
- "../defaults/required_defaults_{{ ansible_distribution }}_{{ ansible_distribution_version }}.yml"
- "../defaults/dummy-defaults.yml"
# NOTE(hwoarang) The 'apt' module needs python-apt installed in the virtualenv
# but it's not possible to do that. See https://github.com/ansible/ansible/issues/14468
# python-apt only works if it's installed on the local system so we need to switch the
# Ansible python interpreter.
- name: "Install required packages"
package:
name: "{{ required_packages }}"
state: present
vars:
ansible_python_interpreter: '/usr/bin/python3'
- name: ensure installation root folder exists
become: yes
file:
state: directory
dest: "{{ git_root }}"
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_gid }}"
- name: download requirements via git
git:
dest: "{{ reqs_git_folder }}"
force: "{{ force_update_repos | bool }}"
repo: "{{ reqs_git_url }}"
version: "{{ reqs_git_branch }}"
update: "{{ update_repos | bool }}"
clone: yes
when: copy_from_local_path | bool == false
- name: copy requirements from local path
command: cp -a {{ reqs_git_url }} {{ reqs_git_folder }} creates={{ reqs_git_folder }}
when: copy_from_local_path | bool
- include: prepare_libvirt.yml
- name: truncate explicit list of vm names
set_fact:
test_vm_node_names: "{{ test_vm_node_names[:(test_vm_num_nodes|int)] }}"
- name: generate test vm names
set_fact:
generated_test_vm_node_names: "{{ generated_test_vm_node_names|default([]) + [item] }}"
with_sequence: count={{ test_vm_num_nodes | int }} format={{ test_vm_node_name_base }}%i
when: test_vm_node_names | length == 0
- name: set test vm names
set_fact:
test_vm_node_names: "{{ generated_test_vm_node_names }}"
when: test_vm_node_names | length == 0
- name: create placeholder var for vm entries in JSON format
set_fact:
testvm_json_data: {}
testvm_nodes_json: []
- include: create_vm.yml
loop: "{{ test_vm_node_names }}"
- name: write to baremetal json file
copy:
dest: "{{ baremetal_json_file }}"
content: "{{ testvm_json_data | to_nice_json }}"
- name: write to nodes json
copy:
dest: "{{ baremetal_nodes_json }}"
content: "{{ {'nodes': testvm_nodes_json} | to_nice_json }}"
- name: >
"Set file permissions such that the baremetal data file
can be read by the user executing Ansible"
file:
path: "{{ baremetal_json_file }}"
owner: "{{ ansible_env.SUDO_USER }}"
when: >
ansible_env.SUDO_USER is defined and
baremetal_json_file != ""
- name: >
"Set file permissions such that the nodes json file
can be read by the user executing Ansible"
file:
path: "{{ baremetal_nodes_json }}"
owner: "{{ ansible_env.SUDO_USER }}"
when: >
ansible_env.SUDO_USER is defined and
baremetal_nodes_json != ""