Make build-test-packages more resilient

OVB failures due to
- ansible_user variable was used instead of ansible_user_id, the first
one being unreliable as is may only be user defined (or undefined).
- lack of become on tasks that needed it

Fixes problem identified by molecule testing
- lack of idempotence on few tasks
- failure when ansible_user variale was not defined

Change-Id: I11adec7104a59bfa29b00c702eb9b7eb6a5c6766
Depends-On: Iade08ee92d7f48e07a625678d2a1c6ac1cd1982b
Partial-Bug: https://tree.taiga.io/project/tripleo-ci-board/task/358
Closes-Bug: #1802825
This commit is contained in:
Sorin Sbarnea 2018-11-09 13:55:22 +00:00 committed by wes hayutin
parent a554bed7e0
commit 2ded6f1df1
3 changed files with 18 additions and 10 deletions

View File

@ -14,13 +14,12 @@
- name: Setup the undercloud
hosts: undercloud
gather_facts: yes
vars:
ansible_user: root
roles:
- undercloud-setup
tasks:
- name: Add eth2 interface from eth2.conf
command: os-net-config -c {{ working_dir }}/eth2.conf -v
become: yes
when:
- network_isolation|bool
- use_testenv_broker|default(false)|bool

View File

@ -38,6 +38,7 @@
rdopkg findpkg -s $PROJECT_NAME -l rdoinfo | grep ^name | awk '{print $2}'
args:
chdir: '{{ build_repo_dir }}/DLRN'
changed_when: false
- debug:
msg: "WARNING: Unable to build {{ artg_change.project }}. No pkg found."

View File

@ -29,6 +29,7 @@
- mock
- openssl-devel
- redhat-rpm-config
- rsync
- rpm-build
- rpmdevtools
- sqlite
@ -41,6 +42,8 @@
- name: Check if virtualenv is in the system
shell: "{{ python_cmd }} -m virtualenv --version"
args:
warn: no
register: virtualenv_exist
changed_when: false
failed_when: false
@ -65,21 +68,23 @@
- name: Add user to mock group
become: yes
user:
name: '{{ ansible_user }}'
name: '{{ ansible_user_id }}'
groups: mock
append: yes
- name: Remove data files from previous runs
file:
path: '{{ build_repo_dir }}/DLRN'
state: absent
when: not dlrn_pre_installed|bool
- name: Ensure DLRN dir is present
file:
path: '{{ build_repo_dir }}/DLRN/'
state: directory
- name: Remove data files from previous runs
shell:
rm -rf '{{ build_repo_dir }}/DLRN/*'
args:
warn: no
register: result
changed_when: result.stdout or result.stderr
- name: drop in the templated version of projects.ini
template:
src: projects.ini.j2
@ -116,7 +121,10 @@
when: dlrn_pre_installed|bool
- name: copy the DLRN scripts in the virtualenv to the scripts dir
shell: "/usr/bin/cp -Rv {{ build_repo_dir }}/dlrn-venv/share/dlrn/scripts {{ build_repo_dir }}/DLRN/"
synchronize:
src: "{{ build_repo_dir }}/dlrn-venv/share/dlrn/scripts"
dest: "{{ build_repo_dir }}/DLRN"
delegate_to: "{{ inventory_hostname }}"
- name: Fetch local rdoinfo copy
git: