diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1730b56e7d24ea89d34931169fe08635390bcf0c..4aaec3ee61f3525a9d9c6638f6a31b090f308d61 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,8 +38,28 @@ build_packer: name: $TARGET_ENV tags: [build] script: - - cd CRI_XCBC && git checkout dev && git pull && cd .. - - cd CRI_Cluster_Monitor && git checkout master && git pull && cd .. + - git submodule update --remote + - declare -A hashmap=(["CRI_XCBC"]="${cluster_ansible_feat_req_ids}" ["CRI_Cluster_Monitor"]="${clustermon_ansible_feat_req_ids}") + - | + for each_repo in ${!hashmap[@]} + do + echo "Inside first for loop cd to: $each_repo" + cd $each_repo + git config user.name "$GITLAB_USER_NAME" + git config user.email "$GITLAB_USER_EMAIL" + echo "Done cd to: $each_repo" + echo "Checking out pull requests ${hashmap[$each_repo]}" + git checkout -B test_feature_requests + git fetch origin +refs/pull/*/merge:refs/remotes/origin/pr/* + for each_feature in ${hashmap[$each_repo]} + do + for num in ${each_feature[@]} + do + git merge --no-ff origin/pr/$num + done + done + cd .. + done - export PKR_VAR_build_image_name="xdmod-$TARGET_ENV-$(TZ=America/Chicago date +%Y-%m-%dT%H%M%S)" - 'sed -i -E "s/(enable_selinix_permissive: ).*/\1true/" CRI_Cluster_Monitor/group_vars/all' - 'sed -i -E "s/(enable_simplesaml: ).*/\1true/" CRI_Cluster_Monitor/group_vars/all' @@ -55,7 +75,7 @@ build_packer: - echo $PKR_VAR_s3_endpoint - packer init xdmod - packer validate xdmod - - packer build -machine-readable xdmod + - packer build -machine-readable -on-error=${on_error} xdmod clean_up: # This job removes older built images stage: clean # It only starts when the job in the build stage completes successfully. diff --git a/xdmod/image.pkr.hcl b/xdmod/image.pkr.hcl index c7501ef7f6841591ced1186ce6aac7ace4ba6ac0..bd45182485d9e9a850f24d2ce6da5f8feb5820e5 100644 --- a/xdmod/image.pkr.hcl +++ b/xdmod/image.pkr.hcl @@ -4,6 +4,10 @@ packer { version = "~> 1" source = "github.com/hashicorp/openstack" } + ansible = { + version = "~> 1" + source = "github.com/hashicorp/ansible" + } } } @@ -16,8 +20,6 @@ source "openstack" "image" { networks = ["${var.external_net}", "${var.internal_net}"] reuse_ips = "false" source_image_name = "${var.source_image_name}" - ssh_keypair_name = "${var.ssh_keypair_name}" - ssh_private_key_file = "${var.private_key_file}" ssh_username = "${var.ssh_username}" #pause_before_connecting = "5m" #ssh_timeout = "10m" @@ -36,54 +38,30 @@ build { ] } - provisioner "file" { - destination = "/CRI_XCBC/" - source = "CRI_XCBC/" - } - provisioner "file" { - destination = "/CRI_Cluster_Monitor/" - source = "CRI_Cluster_Monitor/" + provisioner "ansible" { + use_proxy = false + user = var.ssh_username + groups = ["headnode"] + playbook_file = "./CRI_XCBC/site-build.yaml" + extra_arguments = [ + "-b" + ] } - provisioner "shell" { - environment_vars = [ - "lts_access_key=${var.lts_access_key}", - "lts_secret_key=${var.lts_secret_key}", - "s3_endpoint=${var.s3_endpoint}", - "s3_shibboleth_bucket_name=${var.s3_shibboleth_bucket_name}", - "s3_shibboleth_object_name=${var.s3_shibboleth_object_name}", - "s3_cert_object_name=${var.s3_cert_object_name}" - ] - inline = [ - "sudo -E echo 's3_endpoint: $s3_endpoint'", - "sudo -E ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` /CRI_XCBC/site-build.yaml -b", - "sudo -E ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` /CRI_Cluster_Monitor/clustermon.yml -b", - ] + provisioner "ansible" { + use_proxy = false + user = var.ssh_username + groups = ["headnode"] + playbook_file = "./CRI_Cluster_Monitor/clustermon.yml" + ansible_env_vars =[ "ANSIBLE_VERBOSITY=${var.ANSIBLE_VERBOSITY}", "ANSIBLE_DEBUG=${var.ANSIBLE_DEBUG}", "ANSIBLE_FORCE_COLOR=true"] + extra_arguments = [ + "--extra-vars", "lts_access_key=${var.lts_access_key}", + "--extra-vars", "lts_secret_key=${var.lts_secret_key}", + "--extra-vars", "s3_endpoint=${var.s3_endpoint}", + "--extra-vars", "s3_shibboleth_bucket_name=${var.s3_shibboleth_bucket_name}", + "--extra-vars", "s3_shibboleth_object_name=${var.s3_shibboleth_object_name}", + "--extra-vars", "s3_cert_object_name=${var.s3_cert_object_name}", + "-b", + ] } - - #provisioner "shell" { - # inline = [ - # "sudo rm -rf /CRI_XCBC", - # "sudo rm -rf /CRI_Cluster_Monitor", - # ] - # } - -# provisioner "ansible" { -# user = var.ssh_username -# groups = ["headnode"] -# playbook_file = "./CRI_XCBC/site-build.yaml" -# extra_arguments = [ -# "-b" -# ] -# } - -# provisioner "ansible" { -# user = var.ssh_username -# groups = ["headnode"] -# playbook_file = "./CRI_Cluster_Monitor/clustermon.yml" -# extra_arguments = [ -# "-b", -# "-v" -# ] -# } } diff --git a/xdmod/variables.pkr.hcl b/xdmod/variables.pkr.hcl index 4a7fc75cadf6b7fe8ec68088648b4220b59d00a3..50233df46104cec66c0e8e061b5fb9792d57c3a7 100644 --- a/xdmod/variables.pkr.hcl +++ b/xdmod/variables.pkr.hcl @@ -74,4 +74,14 @@ variable "s3_cert_object_name" { type = string default = "" description = "s3 certificate object name" -} \ No newline at end of file +} +variable "ANSIBLE_DEBUG" { + type = string + default = "false" + description = "to turn on debugging" +} +variable "ANSIBLE_VERBOSITY" { + type = string + default = "0" + description = "to increase verbosity - 0|1|2|3|4" +}