Skip to content

Commit d904411

Browse files
authored
Adding support for reading list-of-1 hosting environments (#40)
1 parent 1e699ba commit d904411

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

templates/resourceclaim.yaml.j2

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#jinja2: trim_blocks:False
22
---
3-
{% if ocp_cloud_provider_name != 'other' %}
43
apiVersion: poolboy.gpte.redhat.com/v1
54
kind: ResourceClaim
65
metadata:
@@ -21,4 +20,3 @@ spec:
2120
vars:
2221
job_vars:
2322
{{ claim_content | to_nice_yaml | indent(12) }}
24-
{% endif %}

translate-engagement-data/site.yml

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
---
2+
23
- name: Translate engagement data into Argo-processable resources
34
hosts: local
45
gather_facts: false
56
tasks:
6-
- name: Read Engagement Data
7-
include_vars:
8-
file: "{{ directory }}/engagement.json"
9-
- name: Read credentials
10-
include_vars:
11-
file: "{{ directory }}/{{ config_dir }}/{{ item }}"
12-
loop:
13-
- "ocp-admin-credentials.json"
14-
- "ocp-ldap-sa-credentials.json"
15-
when: ocp_version is defined
16-
- name: Create OCP manifest directory if not present
17-
file:
18-
path: "{{ directory }}/ocp-init"
19-
state: directory
20-
- name: Assemble Anarchy Governor Name
21-
set_fact:
22-
governor_name: "{{ 'labs.ocp4.' + (engagement_region | default('dev-1') | lower) }}"
23-
- name: Add Claim Content
24-
set_fact:
25-
claim_content:
26-
email: "{{ engagement_lead_email }}"
27-
admin_user: "{{ ocp_admin_username }}"
28-
admin_password: "{{ ocp_admin_password }}"
29-
aws_region: "{{ ocp_cloud_provider_region }}"
30-
ocp4_installer_version: "{{ ocp_version }}"
31-
ocp_ldap_sa_user: "{{ ocp_ldap_sa_username }}"
32-
ocp_ldap_sa_password: "{{ ocp_ldap_sa_password }}"
33-
ocp_subdomain: "{{ ocp_sub_domain }}"
34-
- name: Create Resource Claim
35-
copy:
36-
content: "{{ lookup('template', inventory_dir + '/../files/templates/resourceclaim.yaml.j2') }}"
37-
dest: "{{ directory }}/ocp-init/cluster-init.yaml"
7+
- name: Read Engagement Data
8+
include_vars:
9+
file: "{{ directory }}/engagement.json"
10+
- block:
11+
- name: Set fact used to check if a hosting environment is needed
12+
set_fact:
13+
ocp_cloud_provider_name: "{{ hosting_environments[0].ocp_cloud_provider_name | default('other') }}"
14+
- block:
15+
- name: Read credentials
16+
include_vars:
17+
file: "{{ directory }}/{{ config_dir }}/{{ item }}"
18+
loop:
19+
- "ocp-admin-credentials.json"
20+
- "ocp-ldap-sa-credentials.json"
21+
- name: Create OCP manifest directory if not present
22+
file:
23+
path: "{{ directory }}/ocp-init"
24+
state: directory
25+
- name: Assemble Anarchy Governor Name
26+
set_fact:
27+
governor_name: "{{ 'labs.ocp4.' + (engagement_region | default('dev-1') | lower) }}"
28+
- name: Create Resource Claim
29+
vars:
30+
claim_content:
31+
email: "{{ engagement_lead_email }}"
32+
admin_user: "{{ ocp_admin_username }}"
33+
admin_password: "{{ ocp_admin_password }}"
34+
aws_region: "{{ hosting_environments[0].ocp_cloud_provider_region }}"
35+
ocp4_installer_version: "{{ hosting_environments[0].ocp_version }}"
36+
ocp_ldap_sa_user: "{{ ocp_ldap_sa_username }}"
37+
ocp_ldap_sa_password: "{{ ocp_ldap_sa_password }}"
38+
ocp_subdomain: "{{ hosting_environments[0].ocp_sub_domain }}"
39+
copy:
40+
content: "{{ lookup('template', inventory_dir + '/../files/templates/resourceclaim.yaml.j2') }}"
41+
dest: "{{ directory }}/ocp-init/cluster-init.yaml"
42+
when:
43+
- ocp_cloud_provider_name|trim != 'other'
44+
when:
45+
- hosting_environments is defined
46+
- hosting_environments|length > 0
47+

0 commit comments

Comments
 (0)