Commit 4565ce7c authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

[WIP] Lots of changes

parent 4f22ee78
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -13,8 +13,11 @@ kind_install_path: /usr/local/bin/kind
kubernetes_version: v1.33.1

# Network settings
# Use 0.0.0.0 to bind to all interfaces, allowing external access
api_server_address: "0.0.0.0"
api_server_port: 6443
# External IP for kubeconfig (set to host IP for remote access)
external_host_ip: "10.69.222.3"

# Service NodePorts
prometheus_nodeport: 30090
+27 −3
Original line number Diff line number Diff line
---
# Ansible inventory for OP_Automation
# Since we're managing Kind clusters locally, most tasks run on localhost
# Supports both local and remote deployment

all:
  hosts:
@@ -8,10 +8,34 @@ all:
      ansible_connection: local
      ansible_python_interpreter: "{{ ansible_playbook_python }}"
    
    remote_local:
      # SSH connection to local machine
      ansible_host: 10.69.222.3
      ansible_connection: ssh
      ansible_user: sergio
      ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
      ansible_python_interpreter: /opt/ansible-venv/bin/python
      # This host uses the external IP for kubeconfig generation
      deployment_mode: remote
      host_ip: 10.69.222.3

    vm_ubuntu24:
      ansible_host: 192.168.34.193
      ansible_connection: ssh
      ansible_user: root
      ansible_password: basquet97
      ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
      ansible_python_interpreter: /usr/bin/python3
      deployment_mode: remote
      host_ip: 192.168.34.193
  
  children:
    kind_cluster:
      hosts:
        localhost:
        # Switch between localhost and remote_local to test different modes
        # localhost:  # Standard local deployment
        # remote_local:  # Remote-style deployment with external IP
        vm_ubuntu24:
      vars:
        # Kind cluster configuration
        kind_cluster_name: operator-platform
@@ -19,5 +43,5 @@ all:
        kind_config_template: kind-config.yaml.j2
        
        # Kubeconfig settings
        kubeconfig_output_dir: "{{ playbook_dir }}/../automation/1-kind-cluster"
        kubeconfig_output_dir: "/home/sergio/i2cat/OperatorPlatform/OP_Automation/automation/1-kind-cluster"
        kubeconfig_filename: operator-platform-external-kubeconfig.yaml
+46 −0
Original line number Diff line number Diff line
---
# Playbook: Install Python Dependencies
# Description: Sets up Python virtual environment with required libraries
# Usage: ansible-playbook playbooks/00-install-python-deps.yml -k -K

- name: Install Python Dependencies for Ansible
  hosts: kind_cluster
  gather_facts: true
  become: true
  
  vars:
    venv_path: "/opt/ansible-venv"
    
  tasks:
    - name: Install Python3 venv package
      ansible.builtin.apt:
        name:
          - python3-venv
          - python3-pip
        state: present
        update_cache: true

    - name: Create virtual environment
      ansible.builtin.command:
        cmd: python3 -m venv {{ venv_path }}
        creates: "{{ venv_path }}/bin/python"

    - name: Copy requirements file
      ansible.builtin.copy:
        src: ../requirements.txt
        dest: /tmp/ansible-requirements.txt
        mode: '0644'

    - name: Install Python packages in venv
      ansible.builtin.pip:
        requirements: /tmp/ansible-requirements.txt
        virtualenv: "{{ venv_path }}"
        virtualenv_command: python3 -m venv

    - name: Display success message
      ansible.builtin.debug:
        msg: |
          ✓ Python dependencies installed in {{ venv_path }}
          
          To use this venv, add to your inventory:
          ansible_python_interpreter: {{ venv_path }}/bin/python
+65 −0
Original line number Diff line number Diff line
---
# Playbook: Install Docker
# Description: Installs Docker Engine on Ubuntu
# Usage: ansible-playbook playbooks/00-setup-docker.yml

- name: Install Docker
  hosts: kind_cluster
  gather_facts: true
  become: true
  
  tasks:
    - name: Update apt cache
      ansible.builtin.apt:
        update_cache: true
        cache_valid_time: 3600

    - name: Install prerequisites
      ansible.builtin.apt:
        name:
          - ca-certificates
          - curl
          - gnupg
        state: present

    - name: Create keyrings directory
      ansible.builtin.file:
        path: /etc/apt/keyrings
        state: directory
        mode: '0755'

    - name: Add Docker's official GPG key
      ansible.builtin.shell:
        cmd: |
          curl -fsSL https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
          chmod a+r /etc/apt/keyrings/docker.gpg
        creates: /etc/apt/keyrings/docker.gpg

    - name: Add Docker repository
      ansible.builtin.shell:
        cmd: |
          echo \
          "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/{{ ansible_distribution | lower }} \
          $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
          tee /etc/apt/sources.list.d/docker.list > /dev/null
        creates: /etc/apt/sources.list.d/docker.list

    - name: Update apt cache again
      ansible.builtin.apt:
        update_cache: true

    - name: Install Docker Engine
      ansible.builtin.apt:
        name:
          - docker-ce
          - docker-ce-cli
          - containerd.io
          - docker-buildx-plugin
          - docker-compose-plugin
        state: present

    - name: Start and enable Docker service
      ansible.builtin.service:
        name: docker
        state: started
        enabled: true
+52 −0
Original line number Diff line number Diff line
---
# Playbook: Install kubectl
# Description: Installs kubectl on Debian/Ubuntu
# Usage: ansible-playbook playbooks/00-setup-kubectl.yml

- name: Install kubectl
  hosts: kind_cluster
  gather_facts: true
  become: true
  
  tasks:
    - name: Update apt cache
      ansible.builtin.apt:
        update_cache: true
        cache_valid_time: 3600

    - name: Install prerequisites
      ansible.builtin.apt:
        name:
          - apt-transport-https
          - ca-certificates
          - curl
          - gnupg
        state: present

    - name: Create keyrings directory
      ansible.builtin.file:
        path: /etc/apt/keyrings
        state: directory
        mode: '0755'

    - name: Download Kubernetes public signing key
      ansible.builtin.shell:
        cmd: |
          curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
          chmod a+r /etc/apt/keyrings/kubernetes-apt-keyring.gpg
        creates: /etc/apt/keyrings/kubernetes-apt-keyring.gpg

    - name: Add Kubernetes repository
      ansible.builtin.shell:
        cmd: |
          echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
        creates: /etc/apt/sources.list.d/kubernetes.list

    - name: Update apt cache again
      ansible.builtin.apt:
        update_cache: true

    - name: Install kubectl
      ansible.builtin.apt:
        name: kubectl
        state: present
Loading