{"id":18722432,"url":"https://github.com/nleiva/ansible-snow","last_synced_at":"2025-10-23T22:46:38.171Z","repository":{"id":87030937,"uuid":"274641823","full_name":"nleiva/ansible-snow","owner":"nleiva","description":"Ansible Tower workflow with Cisco and Service Now Collections.","archived":false,"fork":false,"pushed_at":"2022-05-13T18:03:33.000Z","size":253,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-23T22:46:36.977Z","etag":null,"topics":["ansible","ansible-inventory","ansible-playbooks","cisco-ios","pyats","servicenow"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nleiva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-24T10:33:08.000Z","updated_at":"2022-05-13T17:48:58.000Z","dependencies_parsed_at":"2023-05-30T07:15:29.885Z","dependency_job_id":null,"html_url":"https://github.com/nleiva/ansible-snow","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nleiva/ansible-snow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nleiva%2Fansible-snow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nleiva%2Fansible-snow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nleiva%2Fansible-snow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nleiva%2Fansible-snow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nleiva","download_url":"https://codeload.github.com/nleiva/ansible-snow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nleiva%2Fansible-snow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280706795,"owners_count":26376970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-inventory","ansible-playbooks","cisco-ios","pyats","servicenow"],"created_at":"2024-11-07T13:41:24.415Z","updated_at":"2025-10-23T22:46:38.115Z","avatar_url":"https://github.com/nleiva.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible Service Now example\n\n![Ansible Lint](https://github.com/nleiva/ansible-snow/workflows/Ansible%20Lint/badge.svg)\n\nThese playbooks are meant to run as a Workflow to demonstrate the use of [Cisco IOS](https://cloud.redhat.com/ansible/automation-hub/cisco/ios) and [Service Now](https://galaxy.ansible.com/servicenow/servicenow) collections from [Galaxy](https://galaxy.ansible.com) and the Red Hat [Automation Hub](https://cloud.redhat.com/ansible/automation-hub). Each Playbook can run in a different Python virtual enviroment (`venv`).\n\n![Workflow][1]\n\nThis workflow parses data from a Cisco IOS device to create and update an incident. The output should look like this in [Service Now](https://developer.servicenow.com/dev.do):\n\n![ServiceNow][2]\n\n## Dependencies:\n\n### Python libraries\n\n```bash\npip3 install pysnow pyats[library]\n```\n\n### Collections\n\n```bash\nansible-galaxy collection install servicenow.servicenow\nansible-galaxy collection install cisco.ios\n```\n\n### Roles\n\n```bash\nansible-galaxy role install -r roles/requirements.yml\n```\n\nWhile both roles and collections can be specified in one requirements file, they need to be installed separately. The `ansible-galaxy role install -r requirements.yml` will only install roles and `ansible-galaxy collection install -r requirements.yml -p ./` will only install collections. See [Installing roles and collections from the same requirements.yml file](https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-roles-and-collections-from-the-same-requirements-yml-file).\n\n\n## Running the examples locally for testing\n\nYou can pass extra vars `snow_instance`, `snow_user`, and `snow_password` or export environment variables:\n\n```bash\nexport SNOW_INSTANCE=\u003cdev12345\u003e # without '.service-now.com'\nexport SN_USERNAME=\u003cadmin\u003e\nexport SN_PASSWORD=\u003cpassword\u003e\n```\n\nRun any of the playbooks:\n\n```python\n⇨  ansible-playbook create-incident.yml \n\nPLAY [Using ServiceNow Collection] ******************************************************************************************************************************************\n\nTASK [Create an incident] ***************************************************************************************************************************************************\nchanged: [localhost]\n\nTASK [debug] ****************************************************************************************************************************************************************\nok: [localhost] =\u003e {\n    \"new_incident.record.number\": \"INC0010002\"\n}\n```\n\nTo run the rest of them, you need to export the incident number you got.\n\n```yaml\nexport SNOW_NUMBER=INC0010002\n```\n\n## Inventory\n\nFirst, you need to export `SN_INSTANCE`, `SN_USERNAME`, and `SN_PASSWORD`. These identify your [Service Now](https://developer.servicenow.com/dev.do) instance and credentials. For example:\n\n```bash\nexport SN_INSTANCE=\u003cdev12345.service-now.com\u003e # with '.service-now.com'\nexport SN_USERNAME=\u003cadmin\u003e\nexport SN_PASSWORD=\u003cpassword\u003e\n```\n\n1. You can grab the display your full inventory\n\n    ```json\n    ⇨  ansible-inventory -i inventory-snow.yml --list\n    {\n        \"_meta\": {\n            \"hostvars\": {\n                \"DataNoc_gw01_lanset_net\": {\n                    \"sn_fqdn\": \"\",\n                    \"sn_ip_address\": \"208.187.161.1\",\n                    \"sn_name\": \"DataNoc.gw01.lanset.net\",\n                    \"sn_sys_class_name\": \"Network Gear\"\n                },\n                \"IP_Router_1\": {\n                    \"sn_fqdn\": \"\",\n                    \"sn_ip_address\": \"10.0.0.1\",\n                    \"sn_name\": \"IP-Router-1\",\n                    \"sn_sys_class_name\": \"IP Router\"\n                },\n                ...\n            }\n        },\n        \"all\": {\n            \"children\": [\n                \"group_IP_Router\",\n                \"group_IP_Switch\",\n                \"group_Network_Gear\",\n                \"ungrouped\"\n            ]\n        },\n        \"group_IP_Router\": {\n            \"hosts\": [\n                \"IP_Router_1\",\n                \"IP_Router_2\",\n                \"IP_Router_3\"\n            ]\n        },\n        \"group_IP_Switch\": {\n            \"hosts\": [\n                \"IP_Switch_1\"\n            ]\n        },\n        \"group_Network_Gear\": {\n            \"hosts\": [\n                \"DataNoc_gw01_lanset_net\",\n                \"San_Diego_Gateway\",\n                \"nc6500_a01\",\n                \"ny8500_nbxs08\",\n                \"ny8500_nbxs09\"\n            ]\n        }\n    }\n\n    ```\n\n2. Or see it as a graph based on the `keyed_groups`\n\n    ```bash\n    ⇨  ansible-inventory -i inventory-snow.yml --graph\n    @all:\n    |--@group_IP_Router:\n    |  |--IP_Router_1\n    |  |--IP_Router_2\n    |  |--IP_Router_3\n    |--@group_IP_Switch:\n    |  |--IP_Switch_1\n    |--@group_Network_Gear:\n    |  |--DataNoc_gw01_lanset_net\n    |  |--San_Diego_Gateway\n    |  |--nc6500_a01\n    |  |--ny8500_nbxs08\n    |  |--ny8500_nbxs09\n    |--@ungrouped:\n    ```\n\nIn Tower, you will want to import this on Inventory sources. Have `ANSIBLE_INVENTORY_ENABLED: auto` as well as the other required variables in the `ENVIRONMENT VARIABLES` section.\n\n![ServiceNow][3]\n\nLast, but not least, you can add hosts to your inventory with `snow_record`. Take a look at this [example](add-to-inventory.yml)\n\n## Links\n\n- [Galaxy - Service Now](https://galaxy.ansible.com/servicenow/servicenow)\n- [Ansible + ServiceNow Part 1: Opening and Closing Tickets](https://www.ansible.com/blog/ansible-servicenow-opening-and-closing-tickets)\n- [Ansible + ServiceNow Part 2: Parsing facts from network devices using PyATS/Genie](https://www.ansible.com/blog/ansible-servicenow-part-2-parsing-facts-from-network-devices-using-pyats/genie)\n- [Ansible + ServiceNow Part 3: Making outbound RESTful API calls to Red Hat Ansible Tower](https://www.ansible.com/blog/ansible-servicenow-howto-part-3-making-outbound-restful-api-calls-to-ansible-tower)\n- [Governing Self-Service Cloud Provisioning](https://github.com/michaelford85/aws-deploy)\n- [Using inventory plugins](https://docs.ansible.com/ansible/latest/plugins/inventory.html#using-inventory-plugins)\n- [Jinja2 to construct vars and groups based on existing inventory](https://docs.ansible.com/ansible/latest/plugins/inventory/constructed.html)\n\n\n[1]: images/snow_workflow.png\n[2]: images/snow_view.png\n[3]: images/snow_inventory_tower.png","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnleiva%2Fansible-snow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnleiva%2Fansible-snow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnleiva%2Fansible-snow/lists"}