Open tkam8 opened 4 years ago
Considering something like this to rescue from timeouts:
- name: Handle BIG-IQ token timeouts during BIG-IP onboarding
block:
- name: include atc_task_check.yaml
include_tasks: atc_task_check.yaml
when:
- atc_service == "AS3" or atc_service == "Device"
rescue:
- debug:
msg: "caught error: {{ atc_DO_status.json.message }}"
- name: Re authenticate to BIG-IQ
include_tasks: authentication.yaml
when: atc_DO_status.json.message == "Invalid registered claims"
- name: Redo atc_task_check.yaml
include_tasks: atc_task_check.yaml
when:
- atc_service == "AS3" or atc_service == "Device"
Currently auth tokens have a hardcoded maximum lifetime of 5 minutes on BIG-IQ. This might change in the future. However, we should be able to refresh the token.
Updated to handle looping the tasks x number of times, as DO can take longer than 10min...
Think I have something worth considering:
In atc_task_check.yaml , if there is a 401 which is due to token expiration, it enters in the rescue block up to 3 times (or this could be a variable), where it runs the authentication tasks before calling itself (this retry task) to redo the checks.
- name: Wait for DO Task to complete (with retry)
block:
- name: Set the retry count
set_fact:
retry_count: "{{ 0 if retry_count is undefined else retry_count|int + 1 }}"
- name: Run check
uri:
url: "https://{{ provider.server }}:{{ provider.server_port }}{{ atc_url }}/task/{{ atc_DO_result.json.id }}"
method: GET
headers:
X-F5-Auth-Token: "{{ f5_auth_token }}"
return_content: true
validate_certs: "{{ provider.validate_certs }}"
status_code: 200
register: atc_DO_status
#until: atc_DO_status is success
until: "atc_DO_status is success or atc_DO_status.status == 401"
retries: "{{ atc_retries }}"
delay: "{{ atc_delay }}"
delegate_to: localhost
when:
- atc_service == "Device"
- atc_method == "POST"
# Rescue block for handling BIG-IQ token timeouts
rescue:
- fail:
msg: Ended after 3 retries
when: retry_count|int == 3
- debug:
msg: "caught error: {{ atc_DO_status.json.message }}"
- name: Re authenticate to BIG-IQ
include_tasks: authentication.yaml
when: atc_DO_status.json.message == "Invalid registered claims."
- name: Redo check
include_tasks: atc_task_check.yaml
ISSUE TYPE
COMPONENT NAME
ansible-role-f5_atc_deploy_declaration
ANSIBLE VERSION
PYTHON VERSION
BIGIP VERSION
OS / ENVIRONMENT
Running ansible from AWX 9.1.0.0 BIG-IQ 7.1 BIG-IP spun up in GCP with startup script to install AS3, DO, TS
SUMMARY
Need the ability to extend the BIG-IQ token timeout to something like 1200 to account for delay when BIG-IP is provisioning modules like asm, as well as BIG-IQ onboarding/discovery/import tasks. Default is 300s, I need at least 600s.
DO declaration: https://github.com/tkam8/bigiq-ansible/blob/master/lab/tower/templates/onboard_bigip_do_asm.j2
atc_timeout is for socket timeout
BIG-IQ access token timeout is 300s
Log from ansible after 5 min, although I'm setting retries for 10m: