diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e4a59c89addb8ef8f0248e5e0da26a061eb2a00..7824092524b138b5574a82bf3ea2d9d68b5da887 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,6 +38,41 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_PIPELINE_SOURCE == 'schedule' +.get_build_date: &get_build_date + - export BUILD_DATE=$(TZ=America/Chicago date +%Y-%m-%dT%H%M%S) + - echo BUILD_DATE=${BUILD_DATE} + +.update_ansible_repo: &update_ansible_repo + - *get_build_date + - | + if [ ! -d $CI_PROJECT_DIR/CRI_XCBC ]; then + git clone https://github.com/uabrc/CRI_XCBC.git + cd CRI_XCBC + git remote add upstream https://github.com/jprorama/CRI_XCBC.git + cd .. + fi + - cd CRI_XCBC + - git config user.name "${GIT_AUTHOR_NAME}" + - git config user.email "${GIT_AUTHOR_EMAIL}" + - git fetch origin uab-prod + - git fetch upstream dev + - git checkout uab-prod + - git merge origin/uab-prod + - git checkout -b integration + - git merge upstream/dev + - export CRI_XCBC_HEAD=$(git rev-parse --short HEAD) + - export CRI_XCBC_dev=$(git rev-parse --short upstream/dev) + - export CRI_XCBC_prod=$(git rev-parse --short origin/uab-prod) + - cd .. + - export PACKER_IMAGE_HEAD=$(git rev-parse --short HEAD) + - echo CRI_XCBC_HEAD=${CRI_XCBC_HEAD} | tee -a $CI_PROJECT_DIR/image.env + - echo CRI_XCBC_dev=${CRI_XCBC_dev} | tee -a $CI_PROJECT_DIR/image.env + - echo CRI_XCBC_prod=${CRI_XCBC_prod} | tee -a $CI_PROJECT_DIR/image.env + - echo PACKER_IMAGE_HEAD=${PACKER_IMAGE_HEAD} | tee -a $CI_PROJECT_DIR/image.env + +.get_ansible_files: &get_ansible_files + - s3cmd get --force -r --host=$AWS_HOST --host-bucket=$AWS_HOST s3://cheaha-cloud-ansible-files/ ansible/files/ + build_docker_image: image: docker:20.10.17 stage: pre-build @@ -46,7 +81,7 @@ build_docker_image: tags: - dind before_script: - - export BUILD_DATE=$(TZ=America/Chicago date +%Y%m%d) + - *get_build_date - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: - docker build -t $CI_REGISTRY_IMAGE:$BUILD_DATE -t $CI_REGISTRY_IMAGE:latest . @@ -64,46 +99,104 @@ build_docker_image: - Dockerfile allow_failure: true -build_image: +build_base_image: stage: build - environment: - name: knightly tags: - build script: - | - if [ ! -d $CI_PROJECT_DIR/CRI_XCBC ]; then - git clone https://github.com/uabrc/CRI_XCBC.git - cd CRI_XCBC - git remote add upstream https://github.com/jprorama/CRI_XCBC.git - cd .. + if [ -n "${BUILT_BASE_IMAGE_ID}" ]; then + exit 0 + fi + - *update_ansible_repo + - *get_ansible_files + - export REPO_HEAD=$(git rev-parse --short HEAD) + - export PKR_VAR_flavor="m1.medium" + - export PKR_VAR_build_instance_name="base-${REPO_HEAD}" + - export PKR_VAR_image_date_suffix=false + - | + if [ $CI_PIPELINE_SOURCE == 'merge_request_event' ]; then + export PKR_VAR_image_name="base-PR-${CI_MERGE_REQUEST_IID}" + elif [ $CI_PIPELINE_SOURCE == 'schedule' ]; then + export PKR_VAR_image_name="base-${BUILD_DATE}" + fi + - packer validate openstack + - packer build -machine-readable openstack | tee base_build.log + - export BUILT_BASE_IMAGE_ID=$(grep 'Image:' base_build.log | awk '{print $4}') + - echo BUILT_BASE_IMAGE_ID=${BUILT_BASE_IMAGE_ID} | tee -a $CI_PROJECT_DIR/image.env + - openstack image unset --property signature_verified $BUILT_BASE_IMAGE_ID + artifacts: + reports: + dotenv: image.env + expire_in: 30 days + +build_compute_image: + stage: build + needs: [build_base_image] + tags: + - build + script: + - *update_ansible_repo + - *get_ansible_files + - export PKR_VAR_source_image=${BUILT_BASE_IMAGE_ID} + - export REPO_HEAD=$(git rev-parse --short HEAD) + - export PKR_VAR_flavor="m1.medium" + - export PKR_VAR_build_instance_name="compute-${REPO_HEAD}" + - export PKR_VAR_image_date_suffix=false + - | + if [ $CI_PIPELINE_SOURCE == 'merge_request_event' ]; then + export PKR_VAR_image_name="compute-PR-${CI_MERGE_REQUEST_IID}" + elif [ $CI_PIPELINE_SOURCE == 'schedule' ]; then + export PKR_VAR_image_name="compute-${BUILD_DATE}" + fi + - packer validate openstack-compute + - packer build -machine-readable openstack-compute | tee compute_build.log + +build_gpu_image: + stage: build + needs: [build_base_image] + tags: + - build + script: + - *update_ansible_repo + - *get_ansible_files + - FAILED=false + - export GPU_PLACEHOLDER_NAME="gpu1-placeholder" + - export GPU_PLACEHOLDER_FLAVOR="gpu1.medium" + - export GPU_PLACEHOLDER_IMAGE="CentOS-7-x86_64-GenericCloud-2009" + - export PKR_VAR_source_image=${BUILT_BASE_IMAGE_ID} + - export REPO_HEAD=$(git rev-parse --short HEAD) + - export PKR_VAR_flavor="gpu1.medium" + - export PKR_VAR_build_instance_name="gpu-${REPO_HEAD}" + - export PKR_VAR_image_date_suffix=false + - | + if [ $CI_PIPELINE_SOURCE == 'merge_request_event' ]; then + export PKR_VAR_image_name="gpu-PR-${CI_MERGE_REQUEST_IID}" + elif [ $CI_PIPELINE_SOURCE == 'schedule' ]; then + export PKR_VAR_image_name="gpu-${BUILD_DATE}" fi - - cd CRI_XCBC - - git config user.name "${GIT_AUTHOR_NAME}" - - git config user.email "${GIT_AUTHOR_EMAIL}" - - git fetch --all - - git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*' - - git fetch upstream '+refs/pull/*/head:refs/remotes/upstream/pr/*' - - git checkout uab-prod - - git merge origin/uab-prod - - git checkout -b integration - - git merge upstream/dev - - export CRI_XCBC_HEAD=$(git rev-parse --short HEAD) - - export CRI_XCBC_dev=$(git rev-parse --short upstream/dev) - - export CRI_XCBC_prod=$(git rev-parse --short origin/uab-prod) - - cd .. - - export PACKER_IMAGE_HEAD=$(git rev-parse --short HEAD) - - export BUILD_DATE=$(TZ=America/Chicago date +%Y%m%d) - - echo CRI_XCBC_HEAD=${CRI_XCBC_HEAD} | tee -a $CI_PROJECT_DIR/image.env - - echo CRI_XCBC_dev=${CRI_XCBC_dev} | tee -a $CI_PROJECT_DIR/image.env - - echo CRI_XCBC_prod=${CRI_XCBC_prod} | tee -a $CI_PROJECT_DIR/image.env - - echo PACKER_IMAGE_HEAD=${PACKER_IMAGE_HEAD} | tee -a $CI_PROJECT_DIR/image.env - - echo BUILD_DATE=${BUILD_DATE} | tee -a $CI_PROJECT_DIR/image.env + - packer validate openstack-gpu + - openstack server delete --wait $GPU_PLACEHOLDER_NAME + - packer build -machine-readable openstack-gpu | tee gpu_build.log || FAILED=true + - openstack server create --image $GPU_PLACEHOLDER_IMAGE --network cicd-net --flavor $GPU_PLACEHOLDER_FLAVOR $GPU_PLACEHOLDER_NAME + - | + if [ "$FAILED" = true ]; then + exit 1 + fi + +build_ood_image: + stage: build + environment: + name: knightly + tags: + - build + script: + - *update_ansible_repo + - *get_ansible_files - > curl --header "PRIVATE-TOKEN: ${ANSIBLE_VAR_TOKEN}" "${CI_API_V4_URL}/projects/2836/repository/files/knightly/raw?ref=main" -o CRI_XCBC/group_vars/knightly - - s3cmd get --force -r --host=$AWS_HOST --host-bucket=$AWS_HOST s3://cheaha-cloud-ansible-files/ ansible/files/ - 'sed -i -E "s/(lts_access_key: ).*/\1\"${AWS_ACCESS_KEY_ID}\"/" CRI_XCBC/group_vars/knightly' - 'sed -i -E "s/(lts_secret_key: ).*/\1\"${AWS_SECRET_ACCESS_KEY}\"/" CRI_XCBC/group_vars/knightly' - 'sed -i -E "s/(user_register_app_key: ).*/\1\"${SELF_REG_APP_KEY}\"/" CRI_XCBC/group_vars/knightly' @@ -135,8 +228,9 @@ build_image: reports: dotenv: image.env -test: +test_ood_image: stage: test + needs: [build_ood_image] environment: name: knightly tags: @@ -279,4 +373,3 @@ deploy_cheaha: when: manual only: - main - diff --git a/ansible/files/nux-dextop.repo b/ansible/files/nux-dextop.repo index 475d3d4ce4b2fa171a5df146fa31d650115f0a1b..1ee4ace274472d5ba82a769f1d0661e76bf8a4f4 100644 --- a/ansible/files/nux-dextop.repo +++ b/ansible/files/nux-dextop.repo @@ -1,14 +1,14 @@ [nux-dextop] name=Nux.Ro RPMs for general desktop use -baseurl= http://mirror.li.nux.ro/li.nux.ro/nux/dextop/el7/$basearch/ +baseurl=http://li.nux.ro/download/nux/dextop/el7/$basearch/ enabled=1 gpgcheck=1 -gpgkey=http://mirror.li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro +gpgkey=http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro protect=0 [nux-dextop-testing] name=Nux.Ro RPMs for general desktop use - testing -baseurl=http://mirror.li.nux.ro/download/nux/dextop-testing/el7/$basearch/ +baseurl=http://li.nux.ro/download/nux/dextop-testing/el7/$basearch/ enabled=0 gpgcheck=1 gpgkey=http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro diff --git a/ansible/gpu.yml b/ansible/gpu.yml index 5d032dce95f4741643cd86dcfa3783bdfdfa9213..b6ec44d471b8e7fb15e333fef66ce5210620b7c3 100644 --- a/ansible/gpu.yml +++ b/ansible/gpu.yml @@ -5,3 +5,8 @@ roles: - { name: 'install_packages', tags: 'install_packages' } - { name: 'cuda_driver', tags: 'cuda_driver' } + - { name: 'pam_slurm_adopt', tags: 'pam_slurm_adopt' } + - { name: 'install_nhc', tags: 'install_nhc'} + +- name: Setup node for use as a virtual cheaha node + ansible.builtin.import_playbook: cheaha.yml diff --git a/ansible/group_vars/gpu b/ansible/group_vars/gpu index ad9aa51ae61838f6d72e0ae061dda1c877bad851..cd65f8881469975d311684e50c50ee3bc5720b06 100644 --- a/ansible/group_vars/gpu +++ b/ansible/group_vars/gpu @@ -1,6 +1,91 @@ --- - yum_repo_files: [] + yum_repo_files: + - TurboVNC.repo + - cm.repo pkg_list: + - "Lmod-7.8.11" + - "atftp-server" + - "cluster-tools-dell" + - "cluster-tools-slave" + - "cm-boost" + - "cm-config-ceph-release-luminous" + - "cm-config-cm" + - "cm-config-dhclient" + - "cm-config-dracut-slave" + - "cm-config-grub" + - "cm-config-ldap-client" + - "cm-config-limits" + - "cm-config-man" + - "cm-config-named" + - "cm-config-network-slave" + - "cm-config-nfsclient" + - "cm-config-rootfiles-slave" + - "cm-config-selinux" + - "cm-config-ssh-slave" + - "cm-config-sysctl-slave" + - "cm-config-syslog-slave" + - "cm-config-systemd" + - "cm-config-xntp-slave" + - "cm-config-yum" + - "cm-curl" + - "cm-dhcp" + - "cm-freeipmi" + - "cm-ipmitool" + - "cm-ipxe-slave" + - "cm-libpam" + - "cm-libprometheus" + - "cm-lua" + - "cm-mariadb-libs" + - "cm-openssl" + - "cm-python2" + - "cm-python36" + - "cm-slave" + - "cm-uge-client" + - "cmburn" + - "cmburn-slave" + - "cmdaemon" + - "cmdaemon-remotecm" + - "confuse" + - "gcc-recent" + - "gdb-recent" + - "lshw" + - "lua-bit32" + - "lua-filesystem" + - "lua-json" + - "lua-lpeg" + - "lua-posix" + - "lua-term" + - "mysql++" + - "net-snmp-recent" + - "node-installer-slave" + - "openvpn" + - "perl-Config-IniFiles" + - "python-dogpile-cache" + - "python-isodate" + - "python-netaddr" + - "python-netifaces" + - "python-setuptools_scm" + - "python-testtools" + - "python-websockify" + - "python2-cliff" + - "python2-debtcollector" + - "python2-deprecation" + - "python2-fixtures" + - "python2-funcsigs" + - "python2-ipaddress" + - "python2-pbr" + - "python2-positional" + - "python2-pysocks" + - "python2-pyyaml" + - "python2-requests-oauthlib" + - "python2-requestsexceptions" + - "python2-rfc3986" + - "python2-six" + - "python2-stevedore" + - "sdparm" + - "sshpass" + - "swig" + - "turbovnc-2.2.6*" - "cuda-dcgm" - "cuda-dcgm-libs" - "cuda-dcgm-nvvs" diff --git a/openstack-compute/nodeimage.pkr.hcl b/openstack-compute/nodeimage.pkr.hcl index cccebc3a4bebf6dd5a5a53bbee5c26d5afd4818f..bf00471ea5cd36e523e4d34f8a9fa786d94fa749 100644 --- a/openstack-compute/nodeimage.pkr.hcl +++ b/openstack-compute/nodeimage.pkr.hcl @@ -1,43 +1,42 @@ locals { - local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()): ""}" + local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()) : ""}" } source "openstack" "image" { - skip_create_image = var.skip_create_image - image_name = local.local_image_name - source_image_name = var.source_image - image_members = var.image_membership + skip_create_image = var.skip_create_image + image_name = local.local_image_name + source_image = var.source_image + image_members = var.image_membership image_auto_accept_members = var.auto_accept_members - image_tags = var.image_tags - flavor = var.flavor - instance_name = var.build_instance_name - - floating_ip_network = var.floating_ip_network - networks = var.networks - security_groups = var.security_groups - - ssh_username = var.ssh_username + image_tags = var.image_tags + image_disk_format = var.image_format + volume_size = var.volume_size + flavor = var.flavor + instance_name = var.build_instance_name + use_blockstorage_volume = true + floating_ip_network = var.floating_ip_network + networks = var.networks + security_groups = var.security_groups + ssh_username = var.ssh_username } build { sources = ["source.openstack.image"] provisioner "ansible" { - groups = ["compute"] + user = var.ssh_username + groups = ["compute"] playbook_file = "./ansible/compute.yml" - ansible_env_vars = [ - "ANSIBLE_SSH_ARGS='-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=ssh-rsa'", - "ANSIBLE_HOST_KEY_CHECKING=False" - ] - roles_path = "./ansible/roles" + roles_path = "./ansible/roles" extra_arguments = [ - "--scp-extra-args", "'-O'", "--extra-vars", "root_ssh_key='${var.root_ssh_key}'" ] } + provisioner "ansible" { - use_proxy = false - groups = ["compute"] - playbook_file = "./CRI_XCBC/compute-packer.yaml" + user = var.ssh_username + groups = ["compute"] + ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] + playbook_file = "./CRI_XCBC/compute-packer.yaml" } } diff --git a/openstack-compute/variables.pkr.hcl b/openstack-compute/variables.pkr.hcl index 09827195aba2322d506e5a2b57e1f16092e4738b..20efd641406f81250b3cb1cc6514f5078ee2a503 100644 --- a/openstack-compute/variables.pkr.hcl +++ b/openstack-compute/variables.pkr.hcl @@ -1,5 +1,5 @@ variable "root_ssh_key" { - type = string + type = string description = "The root key to use for ssh" } @@ -9,6 +9,12 @@ variable "image_name" { description = "Name of the image in openstack" } +variable "image_format" { + type = string + default = "qcow2" + description = "The format of the resulting image" +} + variable "image_date_suffix" { type = bool default = false @@ -34,8 +40,8 @@ variable "auto_accept_members" { } variable "skip_create_image" { - type = bool - default = false + type = bool + default = false description = "A boolean value for skipping image creation at the end of the build" } @@ -50,29 +56,35 @@ variable "flavor" { } variable "floating_ip_network" { - type = string + type = string description = "floating ip network to use with (temporary) ip assignmnet to a vm" } variable "networks" { - type = list(string) + type = list(string) description = "List of network UUIDs to assign to the network" } variable "security_groups" { - type = list(string) - default = [] + type = list(string) + default = [] description = "A list of security groups to add - you should make sure ssh access is open to the machine" } variable "build_instance_name" { - type = string - default = "compute" + type = string + default = "compute" description = "A name of build instance used for image build" } variable "ssh_username" { - type = string - default = "centos" + type = string + default = "centos" description = "The default username to use for SSH" } + +variable "volume_size" { + type = number + default = 20 + description = "The default volume size for building iamge" +} \ No newline at end of file diff --git a/openstack-gpu/nodeimage.pkr.hcl b/openstack-gpu/nodeimage.pkr.hcl index 7d3ed258d138b3ad3605b9b11e56bb7d2eef4b9a..034ead0c5a3e9a034cc2c9d9f9879c7c9efe33a2 100644 --- a/openstack-gpu/nodeimage.pkr.hcl +++ b/openstack-gpu/nodeimage.pkr.hcl @@ -1,34 +1,42 @@ locals { - local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()): ""}" + local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()) : ""}" } source "openstack" "image" { - image_name = local.local_image_name - source_image_name = var.source_image - flavor = var.flavor - - floating_ip_network = var.floating_ip_network - networks = var.networks - security_groups = var.security_groups - - ssh_username = var.ssh_username + skip_create_image = var.skip_create_image + image_name = local.local_image_name + source_image = var.source_image + image_members = var.image_membership + image_auto_accept_members = var.auto_accept_members + image_tags = var.image_tags + image_disk_format = var.image_format + volume_size = var.volume_size + flavor = var.flavor + instance_name = var.build_instance_name + use_blockstorage_volume = true + floating_ip_network = var.floating_ip_network + networks = var.networks + security_groups = var.security_groups + ssh_username = var.ssh_username } -# regular instance build { sources = ["source.openstack.image"] provisioner "ansible" { - groups = ["gpu"] + user = var.ssh_username + groups = ["gpu"] playbook_file = "./ansible/gpu.yml" - ansible_env_vars = [ - "ANSIBLE_SSH_ARGS='-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=ssh-rsa'", - "ANSIBLE_HOST_KEY_CHECKING=False" - ] - roles_path = "./ansible/roles" + roles_path = "./ansible/roles" extra_arguments = [ - "--scp-extra-args", "'-O'", "--extra-vars", "root_ssh_key='${var.root_ssh_key}'" ] } + + provisioner "ansible" { + user = var.ssh_username + groups = ["compute"] + ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] + playbook_file = "./CRI_XCBC/compute-packer.yaml" + } } diff --git a/openstack-gpu/variables.pkr.hcl b/openstack-gpu/variables.pkr.hcl index 322fb9d56469aee86ae656d3bd82b9b2a081be68..f9614ecdb65bdba8a200cc7de56393c89b25599e 100644 --- a/openstack-gpu/variables.pkr.hcl +++ b/openstack-gpu/variables.pkr.hcl @@ -1,20 +1,50 @@ variable "root_ssh_key" { - type = string + type = string description = "The root key to use for ssh" } variable "image_name" { type = string - default = "cluster-image-gpu" + default = "cluster-image" description = "Name of the image in openstack" } +variable "image_format" { + type = string + default = "qcow2" + description = "The format of the resulting image" +} + variable "image_date_suffix" { type = bool default = false description = "Append a date to the image name (in YYYYMMDDHHMMSS format)" } +variable "image_tags" { + type = list(string) + default = [] + description = "List of tags to be associated to the resulting image" +} + +variable "image_membership" { + type = list(string) + default = [] + description = "Projects/tenants to share the image in openstack with" +} + +variable "auto_accept_members" { + type = bool + default = false + description = "A boolean value for auto accepting image in the projects/tenants defined in image_membership." +} + +variable "skip_create_image" { + type = bool + default = false + description = "A boolean value for skipping image creation at the end of the build" +} + variable "source_image" { type = string description = "The name of the source image to use" @@ -25,24 +55,36 @@ variable "flavor" { description = "The name of the flavor to use" } -variable "ssh_username" { - type = string - default = "centos" - description = "The default username to use for SSH" -} - variable "floating_ip_network" { - type = string + type = string description = "floating ip network to use with (temporary) ip assignmnet to a vm" } variable "networks" { - type = list(string) + type = list(string) description = "List of network UUIDs to assign to the network" } variable "security_groups" { - type = list(string) - default = [] + type = list(string) + default = [] description = "A list of security groups to add - you should make sure ssh access is open to the machine" } + +variable "build_instance_name" { + type = string + default = "gpu" + description = "A name of build instance used for image build" +} + +variable "ssh_username" { + type = string + default = "centos" + description = "The default username to use for SSH" +} + +variable "volume_size" { + type = number + default = 20 + description = "The default volume size for building iamge" +} \ No newline at end of file diff --git a/openstack-ood/nodeimage.pkr.hcl b/openstack-ood/nodeimage.pkr.hcl index 2de64f40e267745aaafdaf0ecba15d526c605d65..65caab7b0db909e752cd6fc21cacd4f228b69c4c 100644 --- a/openstack-ood/nodeimage.pkr.hcl +++ b/openstack-ood/nodeimage.pkr.hcl @@ -1,43 +1,42 @@ locals { - local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()): ""}" + local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()) : ""}" } source "openstack" "image" { - skip_create_image = var.skip_create_image - image_name = local.local_image_name - source_image_name = var.source_image - image_members = var.image_membership + skip_create_image = var.skip_create_image + image_name = local.local_image_name + source_image = var.source_image + image_members = var.image_membership image_auto_accept_members = var.auto_accept_members - image_tags = var.image_tags - image_disk_format = var.image_format - volume_size = 10 - flavor = var.flavor - instance_name = var.build_instance_name - - use_blockstorage_volume = true - floating_ip_network = var.floating_ip_network - networks = var.networks - security_groups = var.security_groups - - ssh_username = var.ssh_username + image_tags = var.image_tags + image_disk_format = var.image_format + volume_size = var.volume_size + flavor = var.flavor + instance_name = var.build_instance_name + use_blockstorage_volume = true + floating_ip_network = var.floating_ip_network + networks = var.networks + security_groups = var.security_groups + ssh_username = var.ssh_username } build { sources = ["source.openstack.image"] provisioner "ansible" { - user = var.ssh_username - groups = ["ood"] + user = var.ssh_username + groups = ["ood"] playbook_file = "./ansible/ood.yml" - roles_path = "./ansible/roles" + roles_path = "./ansible/roles" extra_arguments = [ "--extra-vars", "root_ssh_key='${var.root_ssh_key}'" ] } + provisioner "ansible" { - user = var.ssh_username - groups = ["ood", "knightly"] + user = var.ssh_username + groups = ["ood", "knightly"] ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] - playbook_file = "./CRI_XCBC/ood-packer.yaml" + playbook_file = "./CRI_XCBC/ood-packer.yaml" } } diff --git a/openstack-ood/variables.pkr.hcl b/openstack-ood/variables.pkr.hcl index ddd14de7e661cf1cff5732c62e4ffd4fbf23d4c8..5a6f608cc01a4134e3d276f4a0960e4d2c530f4c 100644 --- a/openstack-ood/variables.pkr.hcl +++ b/openstack-ood/variables.pkr.hcl @@ -1,5 +1,5 @@ variable "root_ssh_key" { - type = string + type = string description = "The root key to use for ssh" } @@ -40,8 +40,8 @@ variable "auto_accept_members" { } variable "skip_create_image" { - type = bool - default = false + type = bool + default = false description = "A boolean value for skipping image creation at the end of the build" } @@ -56,29 +56,35 @@ variable "flavor" { } variable "floating_ip_network" { - type = string + type = string description = "floating ip network to use with (temporary) ip assignmnet to a vm" } variable "networks" { - type = list(string) + type = list(string) description = "List of network UUIDs to assign to the network" } variable "security_groups" { - type = list(string) - default = [] + type = list(string) + default = [] description = "A list of security groups to add - you should make sure ssh access is open to the machine" } variable "build_instance_name" { - type = string - default = "ood" + type = string + default = "ood" description = "A name of build instance used for image build" } variable "ssh_username" { - type = string - default = "centos" + type = string + default = "centos" description = "The default username to use for SSH" } + +variable "volume_size" { + type = number + default = 20 + description = "The default volume size for building iamge" +} \ No newline at end of file diff --git a/openstack/nodeimage.pkr.hcl b/openstack/nodeimage.pkr.hcl index 7988088e8fba1b6dd664a5b12b4d3bd557e4cb1a..cc4316dc9e2d575bfc2382fb8bbb077371f0c459 100644 --- a/openstack/nodeimage.pkr.hcl +++ b/openstack/nodeimage.pkr.hcl @@ -1,39 +1,42 @@ locals { - local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()): ""}" + local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()) : ""}" } source "openstack" "image" { - skip_create_image = var.skip_create_image - image_name = local.local_image_name - source_image_name = var.source_image - image_members = var.image_membership + skip_create_image = var.skip_create_image + image_name = local.local_image_name + source_image = var.source_image + image_members = var.image_membership image_auto_accept_members = var.auto_accept_members - image_tags = var.image_tags - flavor = var.flavor - instance_name = var.build_instance_name - - floating_ip_network = var.floating_ip_network - networks = var.networks - security_groups = var.security_groups - - ssh_username = var.ssh_username + image_tags = var.image_tags + image_disk_format = var.image_format + volume_size = var.volume_size + flavor = var.flavor + instance_name = var.build_instance_name + use_blockstorage_volume = true + floating_ip_network = var.floating_ip_network + networks = var.networks + security_groups = var.security_groups + ssh_username = var.ssh_username } build { sources = ["source.openstack.image"] provisioner "ansible" { - user = var.ssh_username - groups = ["base"] + user = var.ssh_username + groups = ["base"] playbook_file = "./ansible/base.yml" - ansible_env_vars = [ - "ANSIBLE_SSH_ARGS='-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=ssh-rsa'", - "ANSIBLE_HOST_KEY_CHECKING=False" - ] - roles_path = "./ansible/roles" + roles_path = "./ansible/roles" extra_arguments = [ - "--scp-extra-args", "'-O'", "--extra-vars", "root_ssh_key='${var.root_ssh_key}'" ] } + + provisioner "ansible" { + user = var.ssh_username + groups = ["base"] + ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] + playbook_file = "./CRI_XCBC/compute-packer.yaml" + } } diff --git a/openstack/variables.pkr.hcl b/openstack/variables.pkr.hcl index aa810592db45127232fb61d07a9df8a63359658f..ba10499de0da596228dec6fc7f229880eccee33f 100644 --- a/openstack/variables.pkr.hcl +++ b/openstack/variables.pkr.hcl @@ -1,5 +1,5 @@ variable "root_ssh_key" { - type = string + type = string description = "The root key to use for ssh" } @@ -9,6 +9,12 @@ variable "image_name" { description = "Name of the image in openstack" } +variable "image_format" { + type = string + default = "qcow2" + description = "The format of the resulting image" +} + variable "image_date_suffix" { type = bool default = false @@ -34,8 +40,8 @@ variable "auto_accept_members" { } variable "skip_create_image" { - type = bool - default = false + type = bool + default = false description = "A boolean value for skipping image creation at the end of the build" } @@ -50,29 +56,35 @@ variable "flavor" { } variable "floating_ip_network" { - type = string + type = string description = "floating ip network to use with (temporary) ip assignmnet to a vm" } variable "networks" { - type = list(string) + type = list(string) description = "List of network UUIDs to assign to the network" } variable "security_groups" { - type = list(string) - default = [] + type = list(string) + default = [] description = "A list of security groups to add - you should make sure ssh access is open to the machine" } variable "build_instance_name" { - type = string - default = "base" + type = string + default = "base" description = "A name of build instance used for image build" } variable "ssh_username" { - type = string - default = "centos" + type = string + default = "centos" description = "The default username to use for SSH" } + +variable "volume_size" { + type = number + default = 20 + description = "The default volume size for building iamge" +} \ No newline at end of file