| --- |
| # enodebd tasks/main.yml |
| # |
| # SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| - name: include OS-specific vars |
| include_vars: "{{ ansible_os_family }}.yml" |
| |
| - name: include OS-specific tasks |
| include_tasks: "{{ ansible_os_family }}.yml" |
| |
| - name: Create group for enodebd |
| group: |
| name: "{{ enodebd_groupname }}" |
| |
| - name: Create user for enodebd |
| user: |
| name: "{{ enodebd_username }}" |
| group: "{{ enodebd_groupname }}" |
| comment: "{{ enodebd_comment }}" |
| shell: "{{ enodebd_shell }}" |
| system: true |
| password_lock: true |
| |
| - name: Create enodebd dist dir |
| file: |
| path: "{{ enodebd_dist_dir }}" |
| state: directory |
| owner: "{{ enodebd_username }}" |
| group: "{{ enodebd_groupname }}" |
| mode: "0755" |
| |
| - name: Download enodebd distribution .tgz file |
| get_url: |
| url: "https://github.com/aweimeow/enodebd/archive/refs/tags/v{{ enodebd_version }}.tar.gz" |
| dest: "{{ enodebd_dist_dir }}/enodebd_v{{ enodebd_version }}.tar.gz" |
| owner: "{{ enodebd_username }}" |
| group: "{{ enodebd_groupname }}" |
| mode: "0644" |
| checksum: "{{ enodebd_version_checksum }}" |
| |
| - name: Unarchive enodebd distribution |
| unarchive: |
| remote_src: true |
| src: "{{ enodebd_dist_dir }}/enodebd_v{{ enodebd_version }}.tar.gz" |
| dest: "/opt" |
| owner: "{{ enodebd_username }}" |
| group: "{{ enodebd_groupname }}" |
| creates: "/opt/enodebd-{{ enodebd_version }}" |
| |
| - name: Link enodebd distro to working dir |
| file: |
| state: "link" |
| src: "/opt/enodebd-{{ enodebd_version }}" |
| dest: "{{ enodebd_working_dir }}" |
| |
| - name: Create enodebd virtual environment |
| command: |
| chdir: "{{ enodebd_working_dir }}" |
| cmd: "make venv" |
| creates: "/opt/enodebd-{{ enodebd_version }}/venv" |
| |
| - name: Install protobuf |
| command: |
| chdir: "{{ enodebd_working_dir }}" |
| cmd: "make install-protoc" |
| creates: "/opt/protobuf/bin/protoc" |
| |
| - name: Compile enodebd proto files |
| command: |
| chdir: "{{ enodebd_working_dir }}" |
| cmd: "make proto" |
| creates: "/opt/enodebd-{{ enodebd_version }}/metrics_pb2.py" |
| |
| - name: Create enodebd.yml configuration |
| template: |
| src: "{{ item }}.j2" |
| dest: "{{ enodebd_working_dir }}/magma_configs/enodebd.yml" |
| owner: "{{ enodebd_username }}" |
| group: "{{ enodebd_groupname }}" |
| mode: "0644" |
| force: false |
| with_items: |
| - "enodebd.yml" |
| |
| - name: Start enodebd |
| service: |
| name: "{{ item }}" |
| state: "started" |
| enabled: true |
| with_items: |
| - "enodebd" |