GithubHelp home page GithubHelp logo

devopsdunkin / terraform-provider-nagios Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 3.0 8.52 MB

Terraform provider for Nagios XI

Home Page: https://devopsdunkin.github.io/terraform-provider-nagios

License: MIT License

Go 99.51% Dockerfile 0.10% Makefile 0.40%
nagios nagios-xi terraform terraform-provider

terraform-provider-nagios's People

Contributors

devopsdunkin avatar pawelwiecaszek avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-provider-nagios's Issues

Add CHANGELOG

Repo should contain a CHANGELOG.md to track what changes between versions

New data source: authserver

New data source: authserver

To allow users to pull existing authservers into their terraform workflow and allow them to use it for downstream processes, such as creating users with the provider.

The data source should accept server_id as an input and return the following attributes:

enabled
connection_method
ad_account_suffix
ad_domain_controllers
ldap_host
ldap_port
security_level
base_dn

Ability to manage services

Provider should manage Nagios services. It should accept input for all required parameters in Nagios

host_name
service_description
check_command
max_check_attempts
check_interval
retry_interval
check_period
notification_interval
notification_period
contacts/contact_groups

New data source: hostgroup

Provider should have the ability to pull existing hostgroups from Nagios using hostgroup_name and all attributes configured in Nagios for the host group should be returned into state

free_variables for contacts are destroyed during an update

Nagios XI version: 5.6.7

When performing an update on a contact where there is a change to the free_variables attribute, all free_variables are destroyed. This issue lies within Nagios itself as I was able to reproduce the issue outside of the Terraform provider. I wanted to document this issue to revisit at a later date

New resource: users

The provider should allow for the ability to manage Nagios admin users. It should manage state for the users and allow for CRUD operations. It should be able to create local Nagios users, as well as users from a third-party directory services (e.g. LDAP)

is this provider still active?

I am getting this error with terraform init:

Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/google from the dependency lock file
- Finding latest version of hashicorp/nagios...
- Using previously-installed hashicorp/google v4.43.1
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/nagios: provider registry registry.terraform.io does not have
│ a provider named registry.terraform.io/hashicorp/nagios
│
│ All modules should specify their required_providers so that external consumers will get the correct providers when using a module. To
│ see which modules are currently depending on hashicorp/nagios, run the following command:
│     terraform providers

provider setup

provider "nagios" {
    url = "nagios_url"
    token ="tocken"
}

New resource: contact

The provider should allow for the ability to manage Nagios contacts. It should manage state for the contact and allow for CRUD operations

Change resource_host strings to bools

There are fields in resource_host that are specifying an integer of 0 or 1 in order to set a value to true or false in Nagios. We need to change the fields to accept bools in the schema, then perform a conversion using the convertBoolToIntToString() func. This should make more sense for users when using resource_host

Error handling/checking need significant improvements

Discovered that how I am logging errors in the provider is not accurate. We are anticipating that the upstream API will return a HTTP status code to indicate an error, and while that is possible with Nagios, it appears that 99.9% of the time, we will get a 200 HTTP OK. The error will actually reside in the body of the message.

If the API call is not accurate or some other error occurs, we will see something like this:

{ "error": "This would be the message indicating what went wrong" }

If things are successful, it'd be like this:

{ "success": "The host has been added and Nagios core restarted" }

Need to refactor how errors are being detected. I think we should keep what is there currently, but add in additional checks to look for error messages within the body

Applies to:

  • Hosts
  • Hostgroups
  • Servicegroups

New data source: host

Provider should contain a data source to allow users to pull existing hosts from Nagios XI into their Terraform state to use. The data source should accept host_name as the parameter and should return all configured attributes for the host

New data source: service

The provider should have the ability to query Nagios for an existing service, pull it into state as a data source for use

New data source: servicegroup

Provider should have the ability to pull service groups from Nagios into state to be used for other resources or data sources

TestAccHostgroup_updateName test case randomly fails

When running tests, the following will randomly fail at times with no apparent cause. When re-running the tests right after, it passes

=== RUN   TestAccHostgroup_updateName
--- FAIL: TestAccHostgroup_updateName (0.87s)
    testing.go:569: Step 0 error: errors during apply:
        
        Error: Provider produced inconsistent result after apply
        
        When applying changes to nagios_host.host, provider "nagios" produced an
        unexpected new value for was present, but now absent.
        
        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.

Allow objects to be created with enabled flag

Objects should be able to be created with a flag of enabled. This would allow objects to be created that are not active to faciliate testing or if users want to create an object during a build process but don't want it active yet

New resource: contact groups

