From 5268c1ed3fb9816022618ef02995300a6221d98e Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Thu, 20 Nov 2014 09:45:15 +0100 Subject: controller: make the system setup configurable Add the --setup-playbook option for dtf-run-remote which allows us to submit configuration (or any) playbook which will be included into the default one, executed before actual testing. * controller/Makefile.am: s/fedora.yml/default.yml/. * controller/bin/dtf-controller.in: Call dtf-remote-run with --setup-playbook option. * controller/bin/dtf-run-remote.in: Fix the option parsing. Add new option --setup-playbook. (error): New function. (die): Use '$*' instead of '*@'. * controller/share/dtf-controller/ansible/playbooks/fedora.yml: Rename to default.yml. * controller/share/dtf-controller/ansible/playbooks/default.yml: Moved from fedora.yml. * controller/share/--/--/playbooks/include/prepare-testenv.yml: Removed hard-wired configuration. --- controller/bin/dtf-controller.in | 1 + controller/bin/dtf-run-remote.in | 72 +++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 23 deletions(-) (limited to 'controller/bin') diff --git a/controller/bin/dtf-controller.in b/controller/bin/dtf-controller.in index 0c80ef5..a231270 100644 --- a/controller/bin/dtf-controller.in +++ b/controller/bin/dtf-controller.in @@ -71,6 +71,7 @@ sub child_task '--workdir', $dir, '--distro', $run->{distro}, '--distro-version', $run->{distro_version}, + '--setup-playbook', $run->{setup_playbook}, ], "$dir/dtf-run-remote.out", "$dir/dtf-run-remote.err"; diff --git a/controller/bin/dtf-run-remote.in b/controller/bin/dtf-run-remote.in index b83b79c..14f81a4 100644 --- a/controller/bin/dtf-run-remote.in +++ b/controller/bin/dtf-run-remote.in @@ -2,9 +2,7 @@ . "@sysconfdir@/dtf.sh" || exit 1 -longopts="verbose,help,force,testid:,listonly" - -run_playbook=${run_playbook-@ansibleplaybooksdir@/fedora.yml} +run_playbook=${run_playbook-@ansibleplaybooksdir@/default.yml} opt_workdir= opt_distro=fedora @@ -12,26 +10,31 @@ opt_openstack_instance="$DTF_OPENSTACK_DEFAULT_ID" opt_distro_ver=20 opt_extra_rpms= opt_taskdir= +opt_setup_playbook= +opt_help=false -die() { echo >&2 "$@" ; exit 1 ; } +die() { echo >&2 "$*" ; exit 1 ; } +error() { echo >&2 "$*" ; } -longopts="distro:,distro-version:,workdir:,openstack-instance:,extra-rpms-file:" -longopts+=",taskdir:" +longopts="help" +longopts+=",distro:,distro-version:,workdir:,openstack-instance:,extra-rpms-file:" +longopts+=",taskdir:,setup-playbook:" ARGS=$(getopt -o "v" -l "$longopts" -n "getopt" -- "$@") \ || exit 1 eval set -- "$ARGS" while true; do case "$1" in - --taskdir) + --taskdir|--setup-playbook|--distro|--openstack-instance|--workdir) opt=$(sed -e 's/^--//' -e 's/[^[a-zA-Z0-9]/_/g'<<<"$1") eval "opt_$opt=\"${2,,}\"" shift 2 ;; - --distro) - opt_distro="$2" - shift 2 + --help) + opt=$(sed -e 's/^--//' -e 's/[^[a-zA-Z0-9]/_/g'<<<"$1") + eval "opt_$opt=true" + shift ;; --distro-version) @@ -39,17 +42,6 @@ while true; do shift 2 ;; - --openstack-instance) - opt_openstack_instance="$2" - shift 2 - ;; - - --workdir) - # where the remote results are fetched into - opt_workdir="$2" - shift 2 - ;; - --extra-rpms-file) opt_extra_rpms="$(readlink -f "$2")" shift 2 @@ -68,8 +60,41 @@ while true; do esac done -test -z "$opt_openstack_instance" && die "option --openstack-instance=ID not used" -test -z "$opt_taskdir" && die "you must specify --taskdir" +$opt_help && { +cat <