diff --git a/README.md b/README.md index 46dc191..aacd459 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ Once you get the account, follow the *Before you begin* and *1. Prepare* step in This module was tested with: -* Ubuntu 20.04, 22.04 (ubuntu remote user) -* Ubuntu 20.04, 22.04 Minimal (ubuntu remote user) +* Ubuntu 20.04, 22.04, 24.04 (ubuntu remote user) +* Ubuntu 20.04, 22.04 Minimal, 24.04 (ubuntu remote user) * Oracle Linux 8, 9 (opc remote user) ### Terraform OCI user creation (Optional) diff --git a/files/k3s-install-agent.sh b/files/k3s-install-agent.sh index f838435..d2bf219 100644 --- a/files/k3s-install-agent.sh +++ b/files/k3s-install-agent.sh @@ -24,9 +24,16 @@ check_os() { } install_oci_cli_ubuntu(){ - DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3 python3-pip nginx + DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3 python3-pip nginx libnginx-mod-stream systemctl enable nginx - pip install oci-cli + # https://github.com/oracle/oci-cli/issues/875 + LATEST_OCICLI=$(curl -L https://api.github.com/repos/oracle/oci-cli/releases | \ + jq -r 'sort_by(.name) | reverse | .[0].name') ; + echo "LATEST_OCICLI=$${LATEST_OCICLI}" ; + bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)" \ + -s \ + --accept-all-defaults \ + --oci-cli-version $${LATEST_OCICLI} } install_oci_cli_oracle(){ @@ -132,8 +139,9 @@ cat << 'EOF' > /root/find_ips.sh export OCI_CLI_AUTH=instance_principal private_ips=() +export PATH="/root/bin:$PATH" # Fetch the OCID of all the running instances in OCI and store to an array -instance_ocids=$(oci search resource structured-search --query-text "QUERY instance resources where lifeCycleState='RUNNING'" --query 'data.items[*].identifier' --raw-output | jq -r '.[]' ) +instance_ocids=$(oci search resource structured-search --query-text "QUERY instance resources where lifeCycleState='RUNNING'" --query 'data.items[*].identifier' --raw-output | jq -r '.[]' ) # Iterate through the array to fetch details of each instance one by one for val in $${instance_ocids[@]} ; do diff --git a/files/k3s-install-server.sh b/files/k3s-install-server.sh index c6ac19f..04c0634 100644 --- a/files/k3s-install-server.sh +++ b/files/k3s-install-server.sh @@ -580,7 +580,14 @@ if [[ "$operating_system" == "ubuntu" ]]; then apt-get install -y software-properties-common jq DEBIAN_FRONTEND=noninteractive apt-get upgrade -y DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y python3 python3-pip - pip install oci-cli + # https://github.com/oracle/oci-cli/issues/875 + LATEST_OCICLI=$(curl -L https://api.github.com/repos/oracle/oci-cli/releases | \ + jq -r 'sort_by(.name) | reverse | .[0].name') ; + echo "LATEST_OCICLI=$${LATEST_OCICLI}" ; + bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)" \ + -s \ + --accept-all-defaults \ + --oci-cli-version $${LATEST_OCICLI} # Fix /var/log/journal dir size echo "SystemMaxUse=100M" >> /etc/systemd/journald.conf @@ -611,6 +618,7 @@ if [[ "$operating_system" == "oraclelinux" ]]; then fi export OCI_CLI_AUTH=instance_principal +export PATH="/root/bin:$PATH" first_instance=$(oci compute instance list --compartment-id ${compartment_ocid} --availability-domain ${availability_domain} --lifecycle-state RUNNING --sort-by TIMECREATED | jq -r '.data[]|select(."display-name" | endswith("k3s-servers")) | .["display-name"]' | tail -n 1) instance_id=$(curl -s -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance | jq -r '.displayName')