The provider should allow for the ability to manage Nagios contact groups. It should manage state for the contact group and allow for CRUD operations

Look into resourceExists

Need to research the resourceHostgroupExists (or any resourceExists) and see if there is benefit to implementing this. From brief, initial reading, it sounds like a way to reduce number of reads performed which are more resource intensive. Could provide performance improvements but need to look at this in more depth

Add CONTRIBUTING.md

Add a CONTRIBUTING.md to provide a framework for others to contribute to this project

Use reflect package for populating struct and URL params

Currently we statically create and populate the structure, and URL params. We want to rewrite that code so it utilizes the reflect package and can loop through structs and populate the data dynamically. Can also use to get JSON tags to create url params

Basic configuration returns error message

I've pared down my .tf file to this:

provider "nagios" {
    url = "http://monitor.example.com/nagiosxi"
    token = "XXXXX"
}

resource "nagios_host" "install2" {
    name                            = "install2"
    address                         = "172.24.20.202"
    max_check_attempts              = "10"
    check_period                    = "24x7"
    notification_interval           = "1"
    notification_period             = "24x7"
    contacts                        = [
        "nagiosadmin"
    ]
}

When I apply, the host is added to nagios. However, the run also results in this error message:


Error: json: cannot unmarshal object into Go value of type []nagios.Host

  on nagios.tf line 6, in resource "nagios_host" "install2":
   6: resource "nagios_host" "install2" {

I'm not able to see what in my config is causing this.

I'm running the latest MacOS executable and Terraform 12.

Thanks,

--Chris

Change function scope to private

The functions that are called by the resource to create the object (e.g. NewHostgroup) should be privately scopes functions instead of public. When they were created, the design was to put these functions in a different package but since then it seems to have made better sense to keep them contained in one package

Dependent field validation

For any field that has a dependent field that determines if the field is enabled, validation must be performed. For example, if we have

resource "nagios_host" "host1" {
...
     event_handler_enabled = true
...
}

There is a dependent field called event_handler that needs to be provided, so we must check that this was provided as well, and if not, an error must be returned. If event_handler_enabled was not provided or set to false, then the validation does not need to check for the presence of event_handler

Add CI configuration

The project should have a CI pipeline for automated testing to improve stability and reliability of the provider. The pipeline should run the tests that are contained within the project

Provider should implement a resource for a Nagios service

Provider should implement a resource that allows management of a Nagios service. It should require that the following be provided.

host_name
service_description
check_command
max_check_attempts
check_interval
retry_interval
check_period
notification_interval
notification_period
contactsorcontact_groups

Hostgroup membership validation

When adding members to a hostgroup, it must be a valid host, which means it must have all the required attributes filled out in Nagios. If it does not, it will still pseudo validate (meaning Nagios will validate the config and restart core services). But if you look at the hosts, they will show inactive, which means they don't get applied in the config. They do this because not all necessary info is set.

Terraform will always show a change to the resource as it has to "re-add" the hosts.

The hostgroup resource should perform a GET to Nagios for the host name, and validate that all required attributes are set

Implement resource import

The provider should implement the resource import functionality. Users should be able to import existing Nagios objects and infrastructure into TF provider

New resource: time period

The provider should allow for the ability to manage Nagios time periods. It should manage state for the time period and allow for CRUD operations

Ability to manage hostgroup membership

Provider should manage which hostgroups a host should be added to. A host could belong to multiple hostgroups, so it will need to accept a list of strings. The provider will need to validate that the hostgroup exists in Nagios before the host could be added

Nagios auth server unable to be managed with provider

It currently does not appear to be possible to manage authentication servers with the provider.

When creating an auth server through the API, the HTTP response provides a GUID that is used to uniquely identify the auth server in Nagios. Example identifier: 5dd4a593c7262. This field is returned with a key of server_id.

Now, during a GET, we again pass in the server_id as a URL parameter to return only the auth server with that server_id. However, the HTTP response that is returned, gives us the unique identifier with a key of just id. Since it does not appear to be feasible to provide multiple JSON tags in the Go struct type, I don't believe it's possible to manage with the provider.

omitempty tag should be used with resources

For the fields that are not required and have a default value, particularly any boolean values, we are passing in false if nothing is provided. While Nagios is using the same default value, I think the better way to handle this would be to use omitempty on the JSON tags for the structs. This would not pass in anything if no value is provided.

Handling of escape characters

check_command attribute will be passing in special characters, such as !. Provider is choking on this and need to figure a way to handle this in code. Ideally, the user would enter the check_command string as they would in Nagios

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.