# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
---
- name: Install Python 3.10
  apt:
    name:
      - python3.10
      - python3.10-dev
      - python3.10-venv
    state: present

- name: Verify Python 3.10 installation
  stat:
    path: /usr/bin/python3.10
  register: python3_10_bin

- name: Register Python 3.10 alternative
  command: update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
  when: python3_10_bin.stat.exists

- name: Set Python 3.10 as default
  alternatives:
    name: python3
    path: /usr/bin/python3.10
  when: python3_10_bin.stat.exists

- name: Install base dependencies
  apt:
    name:
      - git
      - build-essential
      - curl
      - apt-transport-https
      - gnupg
      - protobuf-compiler
      - rapidjson-dev
      - clang-format
      - openjdk-11-jdk
      - zip
      - unzip
    update_cache: yes