|
58 | 58 | set_fact:
|
59 | 59 | cc_list: "{{ ', '.join(( '{{ engagement_lead_email }}', '{{ technical_lead_email }}' )) }}"
|
60 | 60 |
|
61 |
| - - name: "Set IDM facts" |
62 |
| - set_fact: |
63 |
| - ipa_host: "{{ 'ipa.apps.' + (ocp_sub_domain | lower) + '.' + engagement_region | default('dev-1') + '.' + ocp_base_url }}" |
64 |
| - ipa_admin_user: "{{ ocp_admin_username }}" |
65 |
| - ipa_admin_password: "{{ ocp_admin_password }}" |
66 |
| - ipa_validate_certs: "{{ ipa_validate_certs | default(true) }}" |
67 |
| - |
68 |
| - - name: "Assemble inventory" |
69 |
| - set_fact: |
70 |
| - claim_content: |
71 |
| - env_end_date: "{{ (archive_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}" |
72 |
| - end_date: "{{ (end_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}" |
73 |
| - start_date: "{{ (start_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}" |
74 |
| - customer_name: "{{ customer_name }}" |
75 |
| - project_name: "{{ project_name }}" |
76 |
| - ipa_validate_certs: "{{ ipa_validate_certs }}" |
77 |
| - ipa_host: "{{ ipa_host }}" |
78 |
| - ipa_admin_user: "{{ ipa_admin_user }}" |
79 |
| - ipa_admin_password: "{{ ipa_admin_password }}" |
80 |
| - list_of_mail_cc: "{{ cc_list }}" |
81 |
| - lodestar_identities: |
82 |
| - users: "{{ users }}" |
83 |
| - groups: "{{ usrgrp }}" |
84 |
| - |
85 |
| - - name: "Check For Existing Inventory File" |
86 |
| - stat: |
87 |
| - path: "{{ directory }}/iac/inventories/identity-management/inventory/group_vars/all.yml" |
88 |
| - register: existing_inv |
89 |
| - |
90 |
| - - name: "Pull existing inventory vars" |
91 |
| - include_vars: |
92 |
| - file: "{{ directory }}/iac/inventories/identity-management/inventory/group_vars/all.yml" |
93 |
| - name: existing_inv_contents |
94 |
| - when: |
95 |
| - - existing_inv.stat.exists |
96 |
| - |
97 |
| - - name: "Diff existing vars with new inventory" |
98 |
| - set_fact: |
99 |
| - inv_has_diff: true |
100 |
| - when: |
101 |
| - - existing_inv.stat.exists |
102 |
| - - existing_inv_contents is defined |
103 |
| - - existing_inv_contents != (claim_content | from_yaml) |
104 |
| - |
105 |
| - - name: "Write inventory to file" |
106 |
| - copy: |
107 |
| - content: "{{ claim_content | to_nice_yaml(indent=2) }}" |
108 |
| - dest: "{{ directory }}/iac/inventories/identity-management/inventory/group_vars/all.yml" |
109 |
| - |
110 |
| - - name: "Create hosts file" |
111 |
| - copy: |
112 |
| - content: "[identity-hosts]\nlocalhost" |
113 |
| - dest: "{{ directory }}/iac/inventories/identity-management/inventory/hosts" |
114 |
| - |
115 |
| - - name: "Create ResourceClaim" |
116 |
| - copy: |
117 |
| - content: "{{ lookup('template', inventory_dir + '/../files/templates/resourceclaim.yaml.j2') }}" |
118 |
| - dest: "{{ directory }}/ocp-init/id-mgmt-{{ inv_ts | trim }}.yaml" |
| 61 | + ##################################################################################################################### |
| 62 | + # Right now, the only supported configuration is a list of one hosting environment. |
| 63 | + # In the near future, this should be updated to support more than one, and this comment (and the code below) |
| 64 | + # should be updated to support this. For now, this checking is just looking for more than zero hosting environments, |
| 65 | + # but will default to use the value(s) from the first one. |
| 66 | + |
| 67 | + - block: |
| 68 | + - name: "Set IDM facts" |
| 69 | + set_fact: |
| 70 | + ipa_host: "{{ 'ipa.apps.' + (hosting_environments[0].ocp_sub_domain | lower) + '.' + engagement_region | default('dev-1') + '.' + ocp_base_url }}" |
| 71 | + ipa_admin_user: "{{ ocp_admin_username }}" |
| 72 | + ipa_admin_password: "{{ ocp_admin_password }}" |
| 73 | + ipa_validate_certs: "{{ ipa_validate_certs | default(true) }}" |
| 74 | + |
| 75 | + - name: "Assemble inventory" |
| 76 | + set_fact: |
| 77 | + claim_content: |
| 78 | + env_end_date: "{{ (archive_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}" |
| 79 | + end_date: "{{ (end_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}" |
| 80 | + start_date: "{{ (start_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}" |
| 81 | + customer_name: "{{ customer_name }}" |
| 82 | + project_name: "{{ project_name }}" |
| 83 | + ipa_validate_certs: "{{ ipa_validate_certs }}" |
| 84 | + ipa_host: "{{ ipa_host }}" |
| 85 | + ipa_admin_user: "{{ ipa_admin_user }}" |
| 86 | + ipa_admin_password: "{{ ipa_admin_password }}" |
| 87 | + list_of_mail_cc: "{{ cc_list }}" |
| 88 | + lodestar_identities: |
| 89 | + users: "{{ users }}" |
| 90 | + groups: "{{ usrgrp }}" |
| 91 | + |
| 92 | + - name: "Check For Existing Inventory File" |
| 93 | + stat: |
| 94 | + path: "{{ directory }}/iac/inventories/identity-management/inventory/group_vars/all.yml" |
| 95 | + register: existing_inv |
| 96 | + |
| 97 | + - name: "Pull existing inventory vars" |
| 98 | + include_vars: |
| 99 | + file: "{{ directory }}/iac/inventories/identity-management/inventory/group_vars/all.yml" |
| 100 | + name: existing_inv_contents |
| 101 | + when: |
| 102 | + - existing_inv.stat.exists |
| 103 | + |
| 104 | + - name: "Diff existing vars with new inventory" |
| 105 | + set_fact: |
| 106 | + inv_has_diff: true |
| 107 | + when: |
| 108 | + - existing_inv.stat.exists |
| 109 | + - existing_inv_contents is defined |
| 110 | + - existing_inv_contents != (claim_content | from_yaml) |
| 111 | + |
| 112 | + - name: "Write inventory to file" |
| 113 | + copy: |
| 114 | + content: "{{ claim_content | to_nice_yaml(indent=2) }}" |
| 115 | + dest: "{{ directory }}/iac/inventories/identity-management/inventory/group_vars/all.yml" |
| 116 | + |
| 117 | + - name: "Create hosts file" |
| 118 | + copy: |
| 119 | + content: "[identity-hosts]\nlocalhost" |
| 120 | + dest: "{{ directory }}/iac/inventories/identity-management/inventory/hosts" |
| 121 | + |
| 122 | + - name: "Create ResourceClaim" |
| 123 | + copy: |
| 124 | + content: "{{ lookup('template', inventory_dir + '/../files/templates/resourceclaim.yaml.j2') }}" |
| 125 | + dest: "{{ directory }}/ocp-init/id-mgmt-{{ inv_ts | trim }}.yaml" |
| 126 | + when: |
| 127 | + - (inv_has_diff is defined and inv_has_diff is true) or not existing_inv.stat.exists |
119 | 128 | when:
|
120 |
| - - (inv_has_diff is defined and inv_has_diff is true) or not existing_inv.stat.exists |
| 129 | + - hosting_environments is defined |
| 130 | + - hosting_environments|length > 0 |
| 131 | + - hosting_environments[0].ocp_sub_domain is defined |
0 commit comments