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

Feature Request: Batch Pool Start Task #2458

Closed
MHHenriksen opened this issue Dec 5, 2018 · 4 comments
Closed

Feature Request: Batch Pool Start Task #2458

MHHenriksen opened this issue Dec 5, 2018 · 4 comments

Comments

@MHHenriksen
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Building on #2427, please add support for configuring a start task for a pool.

New or Affected Resource(s)

  • azurerm_batch_pool
  • New data source: azurerm_batch_auto_user

Potential Terraform Configuration

I'm a Terraform rookie, so take this suggestion with a pound of salt.

# Configure the Microsoft Azure Provider
provider "azurerm" {
  # if you're using a Service Principal (shared account) then either set the environment variables, or fill these in:  # subscription_id = "..."  # client_id       = "..."  # client_secret   = "..."  # tenant_id       = "..."
}
 
resource "azurerm_resource_group" "rg" {
  name     = "${var.resource_group_name}"
  location = "${var.location}"
}
 
resource "random_integer" "ri" {
  min = 10000
  max = 99999
}
 
resource "azurerm_storage_account" "stor" {
  name                     = "stor${random_integer.ri.result}"
  resource_group_name      = "${azurerm_resource_group.rg.name}"
  location                 = "${azurerm_resource_group.rg.location}"
  account_tier             = "${var.storage_account_tier}"
  account_replication_type = "${var.storage_replication_type}"
}

resource "azurerm_batch_account" "batch" {
  name                     = "batch${random_integer.ri.result}"
  resource_group_name      = "${azurerm_resource_group.rg.name}"
  location                 = "${azurerm_resource_group.rg.location}"
  storage_account_name     = "${azurerm_storage_account.stor.name}"
}

data "azurerm_batch_auto_user" "pool_admin"
{
    scope = "pool" # or job
    elevated = true
}

resource "azurerm_batch_pool" "pool" {
  id                    = "pool${random_integer.ri.result}"
  vm_size               = "${var.batch_pool_nodes_vm_size}"
  target_dedicated_node = "${var.batch_pool_nodes_count}"
  vm_image              = "${var.batch_pool_nodes_vm_image}"
  node_agent_sku_id     = "${var.batch.pool_nodes_agent_sku_id}"
  start_task {
      command_line         = "/bin/bash -c 'apt-get -y update && apt-get -y install cowsay && cowsay Hello, $person!'"
      user_identity        = "${data.azurerm_batch_auto_user.pool_admin}"
      max_task_retry_count = 1
      environment {
          person = "World"
      }
  }
}

References

@jcorioland
Copy link
Contributor

@MHHenriksen @katbyte - will look at this now that Batch pool feature (#2461) is implemented.

@stuartleeks
Copy link
Contributor

@MHHenriksen - it looks like @jcorioland has implemented the start_task: https://www.terraform.io/docs/providers/azurerm/d/batch_pool.html#start_task

Does that do what you need?

@MHHenriksen
Copy link
Author

Yeah, looks good! We'll let you know if it breaks via new issues.

@ghost
Copy link

ghost commented Apr 20, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants