Skip to content

Commit

Permalink
feat: jasper reports (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrwils authored Feb 26, 2025
1 parent 8e6ea3f commit f8672ac
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 1 deletion.
24 changes: 23 additions & 1 deletion generators/gh-maven-build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,25 @@ export default class extends Generator {
message: 'Deploy on-prem:',
default: false,
},
{
type: 'confirm',
name: 'deployJasperReports',
message: 'Deploy Jasper Reports:',
default: false,
},
{
type: 'input',
name: 'jasperServerInstance',
message: 'Jasper Reports server instance:',
default: 'JCRS',
when: (answers) => answers.deployJasperReports,
},
{
type: 'input',
name: 'playbookPath',
message: 'Playbook path:',
default: 'playbooks',
when: (answers) => answers.deployOnPrem,
when: (answers) => answers.deployOnPrem || answers.deployJasperReports,
},
{
type: 'input',
Expand Down Expand Up @@ -314,6 +327,15 @@ export default class extends Generator {
playbook_args,
playbook_options,
);
const jasper_reports_args = [
this.answers.projectName,
this.answers.jasperServerInstance,
this.answers.playbookPath,
];
this.composeWith(
'nr-repository-composer:pd-jasper-reports',
jasper_reports_args,
);
}
}

Expand Down
53 changes: 53 additions & 0 deletions generators/pd-jasper-reports/index.js
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 generators/pd-jasper-reports/templates/jasper-reports.yaml
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
10 changes: 10 additions & 0 deletions generators/util/yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export const pathToProps = [
prop: 'deployOnPrem',
writeEmpty: false,
},
{
path: ['metadata', 'annotations', 'playbook.io.nrs.gov.bc.ca/deployJasperReports'],
prop: 'deployJasperReports',
writeEmpty: false,
},
{
path: ['metadata', 'annotations', 'playbook.io.nrs.gov.bc.ca/jasperServerInstance'],
prop: 'jasperServerInstance',
writeEmpty: false,
},
{
path: ['metadata', 'annotations', 'playbook.io.nrs.gov.bc.ca/playbookPath'],
prop: 'playbookPath',
Expand Down

0 comments on commit f8672ac

Please sign in to comment.