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

octopusdeploy_deployment_process.run_script_action Capitalizes Boolean values #530

Open
edgarschaap-omnia opened this issue Jul 13, 2023 · 1 comment
Labels
area/deployment-processes category/dev-experience Issues about the dev experience of using the provider, writing correct HCL etc kind/bug Something isn't working kind/question Further information is requested

Comments

@edgarschaap-omnia
Copy link

Describe the bug
When creating octopus_deployment_process resource, within the step block and then run_script_action block, defined booleans for Octopus.Action.* properties end up being capitalized.

Steps to reproduce

  1. Create a simple octopusdeploy_deployment_process resource with a run_on_server property set to either true or false and for one more example Octopus.Features.SubstituteInFiles feature enabled.
  resource "octopusdeploy_deployment_process" "project_deployment_process" {
    project_id = octopusdeploy_project.project.id
    step {
      condition           = "Success"
      name                = "Slack - Notify Deployment Started"
      package_requirement = "LetOctopusDecide"
      start_trigger       = "StartAfterPrevious"
  
      run_script_action {
        condition         = "Success"
        name              = "Slack - Notify Deployment Started"
        run_on_server     = true
        is_required       = true
  
        features          = [ "Octopus.Features.SubstituteInFiles" ]
        script_source     = "Inline"
        script_syntax     = "PowerShell"
        script_body       = <<-EOT
                                function Slack-Rich-Notification ($notification)
                                {
                                    # ...
                                };
                            EOT
      }
    }
  }
  1. During the plan everything seems fine:
    ...
      
    + features                           = [
                  + "Octopus.Features.SubstituteInFiles",
                ]
      
    ...     

    + run_on_server                      = true

    ...
  1. Verifying created configuration on Octopus Deploy, Executed Location is set to Run on each deployment (most likely default false for run_on_server) instead of octopus deploy server
    image
  2. Comparing this step creation when done manually vs through terraform the json configuration stored in octopus deploy sql server we see that manual creation stores this in lowercase, while through terraform it is capitalized:

image

Also seems the case for other Octopus.Action.* boolean properties:

image

But not for values outside of the Octopus.Action.* properties scope, for instance the run_script_action.is_required property :

image

Expected behavior
When I set the run_script_action.run_on_server property, through terraform, I expect same behaviour when creating this step manually, so the value for Octopus.Action.RunOnServer in the JSON configuration should be stored in lower case and other Octopus.Action.* booleans as well.

Logs and other supporting information
During the initial creation, the tf plan doesn't show any wrong signs, however, when changing configure for instance for run_on_server from true to false we can see that the value is stored capitalized as well:

- "Octopus.Action.RunOnServer" = "True" -> null

Screenshots
Already included in previous parts

Environment and versions:

  • OS: [ Windows Server 2022 ]
  • Octopus Server Version: [v2023.2 (Build 12643)]
  • Terraform Version: [1.3.5]
  • Octopus Terraform Provider Version: [0.12.4]
@mjhilton mjhilton added kind/bug Something isn't working area/deployment-processes category/dev-experience Issues about the dev experience of using the provider, writing correct HCL etc labels Sep 20, 2024
@mjhilton
Copy link
Contributor

I need to do a little more testing, but I'm not 100% sure that the capitalisation of the value is what's causing the symptoms you're seeing here.

For a fresh self-hosted Octopus Server instance with no other configuration done to it, the "Run on Server" option is available. However, as soon as you configure a Worker Pool for the instance (or, if you're running on Octopus Cloud, where we provide Worker Pools for you), the "Run on Server" option changes to "Run on a Worker", and an associated "Worker Pool" needs to be selected.

I suspect that this is what's happening in the example here: the instance is either on Octopus Cloud, or self-hosted with a Worker Pool configured, and thus just "Run on Server" isn't valid on its own.

To fix this, you need to also specify a worker_pool_id against the step. Once you've done that, the settings will stick, and you'll see that the run_on_server value in the Step's JSON ends up as true rather than True.

This is a fairly terrible experience if you're trying to write Terraform for this and don't know the intricacies of Run on Server vs Run on Worker, and very difficult to know what's gone wrong. I'd like us to fix this experience, or at least the discoverability of information about why this is happening and how to work around it.

@edgarschaap-omnia: I know this was over a year ago now, but I wonder if you're able to confirm whether the Octopus Instance you were using was a Cloud instance, or if it was self-hosted but had Worker Pools defined?

@mjhilton mjhilton added the kind/question Further information is requested label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deployment-processes category/dev-experience Issues about the dev experience of using the provider, writing correct HCL etc kind/bug Something isn't working kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants