Files
ansible-windows/roles/storage_api/tasks/python_service.yaml

47 lines
1.1 KiB
YAML

---
- 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: 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_template:
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
...