Browse Source

Set remote test directories owner user

Change-Id: I007b5f88a72f4c3a821466358d0c3793008354cf
changes/85/721585/7
Federico Ressi 1 year ago
parent
commit
3eadbe21f9
  1. 23
      infrared_plugin/plugin.spec
  2. 11
      roles/tobiko-common/defaults/main.yaml
  3. 4
      roles/tobiko-deploy/defaults/main.yaml
  4. 16
      roles/tobiko-deploy/tasks/deploy-dir.yaml
  5. 2
      roles/tobiko-deploy/tasks/deploy.yaml

23
infrared_plugin/plugin.spec

@ -12,6 +12,13 @@ subparsers:
include_groups: ["Ansible options", "Inventory", "Common options", "Answers file"]
groups:
- title: Common options
options:
no-become:
type: Flag
help: Forbid roles from escalate tasks execution as superuser
ansible_variable: test_no_become
- title: Topology options
options:
host:
@ -39,6 +46,14 @@ subparsers:
type: Value
help: Test host directory where test cases (and tox.ini file) are found
ansible_variable: test_dir
test-user:
type: Value
help: Test host user that should own tests directory
ansible_variable: test_user
test-group:
type: Value
help: Test host user group that should own tests directory
ansible_variable: test_group
test-repo:
type: Value
help: Git URL from where to download test files
@ -63,6 +78,14 @@ subparsers:
type: Value
help: Test host directory where Tobiko has to be deployed to
ansible_variable: tobiko_dir
tobiko-user:
type: Value
help: Test host user that should own Tobiko directory
ansible_variable: tobiko_user
tobiko-group:
type: Value
help: Test host user group that should own Tobiko directory
ansible_variable: tobiko_group
tobiko-repo:
type: Value
help: Git URL from where to download tobiko files

11
roles/tobiko-common/defaults/main.yaml

@ -3,7 +3,8 @@
# --- Tobiko workflow stages
test_stage: all
test_no_become: false
test_become: '{{ not (test_no_become | bool) }}'
# --- Test deploy options -----------------------------------------------------
@ -16,9 +17,11 @@ test_project:
"{{ test_git_repo | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}"
test_git_repo: '{{ git_base }}/x/tobiko.git'
test_git_refspec: ''
test_git_remote: 'origin'
test_git_remote: '{{ omit }}'
test_git_version: 'master'
test_src_dir: ''
test_user: '{{ ansible_user | default(omit) }}'
test_group: '{{ test_user }}'
# NOTE: if test_dir and tobiko_dir variables endup being the same actual
@ -30,9 +33,11 @@ tobiko_project:
"{{ tobiko_git_repo | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}"
tobiko_git_repo: '{{ git_base }}/x/tobiko.git'
tobiko_git_refspec: ''
tobiko_git_remote: 'origin'
tobiko_git_remote: '{{ omit }}'
tobiko_git_version: 'master'
tobiko_src_dir: ''
tobiko_user: '{{ ansible_user | default(omit) }}'
tobiko_group: '{{ tobiko_user }}'
# --- Test configuration options ----------------------------------------------

4
roles/tobiko-deploy/defaults/main.yaml

@ -8,6 +8,8 @@ test_deploy_dirs:
# test suite directory
- clean_dir: '{{ clean_deploy_dir }}'
dest_dir: '{{ test_dir }}'
dest_user: '{{ test_user }}'
dest_group: '{{ test_group }}'
git_repo: '{{ test_git_repo }}'
git_refspec: '{{ test_git_refspec }}'
git_remote: '{{ test_git_remote }}'
@ -17,6 +19,8 @@ test_deploy_dirs:
# Tobiko framework directory
- clean_dir: '{{ clean_deploy_dir }}'
dest_dir: '{{ tobiko_dir }}'
dest_user: '{{ tobiko_user }}'
dest_group: '{{ tobiko_group }}'
git_repo: '{{ tobiko_git_repo }}'
git_refspec: '{{ tobiko_git_refspec }}'
git_remote: '{{ tobiko_git_remote }}'

16
roles/tobiko-deploy/tasks/deploy-dir.yaml

@ -16,13 +16,21 @@
- clean_dir | bool
- name: "create directory '{{ dest_dir }}'"
- name: "setup directory '{{ dest_dir }}'"
file:
path: "{{ dest_dir | realpath }}"
state: directory
owner: '{{ dest_user | default(omit) }}'
group: '{{ dest_group | default(omit) }}'
mode: '0755'
recurse: yes
become: '{{ test_become | bool }}'
register: create_dest_dir
- debug: var=create_dest_dir
- name: "override git_version and src_dir because git_refspec is '{{ git_refspec }}'"
set_fact:
git_version: 'FETCH_HEAD'
@ -30,13 +38,13 @@
when: '(git_refspec | length) > 0'
- name: "checkout files from '{{ git_repo }}[{{ git_refspec or git_version }}]' to '{{ dest_dir }}'"
- name: "checkout files from '{{ git_repo }}[{{ git_refspec | default(git_version) }}]' to '{{ dest_dir }}'"
git:
dest: '{{ dest_dir }}'
repo: '{{ git_repo }}'
refspec: '{{ git_refspec }}'
refspec: '{{ git_refspec | default(omit) }}'
version: '{{ git_version }}'
remote: '{{ git_remote }}'
remote: '{{ git_remote | default(omit) }}'
force: yes
register: checkout_files
when: '((src_dir | length) == 0) or (create_dest_dir is changed)'

2
roles/tobiko-deploy/tasks/deploy.yaml

@ -10,9 +10,11 @@
loop_control:
label: '{{ item.dest_dir }}'
- name: "show combined deploy variables"
debug: var=_test_deploy_dirs
- name: "deploy test directories'"
include_tasks: deploy-dir.yaml
loop: '{{ _test_deploy_dirs | dictsort }}'

Loading…
Cancel
Save