96 lines
4.3 KiB
YAML
96 lines
4.3 KiB
YAML
---
|
|
- name: "STRESS-SETUP: Manage auth simulation generator"
|
|
hosts: workers
|
|
gather_facts: no
|
|
vars:
|
|
tmux_session_auth_gen: "stress-auth-{{ (profile_prefix | default('default')) | replace(',', '-') }}"
|
|
auth_policy: "policies/12_queue_auth_simulation.yaml"
|
|
vars_files:
|
|
- "group_vars/all/vault.yml"
|
|
pre_tasks:
|
|
- name: Set inventory_env fact
|
|
ansible.builtin.set_fact:
|
|
inventory_env: "{{ inventory_file | basename | splitext | first | replace('inventory.', '') }}"
|
|
- name: Load environment-specific variables
|
|
ansible.builtin.include_vars: "{{ item }}"
|
|
with_fileglob:
|
|
- "group_vars/all/generated_vars{{ '.' + inventory_env if inventory_env else '' }}.yml"
|
|
tasks:
|
|
- name: Define base directory for node
|
|
ansible.builtin.set_fact:
|
|
base_dir: "{{ airflow_worker_dir }}"
|
|
|
|
- name: Validate profile_prefix is provided when starting or stopping
|
|
ansible.builtin.fail:
|
|
msg: "profile_prefix is required when start_generator=true or stop_generator=true"
|
|
when:
|
|
- (start_generator | default(false) | bool or stop_generator | default(false) | bool)
|
|
- profile_prefix is not defined
|
|
|
|
- name: "Display policy being used for auth generator"
|
|
ansible.builtin.debug:
|
|
msg: "Using auth generator policy: {{ auth_policy }}"
|
|
when: start_generator | default(false) | bool
|
|
|
|
- name: Manage auth generator process
|
|
ansible.builtin.include_tasks:
|
|
file: manage-processes-tasks.yml
|
|
vars:
|
|
tmux_session_name: "{{ tmux_session_auth_gen }}"
|
|
working_dir: "{{ base_dir }}"
|
|
command_to_run: >
|
|
./bin/ytops-client stress-policy
|
|
--policy {{ auth_policy }}
|
|
{% if dummy_batch | default(true) | bool %}--dummy-batch{% endif %}
|
|
{% if auth_min_seconds is defined %}--set 'settings.dummy_simulation_settings.auth_min_seconds={{ auth_min_seconds }}'{% endif %}
|
|
{% if auth_max_seconds is defined %}--set 'settings.dummy_simulation_settings.auth_max_seconds={{ auth_max_seconds }}'{% endif %}
|
|
{% if batch_size is defined %}--set 'queue_policy.batch_size={{ batch_size }}'{% endif %}
|
|
{% if create_download_tasks is defined %}--set 'queue_policy.create_download_tasks={{ create_download_tasks }}'{% endif %}
|
|
{% if formats_to_download is defined %}--set 'queue_policy.formats_to_download={{ formats_to_download }}'{% endif %}
|
|
{% if profile_prefix is defined %}--set 'execution_control.worker_pools=[{"profile_prefix": "{{ profile_prefix }}", "workers": 1}]'{% endif %}
|
|
--profile-prefix {{ profile_prefix }}
|
|
process_grep_pattern: "ytops-client.*stress-policy.*--policy {{ auth_policy }}.*--profile-prefix {{ profile_prefix }}"
|
|
start_process: "{{ start_generator | default(false) | bool }}"
|
|
stop_process: "{{ stop_generator | default(false) | bool }}"
|
|
check_status: "{{ vars.check_status | default(false) | bool }}"
|
|
|
|
- name: List active tmux sessions
|
|
ansible.builtin.shell:
|
|
cmd: tmux list-sessions 2>/dev/null || true
|
|
register: tmux_sessions
|
|
changed_when: false
|
|
|
|
- name: Display active sessions
|
|
ansible.builtin.debug:
|
|
msg: "Active tmux sessions: {{ tmux_sessions.stdout_lines }}"
|
|
|
|
- name: Check tmux session output for errors
|
|
block:
|
|
- name: Wait for a moment for the process to start
|
|
ansible.builtin.pause:
|
|
seconds: 2
|
|
|
|
- name: Capture tmux pane content
|
|
ansible.builtin.shell:
|
|
cmd: "tmux capture-pane -p -t {{ tmux_session_auth_gen }}"
|
|
register: tmux_output
|
|
changed_when: false
|
|
ignore_errors: true
|
|
|
|
- name: Display tmux pane content if session exists
|
|
ansible.builtin.debug:
|
|
msg: "Initial output from tmux session '{{ tmux_session_auth_gen }}':"
|
|
when: tmux_output.rc == 0
|
|
|
|
- name: Show output lines if session exists
|
|
ansible.builtin.debug:
|
|
var: tmux_output.stdout_lines
|
|
when: tmux_output.rc == 0
|
|
|
|
- name: Report if session not found
|
|
ansible.builtin.debug:
|
|
msg: "Tmux session '{{ tmux_session_auth_gen }}' was not found. It may have exited immediately upon starting."
|
|
when: tmux_output.rc != 0
|
|
|
|
when: start_generator | default(false) | bool
|