Skip to content

Commit 952a6cc

Browse files
authored
Feature/do500 schedules generation (#68)
* Add tower_job_schedules for do500 Added tower job schedules and launch for the do500 engagements. * Fixed user list generation for do500 * Renamed jinja template file for residency * Fixed mailing lists for DO500 notifications
1 parent da1a7e0 commit 952a6cc

File tree

5 files changed

+122
-3
lines changed

5 files changed

+122
-3
lines changed

inventory-generation/notifications/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
dest: "{{ directory }}/iac/inventories/notifications/inventory/group_vars/all/list_of_users.yaml"
6262
when:
6363
- start_date is defined
64-
- engagement_type | default('') == 'Residency'
64+
- engagement_type | default('') == 'Residency' or engagement_type | default('') == 'DO500'
6565
- (hosting_environments is defined) and (hosting_environments | length > 0)
6666
- (archive_date | default('2006-01-02T15:04:05.000Z') | to_datetime('%Y-%m-%dT%H:%M:%S.%fZ')).strftime('%s') > now(utc=true).strftime('%s')

inventory-generation/tower_jobs_launch/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
when:
8484
- start_date is defined
8585
- (hosting_environments is defined) and (hosting_environments | length > 0)
86-
- engagement_type | default('') == 'Residency'
86+
- engagement_type | default('') == 'Residency' or engagement_type | default('') == 'DO500'
8787
- (archive_date | default('2006-01-02T15:04:05.000Z') | to_datetime('%Y-%m-%dT%H:%M:%S.%fZ')).strftime('%s') > now(utc=true).strftime('%s')
8888

8989
- import_playbook: '{{ infra_ansible_directory }}/playbooks/ansible/tower/configure-ansible-tower.yml'

inventory-generation/tower_jobs_schedules/main.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
block:
2222
- name: "Write inventory to file"
2323
template:
24-
src: "tower-management-host.yaml.j2"
24+
src: "residency-tower-management-host.yaml.j2"
2525
dest: "{{ directory }}/iac/inventories/tower_jobs_schedules/inventory/group_vars/tower-management-host.yaml"
2626

2727
- name: "Create hosts file"
@@ -32,3 +32,19 @@
3232
- start_date is defined
3333
- engagement_type | default('') == 'Residency'
3434
- (archive_date | default('2006-01-02T15:04:05.000Z') | to_datetime('%Y-%m-%dT%H:%M:%S.%fZ')).strftime('%s') > now(utc=true).strftime('%s')
35+
36+
- name: DO500 Engagement Type inventory
37+
block:
38+
- name: "Write inventory to file"
39+
template:
40+
src: "do500-tower-management-host.yaml.j2"
41+
dest: "{{ directory }}/iac/inventories/tower_jobs_schedules/inventory/group_vars/tower-management-host.yaml"
42+
43+
- name: "Create hosts file"
44+
copy:
45+
src: "hosts"
46+
dest: "{{ directory }}/iac/inventories/tower_jobs_schedules/inventory/hosts"
47+
when:
48+
- start_date is defined
49+
- engagement_type | default('') == 'DO500'
50+
- (archive_date | default('2006-01-02T15:04:05.000Z') | to_datetime('%Y-%m-%dT%H:%M:%S.%fZ')).strftime('%s') > now(utc=true).strftime('%s')
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#jinja2: trim_blocks:False
2+
---
3+
start_date: "{{ (start_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}"
4+
end_date: "{{ (end_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}"
5+
archive_date: "{{ (archive_date | regex_replace('^(.*)T.*$', '\\1') | to_datetime('%Y-%m-%d')).strftime('%d %b %Y') }}"
6+
7+
timezone: "{{ timezone | default("UTC") }}"
8+
9+
delete_missing_items: false
10+
11+
ansible_tower:
12+
url: "{{ ansible_tower_url }}"
13+
admin_username: "{{ ansible_tower_admin_username | default('admin') }}"
14+
admin_password: "{{ ansible_tower_admin_password }}"
15+
projects:
16+
- name: "{{ customer_engagement }}-project"
17+
description: "Project for {{ customer_engagement }}"
18+
organization: "{{ organization }}"
19+
scm_type: "git"
20+
scm_url: "{{ url }}"
21+
scm_branch: "master"
22+
scm_credential_name: "{{ scm_credential_name }}"
23+
scm_update_on_launch: true
24+
job_templates:
25+
- name: "{{ customer_engagement }}-email-notify-list-of-users"
26+
description: "Job Template to send email notifications to users"
27+
inventory: "{{ customer_engagement }}-tower-mail-host"
28+
project: "infra-ansible"
29+
playbook: "playbooks/notifications/email-notify-list-of-users.yml"
30+
ask_variables_on_launch: true
31+
inventories:
32+
- name: "{{ customer_engagement }}-tower-mail-host"
33+
variables: ""
34+
organization: "{{ organization }}"
35+
sources:
36+
- name: "{{ customer_engagement }}-mail-host-credentials"
37+
description: "Email credentials for infra-ansible/mail-host"
38+
credential: "{{ scm_credential_name }}"
39+
source_project: "{{ mail_host_source_project }}"
40+
source: "scm"
41+
source_path: "redhat.com/inventory/hosts"
42+
update_on_launch: true
43+
source_vars: |-
44+
---
45+
- name: "{{ customer_engagement }}-notification-templates"
46+
description: "Notification templates for {{ customer_engagement }}"
47+
credential: "{{ scm_credential_name }}"
48+
source_project: "{{ customer_engagement }}-project"
49+
source: "scm"
50+
source_path: "iac/inventories/notifications/inventory/hosts"
51+
update_on_launch: true
52+
source_vars: |-
53+
---
54+
55+
schedules:
56+
- name: "{{ customer_engagement }}-welcome-internal"
57+
description: "Welcome Internal for internal {{ company_name }} engagement members"
58+
{% raw -%}
59+
rrule: "{{ start_date | parse_datetime | replace_datetime(hour=5) | to_rrule(timezone=timezone) }}"
60+
{%- endraw %}
61+
unified_job_template: "{{ customer_engagement }}-email-notify-list-of-users"
62+
enabled: {{ enable_notifications | default(false) }}
63+
extra_data:
64+
body: {% raw %}"{{ welcome_internal.body }}"{% endraw %}
65+
title: {% raw %}"{{ welcome_internal.title }}"{% endraw %}
66+
list_of_users: {% raw %}"{{ internal.list_of_users | default([]) }}"{% endraw %}
67+
list_of_mail_cc: {% raw %}"{{ list_of_mail_cc | default([]) }}"{% endraw %}
68+
- name: "{{ customer_engagement }}-welcome-all"
69+
description: "Welcome notification for {{ company_name }} and {{ customer_name }}"
70+
{% raw -%}
71+
rrule: "{{ start_date | parse_datetime | replace_datetime(hour=5) | to_rrule(timezone=timezone) }}"
72+
{%- endraw %}
73+
unified_job_template: "{{ customer_engagement }}-email-notify-list-of-users"
74+
enabled: {{ enable_notifications | default(false) }}
75+
extra_data:
76+
body: {% raw %}"{{ welcome_all.body }}"{% endraw %}
77+
title: {% raw %}"{{ welcome_all.title }}"{% endraw %}
78+
list_of_users: {% raw %}"{{ full.list_of_users | default([]) }}"{% endraw %}
79+
list_of_mail_cc: {% raw %}"{{ list_of_mail_cc | default([]) }}"{% endraw %}
80+
- name: "{{ customer_engagement }}-shutoff-reminder"
81+
description: "Shutoff reminder e-mail for the {{ customer_engagement }} engagement"
82+
{% raw -%}
83+
rrule: "{{ end_date | parse_datetime | replace_datetime(hour=5) | add_time(days=3) | to_rrule(timezone=timezone) }}"
84+
{%- endraw %}
85+
unified_job_template: "{{ customer_engagement }}-email-notify-list-of-users"
86+
enabled: {{ enable_notifications | default(false) }}
87+
extra_data:
88+
body: {% raw %}"{{ shutoff_reminder.body }}"{% endraw %}
89+
title: {% raw %}"{{ shutoff_reminder.title }}"{% endraw %}
90+
list_of_users: {% raw %}"{{ internal.list_of_users | default([]) }}"{% endraw %}
91+
list_of_mail_cc: {% raw %}"{{ list_of_mail_cc | default([]) }}"{% endraw %}
92+
- name: "{{ customer_engagement }}-shutoff"
93+
description: "Shutoff e-mail for the {{ customer_engagement }} engagement"
94+
{% raw -%}
95+
rrule: "{{ archive_date | parse_datetime | replace_datetime(hour=5) | to_rrule(timezone=timezone) }}"
96+
{%- endraw %}
97+
unified_job_template: "{{ customer_engagement }}-email-notify-list-of-users"
98+
enabled: {{ enable_notifications | default(false) }}
99+
extra_data:
100+
body: {% raw %}"{{ shutoff.body }}"{% endraw %}
101+
title: {% raw %}"{{ shutoff.title }}"{% endraw %}
102+
list_of_users: {% raw %}"{{ internal.list_of_users | default([]) }}"{% endraw %}
103+
list_of_mail_cc: {% raw %}"{{ list_of_mail_cc | default([]) }}"{% endraw %}
File renamed without changes.

0 commit comments

Comments
 (0)