Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change some resource arguments to required and add autodoc documentation #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

howto-kubernetes-info
Copy link

Foreman requires mtu, network type, ipam and boot mode but they was flagged as optional in this module. Changed arguments to required and added autodoc documentation.

cat main.tf

terraform {
  required_providers {
    foreman = {
      source  = "terraform-coop/foreman"
      version = "0.6.2"
    }
  }
}

provider "foreman" {
  provider_loglevel = "DEBUG"
  provider_logfile = "terraform-provider-foreman.log"

  client_username = <hidden>
  client_password = <hidden>
  client_tls_insecure = "true"
  location_id = -1
  organization_id = -1

  server_hostname = "192.168.122.244"
  server_protocol = "https"
}

resource "foreman_subnet" "example" {
  mask = "255.255.255.0"
  name = "10.228.247.0 BO1"
  network = "10.228.247.0"
  #network_type = "IPv4"
  #boot_mode = "DHCP"
  #ipam = "DHCP"
  #mtu = 1500
}

Terraform apply output :

terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  + create

Terraform will perform the following actions:

  # foreman_subnet.example will be created
  + resource "foreman_subnet" "example" {
      + __meta__ = (known after apply)
      + id       = (known after apply)
      + mask     = "255.255.255.0"
      + name     = "10.228.247.0 BO1"
      + network  = "10.228.247.0"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

foreman_subnet.example: Creating...
╷
│ Error: HTTP Error:{
│   endpoint:   [https://192.168.122.244/api/subnets]
│   statusCode: [500]
│   respBody:   [{
│   "error": {"message":"ERF42-0624 [Foreman::Exception]: unknown network_type"}
│ }
│ ]
│ }
│ 
│   with foreman_subnet.example,
│   on main.tf line 26, in resource "foreman_subnet" "example":
│   26: resource "foreman_subnet" "example" {
│ 
╵

terraform apply output with added network_type:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  + create

Terraform will perform the following actions:

  # foreman_subnet.example will be created
  + resource "foreman_subnet" "example" {
      + __meta__     = (known after apply)
      + id           = (known after apply)
      + mask         = "255.255.255.0"
      + name         = "10.228.247.0 BO1"
      + network      = "10.228.247.0"
      + network_type = "IPv4"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

foreman_subnet.example: Creating...
╷
│ Error: HTTP Error:{
│   endpoint:   [https://192.168.122.244/api/subnets]
│   statusCode: [422]
│   respBody:   [{
│   "error": {"id":null,"errors":{"boot_mode":["is not included in the list"],"ipam":["not supported by this protocol"],"mtu":["must be greater than or equal to 68"]},"full_messages":["Boot mode is not included in the list","Ipam not supported by this protocol","Mtu must be greater than or equal to 68"]}
│ }
│ ]
│ }
│ 
│   with foreman_subnet.example,
│   on main.tf line 26, in resource "foreman_subnet" "example":
│   26: resource "foreman_subnet" "example" {
│ 
╵

Foreman requires mtu, network type, ipam and boot mode but they was flagged
as optional in this module. Changed arguments to required and added autodoc
documentation.
@lhw
Copy link
Contributor

lhw commented Jun 8, 2024

Could you run the autodoc command to update the docs accordingly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants