From 0ca561a5a0f6e6d3616be9185e114bf539e4eaac Mon Sep 17 00:00:00 2001 From: Chris Hambridge Date: Thu, 3 Sep 2020 16:59:52 -0400 Subject: [PATCH] Allow configurable upload_cycle_seconds. --- roles/setup/defaults/main.yml | 1 + roles/setup/tasks/main.yml | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/setup/defaults/main.yml b/roles/setup/defaults/main.yml index 00711bf..1e716e7 100644 --- a/roles/setup/defaults/main.yml +++ b/roles/setup/defaults/main.yml @@ -5,3 +5,4 @@ current_year: '{{ ansible_date_time.year | int }}' setup_template_path: '/tmp/cost-mgmt-operator-collect' setup_template_dir: "{{ lookup('password', '/dev/null chars=ascii_letters') }}" setup_delete_after: 'true' +upload_cycle_seconds: 21600 \ No newline at end of file diff --git a/roles/setup/tasks/main.yml b/roles/setup/tasks/main.yml index a85230b..fd524d6 100644 --- a/roles/setup/tasks/main.yml +++ b/roles/setup/tasks/main.yml @@ -80,7 +80,7 @@ - name: Set collect_data set_fact: collect_data: true - when: upload_time_diff is not defined or (( upload_time_diff | int ) > 360) + when: upload_time_diff is not defined or (( upload_time_diff | int ) > upload_cycle_seconds) - name: print collect_data debug: @@ -99,23 +99,30 @@ msg: 'Metering has not been configured.' when: not metering_objects.resources +- name: Set upload_cycle_seconds + set_fact: + upload_cycle_seconds: "{{ current_cr_spec.upload_cycle_seconds | int }}" + when: + - current_cr_spec is defined + - current_cr_spec.upload_cycle_seconds is defined + - name: Set current_day set_fact: - current_day: "{{ cost_mgmt_setup.resources[0].spec.current_day | int }}" + current_day: "{{ current_cr_spec.current_day | int }}" when: - current_cr_spec is defined - current_cr_spec.current_day is defined - name: Set current_month set_fact: - current_month: "{{ cost_mgmt_setup.resources[0].spec.current_month | int }}" + current_month: "{{ current_cr_spec.current_month | int }}" when: - current_cr_spec is defined - current_cr_spec.current_month is defined - name: Set current_year set_fact: - current_year: "{{ cost_mgmt_setup.resources[0].spec.current_year | int }}" + current_year: "{{ current_cr_spec.current_year | int }}" when: - current_cr_spec is defined - current_cr_spec.current_year is defined