From fddf9bb7c4decc552224cc747dc44e12c7cf197b Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Fri, 25 Oct 2024 12:00:20 -0400 Subject: [PATCH] Update installer arch/arm arguments --- deploy/scripts/install-combine.sh | 15 ++++++++--- deploy/scripts/package_images.py | 41 ++++++++++++++--------------- installer/make-combine-installer.sh | 4 +-- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/deploy/scripts/install-combine.sh b/deploy/scripts/install-combine.sh index 0432f2b427..7815df6b81 100755 --- a/deploy/scripts/install-combine.sh +++ b/deploy/scripts/install-combine.sh @@ -78,11 +78,16 @@ install-kubernetes () { # Setup Kubernetes environment and WiFi Access Point cd ${DEPLOY_DIR}/ansible + # Set -e/--extra-vars for ansible-playbook + EXTRA_VARS="-e k8s_user=${whoami}" if [ -d "${DEPLOY_DIR}/airgap-images" ] ; then - ansible-playbook playbook_desktop_setup.yml -K -e k8s_user=`whoami` -e install_airgap_images=true $(((DEBUG == 1)) && echo "-vv") - else - ansible-playbook playbook_desktop_setup.yml -K -e k8s_user=`whoami` $(((DEBUG == 1)) && echo "-vv") + EXTRA_VARS="${EXTRA_VARS} -e install_airgap_images=true" + fi + if [ $ARM == 1 ] ; then + EXTRA_VARS="${EXTRA_VARS} -e cpu_arch=arm64" fi + + ansible-playbook playbook_desktop_setup.yml -K ${EXTRA_VARS} $(((DEBUG == 1)) && echo "-vv") } # Set the KUBECONFIG environment variable so that the cluster can @@ -193,6 +198,7 @@ CONFIG_DIR=${HOME}/.config/combine mkdir -p ${CONFIG_DIR} SINGLE_STEP=0 IS_SERVER=0 +ARM=0 DEBUG=0 # See if we need to continue from a previous install @@ -207,6 +213,9 @@ fi while (( "$#" )) ; do OPT=$1 case $OPT in + arm) + ARM=1 + ;; clean) next-state "Pre-reqs" if [ -f ${CONFIG_DIR}/env ] ; then diff --git a/deploy/scripts/package_images.py b/deploy/scripts/package_images.py index 5916d74829..9bfb0b2a24 100755 --- a/deploy/scripts/package_images.py +++ b/deploy/scripts/package_images.py @@ -8,7 +8,7 @@ image names are extracted from the templates and then pulled from the repo and stored in ../images as compressed tarballs; zstd compression is used. -By default, packs images for amd64 architecture; use --arm to pack for arm64 instead. +By default, packs images for amd64; use --arch for a different architecture. """ import argparse @@ -42,10 +42,10 @@ def parse_args() -> argparse.Namespace: parser.add_argument("output_dir", help="Directory for the collected image files.") # Add Optional arguments parser.add_argument( - "--arm", - action="store_true", - help="Package for arm64 instead of the default amd64", - default=False, + "--arch", + choices=["amd64", "arm64"], + default="amd64", + help="Target cpu architecture.", ) parser.add_argument( "--config", @@ -67,16 +67,15 @@ def parse_args() -> argparse.Namespace: return parser.parse_args() -def package_k3s(dest_dir: Path, *, arm: bool = False, debug: bool = False) -> None: +def package_k3s(dest_dir: Path, *, arch: str = "arm64", debug: bool = False) -> None: logging.info("Packaging k3s images.") - extra_vars = f"'package_dir':'{dest_dir}'" - if arm: - extra_vars += ",'cpu_arch':'arm64'" ansible_cmd = [ "ansible-playbook", "playbook_k3s_airgapped_files.yml", "--extra-vars", - "{" + extra_vars + "}", + f"package_dir={dest_dir}", + "--extra-vars", + f"cpu_arch={arch}", ] if debug: ansible_cmd.append("-vv") @@ -84,14 +83,14 @@ def package_k3s(dest_dir: Path, *, arm: bool = False, debug: bool = False) -> No def package_images( - image_list: List[str], tar_file: Path, *, arm: bool = False, debug: bool = False + image_list: List[str], tar_file: Path, *, arch: str = "amd64", debug: bool = False ) -> None: container_cli_cmd = [os.getenv("CONTAINER_CLI", "docker")] if container_cli_cmd[0] == "nerdctl": container_cli_cmd.extend(["--namespace", "k8s.io"]) # Pull each image - pull_cmd = container_cli_cmd + ["pull", f"--platform=linux/{'arm64' if arm else 'amd64'}"] + pull_cmd = container_cli_cmd + ["pull", f"--platform=linux/{arch}"] for image in image_list: run_cmd(pull_cmd + [image], print_cmd=debug, print_output=debug) @@ -112,7 +111,7 @@ def package_middleware( cluster_type: str, image_dir: Path, chart_dir: Path, - arm: bool = False, + arch: str = "amd64", debug: bool = False, ) -> None: logging.info("Packaging middleware images.") @@ -168,12 +167,12 @@ def package_middleware( middleware_images.append(match.group(1)) logging.debug(f"Middleware images: {middleware_images}") - out_file = f"middleware-airgap-images-{'arm64' if arm else 'amd64'}.tar" - package_images(middleware_images, image_dir / out_file, arm=arm, debug=debug) + out_file = f"middleware-airgap-images-{arch}.tar" + package_images(middleware_images, image_dir / out_file, arch=arch, debug=debug) def package_thecombine( - tag: str, image_dir: Path, *, arm: bool = False, debug: bool = False + tag: str, image_dir: Path, *, arch: str = "amd64", debug: bool = False ) -> None: logging.info(f"Packaging The Combine version {tag}.") logging.debug("Create helm charts from templates") @@ -206,8 +205,8 @@ def package_thecombine( logging.debug(f"Combine images: {combine_images}") # Logout of AWS to allow pulling the images - out_file = f"combine-airgap-images-{'arm64' if arm else 'amd64'}.tar" - package_images(combine_images, image_dir / out_file, arm=arm, debug=debug) + out_file = f"combine-airgap-images-{arch}.tar" + package_images(combine_images, image_dir / out_file, arch=arch, debug=debug) def main() -> None: @@ -228,16 +227,16 @@ def main() -> None: os.environ["AWS_DEFAULT_REGION"] = "" # Update helm repos - package_k3s(image_dir, arm=args.arm, debug=args.debug) + package_k3s(image_dir, arch=args.arch, debug=args.debug) package_middleware( args.config, cluster_type="standard", image_dir=image_dir, chart_dir=chart_dir, - arm=args.arm, + arch=args.arch, debug=args.debug, ) - package_thecombine(args.tag, image_dir, arm=args.arm, debug=args.debug) + package_thecombine(args.tag, image_dir, arch=args.arch, debug=args.debug) if __name__ == "__main__": diff --git a/installer/make-combine-installer.sh b/installer/make-combine-installer.sh index 0ad68ce77c..13c2d0cc3f 100755 --- a/installer/make-combine-installer.sh +++ b/installer/make-combine-installer.sh @@ -62,7 +62,7 @@ if [[ $NET_INSTALL == 0 ]] ; then # Package The Combine for "offline" installation TEMP_DIR=/tmp/images-$$ pushd scripts - ./package_images.py ${COMBINE_VERSION} ${TEMP_DIR} $((( ARM == 1 )) && echo "--arm") $((( DEBUG == 1 )) && echo "--debug") + ./package_images.py ${COMBINE_VERSION} ${TEMP_DIR} $((( ARM == 1 )) && echo "--arch arm64") $((( DEBUG == 1 )) && echo "--debug") INSTALLER_NAME="combine-installer.run" popd else @@ -79,7 +79,7 @@ for DIR in venv scripts/__pycache__ ; do done cd ${SCRIPT_DIR} -makeself $((( DEBUG == 0)) && echo "--tar-quietly" ) ../deploy ${INSTALLER_NAME} "Combine Installer" scripts/install-combine.sh ${COMBINE_VERSION} +makeself $((( DEBUG == 0)) && echo "--tar-quietly" ) ../deploy ${INSTALLER_NAME} "Combine Installer" scripts/install-combine.sh ${COMBINE_VERSION} $((( ARM == 1 )) && echo "arm") if [[ $NET_INSTALL == 0 ]] ; then makeself --append ${TEMP_DIR} ${INSTALLER_NAME} rm -rf ${TEMP_DIR}