Skip to main content

nautobot-plugin-chatops-ansible

A plugin for Nautobot Chatops Plugin

Build Status

Branch Status
main Build Status
develop Build Status

Summary

Chatbot that allows users to communicate directly with Ansible AWX/Tower from various chat platforms.

The Nautobot Chatops Ansible plugin extends the capabilities of the Nautobot Chatops plugin to include a new command available to the plugin. This is done by registering to the Python entry point in Nautobot Plugin Chatops, that provides functionality to the code written to interact with Ansible. This plugin introduces the following sub commands to the ansible command:

  • get_dashboard
  • get_inventory
  • get_projects
  • get_job_templates
  • run_job_template
  • get_jobs

Get Dashboard

The dashboard command provides an Ansible Tower/AWX status dashboard. This gives a summary of:

  • How many hosts are on the Tower system
  • How many failed hosts (last job is failed)
  • Total number of inventories
  • How many inventories have failed
  • How many project sync failures have occurred

Get Inventory

The inventory sub-command provides inventories available and the details of those inventories.

Get Projects

Get projects will gather information about the projects available within the Ansible Tower/AWX instance. Information such as the name, description, SCM URL, and SCM branch are provided.

Get Job Templates

This gathers the information about the defined job templates on the Ansible Tower/AWX instance. It will provide the name, description, project, and the associated inventory with the Job Template configured.

Run Job Template

The natural progression of gathering job templates is then to execute a particular job template. Executes a Job Template that does not require extra vars or surveys to be completed. The Job ID for the executed job template will be provided via a chat response.

Get Jobs

The get jobs sub command will ask Tower for the last number of jobs, with a default count of the last 10 jobs. This will give the status of the jobs including:

  • Job ID
  • Name of the Job
  • User that launched the job
  • Created
  • Finish time
  • Status of the job

Installation

The plugin is available as a Python package in PyPI and can be installed with pip

pip install git+https://github.com/nautobot/nautobot-plugin-chatops-ansible.git

This ChatOps Plugin to Nautobot ChatOps Plugin requires the following list of environment variables to be added into the environment.

  • NAUTOBOT_TOWER_URI: Ansible Tower HTTP URI
  • NAUTOBOT_TOWER_USERNAME: Ansible Tower username
  • NAUTOBOT_TOWER_PASSWORD: Ansible Tower password

Once you have updated your environment file, restart both nautobot and nautobot-worker

$ sudo systemctl restart nautobot nautobot-worker

Usage

Command setup

Add a slash command to Slack called /ansible. See the nautobot-chatops installation guide for instructions on adding a slash command to your Slack channel.

You may need to adjust your Access Grants in Nautobot depending on your security requirements.

Contributing

Pull requests are welcomed and automatically built and tested against multiple version of Python and multiple version of Nautobot through TravisCI.

The project is packaged with a light development environment based on docker-compose to help with the local development of the project and to run the tests within TravisCI.

The project is following Network to Code software development guideline and is leveraging:

  • Black, Pylint, Bandit and pydocstyle for Python linting and formatting.
  • Django unit test to ensure the plugin is working properly.

CLI Helper Commands

The project is coming with a CLI helper based on invoke to help setup the development environment. The commands are listed below in 3 categories dev environment, utility and testing.

Each command can be executed with invoke <command>. All commands support the arguments --nautobot-ver and --python-ver if you want to manually define the version of Python and Nautobot to use. Each command also has its own help invoke <command> --help

Local dev environment

  build            Build all docker images.
  debug            Start Nautobot and its dependencies in debug mode.
  destroy          Destroy all containers and volumes.
  start            Start Nautobot and its dependencies in detached mode.
  stop             Stop Nautobot and its dependencies.

Utility

  cli              Launch a bash shell inside the running Nautobot container.
  create-user      Create a new user in django (default: admin), will prompt for password.
  makemigrations   Run Make Migration in Django.
  nbshell          Launch a nbshell session.

Testing

  tests            Run all tests.
  pydocstyle       Run pydocstyle to validate docstring formatting adheres to NTC defined standards.
  bandit           Run bandit to validate basic static code security analysis.
  black            Run black to check that Python files adhere to its style standards.
  unittest         Run Django unit tests for the plugin.

Questions

For any questions or comments, feel free to swing by the Network to Code slack channel (channel #networktocode). Sign up here

Metadata

Release files for nautobot-chatops-ansible 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nautobot-chatops-ansible 1.0.3
File Size Uploaded Provenance
nautobot-chatops-ansible-1.0.3.tar.gz 28.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nautobot-chatops-ansible 1.0.3
File Interpreter ABI Platform
nautobot_chatops_ansible-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 59.1 kB

Release files / nautobot-chatops-ansible-1.0.3.tar.gz

Download URL nautobot-chatops-ansible-1.0.3.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
af1cc52d6a13ee2f649db84644441678904f79900e76bffd04c5ee23aef37d3f
BLAKE2b-256 checksum
How to use checksums
6d35b4e4588f3f28d3fbdcd16a20d92cd3636653dbe579cc984eacd3223164e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.6.7 Linux/4.15.0-1077-gcp

Release files / nautobot_chatops_ansible-1.0.3-py3-none-any.whl

Download URL nautobot_chatops_ansible-1.0.3-py3-none-any.whl
Size 31.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7841e5b2c21d1ce61fa33c40581b3f45e62c48c6d66052565923698a443b4beb
BLAKE2b-256 checksum
How to use checksums
462344770c826183b865b1f799cadb701b5cd0ef56902b4545ffb09973c5c479
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.6.7 Linux/4.15.0-1077-gcp

Security for nautobot-chatops-ansible 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page