| 
1 | 1 | ---  | 
2 | 2 | # Create Controller applications  | 
3 |  | -- name: Managing Controller Applications  | 
4 |  | -  application:  | 
5 |  | -    name: "{{ __application_item.name | mandatory }}"  | 
6 |  | -    new_name: "{{ __application_item.new_name | default(omit, true) }}"  | 
7 |  | -    organization: "{{ __application_item.organization | mandatory }}"  | 
8 |  | -    description: "{{ __application_item.description | default(('' if controller_configuration_applications_enforce_defaults else omit), true) }}"  | 
9 |  | -    authorization_grant_type: "{{ __application_item.authorization_grant_type | default('password') }}"  | 
10 |  | -    client_type: "{{ __application_item.client_type | default('public') }}"  | 
11 |  | -    redirect_uris: "{{ __application_item.redirect_uris | default([]) }}"  | 
12 |  | -    skip_authorization: "{{ __application_item.skip_authorization | default((false if controller_configuration_applications_enforce_defaults else omit), true) }}"  | 
13 |  | -    state: "{{ __application_item.state | default(controller_state | default('present')) }}"  | 
14 |  | - | 
15 |  | -    # Role specific options  | 
16 |  | -    controller_username: "{{ controller_username | default(omit, true) }}"  | 
17 |  | -    controller_password: "{{ controller_password | default(omit, true) }}"  | 
18 |  | -    controller_oauthtoken: "{{ controller_oauthtoken | default(omit, true) }}"  | 
19 |  | -    request_timeout: "{{ controller_request_timeout | default(omit, true) }}"  | 
20 |  | -    controller_host: "{{ controller_hostname | default(omit, true) }}"  | 
21 |  | -    controller_config_file: "{{ controller_config_file | default(omit, true) }}"  | 
22 |  | -    validate_certs: "{{ controller_validate_certs | default(omit) }}"  | 
23 |  | -  loop: "{{ applications if applications is defined else controller_applications }}"  | 
24 |  | -  loop_control:  | 
25 |  | -    loop_var: __application_item  | 
26 |  | -    label: "{{ __operation.verb }} Controller Application {{ __application_item.name }}"  | 
27 |  | -    pause: "{{ controller_configuration_applications_loop_delay }}"  | 
28 |  | -  no_log: "{{ controller_configuration_applications_secure_logging }}"  | 
29 |  | -  async: "{{ ansible_check_mode | ternary(0, 1000) }}"  | 
30 |  | -  poll: 0  | 
31 |  | -  register: __applications_job_async  | 
32 |  | -  changed_when: (__applications_job_async.changed if ansible_check_mode else false)  | 
 | 3 | +- name: Manage Controller Applications Block  | 
33 | 4 |   vars:  | 
34 |  | -    __operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}"  | 
35 | 5 |     ansible_async_dir: "{{ controller_configuration_async_dir }}"  | 
 | 6 | +  no_log: "{{ controller_configuration_applications_secure_logging }}"  | 
 | 7 | +  block:  | 
 | 8 | +    - name: Managing Controller Applications  | 
 | 9 | +      application:  | 
 | 10 | +        name: "{{ __application_item.name | mandatory }}"  | 
 | 11 | +        new_name: "{{ __application_item.new_name | default(omit, true) }}"  | 
 | 12 | +        organization: "{{ __application_item.organization | mandatory }}"  | 
 | 13 | +        description: "{{ __application_item.description | default(('' if controller_configuration_applications_enforce_defaults else omit), true) }}"  | 
 | 14 | +        authorization_grant_type: "{{ __application_item.authorization_grant_type | default('password') }}"  | 
 | 15 | +        client_type: "{{ __application_item.client_type | default('public') }}"  | 
 | 16 | +        redirect_uris: "{{ __application_item.redirect_uris | default([]) }}"  | 
 | 17 | +        skip_authorization: "{{ __application_item.skip_authorization | default((false if controller_configuration_applications_enforce_defaults else omit), true) }}"  | 
 | 18 | +        state: "{{ __application_item.state | default(controller_state | default('present')) }}"  | 
36 | 19 | 
 
  | 
37 |  | -- name: Flag for errors (check mode only)  | 
38 |  | -  ansible.builtin.set_fact:  | 
39 |  | -    error_flag: true  | 
40 |  | -  when: ansible_check_mode and __applications_job_async.failed is defined and __applications_job_async.failed  | 
 | 20 | +        # Role specific options  | 
 | 21 | +        controller_username: "{{ controller_username | default(omit, true) }}"  | 
 | 22 | +        controller_password: "{{ controller_password | default(omit, true) }}"  | 
 | 23 | +        controller_oauthtoken: "{{ controller_oauthtoken | default(omit, true) }}"  | 
 | 24 | +        request_timeout: "{{ controller_request_timeout | default(omit, true) }}"  | 
 | 25 | +        controller_host: "{{ controller_hostname | default(omit, true) }}"  | 
 | 26 | +        controller_config_file: "{{ controller_config_file | default(omit, true) }}"  | 
 | 27 | +        validate_certs: "{{ controller_validate_certs | default(omit) }}"  | 
 | 28 | +      loop: "{{ applications if applications is defined else controller_applications }}"  | 
 | 29 | +      loop_control:  | 
 | 30 | +        loop_var: __application_item  | 
 | 31 | +        label: "{{ __operation.verb }} Controller Application {{ __application_item.name }}"  | 
 | 32 | +        pause: "{{ controller_configuration_applications_loop_delay }}"  | 
 | 33 | +      async: "{{ ansible_check_mode | ternary(0, 1000) }}"  | 
 | 34 | +      poll: 0  | 
 | 35 | +      register: __applications_job_async  | 
 | 36 | +      changed_when: (__applications_job_async.changed if ansible_check_mode else false)  | 
 | 37 | +      vars:  | 
 | 38 | +        __operation: "{{ operation_translate[__application_item.state | default(controller_state) | default('present')] }}"  | 
41 | 39 | 
 
  | 
42 |  | -- name: Managing Controller Applications | Wait for finish the Application management  | 
43 |  | -  ansible.builtin.async_status:  | 
44 |  | -    jid: "{{ __applications_job_async_results_item.ansible_job_id }}"  | 
45 |  | -  register: __applications_job_async_result  | 
46 |  | -  until: __applications_job_async_result.finished  | 
47 |  | -  retries: "{{ controller_configuration_applications_async_retries }}"  | 
48 |  | -  delay: "{{ controller_configuration_applications_async_delay }}"  | 
49 |  | -  loop: "{{ __applications_job_async.results }}"  | 
50 |  | -  loop_control:  | 
51 |  | -    loop_var: __applications_job_async_results_item  | 
52 |  | -    label: "{{ __operation.verb }} Controller Application {{ __applications_job_async_results_item.__application_item.name }} | Wait for finish the Application {{  | 
53 |  | -      __operation.action }}"  | 
54 |  | -  when: not ansible_check_mode and __applications_job_async_results_item.ansible_job_id is defined  | 
55 |  | -  no_log: "{{ controller_configuration_applications_secure_logging }}"  | 
56 |  | -  vars:  | 
57 |  | -    __operation: "{{ operation_translate[__applications_job_async_results_item.__application_item.state | default(controller_state) | default('present')] }}"  | 
58 |  | -    ansible_async_dir: "{{ controller_configuration_async_dir }}"  | 
 | 40 | +    - name: Flag for errors (check mode only)  | 
 | 41 | +      ansible.builtin.set_fact:  | 
 | 42 | +        error_flag: true  | 
 | 43 | +      when: ansible_check_mode and __applications_job_async.failed is defined and __applications_job_async.failed  | 
 | 44 | + | 
 | 45 | +    - name: Managing Controller Applications | Wait for finish the Application management  | 
 | 46 | +      when:  | 
 | 47 | +        - not ansible_check_mode  | 
 | 48 | +        - __applications_job_async_results_item.ansible_job_id is defined  | 
 | 49 | +      ansible.builtin.include_role:  | 
 | 50 | +        name: infra.controller_configuration.collect_async_status  | 
 | 51 | +      loop: "{{ __applications_job_async.results }}"  | 
 | 52 | +      loop_control:  | 
 | 53 | +        loop_var: __applications_job_async_results_item  | 
 | 54 | +        label: "{{ __operation.verb }} Controller Application {{ __applications_job_async_results_item.__application_item.name }} | Wait for finish the Application {{  | 
 | 55 | +          __operation.action }}"  | 
 | 56 | +      vars:  | 
 | 57 | +        cas_secure_logging: "{{ controller_configuration_applications_secure_logging }}"  | 
 | 58 | +        cas_async_delay: "{{ controller_configuration_applications_async_delay }}"  | 
 | 59 | +        cas_async_retries: "{{ controller_configuration_applications_async_retries }}"  | 
 | 60 | +        cas_job_async_results_item: "{{ __applications_job_async_results_item }}"  | 
 | 61 | +        cas_error_list_var_name: "controller_applications_errors"  | 
 | 62 | +        __operation: "{{ operation_translate[__applications_job_async_results_item.__application_item.state | default(controller_state) | default('present')] }}"  | 
 | 63 | + | 
 | 64 | +  always:  | 
 | 65 | +    - name: Cleanup async results files  | 
 | 66 | +      when:  | 
 | 67 | +        - not ansible_check_mode  | 
 | 68 | +        - __applications_job_async_results_item.ansible_job_id is defined  | 
 | 69 | +      ansible.builtin.async_status:  | 
 | 70 | +        jid: "{{ __applications_job_async_results_item.ansible_job_id }}"  | 
 | 71 | +        mode: cleanup  | 
 | 72 | +      loop: "{{ __applications_job_async.results }}"  | 
 | 73 | +      loop_control:  | 
 | 74 | +        loop_var: __applications_job_async_results_item  | 
 | 75 | +        label: "Cleaning up job results file: {{ __applications_job_async_results_item.results_file | default('Unknown') }}"  | 
59 | 76 | ...  | 
0 commit comments