disk service jenkinsfile less verbose
This commit is contained in:
@ -1,15 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Create directory structure
|
||||
ansible.windows.win_file:
|
||||
path: "{{ python_service_root }}"
|
||||
state: directory
|
||||
|
||||
- name: Copy disk_service.py
|
||||
ansible.windows.win_copy:
|
||||
src: disk_service.py
|
||||
dest: "{{ python_service_root }}\disk_service.py"
|
||||
|
||||
|
||||
|
||||
...
|
||||
@ -8,10 +8,11 @@
|
||||
include_tasks: python_venv.yaml
|
||||
|
||||
- name: build python exe
|
||||
include_tasks: build_py_bin.yaml
|
||||
include_tasks: python_service.yaml
|
||||
|
||||
#- name: set up nssm service
|
||||
# include_tasks: nssm.yaml
|
||||
- name: set up nssm service
|
||||
include_tasks: nssm.yaml
|
||||
|
||||
|
||||
|
||||
...
|
||||
@ -5,9 +5,21 @@
|
||||
name: nssm
|
||||
state: present
|
||||
|
||||
- name: Install the foo service
|
||||
- name: Install disk_api service
|
||||
community.windows.win_nssm:
|
||||
name: foo
|
||||
application: C:\windows\foo.exe
|
||||
name: "{{ disk_service_name }}"
|
||||
application: "{{ storage_api_root }}\\dist\\disk_service.exe"
|
||||
|
||||
- name: Set disk_api service startup auto and start
|
||||
ansible.windows.win_service:
|
||||
name: "{{ disk_service_name }}"
|
||||
start_mode: auto
|
||||
state: started
|
||||
register: disk_service_status
|
||||
|
||||
- name: Show service result
|
||||
debug:
|
||||
msg:
|
||||
- "{{ disk_service_status }}"
|
||||
|
||||
...
|
||||
40
roles/storage_api/tasks/python_service.yaml
Normal file
40
roles/storage_api/tasks/python_service.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
|
||||
- name: Create directory structure
|
||||
ansible.windows.win_file:
|
||||
path: "{{ storage_api_root }}"
|
||||
state: directory
|
||||
|
||||
- name: Stop service if running
|
||||
ansible.windows.win_service:
|
||||
name: "{{ disk_service_name }}"
|
||||
state: paused
|
||||
|
||||
- name: Copy disk_service.py
|
||||
ansible.windows.win_copy:
|
||||
src: disk_service.py
|
||||
dest: "{{ storage_api_root }}\\disk_service.py"
|
||||
|
||||
- name: install pyinstaller
|
||||
win_shell: "{{ python_venv_bin }} -m pip install pyinstaller"
|
||||
|
||||
- name: compile binary
|
||||
become: no
|
||||
win_shell: "{{ python_venv }}\\Scripts\\pyinstaller.exe -F {{ storage_api_root }}\\disk_service.py"
|
||||
args:
|
||||
chdir: "{{ storage_api_root }}"
|
||||
|
||||
- name: Open up port 5000
|
||||
community.windows.win_firewall_rule:
|
||||
name: _ansible_python_disk_service
|
||||
description: "Firewall rule to allow traffic for Disk info API"
|
||||
localport: 5000
|
||||
action: allow
|
||||
direction: in
|
||||
protocol: tcp
|
||||
state: present
|
||||
enabled: true
|
||||
|
||||
|
||||
|
||||
...
|
||||
@ -13,19 +13,31 @@
|
||||
- name: Copy requirements.txt
|
||||
ansible.windows.win_copy:
|
||||
src: requirements.txt
|
||||
dest: "{{ python_venv }}\requirements.txt"
|
||||
dest: "{{ python_venv }}\\requirements.txt"
|
||||
|
||||
- name: Create virtual environment
|
||||
win_shell: "py -m venv {{ python_venv }}"
|
||||
win_shell: "python -m venv {{ python_venv }}"
|
||||
|
||||
- name: Upgrade pip in the virtual environment
|
||||
win_shell: "{{ python_venv }}\pip install --upgrade pip"
|
||||
win_shell: "{{ python_venv_bin }} -m pip install --upgrade pip"
|
||||
args:
|
||||
chdir: "{{ python_venv }}"
|
||||
|
||||
- name: Install Python dependencies from requirements.txt
|
||||
win_shell: "{{ python_venv }}\pip install -r {{ python_venv }}\requirements.txt"
|
||||
win_shell: "{{ python_venv_bin }} -m pip install -r {{ python_venv }}\\requirements.txt"
|
||||
args:
|
||||
chdir: "{{ python_venv }}"
|
||||
|
||||
|
||||
|
||||
#- name: Upgrade pip in the virtual environment
|
||||
# win_shell: "{{ python_venv }}\\pip install --upgrade pip"
|
||||
# args:
|
||||
# chdir: "{{ python_venv }}"
|
||||
#
|
||||
#- name: Install Python dependencies from requirements.txt
|
||||
# win_shell: "{{ python_venv }}\\pip install -r {{ python_venv }}\\requirements.txt"
|
||||
# args:
|
||||
# chdir: "{{ python_venv }}"
|
||||
|
||||
...
|
||||
Reference in New Issue
Block a user