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

Add a variable to trigger different software stacks #124

Merged
merged 6 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
cmd-ntrf marked this conversation as resolved.
Show resolved Hide resolved
"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')"
}