Skip to content

Commit

Permalink
Add a variable to trigger different software stacks (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocaisa committed Nov 25, 2020
1 parent 5dace7e commit d226900
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cloud-init/puppetmaster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ runcmd:
- git clone ${puppetenv_git} /etc/puppetlabs/code/environments/production
- "(cd /etc/puppetlabs/code/environments/production; git checkout ${puppetenv_rev})"
- mkdir -p /etc/puppetlabs/data
- mkdir -p /etc/puppetlabs/facts
- chgrp -R puppet /etc/puppetlabs/data
- chgrp -R puppet /etc/puppetlabs/facts
- ln -sf /etc/puppetlabs/data/terraform_data.yaml /etc/puppetlabs/code/environments/production/data/
- ln -sf /etc/puppetlabs/data/user_data.yaml /etc/puppetlabs/code/environments/production/data/
- ln -sf /etc/puppetlabs/facts/terraform_facts.yaml /etc/puppetlabs/code/environments/production/site/profile/facts.d
- /opt/puppetlabs/puppet/bin/gem install librarian-puppet
- "(cd /etc/puppetlabs/code/environments/production/ && HOME=/root PATH=$PATH:/opt/puppetlabs/puppet/bin /opt/puppetlabs/puppet/bin/librarian-puppet install)"
# Bootstrap services that are essential to puppet agents
Expand Down
27 changes: 25 additions & 2 deletions common/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ data "template_file" "hieradata" {
}
}

data "http" "facts_template" {
url = "${replace(var.puppetenv_git, ".git", "")}/raw/${var.puppetenv_rev}/site/profile/facts.d/terraform_facts.yaml.tmpl"
}

data "template_file" "facts" {
template = data.http.facts_template.body

vars = {
software_stack = var.software_stack
}
}

data "template_cloudinit_config" "mgmt_config" {
count = var.instances["mgmt"]["count"]
part {
Expand Down Expand Up @@ -167,6 +179,7 @@ resource "null_resource" "deploy_hieradata" {
triggers = {
user_data = md5(var.hieradata)
hieradata = md5(data.template_file.hieradata.rendered)
facts = md5(data.template_file.facts.rendered)
puppetmaster = local.puppetmaster_id
}

Expand All @@ -175,6 +188,11 @@ resource "null_resource" "deploy_hieradata" {
destination = "terraform_data.yaml"
}

provisioner "file" {
content = data.template_file.facts.rendered
destination = "terraform_facts.yaml"
}

provisioner "file" {
content = var.hieradata
destination = "user_data.yaml"
Expand All @@ -183,9 +201,14 @@ resource "null_resource" "deploy_hieradata" {
provisioner "remote-exec" {
inline = [
"sudo mkdir -p /etc/puppetlabs/data",
"sudo mkdir -p /etc/puppetlabs/facts",
"sudo install -m 650 terraform_data.yaml user_data.yaml /etc/puppetlabs/data/",
"sudo install -m 650 terraform_facts.yaml /etc/puppetlabs/facts/",
# These chgrp commands do nothing if the puppet group does not yet exist
# so these are also handled by puppetmaster.yaml
"sudo chgrp puppet /etc/puppetlabs/data/terraform_data.yaml /etc/puppetlabs/data/user_data.yaml &> /dev/null || true",
"rm -f terraform_data.yaml user_data.yaml"
"sudo chgrp puppet /etc/puppetlabs/facts/terraform_facts.yaml &> /dev/null || true",
"rm -f terraform_data.yaml user_data.yaml terraform_facts.yaml",
]
}
}
}
8 changes: 7 additions & 1 deletion common/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,10 @@ variable "generate_ssh_key" {
type = bool
default = false
description = "If set to true, Terraform will generate an ssh keypair to connect to the cluster. Default: false"
}
}

variable "software_stack" {
type = string
default = "computecanada"
description = "Provider of research computing software stack (can be 'computecanada' or 'eessi')"
}
11 changes: 11 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,17 @@ public keys provided in `public_keys`.

**Post Build Modification Effect**: rebuild of all instances at next `terraform apply`.

### 4.15 software_stack (optional)

**default_value**: `computecanada`

Defines the research computing software stack to be provided. The default value `computecanada`
provides the Compute Canada software stack, but Magic Castle also
supports the [EESSI](https://eessi.github.io/docs/) software stack (as an alternative) by setting this
value to `eessi`.

**Post Build Modification Effect**: trigger scp of hieradata files at next `terraform apply`.

## 5. Cloud Specific Configuration

### 5.1 OpenStack and OVH
Expand Down

0 comments on commit d226900

Please sign in to comment.