-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
import Generator from 'yeoman-generator'; | ||
// eslint-disable-next-line no-unused-vars | ||
import yosay from 'yosay'; | ||
// eslint-disable-next-line no-unused-vars | ||
import chalk from 'chalk'; | ||
import * as fs from 'node:fs'; | ||
|
||
/** | ||
* Generate the Ansible playbook needed for Jasper Reports deployments | ||
*/ | ||
export default class extends Generator { | ||
constructor(args, opts) { | ||
super(args, opts); | ||
|
||
this.argument('projectName', { | ||
type: String, | ||
required: true, | ||
description: 'Project Name', | ||
}); | ||
this.argument('jasperServerInstance', { | ||
type: String, | ||
required: true, | ||
description: 'Jasper Server Instance', | ||
}); | ||
this.argument('playbookPath', { | ||
type: String, | ||
required: true, | ||
description: 'Playbook Path', | ||
}); | ||
} | ||
|
||
// Generate playbook file | ||
writing() { | ||
this.log('Generating playbook file'); | ||
if ( | ||
!fs.existsSync( | ||
this.destinationPath(`${this.options.playbookPath}/jasper-reports.yaml`), | ||
) | ||
) { | ||
this.fs.copyTpl( | ||
this.templatePath('jasper-reports.yaml'), | ||
this.destinationPath(`${this.options.playbookPath}/jasper-reports.yaml`), | ||
{ | ||
projectNameUpperCase: this.options.projectName.toUpperCase(), | ||
jasperServerInstanceUpperCase: this.options.jasperServerInstance.toUpperCase(), | ||
}, | ||
); | ||
} | ||
|
||
this.config.save(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
generators/pd-jasper-reports/templates/jasper-reports.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
--- | ||
- name: Deploy <%= projectNameUpperCase %> Jasper Reports | ||
hosts: localhost | ||
connection: local | ||
collections: | ||
- polaris.deploy | ||
vars: | ||
jasper_server_instance: <%= jasperServerInstanceUpperCase %> | ||
jasper_project_name: <%= projectNameUpperCase %> | ||
jasper_ds_0_url: "{{ lookup('ansible.builtin.env', 'PODMAN_cfg_jasper_ds_0_url') | default('') }}" | ||
jasper_ds_0_user: "{{ lookup('ansible.builtin.env', 'PODMAN_cfg_jasper_ds_0_user') | default('') }}" | ||
jasper_ds_0_password: "{{ lookup('ansible.builtin.env', 'PODMAN_cfg_jasper_ds_0_password') | default('') }}" | ||
jasper_deployer_url: "{{ lookup('ansible.builtin.env', 'PODMAN_cfg_jasper_deployer_url') | default('') }}" | ||
jasper_deployer_user: "{{ lookup('ansible.builtin.env', 'PODMAN_cfg_jasper_deployer_user') | default('') }}" | ||
jasper_deployer_password: "{{ lookup('ansible.builtin.env', 'PODMAN_cfg_jasper_deployer_password') | default('') }}" | ||
|
||
tasks: | ||
- name: Create packages | ||
include_role: | ||
name: jasper_reports | ||
tags: create_packages | ||
|
||
- name: Deploy to node 1 | ||
when: jasper_env in ["dev", "test", "prod"] | ||
include_role: | ||
name: jasper_reports | ||
tags: deploy_packages | ||
|
||
- name: Deploy to node 2 | ||
when: jasper_env in ["test", "prod"] | ||
include_role: | ||
name: jasper_reports | ||
vars: | ||
jasper_route_id: ".2" | ||
tags: deploy_packages | ||
|
||
- name: Delete staging directory | ||
include_role: | ||
name: jasper_reports | ||
tags: delete_staging_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters