Set remote test directories owner user

Change-Id: I007b5f88a72f4c3a821466358d0c3793008354cf
This commit is contained in:
Federico Ressi 2020-04-21 14:49:12 +02:00
parent b77367e8bc
commit 3eadbe21f9
5 changed files with 49 additions and 7 deletions

View File

@ -12,6 +12,13 @@ subparsers:
include_groups: ["Ansible options", "Inventory", "Common options", "Answers file"] include_groups: ["Ansible options", "Inventory", "Common options", "Answers file"]
groups: 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 - title: Topology options
options: options:
host: host:
@ -39,6 +46,14 @@ subparsers:
type: Value type: Value
help: Test host directory where test cases (and tox.ini file) are found help: Test host directory where test cases (and tox.ini file) are found
ansible_variable: test_dir 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: test-repo:
type: Value type: Value
help: Git URL from where to download test files help: Git URL from where to download test files
@ -63,6 +78,14 @@ subparsers:
type: Value type: Value
help: Test host directory where Tobiko has to be deployed to help: Test host directory where Tobiko has to be deployed to
ansible_variable: tobiko_dir 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: tobiko-repo:
type: Value type: Value
help: Git URL from where to download tobiko files help: Git URL from where to download tobiko files

View File

@ -3,7 +3,8 @@
# --- Tobiko workflow stages # --- Tobiko workflow stages
test_stage: all test_stage: all
test_no_become: false
test_become: '{{ not (test_no_become | bool) }}'
# --- Test deploy options ----------------------------------------------------- # --- Test deploy options -----------------------------------------------------
@ -16,9 +17,11 @@ test_project:
"{{ test_git_repo | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}" "{{ test_git_repo | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}"
test_git_repo: '{{ git_base }}/x/tobiko.git' test_git_repo: '{{ git_base }}/x/tobiko.git'
test_git_refspec: '' test_git_refspec: ''
test_git_remote: 'origin' test_git_remote: '{{ omit }}'
test_git_version: 'master' test_git_version: 'master'
test_src_dir: '' 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 # 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 | urlsplit('path') | regex_replace('^\\/|\\/$', '') | splitext | first }}"
tobiko_git_repo: '{{ git_base }}/x/tobiko.git' tobiko_git_repo: '{{ git_base }}/x/tobiko.git'
tobiko_git_refspec: '' tobiko_git_refspec: ''
tobiko_git_remote: 'origin' tobiko_git_remote: '{{ omit }}'
tobiko_git_version: 'master' tobiko_git_version: 'master'
tobiko_src_dir: '' tobiko_src_dir: ''
tobiko_user: '{{ ansible_user | default(omit) }}'
tobiko_group: '{{ tobiko_user }}'
# --- Test configuration options ---------------------------------------------- # --- Test configuration options ----------------------------------------------

View File

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

View File

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

View File

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