Giter Club home page Giter Club logo

opsview-ansible-modules's Introduction

Opsview Ansible Modules

Ansible modules for interacting with Opsview Monitor!

Opsview Logo

Requirements

Installing

# Replace /etc/ansible with wherever your playbooks live

sudo pip install 'pyopsview>=5.3.3'

sudo mkdir /etc/ansible/library/
sudo mkdir /etc/ansible/module_utils/

git clone https://github.com/opsview/opsview-ansible-modules.git

sudo cp -p opsview-ansible-modules/library/*.py /etc/ansible/library
sudo cp -p opsview-ansible-modules/module_utils/*.py /etc/ansible/module_utils

Documentation

All of the documentation is available with ansible-doc

Examples

---
- hosts: webservers_eu_west
  connection: local
  vars:
    opsview_username: admin
    opsview_password: initial
    opsview_endpoint: http://opsview.example.com

  handlers:
    - name: Reload Opsview
      opsview_reload:
        username: '{{ opsview_username }}'
        endpoint: '{{ opsview_endpoint }}'
        token: '{{ opsview_login.token }}'
      # Handle failures in case there's already a reload in progress.
      register: reload_status
      ignore_errors: true
      until: reload_status|succeeded
      retries: 3
      delay: 30

  tasks:
    # Speed up operations by logging into Opsview first and using the
    # auth token directly
    - name: Log into Opsview
      opsview_login:
        username: '{{ opsview_username }}'
        password: '{{ opsview_password }}'
        endpoint: '{{ opsview_endpoint }}'
      register: opsview_login
      delegate_to: localhost

    - name: Create the WebServer hostgroup
      opsview_host_group:
        username: '{{ opsview_username }}'
        token: '{{ opsview_login.token }}'
        endpoint: '{{ opsview_endpoint }}'
        name: Web Servers
        parent: Production EU West 1
      notify: Reload Opsview
      delegate_to: localhost
      run_once: true
      register: webserver_host_group

    - debug:
        msg: 'Web Server Host Group ID: {{ webserver_host_group.object_id }}'

    - name: Add WebServer to Opsview
      opsview_host:
        username: '{{ opsview_username }}'
        token: '{{ opsview_login.token }}'
        endpoint: '{{ opsview_endpoint }}'
        name: '{{ ansible_hostname | default(inventory_hostname) }}'
        address: '{{ ansible_default_ipv4.address }}'
        monitored_by: Master Monitoring Server
        host_group: Web Servers
        host_templates:
          - Network - Base
          - OS - Opsview Agent
          - OS - Unix Advanced
        service_checks:
          # Lists can be specified in a simple format:
          - Apache current requests
          # Or in a dictionary format if more fields need to be supplied:
          - name: Zombie Processes
            remove_service_check: true
        notify: Reload Opsview
        delegate_to: localhost

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

opsview-ansible-modules's People

Contributors

jpgxs avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

opsview-ansible-modules's Issues

Support Python 3.7

From Python 3.7 async is a reserved keyword.

This causes an exception in the opsview_reload module:

Traceback (most recent call last):
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 140, in run
res = self._execute()
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 612, in _execute
result = self._handler.run(task_vars=variables)
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/plugins/action/normal.py", line 46, in run
result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/plugins/action/init.py", line 742, in _execute_module
(module_style, shebang, module_data, module_path) = self._configure_module(module_name=module_name, module_args=module_args, task_vars=task_vars)
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/plugins/action/init.py", line 178, in _configure_module
environment=final_environment)
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/executor/module_common.py", line 973, in modify_module
environment=environment)
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/executor/module_common.py", line 791, in _find_module_utils
recursive_finder(module_name, b_module_data, py_module_names, py_module_cache, zf)
File "/usr/local/Cellar/ansible/2.7.8/libexec/lib/python3.7/site-packages/ansible/executor/module_common.py", line 538, in recursive_finder
tree = ast.parse(data)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "", line 165
opsview_client.reload(async=True)
^
SyntaxError: invalid syntax

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.