From cf90f1e145d52034558fda338a87cff63b87b6a7 Mon Sep 17 00:00:00 2001 From: Ajay Chenampara Date: Wed, 2 Mar 2022 11:44:23 -0500 Subject: [PATCH] Ajay windows (#3) add windows workflow with ServiceNow --- windows/backup.yml | 7 ++ windows/setup.yml | 205 ++++++++++++++++++++++++++++++++++++++++++++- windows/snow.yml | 32 +++++++ 3 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 windows/backup.yml create mode 100644 windows/snow.yml diff --git a/windows/backup.yml b/windows/backup.yml new file mode 100644 index 0000000..86081b9 --- /dev/null +++ b/windows/backup.yml @@ -0,0 +1,7 @@ +--- +- hosts: windows + name: Rollback playbook + tasks: + - name: "Rollback this step" + debug: + msg: "Rolling back this step" diff --git a/windows/setup.yml b/windows/setup.yml index 7e47a47..64508b5 100644 --- a/windows/setup.yml +++ b/windows/setup.yml @@ -1,7 +1,13 @@ --- +user_message: | + You will need to update SNOW credentials with your SNOW instance details if you plan to demo this. + controller_components: - projects + - credential_types + - credentials - job_templates + - workflow_job_templates controller_projects: - name: Fact Scan @@ -9,6 +15,42 @@ controller_projects: scm_type: git scm_url: 'https://github.com/ansible/awx-facts-playbooks.git' +controller_credential_types: + - name: "SNOW Credential Type" + description: "credential to store SNOW" + kind: cloud + inputs: + fields: + - id: SNOW_USERNAME + type: string + label: Service Now Username + - id: SNOW_INSTANCE + type: string + label: Service Now Instance Name (devXXXXX) + - id: SNOW_PASSWORD + type: string + label: Service Now Password + secret: true + required: + - SNOW_USERNAME + - SNOW_INSTANCE + - SNOW_PASSWORD + injectors: + extra_vars: + snow_username: "{% raw %}{ { SNOW_USERNAME }}{% endraw %}" + snow_password: "{% raw %}{ { SNOW_PASSWORD }}{% endraw %}" + snow_instance: "{% raw %}{ { SNOW_INSTANCE }}{% endraw %}" + +controller_credentials: +- name: SNOW Credential + description: Credentials + organization: Default + credential_type: "SNOW Credential Type" + inputs: + SNOW_USERNAME: "admin" #update after install + SNOW_PASSWORD: "XXX" #update after install + SNOW_INSTANCE: "devXxxxx" #update after install + controller_templates: - name: "WINDOWS / Install IIS" job_type: run @@ -114,7 +156,6 @@ controller_templates: type: text variable: package_name required: true - - name: "WINDOWS / Arbitrary PowerShell" job_type: run inventory: "Workshop Inventory" @@ -203,3 +244,165 @@ controller_templates: type: text variable: surname required: true + + - name: "Rollback" + job_type: run + inventory: "Workshop Inventory" + limit: "student1-win1" + project: "Ansible official demo project" + playbook: "windows/backup.yml" + execution_environment: "windows workshop execution environment" + credentials: + - "Workshop Credential" + + - name: "Open SNOW Change Request" + job_type: run + inventory: "Workshop Inventory" + limit: "student1-ansible-1" + project: "Ansible official demo project" + playbook: "windows/snow.yml" + credentials: + - "SNOW Credential" + - "Workshop Credential" + + - name: "Send Completion Notification" + job_type: run + inventory: "Workshop Inventory" + limit: "student1-win1" + project: "Ansible official demo project" + playbook: "windows/backup.yml" + execution_environment: "windows workshop execution environment" + credentials: + - "Workshop Credential" + + - name: "Alert Ops!" + job_type: run + inventory: "Workshop Inventory" + limit: "student1-win1" + project: "Ansible official demo project" + playbook: "windows/backup.yml" + execution_environment: "windows workshop execution environment" + credentials: + - "Workshop Credential" + +controller_workflows: + - name: "Windows Demo Workflow" + organization: + name: "Default" + workflow_nodes: + - unified_job_template: + name: "Ansible official demo project" + type: project_update + organization: + name: "Default" + identifier: node100 + related: + success_nodes: + - identifier: node101 + - unified_job_template: + name: "Open SNOW Change Request" + type: job_template + organization: + name: "Default" + identifier: node101 + related: + success_nodes: + - identifier: node201 + - unified_job_template: + name: "WINDOWS / Windows updates" + type: job_template + organization: + name: "Default" + identifier: node201 + related: + success_nodes: + - identifier: node301 + failure_nodes: + - identifier: node302 + always_nodes: [] + - unified_job_template: + name: "WINDOWS / Install IIS" + type: job_template + organization: + name: "Default" + identifier: node301 + related: + success_nodes: + - identifier: node401 + failure_nodes: + - identifier: node402 + always_nodes: [] + - unified_job_template: + name: "Rollback" + type: workflow_approval + organization: + name: "Default" + related: + success_nodes: [] + failure_nodes: [] + always_nodes: [] + identifier: node302 + - unified_job_template: + name: "WINDOWS / Chocolatey install multiple" + type: workflow_approval + organization: + name: "Default" + identifier: node401 + related: + success_nodes: + - identifier: node501 + failure_nodes: + - identifier: node502 + always_nodes: [] + - unified_job_template: + name: "Rollback" + type: job_template + organization: + name: "Default" + identifier: node402 + related: + success_nodes: [] + failure_nodes: [] + always_nodes: [] + - unified_job_template: + name: "Send Completion Notification" + type: job_template + organization: + name: "Default" + identifier: node501 + related: + success_nodes: [] + failure_nodes: [] + always_nodes: [] + - unified_job_template: + name: "Manual override" + type: workflow_approval + organization: + name: "Default" + related: + success_nodes: + - identifier: node601 + failure_nodes: + - identifier: node602 + always_nodes: [] + identifier: node502 + - unified_job_template: + name: "Rollback" + type: job_template + organization: + name: "Default" + identifier: node602 + related: + success_nodes: [] + failure_nodes: [] + always_nodes: [] + - unified_job_template: + name: "Alert Ops!" + type: job_template + organization: + name: "Default" + identifier: node601 + related: + success_nodes: [] + failure_nodes: [] + always_nodes: [] diff --git a/windows/snow.yml b/windows/snow.yml new file mode 100644 index 0000000..4b1aa1b --- /dev/null +++ b/windows/snow.yml @@ -0,0 +1,32 @@ +--- +- name: open a change request + hosts: student1-ansible-1 + vars: + change_request: + severity: 2 + priority: 2 + description: Automated Provisioning + justification: Ansible Triggered + implementation_plan: Updated by Red Hat AAP + risk_impact_analysis: Changes are made automatically based on approved changes + test_plan: Run synthetic validation tests post-deployment + short_description: Automated Provisioning + tasks: + - name: Create a change request + servicenow.itsm.change_request: + instance: + host: "https://{{ snow_instance }}.service-now.com" + username: "{{ snow_username }}" + password: "{{ snow_password }}" + type: standard + state: new + requested_by: admin + short_description: "{{ change_request.short_description }}" + description: "{{ change_request.description }}" + priority: moderate + risk: low + impact: low + register: new_incident + + - debug: + var: new_incident.record.number