Commit 3196928d authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

decouple i2edge deps from i2edge

parent 4565ce7c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ kubernetes_version: v1.33.1
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"
external_host_ip: "192.168.123.188"

# Service NodePorts
prometheus_nodeport: 30090
+11 −12
Original line number Diff line number Diff line
@@ -8,17 +8,6 @@ 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
@@ -29,13 +18,23 @@ all:
      deployment_mode: remote
      host_ip: 192.168.34.193

    openop_dev_vm:
      ansible_host: openop-dev-vm
      ansible_connection: ssh
      ansible_user: ubuntu
      ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
      ansible_python_interpreter: /usr/bin/python3
      deployment_mode: remote
      host_ip: 192.168.123.188
  
  children:
    kind_cluster:
      hosts:
        # Switch between localhost and remote_local to test different modes
        # localhost:  # Standard local deployment
        # remote_local:  # Remote-style deployment with external IP
        vm_ubuntu24:
        # vm_ubuntu24:
        openop_dev_vm:
      vars:
        # Kind cluster configuration
        kind_cluster_name: operator-platform
+29 −0
Original line number Diff line number Diff line
@@ -9,10 +9,17 @@
  become: true
  
  tasks:
    - name: Check if Docker is already installed
      ansible.builtin.command: docker --version
      register: docker_check
      failed_when: false
      changed_when: false

    - name: Update apt cache
      ansible.builtin.apt:
        update_cache: true
        cache_valid_time: 3600
      when: docker_check.rc != 0

    - name: Install prerequisites
      ansible.builtin.apt:
@@ -21,12 +28,24 @@
          - curl
          - gnupg
        state: present
      when: docker_check.rc != 0

    - name: Create keyrings directory
      ansible.builtin.file:
        path: /etc/apt/keyrings
        state: directory
        mode: '0755'
      when: docker_check.rc != 0

    - name: Remove conflicting Docker repository files
      ansible.builtin.file:
        path: "{{ item }}"
        state: absent
      loop:
        - /etc/apt/sources.list.d/docker.list
        - /etc/apt/keyrings/docker.gpg
        - /etc/apt/keyrings/docker.asc
      when: docker_check.rc != 0

    - name: Add Docker's official GPG key
      ansible.builtin.shell:
@@ -34,6 +53,7 @@
          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
      when: docker_check.rc != 0

    - name: Add Docker repository
      ansible.builtin.shell:
@@ -43,10 +63,12 @@
          $(. /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
      when: docker_check.rc != 0

    - name: Update apt cache again
      ansible.builtin.apt:
        update_cache: true
      when: docker_check.rc != 0

    - name: Install Docker Engine
      ansible.builtin.apt:
@@ -57,9 +79,16 @@
          - docker-buildx-plugin
          - docker-compose-plugin
        state: present
      when: docker_check.rc != 0

    - name: Start and enable Docker service
      ansible.builtin.service:
        name: docker
        state: started
        enabled: true
      when: docker_check.rc != 0

    - name: Display Docker installation status
      ansible.builtin.debug:
        msg: "Docker is already installed and will be skipped"
      when: docker_check.rc == 0
+12 −0
Original line number Diff line number Diff line
@@ -49,6 +49,15 @@
        kind_cluster_recreate: "{{ recreate_cluster | default('no') | lower in ['yes', 'y'] }}"

  post_tasks:
    - name: Ensure local kubeconfig directory exists
      ansible.builtin.file:
        path: "{{ kubeconfig_output_dir }}"
        state: directory
        mode: '0755'
      delegate_to: localhost
      run_once: true
      become: false

    - name: Create environment setup script
      ansible.builtin.copy:
        dest: "{{ kubeconfig_output_dir }}/setup-env.sh"
@@ -64,6 +73,9 @@
          echo ""
          echo "To use this cluster in other terminals, run:"
          echo "  source {{ kubeconfig_output_dir }}/setup-env.sh"
      delegate_to: localhost
      run_once: true
      become: false

    - name: Final instructions
      ansible.builtin.debug:
+109 −0
Original line number Diff line number Diff line
---
# Playbook: Install i2edge Dependencies
# Description: Installs Helm, Prometheus Stack, and Node Feature Discovery
# Usage: ansible-playbook ansible/playbooks/01-install-i2edge-dependencies.yml

- name: Install i2edge Dependencies
  hosts: kind_cluster
  gather_facts: true
  
  vars:
    # Set the kubeconfig path based on deployment mode
    kubeconfig_path: "{% if deployment_mode is defined and deployment_mode == 'remote' %}/home/{{ ansible_user }}/kind-cluster-config/{{ kubeconfig_filename }}{% else %}{{ kubeconfig_output_dir }}/{{ kubeconfig_filename }}{% endif %}"
  
  pre_tasks:
    - name: Set kubeconfig path for remote deployment
      ansible.builtin.set_fact:
        kubeconfig_path: "/home/{{ ansible_user }}/kind-cluster-config/{{ kubeconfig_filename }}"
      when: deployment_mode is defined and deployment_mode == 'remote'

    - name: Set kubeconfig path for local deployment
      ansible.builtin.set_fact:
        kubeconfig_path: "{{ kubeconfig_output_dir }}/{{ kubeconfig_filename }}"
      when: deployment_mode is not defined or deployment_mode != 'remote'

    - name: Display playbook information
      ansible.builtin.debug:
        msg: |
          ==========================================
          Installing i2edge Dependencies
          ==========================================
          Components to install:
            1. Helm 3
            2. Prometheus Stack (monitoring namespace)
            3. Node Feature Discovery
          
          Cluster: {{ kind_cluster_name | default('operator-platform') }}
          Kubeconfig: {{ kubeconfig_path }}
          ==========================================

    - name: Verify Kind cluster exists
      ansible.builtin.shell: kubectl --kubeconfig={{ kubeconfig_path }} cluster-info
      changed_when: false
      register: cluster_check
      failed_when: cluster_check.rc != 0

    - name: Display cluster information
      ansible.builtin.debug:
        msg: " Cluster is accessible: {{ cluster_check.stdout_lines[0] }}"

    - name: Get cluster nodes
      ansible.builtin.shell: kubectl --kubeconfig={{ kubeconfig_path }} get nodes
      register: cluster_nodes
      changed_when: false

    - name: Display cluster nodes
      ansible.builtin.debug:
        msg: "{{ cluster_nodes.stdout_lines }}"

  roles:
    - role: helm
      tags: ['helm', 'dependencies']
    
    - role: prometheus
      tags: ['prometheus', 'monitoring', 'dependencies']
    
    - role: node-feature-discovery
      tags: ['nfd', 'node-feature-discovery', 'dependencies']

  post_tasks:
    - name: Display installation summary
      ansible.builtin.debug:
        msg: |
          ==========================================
          ✓ i2edge dependencies installed!
          ==========================================
          
          Components installed:
            ✓ Helm 3
            ✓ Prometheus Stack
              - Namespace: {{ prometheus_namespace | default('monitoring') }}
              - Prometheus: {{ prometheus_nodeport | default('30090') }}
              - Grafana: {{ grafana_nodeport | default('30091') }}
              - Alertmanager: {{ alertmanager_nodeport | default('30092') }}
              - Grafana credentials: admin/{{ grafana_admin_password | default('admin') }}
            ✓ Node Feature Discovery
              - Custom labels applied
          
          Access Prometheus Stack:
            Prometheus: http://{{ kubeconfig_server_host }}:{{ prometheus_nodeport | default('30090') }}
            Grafana: http://{{ kubeconfig_server_host }}:{{ grafana_nodeport | default('30091') }}
            Alertmanager: http://{{ kubeconfig_server_host }}:{{ alertmanager_nodeport | default('30092') }}
          
          Useful commands:
            # Check Prometheus pods
            kubectl get pods -n {{ prometheus_namespace | default('monitoring') }}
            
            # Check NFD labels
            kubectl get nodes --show-labels
          
          Configuration files:
            Kubeconfig: {{ kubeconfig_output_dir }}/{{ kubeconfig_filename }}
            Prometheus values: {{ kubeconfig_output_dir }}/prometheus-values.yaml
            NFD labels: {{ kubeconfig_output_dir }}/nfd-node-labels.yaml
          
          Next step:
            Deploy i2edge application with:
            ansible-playbook ansible/playbooks/02-deploy-i2edge.yml
          ==========================================
      tags: ['always']
Loading