devopsdunkin / terraform-provider-nagios Goto Github PK
View Code? Open in Web Editor NEWTerraform provider for Nagios XI
Home Page: https://devopsdunkin.github.io/terraform-provider-nagios
License: MIT License
Terraform provider for Nagios XI
Home Page: https://devopsdunkin.github.io/terraform-provider-nagios
License: MIT License
Repo should contain a CHANGELOG.md
to track what changes between versions
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
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
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
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
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)
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"
}
The provider should allow for the ability to manage Nagios contacts. It should manage state for the contact and allow for CRUD operations
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
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:
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
The provider should have the ability to query Nagios for an existing service, pull it into state as a data source for use
Provider should have the ability to pull service groups from Nagios into state to be used for other resources or data sources
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.
Hostgroup tests should include a test that creates a hostgroup with no members, then updates with one member and then adds two before destroying. This will test that the data conversion works between Nagios API and Terraform schema.
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
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
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 a CONTRIBUTING.md to provide a framework for others to contribute to this project
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
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
Provider should allow for the management of servicegroups and provide test cases
A service must have a host or host group attached to it in order for Nagios to validate and apply the configuration. Both attributes do not need to be required but one needs to be.
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
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
Hostgroups should support the ability to manage the Notes, NoteURL and ActionURL attributes
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 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
Provider should have a resource that manages the lifecycle of Nagios hosts
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
The provider should implement the resource import functionality. Users should be able to import existing Nagios objects and infrastructure into TF provider
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
Test cases should exist to prove the functionality of managing Nagios hosts
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
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.
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.
resource_service
should support attributes to specify hostgroups that the service should run on. It should also support a servicegroups attribute to determine which servicegroup the service belongs to
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.