From 27d60b7dde7e8d49533bff274464c7f25e1670b8 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Tue, 15 Oct 2024 10:37:48 +0300 Subject: [PATCH] Add example usage and import instructions to HAProxy docs This commit enhances the documentation for HAProxy User list and Global sections by including example usage and detailed import instructions. These additions should help users better understand how to configure and import sections in Terraform. --- docs/resources/haproxy_section_global.md | 36 ++++++++++++++++ docs/resources/haproxy_section_user_list.md | 42 +++++++++++++++++++ .../resources/haproxy_section_global.md.tmpl | 6 +-- 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/docs/resources/haproxy_section_global.md b/docs/resources/haproxy_section_global.md index 3f1a494..16766c6 100644 --- a/docs/resources/haproxy_section_global.md +++ b/docs/resources/haproxy_section_global.md @@ -11,6 +11,25 @@ description: |- Manage HAProxy Global sections. Since this section exists by default and cannot be deleted, it can only be imported and edited. Please note that changes may cause HAProxy to restart. +## Example Usage + +```terraform +provider "roxywi" { + base_url = "https://..." + login = "test" + password = "testpass" +} + +resource "roxywi_haproxy_section_global" "example" { + server_id = 1 + chroot = "/var/lib/haproxy" + daemon = true + socket = ["*:1999 level admin", "/var/run/haproxy.sock mode 600 level admin", "/var/lib/haproxy/stats"] + log = ["127.0.0.1 local1", "127.0.0.1 local1 notice"] + maxconn = 5000 + action = "restart" +} +``` ## Schema @@ -46,3 +65,20 @@ Optional: - `delete` (String) - `update` (String) + +## Import + +In Terraform v1.7.0 and later, use an import block to import Group. For example: + +```terraform +import { + to = roxywi_haproxy_section_global.example + id = "1-global" +} +``` + +Using terraform import, import Group can be imported using the `id`, e.g. For example: + +```shell +% terraform import roxywi_haproxy_section_global.example 1-global +``` \ No newline at end of file diff --git a/docs/resources/haproxy_section_user_list.md b/docs/resources/haproxy_section_user_list.md index fd88edb..70fca1c 100644 --- a/docs/resources/haproxy_section_user_list.md +++ b/docs/resources/haproxy_section_user_list.md @@ -11,6 +11,31 @@ description: |- Manage HAProxy User list sections. Please note that changes may cause HAProxy to restart. +## Example Usage + +```terraform +provider "roxywi" { + base_url = "https://..." + login = "test" + password = "testpass" +} + +resource "roxywi_haproxy_section_user_list" "example" { + userlist_groups = ["group1", "group2"] + userlist_users { + user = "user1" + password = "password1" + group = "group2" + } + userlist_users { + user = "user2" + password = "password2" + } + + name = "user_list" + server_id = 1 +} +``` ## Schema @@ -52,3 +77,20 @@ Optional: - `create` (String) - `delete` (String) - `update` (String) + +## Import + +In Terraform v1.7.0 and later, use an import block to import Group. For example: + +```terraform +import { + to = roxywi_haproxy_section_user_list.example + id = "1-user_list" +} +``` + +Using terraform import, import Group can be imported using the `id`, e.g. For example: + +```shell +% terraform import roxywi_haproxy_section_user_list.example 1-user_list +``` \ No newline at end of file diff --git a/templates/resources/haproxy_section_global.md.tmpl b/templates/resources/haproxy_section_global.md.tmpl index 667dca8..7c29ce0 100644 --- a/templates/resources/haproxy_section_global.md.tmpl +++ b/templates/resources/haproxy_section_global.md.tmpl @@ -25,14 +25,12 @@ Manage HAProxy Global sections. Since this section exists by default and cannot ### Optional - `action` (String) What action should be taken after changing the config. Available: save, reload, restart. -- `chroot` (String) HAProxy is designed to isolate itself into a chroot jail during startup, where -it cannot perform any file-system access at all. +- `chroot` (String) HAProxy is designed to isolate itself into a chroot jail during startup, where it cannot perform any file-system access at all. - `daemon` (Boolean) Start as a daemon. The process detaches from the current terminal after forking, and errors are not reported anymore in the terminal. - `group` (String) A group with what HAProxy will be started. - `log` (List of String) A list loging settings. - `maxconn` (Number) Limits the per-process connection limit. -- `option` (String) Here you can put addinional options separeted by ' -'. +- `option` (String) Here you can put addinional options separeted by '\\n'. - `pidfile` (String) Path to the pid file. - `socket` (List of String) A list socket settings. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))