diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 71563066..7952af34 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,10 +1,14 @@ # https://hub.docker.com/_/fedora -FROM fedora:37 +FROM fedora:38 # update and install OS packages -RUN dnf -y update && dnf -y install \ +RUN dnf -y update && dnf -y groupinstall "Development Tools" && \ + dnf -y install \ python3-pip \ python3-devel \ + libffi-devel \ + oniguruma-devel \ + gcc \ wget \ vim \ unzip \ @@ -17,6 +21,8 @@ RUN pip3 install -r requirements.txt # configure user and sudo RUN useradd vscode +# permission to vscode user +# RUN mkdir -p /workspaces && chown -R vscode:vscode /workspaces RUN sudo sed -e 's/^%wheel/#%wheel/g' -e 's/^# %wheel/%wheel/g' \ -i /etc/sudoers && \ usermod -aG wheel vscode diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9ab305fd..161a1d87 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,9 +5,6 @@ "build": { "dockerfile": "Dockerfile", "context" : ".." - // Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04 - // Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon. - // "args": { "VARIANT": "ubuntu-22.04" } }, // Set *default* container specific settings.json values on container create. @@ -24,5 +21,5 @@ // "postCreateCommand": "uname -a", // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" + // "remoteUser": "vscode" } diff --git a/tracks/getting-started-servicenow-automation/01-incident-creation/assignment.md b/tracks/getting-started-servicenow-automation/01-incident-creation/assignment.md index 2d75867b..9917cb73 100755 --- a/tracks/getting-started-servicenow-automation/01-incident-creation/assignment.md +++ b/tracks/getting-started-servicenow-automation/01-incident-creation/assignment.md @@ -7,12 +7,9 @@ teaser: Automate incident creation notes: - type: text contents: |- -

- -

