From 6d5116104b4cfc14483eea49c09372bd1ac2c603 Mon Sep 17 00:00:00 2001 From: ArdavanPb Date: Wed, 23 Jul 2025 11:57:58 +0330 Subject: [PATCH] add comment, add run datadiode python --- roles/install-datadiode.yml | 11 +++++++++++ roles/install-rx.yml | 24 +++++++++++++++++++++++- roles/intall-tx.yml | 27 ++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/roles/install-datadiode.yml b/roles/install-datadiode.yml index 581fc76..4177685 100644 --- a/roles/install-datadiode.yml +++ b/roles/install-datadiode.yml @@ -3,6 +3,11 @@ hosts: All_server become: yes # برای اجرای دستورات با دسترسی ریشه tasks: + - name: Update all packages + zypper: + name: '*' + state: latest + - name: Install Git zypper: name: git @@ -17,3 +22,9 @@ zypper: name: libgthread-2_0-0 state: present + + - name: Symlink /usr/local/bin/python to python3.11 + become: yes + ansible.builtin.command: + cmd: ln -sfn /usr/bin/python3.11 /usr/local/bin/python + creates: /usr/local/bin/python \ No newline at end of file diff --git a/roles/install-rx.yml b/roles/install-rx.yml index ae5383d..4e0fbae 100644 --- a/roles/install-rx.yml +++ b/roles/install-rx.yml @@ -5,7 +5,10 @@ vars: git_username: tester git_password: Datall@0000 + app_path: /opt/DataDiodeRServer + venv_path: "{{ app_path }}/.env" tasks: + #section clone in git - name: Remove existing DataDiodeRServer directory file: path: /opt/DataDiodeRServer @@ -22,7 +25,26 @@ owner: datall group: users state: directory + + #section active python and install requirements + - name: Create a Python 3 venv + ansible.builtin.command: + cmd: python3 -m venv "{{ venv_path }}" + args: + creates: "{{ venv_path }}/bin/activate" + + - name: Upgrade pip & setuptools inside the venv + ansible.builtin.command: + cmd: "{{ venv_path }}/bin/python -m pip install --upgrade pip setuptools" + + - name: Install requirements into the venv + ansible.builtin.pip: + requirements: "{{ app_path }}/requirements.txt" + virtualenv: "{{ venv_path }}" + virtualenv_command: python3 -m venv + virtualenv_site_packages: no + #section copy scripts to path - name: Copy all scripts from scripts directory to /usr/sbin copy: src: /opt/DataDiodeRServer/scripts/ @@ -32,7 +54,7 @@ mode: '0755' recurse: yes - + #section copy systemd file enable and start - name: Copy datadiode.service to /etc/systemd/system/ copy: src: /opt/DataDiodeRServer/service/datadiode.service diff --git a/roles/intall-tx.yml b/roles/intall-tx.yml index 04dbe86..097d502 100644 --- a/roles/intall-tx.yml +++ b/roles/intall-tx.yml @@ -4,8 +4,11 @@ become: yes # برای اجرای دستورات با دسترسی ریشه vars: git_username: tester - git_password: Datall@0000 + git_password: Datall@0000\ + app_path: /opt/DataDiodeTServer + venv_path: "{{ app_path }}/.env" tasks: + #section clone in git - name: Remove existing DataDiodeTServer directory file: path: /opt/DataDiodeTServer @@ -22,7 +25,25 @@ owner: datall group: users state: directory - + #section active python and install requirements + - name: Create a Python 3 venv + ansible.builtin.command: + cmd: python3 -m venv "{{ venv_path }}" + args: + creates: "{{ venv_path }}/bin/activate" + + - name: Upgrade pip & setuptools inside the venv + ansible.builtin.command: + cmd: "{{ venv_path }}/bin/python -m pip install --upgrade pip setuptools" + + - name: Install requirements into the venv + ansible.builtin.pip: + requirements: "{{ app_path }}/requirements.txt" + virtualenv: "{{ venv_path }}" + virtualenv_command: python3 -m venv + virtualenv_site_packages: no + + #section copy scripts to path - name: Copy all scripts from scripts directory to /usr/sbin copy: src: /opt/DataDiodeRServer/scripts/ @@ -32,7 +53,7 @@ mode: '0755' recurse: yes - + #section copy systemd file enable and start - name: Copy datadiode.service to /etc/systemd/system/ copy: src: /opt/DataDiodeTServer/service/datadiode.service