storage api python service templated and port added to jenkinsfile

This commit is contained in:
2025-10-26 20:19:08 -07:00
parent a483c5eae1
commit 0e694894ca
16 changed files with 338 additions and 70 deletions

View File

@ -12,7 +12,8 @@
- name: set up nssm service
include_tasks: nssm.yaml
- name: set up scheduled task
include_tasks: update_task.yaml
...

View File

@ -1,5 +1,15 @@
---
- name: Copy CrystalDiskInfo archive
ansible.windows.win_copy:
src: /var/jenkins_home/ansible-files/programs/CrystalDiskInfo.zip
dest: "{{ storage_api_root }}\\CrystalDiskInfo.zip"
- name: Extract CrystalDiskInfo archive
community.windows.win_unzip:
src: "{{ storage_api_root }}\\CrystalDiskInfo.zip"
dest: "{{ storage_api_root }}\\dist\\"
- name: Install nssm
win_chocolatey:
name: nssm
@ -20,6 +30,20 @@
- name: Show service result
debug:
msg:
- "{{ disk_service_status }}"
- "name........ {{ disk_service_status.name }}"
- "exists...... {{ disk_service_status.exists }}"
- "path........ {{ disk_service_status.path }}"
- "start_mode.. {{ disk_service_status.start_mode }}"
- "state....... {{ disk_service_status.state }}"
- "username.... {{ disk_service_status.username }}"
- "failed...... {{ disk_service_status.failed }}"
- name: Test API
win_shell: "C:\\Windows\\system32\\curl http://{{ ansible_ssh_host }}:5000/disk"
register: api_test_output
- name: Show Test Results
debug:
msg: "{{ api_test_output.stdout_lines }}"
...

View File

@ -1,17 +1,26 @@
---
- name: Create directory structure
- name: Create service working folder
ansible.windows.win_file:
path: "{{ storage_api_root }}"
state: directory
- name: Stop service if running
ignore_errors: yes
ansible.windows.win_service:
name: "{{ disk_service_name }}"
state: paused
state: stopped
- name: Check hostname
ansible.windows.win_command: hostname
register: hostname_output
- name: display hostname
debug:
msg: "Hostname: {{ hostname_output.stdout_lines[0] }}"
- name: Copy disk_service.py
ansible.windows.win_copy:
ansible.windows.win_template:
src: disk_service.py
dest: "{{ storage_api_root }}\\disk_service.py"
@ -35,6 +44,4 @@
state: present
enabled: true
...

View File

@ -28,16 +28,4 @@
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 }}"
...

View File

@ -0,0 +1,20 @@
---
- name: Create Scheduled Task to run crystaldiskinfo
win_scheduled_task:
name: Update CrystalDiskInfo Cache File
username: SYSTEM
actions:
- path: "{{ storage_api_root }}\\dist\\DiskInfo64.exe"
arguments: |
/CopyExit
triggers:
- type: registration
- type: daily
start_boundary: '{{ ansible_date_time.date }}T01:00:00'
- type: boot
state: present
enabled: yes
...