The ServiceNow integration for Ansible Automation Platform is made possible through a certified content collection called `servicenow.itsm`. This collection - is made available on Automation Hub on `console.redhat.com`. The environment that + is made available on Automation Hub on [console.redhat.com](https://console.redhat.com). The environment that is being created for you includes this collection in an execution environment that allows Ansible Automation Platform to execute tasks against a ServiceNow instance. @@ -37,7 +34,7 @@ tabs: url: https://ansible.service-now.com new_window: true difficulty: basic -timelimit: 400 +timelimit: 420 --- 👋 Introduction ==== @@ -45,7 +42,7 @@ In ITIL, an incident refers to an unplanned outage or reduction in quality of an The servicenow.itsm certified collection allows organizations to leverage incident management within Ansible Automation Platform workflows. -A playbook as been created in the `VS Code` tab called `incident-create.yml`. +A playbook has been created in the `VS Code` tab called `incident-create.yml`. - Inspect this playbook and review the in-line comments to understand how the collection is being leveraged. ▶️ Create incident @@ -59,7 +56,14 @@ A playbook as been created in the `VS Code` tab called `incident-create.yml`. ==== If the previous step completed successfully, you should see a new incident has been created. To verify that this is the case: -- Use the ServiceNow credentials from `readme.md` to access ServiceNow from the `ServiceNow` tab. +- Use the ServiceNow credentials listed below or from `readme.md` to access ServiceNow from the `ServiceNow` tab. + + +| key | value | +| -------- | -------- | +| username | [[ Instruqt-Var key="SANDBOX" hostname="controller" ]] | +| password | [[ Instruqt-Var key="SANDBOX" hostname="controller" ]] + - In ServiceNow, click the star icon to access pre-configured favorites and select `Self-service - Incidents`: ![servicenow screenshot](../assets/snow-star.png) @@ -71,4 +75,4 @@ Move onto the next section by selecting the green "Next" button below. 🐛 Encountered an issue? ==== -If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+incident-creation&assignees=cloin). \ No newline at end of file +If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+incident-creation+(Sandbox+id:+[[ Instruqt-Var key="SANDBOX" hostname="controller" ]])&assignees=cloin&body=). \ No newline at end of file diff --git a/tracks/getting-started-servicenow-automation/01-incident-creation/setup-controller b/tracks/getting-started-servicenow-automation/01-incident-creation/setup-controller index 0c24c9e8..91b3a204 100755 --- a/tracks/getting-started-servicenow-automation/01-incident-creation/setup-controller +++ b/tracks/getting-started-servicenow-automation/01-incident-creation/setup-controller @@ -69,7 +69,7 @@ tee /home/rhel/challenge-1/template-create.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "incident-create.yml" + playbook: "student_project/incident-create.yml" execution_environment: "ServiceNow EE" use_fact_cache: false credentials: diff --git a/tracks/getting-started-servicenow-automation/02-attach-problem/assignment.md b/tracks/getting-started-servicenow-automation/02-attach-problem/assignment.md index 9fcb69e4..b04cda14 100755 --- a/tracks/getting-started-servicenow-automation/02-attach-problem/assignment.md +++ b/tracks/getting-started-servicenow-automation/02-attach-problem/assignment.md @@ -25,7 +25,7 @@ tabs: url: https://ansible.service-now.com new_window: true difficulty: basic -timelimit: 400 +timelimit: 420 --- 👋 Introduction ==== @@ -53,4 +53,4 @@ Move onto the next section by selecting the green "Next" button below. 🐛 Encountered an issue? ==== -If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+attach-problem&assignees=cloin). \ No newline at end of file +If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+attach-problem+(Sandbox+id:+[[ Instruqt-Var key="SANDBOX" hostname="controller" ]])&assignees=cloin). \ No newline at end of file diff --git a/tracks/getting-started-servicenow-automation/02-attach-problem/setup-controller b/tracks/getting-started-servicenow-automation/02-attach-problem/setup-controller index 60316449..b999614a 100755 --- a/tracks/getting-started-servicenow-automation/02-attach-problem/setup-controller +++ b/tracks/getting-started-servicenow-automation/02-attach-problem/setup-controller @@ -40,7 +40,7 @@ tee /home/rhel/servicenow_project/problem-attach.yml << EOF - name: Assign a problem to a user for assessment servicenow.itsm.problem: number: "{{ problem.record.number }}" - state: assess + state: 1 assigned_to: "{{ lookup('env', 'SN_USERNAME') }}" - name: Update incident status now that problem has been created @@ -78,7 +78,7 @@ tee /home/rhel/challenge-2/template-create.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "problem-attach.yml" + playbook: "student_project/problem-attach.yml" execution_environment: "ServiceNow EE" credentials: - "servicenow credential" diff --git a/tracks/getting-started-servicenow-automation/03-fix-and-close/assignment.md b/tracks/getting-started-servicenow-automation/03-fix-and-close/assignment.md index 44ead5c8..c060a01d 100755 --- a/tracks/getting-started-servicenow-automation/03-fix-and-close/assignment.md +++ b/tracks/getting-started-servicenow-automation/03-fix-and-close/assignment.md @@ -25,7 +25,7 @@ tabs: url: https://ansible.service-now.com new_window: true difficulty: basic -timelimit: 400 +timelimit: 420 --- 👋 Introduction ==== @@ -36,7 +36,7 @@ A new playbook has been created in your `VS Code` tab. ▶️ Create a change request ==== -- Navigate to `Resources > Job Templates` in automation controller and launch the job template `3 - Attach change request (change-attach.yml)` +- Navigate to `Resources > Templates` in automation controller and launch the job template `3 - Attach change request (change-attach.yml)` - Watch for job completion in automation controller 🔍 Inspect results @@ -47,4 +47,4 @@ Move onto the next section by selecting the green "Next" button below. 🐛 Encountered an issue? ==== -If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+fix-and-close&assignees=cloin). \ No newline at end of file +If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+fix-and-close+(Sandbox+id:+[[ Instruqt-Var key="SANDBOX" hostname="controller" ]])&assignees=cloin). \ No newline at end of file diff --git a/tracks/getting-started-servicenow-automation/03-fix-and-close/setup-controller b/tracks/getting-started-servicenow-automation/03-fix-and-close/setup-controller index 73bd2afd..215d1b87 100755 --- a/tracks/getting-started-servicenow-automation/03-fix-and-close/setup-controller +++ b/tracks/getting-started-servicenow-automation/03-fix-and-close/setup-controller @@ -34,7 +34,7 @@ tee /home/rhel/servicenow_project/change-attach.yml << EOF - name: Assign problem for assessment servicenow.itsm.problem: number: "{{ item.number }}" - state: assess + state: 3 assigned_to: "{{ demo_username }}" loop: "{{ problem_list }}" @@ -78,7 +78,7 @@ tee /home/rhel/challenge-3/template-create.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "change-attach.yml" + playbook: "student_project/change-attach.yml" execution_environment: "ServiceNow EE" credentials: - "servicenow credential" diff --git a/tracks/getting-started-servicenow-automation/04-configuration-items/assignment.md b/tracks/getting-started-servicenow-automation/04-configuration-items/assignment.md index d6b305e5..3ebb8a1b 100755 --- a/tracks/getting-started-servicenow-automation/04-configuration-items/assignment.md +++ b/tracks/getting-started-servicenow-automation/04-configuration-items/assignment.md @@ -21,7 +21,7 @@ tabs: url: https://ansible.service-now.com new_window: true difficulty: basic -timelimit: 400 +timelimit: 420 --- 👋 Introduction ==== @@ -53,4 +53,4 @@ Move onto the next section by selecting the green "Next" button below. 🐛 Encountered an issue? ==== -If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+configuration-items&assignees=cloin). \ No newline at end of file +If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+configuration-items+(Sandbox+id:+[[ Instruqt-Var key="SANDBOX" hostname="controller" ]])&assignees=cloin). \ No newline at end of file diff --git a/tracks/getting-started-servicenow-automation/04-configuration-items/setup-controller b/tracks/getting-started-servicenow-automation/04-configuration-items/setup-controller index 46998747..ae8b2573 100755 --- a/tracks/getting-started-servicenow-automation/04-configuration-items/setup-controller +++ b/tracks/getting-started-servicenow-automation/04-configuration-items/setup-controller @@ -31,12 +31,15 @@ tee /home/rhel/servicenow_project/create-update-config-items.yml << EOF connection: local collections: - servicenow.itsm + vars: + demo_username: "{{ lookup('env', 'SN_USERNAME') }}" tasks: - name: Create/update configuration item servicenow.itsm.configuration_item: - name: "{{ item.hostname }}" + name: "{{ item.hostname }}-{{ demo_username }}" + assigned_to: "{{ demo_username }}" ip_address: "{{ item.default_ip }}" mac_address: "{{ item.default_mac }}" environment: test @@ -45,6 +48,12 @@ tee /home/rhel/servicenow_project/create-update-config-items.yml << EOF loop: "{{ node_info }}" register: configuration_item + - name: debug + debug: + msg: "{{ configuration_item }}" + + + EOF # chown above file @@ -68,7 +77,7 @@ tee /home/rhel/challenge-4/template-create.yml << EOF organization: "Default" inventory: "rhel inventory" project: "ServiceNow" - playbook: "collect-node-info.yml" + playbook: "student_project/collect-node-info.yml" execution_environment: "ServiceNow EE" credentials: - "rhel credential" @@ -87,7 +96,7 @@ tee /home/rhel/challenge-4/template-create.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "create-update-config-items.yml" + playbook: "student_project/create-update-config-items.yml" execution_environment: "ServiceNow EE" credentials: - "servicenow credential" diff --git a/tracks/getting-started-servicenow-automation/05-query-and-update-records/assignment.md b/tracks/getting-started-servicenow-automation/05-query-and-update-records/assignment.md index 9cf20576..3c6144f1 100755 --- a/tracks/getting-started-servicenow-automation/05-query-and-update-records/assignment.md +++ b/tracks/getting-started-servicenow-automation/05-query-and-update-records/assignment.md @@ -25,7 +25,7 @@ tabs: url: https://ansible.service-now.com new_window: true difficulty: basic -timelimit: 400 +timelimit: 420 --- 👋 Introduction ==== @@ -47,4 +47,4 @@ Now that everything has been cleaned up, move onto the next challenge! Click the 🐛 Encountered an issue? ==== -If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+query-and-update-records&assignees=cloin). \ No newline at end of file +If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+query-and-update-records+(Sandbox+id:+[[ Instruqt-Var key="SANDBOX" hostname="controller" ]])&assignees=cloin). \ No newline at end of file diff --git a/tracks/getting-started-servicenow-automation/05-query-and-update-records/setup-controller b/tracks/getting-started-servicenow-automation/05-query-and-update-records/setup-controller index 86379e8b..aa808b47 100755 --- a/tracks/getting-started-servicenow-automation/05-query-and-update-records/setup-controller +++ b/tracks/getting-started-servicenow-automation/05-query-and-update-records/setup-controller @@ -138,7 +138,7 @@ tee /home/rhel/challenge-5/template-create.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "close-records-by-user.yml" + playbook: "student_project/close-records-by-user.yml" execution_environment: "ServiceNow EE" credentials: - "servicenow credential" diff --git a/tracks/getting-started-servicenow-automation/06-servicenow-inventory/assignment.md b/tracks/getting-started-servicenow-automation/06-servicenow-inventory/assignment.md index 9ac69e20..1ac1b27b 100755 --- a/tracks/getting-started-servicenow-automation/06-servicenow-inventory/assignment.md +++ b/tracks/getting-started-servicenow-automation/06-servicenow-inventory/assignment.md @@ -24,8 +24,8 @@ tabs: hostname: controller url: https://ansible.service-now.com new_window: true -difficulty: basic -timelimit: 400 +difficulty: "" +timelimit: 420 --- 👋 Introduction ==== @@ -37,7 +37,7 @@ A new inventory has been added to Automation Controller, but it hasn't queried a 👀 Review inventories ==== -- First, open the Automation Controller tab and navigator the right hand navigation pane to `Hosts`. Notice that this list is empty. This is because the integration between Ansible Automation Platform and ServiceNow is an API to API integration where the endpoints we're targeting are not individual hosts, but an API. +- First, open the Automation Controller tab and navigate the right hand navigation pane to `Hosts`. Notice that this list is empty. This is because the integration between Ansible Automation Platform and ServiceNow is an API to API integration where the endpoints we're targeting are not individual hosts, but an API. ▶️ Sync ServiceNow inventory ==== @@ -70,4 +70,4 @@ group_by: 🐛 Encountered an issue? ==== -If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+servicenow-inventory&assignees=cloin). \ No newline at end of file +If you have encountered an issue or have noticed something not quite right, please [open an issue](https://github.com/ansible/instruqt/issues/new?labels=getting-started-servicenow-automation&title=New+servicenow+issue:+servicenow-inventory+(Sandbox+id:+[[ Instruqt-Var key="SANDBOX" hostname="controller" ]])&assignees=cloin). \ No newline at end of file diff --git a/tracks/getting-started-servicenow-automation/06-servicenow-inventory/setup-controller b/tracks/getting-started-servicenow-automation/06-servicenow-inventory/setup-controller index 8d44846c..7d711285 100755 --- a/tracks/getting-started-servicenow-automation/06-servicenow-inventory/setup-controller +++ b/tracks/getting-started-servicenow-automation/06-servicenow-inventory/setup-controller @@ -21,7 +21,7 @@ tee /home/rhel/challenge-6/create-inventory-project.yml << EOF organization: Default state: present scm_type: git - scm_url: https://github.com/cloin/servicenow_inventory + scm_url: https://github.com/cloin/instruqt-snow scm_update_on_launch: true controller_host: "https://localhost" controller_username: admin diff --git a/tracks/getting-started-servicenow-automation/assets/snow-aap.png b/tracks/getting-started-servicenow-automation/assets/snow-aap.png deleted file mode 100644 index b277911a..00000000 Binary files a/tracks/getting-started-servicenow-automation/assets/snow-aap.png and /dev/null differ diff --git a/tracks/getting-started-servicenow-automation/config.yml b/tracks/getting-started-servicenow-automation/config.yml index 295c4c3a..66ca429a 100644 --- a/tracks/getting-started-servicenow-automation/config.yml +++ b/tracks/getting-started-servicenow-automation/config.yml @@ -1,16 +1,19 @@ version: "3" virtualmachines: - - name: node2 - image: red-hat-mbu/ansible - shell: /bin/su - rhel -s /bin/bash - machine_type: n1-standard-1 - - name: node1 - image: red-hat-mbu/ansible - shell: /bin/su - rhel -s /bin/bash - machine_type: n1-standard-1 - - name: controller - image: red-hat-mbu/automation-controller - shell: /bin/su - rhel -s /bin/bash - environment: - TERM: xterm - machine_type: n1-standard-4 +- name: node2 + image: red-hat-mbu/ansible + shell: /bin/su - rhel -s /bin/bash + machine_type: n1-standard-1 +- name: node1 + image: red-hat-mbu/ansible + shell: /bin/su - rhel -s /bin/bash + machine_type: n1-standard-1 +- name: controller + image: red-hat-mbu/automation-controller + shell: /bin/su - rhel -s /bin/bash + environment: + TERM: xterm + machine_type: n1-standard-4 + allow_external_ingress: + - http + - https diff --git a/tracks/getting-started-servicenow-automation/track.yml b/tracks/getting-started-servicenow-automation/track.yml index 5d4307e2..1de629ae 100755 --- a/tracks/getting-started-servicenow-automation/track.yml +++ b/tracks/getting-started-servicenow-automation/track.yml @@ -1,23 +1,25 @@ slug: getting-started-servicenow-automation id: faoq9b1onz2h -type: track -title: Getting started with ServiceNow automation -teaser: Explore base functionality provided by the ServiceNow collection for Ansible - Automation Platform +title: Get started with ServiceNow automation description: Ansible Automation Platform brings certified integrations to some of the most popular IT services. Learn how to leverage a supported integration with ServiceNow in order to implement closed loop automation through incident and CMDB management to ensure your organizations source of truth remains trustworthy. icon: "" -level: beginner tags: - itsm -- ' servicenow' -- ' cmdb' +- cmdb +- servicenow owner: redhat developers: - colin@redhat.com -private: false -published: true show_timer: true -checksum: "17712047228775310334" +timelimit: 3300 +lab_config: + overlay: false + width: 33 + position: right + extend_ttl: 3300 + feedback_recap_enabled: true + loadingMessages: true +checksum: "13692025422635255806" diff --git a/tracks/getting-started-servicenow-automation/track_scripts/cleanup-controller b/tracks/getting-started-servicenow-automation/track_scripts/cleanup-controller index 2a4a95c8..f54779fa 100755 --- a/tracks/getting-started-servicenow-automation/track_scripts/cleanup-controller +++ b/tracks/getting-started-servicenow-automation/track_scripts/cleanup-controller @@ -5,25 +5,25 @@ USER=rhel su - rhel -c 'mkdir /home/rhel/cleanup' # creates a playbook to create a user in SNOW -tee /home/rhel/servicenow_project/create-snow-user.yml << EOF ---- -- name: Run JT from Controller - hosts: localhost - connection: local - gather_facts: false - vars: - cleanup: true - tasks: - - - name: run jt - awx.awx.job_launch: - job_template: "SNOW - Configure/Destroy demo account" - extra_vars: - demo_username: "{{ lookup('env', 'SN_USERNAME') }}" - demo_password: "{{ lookup('env', 'SN_USERNAME') }}" - cleanup: "{{ cleanup }}" - -EOF +# tee /home/rhel/servicenow_project/create-snow-user.yml << EOF +# --- +# - name: Run JT from Controller +# hosts: localhost +# connection: local +# gather_facts: false +# vars: +# cleanup: true +# tasks: + +# - name: run jt +# awx.awx.job_launch: +# job_template: "SNOW - Configure/Destroy demo account" +# extra_vars: +# demo_username: "{{ lookup('env', 'SN_USERNAME') }}" +# demo_password: "{{ lookup('env', 'SN_USERNAME') }}" +# cleanup: "{{ cleanup }}" + +# EOF # chown above file sudo chown rhel:rhel /home/rhel/servicenow_project/create-snow-user.yml @@ -164,7 +164,7 @@ tee /home/rhel/cleanup/cleanup.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "close-records-by-user.yml" + playbook: "student_project/close-records-by-user.yml" execution_environment: "ServiceNow EE" credentials: - "servicenow credential" @@ -189,7 +189,7 @@ tee /home/rhel/cleanup/cleanup.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow" - playbook: "create-snow-user.yml" + playbook: "admin_project/create-snow-user.yml" execution_environment: "ServiceNow EE" use_fact_cache: true ask_variables_on_launch: true @@ -202,14 +202,14 @@ tee /home/rhel/cleanup/cleanup.yml << EOF controller_password: ansible123! validate_certs: false - - awx.awx.job_launch: - job_template: "0 - Create SNOW demo user" - extra_vars: - cleanup: true - controller_host: https://localhost - controller_username: admin - controller_password: ansible123! - validate_certs: false +# - awx.awx.job_launch: +# job_template: "0 - Create SNOW demo user" +# extra_vars: +# cleanup: true +# controller_host: https://localhost +# controller_username: admin +# controller_password: ansible123! +# validate_certs: false EOF diff --git a/tracks/getting-started-servicenow-automation/track_scripts/setup-controller b/tracks/getting-started-servicenow-automation/track_scripts/setup-controller index 15d6b65f..2891d23a 100755 --- a/tracks/getting-started-servicenow-automation/track_scripts/setup-controller +++ b/tracks/getting-started-servicenow-automation/track_scripts/setup-controller @@ -1,6 +1,8 @@ #!/bin/bash USER=rhel +agent variable set SANDBOX $INSTRUQT_PARTICIPANT_ID + # creates the correct credential for servicenow on Controller su - rhel -c 'ansible-galaxy collection install awx.awx' @@ -18,28 +20,28 @@ chmod a+x /home/rhel/ # symlink project directories so they can be picked up by controller su - awx -c 'ln -s /home/rhel/servicenow_project/ /var/lib/awx/projects/' -su - awx -c 'ln -s /tmp/admin_project/ /var/lib/awx/projects/' +# su - awx -c 'ln -s /tmp/admin_project/ /var/lib/awx/projects/' # creates a playbook to create a user in SNOW -tee /tmp/admin_project/create-snow-user.yml << EOF ---- -- name: Run JT from Controller - hosts: localhost - connection: local - gather_facts: false - vars: - cleanup: true - tasks: +# tee /tmp/admin_project/create-snow-user.yml << EOF +# --- +# - name: Run JT from Controller +# hosts: localhost +# connection: local +# gather_facts: false +# vars: +# cleanup: true +# tasks: - - name: run jt - awx.awx.job_launch: - job_template: "SNOW - Configure/Destroy demo account" - extra_vars: - demo_username: "{{ lookup('env', 'SN_USERNAME') }}" - demo_password: "{{ lookup('env', 'SN_USERNAME') }}" - cleanup: "{{ cleanup }}" +# - name: run jt +# awx.awx.job_launch: +# job_template: "SNOW - Configure/Destroy demo account" +# extra_vars: +# demo_username: "{{ lookup('env', 'SN_USERNAME') }}" +# demo_password: "{{ lookup('env', 'SN_USERNAME') }}" +# cleanup: "{{ cleanup }}" -EOF +# EOF # chown above file sudo chown rhel:rhel /tmp/admin_project/create-snow-user.yml @@ -107,6 +109,7 @@ tee /home/rhel/setup-controller.yml << EOF description: "rhel host" inventory: "rhel inventory" state: present + enabled: true controller_host: "https://localhost" controller_username: admin controller_password: ansible123! @@ -136,8 +139,8 @@ tee /home/rhel/setup-controller.yml << EOF description: "Project containing users ServiceNow playbooks" organization: Default state: present - scm_type: manual - local_path: servicenow_project + scm_type: git + scm_url: https://github.com/cloin/instruqt-snow controller_host: "https://localhost" controller_username: admin controller_password: ansible123! @@ -149,8 +152,8 @@ tee /home/rhel/setup-controller.yml << EOF description: "Project containing users ServiceNow playbooks for admin use" organization: Default state: present - scm_type: manual - local_path: admin_project + scm_type: git + scm_url: https://github.com/cloin/instruqt-snow controller_host: "https://localhost" controller_username: admin controller_password: ansible123! @@ -163,7 +166,7 @@ tee /home/rhel/setup-controller.yml << EOF organization: "Default" inventory: "Demo Inventory" project: "ServiceNow - admin" - playbook: "create-snow-user.yml" + playbook: "admin_project/create-snow-user.yml" execution_environment: "ServiceNow EE" ask_variables_on_launch: true credentials: @@ -184,30 +187,6 @@ tee /home/rhel/setup-controller.yml << EOF controller_username: admin controller_password: ansible123! validate_certs: false - - # - name: Remove job template - # job_template: - # name: "{{ item }}" - # job_type: "run" - # organization: "Default" - # inventory: "Demo Inventory" - # # project: "ServiceNow" - # # playbook: "incident-create.yml" - # # credentials: - # # - "servicenow credential" - # state: "absent" - # controller_host: "https://localhost" - # controller_username: admin - # controller_password: ansible123! - # validate_certs: false - # loop: - # - "Demo Job Template" - # - "0 - Create SNOW demo user" - - # - name: Remove SNOW user create playbook from project directory - # ansible.builtin.file: - # path: /home/rhel/servicenow_project/create-snow-user.yml - # state: absent EOF @@ -215,6 +194,7 @@ EOF sudo chown rhel:rhel /home/rhel/setup-controller.yml # execute above playbook +echo "execute setup-controller playbook" su - rhel -c 'ansible-playbook /home/rhel/setup-controller.yml' @@ -232,6 +212,15 @@ su - rhel -c 'tee -a /home/rhel/servicenow_project/readme.md << EOF EOF' +# Fixes an issue with podman that produces this error: "Error: error creating tmpdir: mkdir /run/user/1000: permission denied" +su - $USER -c 'loginctl enable-linger $USER' + +# Pull the servicenow EE +su - $USER -c 'podman pull quay.io/acme_corp/servicenow-ee:latest' + +# Update ansible extension +su - $USER -c 'code-server --install-extension redhat.ansible --force' + # set vscode default settings su - $USER -c 'cat >/home/$USER/.local/share/code-server/User/settings.json </home/$USER/.local/share/code-server/User/settings.json </home/rhel/servicenow_project/ansible-navigator.yml <> /home/rhel/.bashrc' +su - $USER -c 'echo "export SN_USERNAME=$INSTRUQT_PARTICIPANT_ID" >> /home/rhel/.bashrc' +su - $USER -c 'echo "export SN_PASSWORD=$INSTRUQT_PARTICIPANT_ID" >> /home/rhel/.bashrc' +echo "remove old navigator rpm install" +su - $USER -c 'sudo dnf -y remove ansible-navigator' +echo "get latest upstream navigator" +# su - $USER -c 'pip3.9 install --user ansible-navigator'