Skip to content
Snippets Groups Projects
Commit 22e82b13 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Format template files

parent 137f3943
No related branches found
No related tags found
1 merge request!1Update ravi89 main
locals { locals {
local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()): ""}" local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()) : ""}"
} }
source "openstack" "image" { source "openstack" "image" {
skip_create_image = var.skip_create_image skip_create_image = var.skip_create_image
image_name = local.local_image_name image_name = local.local_image_name
source_image = var.source_image source_image = var.source_image
image_members = var.image_membership image_members = var.image_membership
image_auto_accept_members = var.auto_accept_members image_auto_accept_members = var.auto_accept_members
image_tags = var.image_tags image_tags = var.image_tags
image_disk_format = var.image_format image_disk_format = var.image_format
volume_size = 10 volume_size = 10
flavor = var.flavor flavor = var.flavor
instance_name = var.build_instance_name instance_name = var.build_instance_name
use_blockstorage_volume = true
use_blockstorage_volume = true floating_ip_network = var.floating_ip_network
floating_ip_network = var.floating_ip_network networks = var.networks
networks = var.networks security_groups = var.security_groups
security_groups = var.security_groups ssh_username = var.ssh_username
ssh_username = var.ssh_username
} }
build { build {
sources = ["source.openstack.image"] sources = ["source.openstack.image"]
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["compute"] groups = ["compute"]
playbook_file = "./ansible/compute.yml" playbook_file = "./ansible/compute.yml"
roles_path = "./ansible/roles" roles_path = "./ansible/roles"
extra_arguments = [ extra_arguments = [
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'" "--extra-vars", "root_ssh_key='${var.root_ssh_key}'"
] ]
} }
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["compute"] groups = ["compute"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
playbook_file = "./CRI_XCBC/compute-packer.yaml" playbook_file = "./CRI_XCBC/compute-packer.yaml"
} }
} }
variable "root_ssh_key" { variable "root_ssh_key" {
type = string type = string
description = "The root key to use for ssh" description = "The root key to use for ssh"
} }
...@@ -40,8 +40,8 @@ variable "auto_accept_members" { ...@@ -40,8 +40,8 @@ variable "auto_accept_members" {
} }
variable "skip_create_image" { variable "skip_create_image" {
type = bool type = bool
default = false default = false
description = "A boolean value for skipping image creation at the end of the build" description = "A boolean value for skipping image creation at the end of the build"
} }
...@@ -56,29 +56,29 @@ variable "flavor" { ...@@ -56,29 +56,29 @@ variable "flavor" {
} }
variable "floating_ip_network" { variable "floating_ip_network" {
type = string type = string
description = "floating ip network to use with (temporary) ip assignmnet to a vm" description = "floating ip network to use with (temporary) ip assignmnet to a vm"
} }
variable "networks" { variable "networks" {
type = list(string) type = list(string)
description = "List of network UUIDs to assign to the network" description = "List of network UUIDs to assign to the network"
} }
variable "security_groups" { variable "security_groups" {
type = list(string) type = list(string)
default = [] default = []
description = "A list of security groups to add - you should make sure ssh access is open to the machine" description = "A list of security groups to add - you should make sure ssh access is open to the machine"
} }
variable "build_instance_name" { variable "build_instance_name" {
type = string type = string
default = "compute" default = "compute"
description = "A name of build instance used for image build" description = "A name of build instance used for image build"
} }
variable "ssh_username" { variable "ssh_username" {
type = string type = string
default = "centos" default = "centos"
description = "The default username to use for SSH" description = "The default username to use for SSH"
} }
locals { locals {
local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()): ""}" local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("YYYYMMDDHHmm", timestamp()) : ""}"
} }
source "openstack" "image" { source "openstack" "image" {
skip_create_image = var.skip_create_image skip_create_image = var.skip_create_image
image_name = local.local_image_name image_name = local.local_image_name
source_image = var.source_image source_image = var.source_image
image_members = var.image_membership image_members = var.image_membership
image_auto_accept_members = var.auto_accept_members image_auto_accept_members = var.auto_accept_members
image_tags = var.image_tags image_tags = var.image_tags
image_disk_format = var.image_format image_disk_format = var.image_format
volume_size = 10 volume_size = 10
flavor = var.flavor flavor = var.flavor
instance_name = var.build_instance_name instance_name = var.build_instance_name
use_blockstorage_volume = true
use_blockstorage_volume = true floating_ip_network = var.floating_ip_network
floating_ip_network = var.floating_ip_network networks = var.networks
networks = var.networks security_groups = var.security_groups
security_groups = var.security_groups ssh_username = var.ssh_username
ssh_username = var.ssh_username
} }
# regular instance
build { build {
sources = ["source.openstack.image"] sources = ["source.openstack.image"]
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["gpu"] groups = ["gpu"]
playbook_file = "./ansible/gpu.yml" playbook_file = "./ansible/gpu.yml"
roles_path = "./ansible/roles" roles_path = "./ansible/roles"
extra_arguments = [ extra_arguments = [
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'" "--extra-vars", "root_ssh_key='${var.root_ssh_key}'"
] ]
} }
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["compute"] groups = ["compute"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
playbook_file = "./CRI_XCBC/compute-packer.yaml" playbook_file = "./CRI_XCBC/compute-packer.yaml"
} }
} }
variable "root_ssh_key" { variable "root_ssh_key" {
type = string type = string
description = "The root key to use for ssh" description = "The root key to use for ssh"
} }
...@@ -40,8 +40,8 @@ variable "auto_accept_members" { ...@@ -40,8 +40,8 @@ variable "auto_accept_members" {
} }
variable "skip_create_image" { variable "skip_create_image" {
type = bool type = bool
default = false default = false
description = "A boolean value for skipping image creation at the end of the build" description = "A boolean value for skipping image creation at the end of the build"
} }
...@@ -56,29 +56,29 @@ variable "flavor" { ...@@ -56,29 +56,29 @@ variable "flavor" {
} }
variable "floating_ip_network" { variable "floating_ip_network" {
type = string type = string
description = "floating ip network to use with (temporary) ip assignmnet to a vm" description = "floating ip network to use with (temporary) ip assignmnet to a vm"
} }
variable "networks" { variable "networks" {
type = list(string) type = list(string)
description = "List of network UUIDs to assign to the network" description = "List of network UUIDs to assign to the network"
} }
variable "security_groups" { variable "security_groups" {
type = list(string) type = list(string)
default = [] default = []
description = "A list of security groups to add - you should make sure ssh access is open to the machine" description = "A list of security groups to add - you should make sure ssh access is open to the machine"
} }
variable "build_instance_name" { variable "build_instance_name" {
type = string type = string
default = "gpu" default = "gpu"
description = "A name of build instance used for image build" description = "A name of build instance used for image build"
} }
variable "ssh_username" { variable "ssh_username" {
type = string type = string
default = "centos" default = "centos"
description = "The default username to use for SSH" description = "The default username to use for SSH"
} }
locals { locals {
local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()): ""}" local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()) : ""}"
} }
source "openstack" "image" { source "openstack" "image" {
skip_create_image = var.skip_create_image skip_create_image = var.skip_create_image
image_name = local.local_image_name image_name = local.local_image_name
source_image = var.source_image source_image = var.source_image
image_members = var.image_membership image_members = var.image_membership
image_auto_accept_members = var.auto_accept_members image_auto_accept_members = var.auto_accept_members
image_tags = var.image_tags image_tags = var.image_tags
image_disk_format = var.image_format image_disk_format = var.image_format
volume_size = 10 volume_size = 10
flavor = var.flavor flavor = var.flavor
instance_name = var.build_instance_name instance_name = var.build_instance_name
use_blockstorage_volume = true
use_blockstorage_volume = true floating_ip_network = var.floating_ip_network
floating_ip_network = var.floating_ip_network networks = var.networks
networks = var.networks security_groups = var.security_groups
security_groups = var.security_groups ssh_username = var.ssh_username
ssh_username = var.ssh_username
} }
build { build {
sources = ["source.openstack.image"] sources = ["source.openstack.image"]
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["ood"] groups = ["ood"]
playbook_file = "./ansible/ood.yml" playbook_file = "./ansible/ood.yml"
roles_path = "./ansible/roles" roles_path = "./ansible/roles"
extra_arguments = [ extra_arguments = [
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'" "--extra-vars", "root_ssh_key='${var.root_ssh_key}'"
] ]
} }
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["ood", "knightly"] groups = ["ood", "knightly"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
playbook_file = "./CRI_XCBC/ood-packer.yaml" playbook_file = "./CRI_XCBC/ood-packer.yaml"
} }
} }
variable "root_ssh_key" { variable "root_ssh_key" {
type = string type = string
description = "The root key to use for ssh" description = "The root key to use for ssh"
} }
...@@ -40,8 +40,8 @@ variable "auto_accept_members" { ...@@ -40,8 +40,8 @@ variable "auto_accept_members" {
} }
variable "skip_create_image" { variable "skip_create_image" {
type = bool type = bool
default = false default = false
description = "A boolean value for skipping image creation at the end of the build" description = "A boolean value for skipping image creation at the end of the build"
} }
...@@ -56,29 +56,29 @@ variable "flavor" { ...@@ -56,29 +56,29 @@ variable "flavor" {
} }
variable "floating_ip_network" { variable "floating_ip_network" {
type = string type = string
description = "floating ip network to use with (temporary) ip assignmnet to a vm" description = "floating ip network to use with (temporary) ip assignmnet to a vm"
} }
variable "networks" { variable "networks" {
type = list(string) type = list(string)
description = "List of network UUIDs to assign to the network" description = "List of network UUIDs to assign to the network"
} }
variable "security_groups" { variable "security_groups" {
type = list(string) type = list(string)
default = [] default = []
description = "A list of security groups to add - you should make sure ssh access is open to the machine" description = "A list of security groups to add - you should make sure ssh access is open to the machine"
} }
variable "build_instance_name" { variable "build_instance_name" {
type = string type = string
default = "ood" default = "ood"
description = "A name of build instance used for image build" description = "A name of build instance used for image build"
} }
variable "ssh_username" { variable "ssh_username" {
type = string type = string
default = "centos" default = "centos"
description = "The default username to use for SSH" description = "The default username to use for SSH"
} }
locals { locals {
local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()): ""}" local_image_name = "${var.image_name}${var.image_date_suffix ? formatdate("-YYYYMMDDHHmm", timestamp()) : ""}"
} }
source "openstack" "image" { source "openstack" "image" {
skip_create_image = var.skip_create_image skip_create_image = var.skip_create_image
image_name = local.local_image_name image_name = local.local_image_name
source_image = var.source_image source_image = var.source_image
image_members = var.image_membership image_members = var.image_membership
image_auto_accept_members = var.auto_accept_members image_auto_accept_members = var.auto_accept_members
image_tags = var.image_tags image_tags = var.image_tags
image_disk_format = var.image_format image_disk_format = var.image_format
volume_size = 10 volume_size = 10
flavor = var.flavor flavor = var.flavor
instance_name = var.build_instance_name instance_name = var.build_instance_name
use_blockstorage_volume = true
use_blockstorage_volume = true floating_ip_network = var.floating_ip_network
floating_ip_network = var.floating_ip_network networks = var.networks
networks = var.networks security_groups = var.security_groups
security_groups = var.security_groups ssh_username = var.ssh_username
ssh_username = var.ssh_username
} }
build { build {
sources = ["source.openstack.image"] sources = ["source.openstack.image"]
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["base"] groups = ["base"]
playbook_file = "./ansible/base.yml" playbook_file = "./ansible/base.yml"
roles_path = "./ansible/roles" roles_path = "./ansible/roles"
extra_arguments = [ extra_arguments = [
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'" "--extra-vars", "root_ssh_key='${var.root_ssh_key}'"
] ]
} }
provisioner "ansible" { provisioner "ansible" {
user = var.ssh_username user = var.ssh_username
groups = ["base"] groups = ["base"]
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
playbook_file = "./CRI_XCBC/compute-packer.yaml" playbook_file = "./CRI_XCBC/compute-packer.yaml"
} }
} }
variable "root_ssh_key" { variable "root_ssh_key" {
type = string type = string
description = "The root key to use for ssh" description = "The root key to use for ssh"
} }
...@@ -40,8 +40,8 @@ variable "auto_accept_members" { ...@@ -40,8 +40,8 @@ variable "auto_accept_members" {
} }
variable "skip_create_image" { variable "skip_create_image" {
type = bool type = bool
default = false default = false
description = "A boolean value for skipping image creation at the end of the build" description = "A boolean value for skipping image creation at the end of the build"
} }
...@@ -56,29 +56,29 @@ variable "flavor" { ...@@ -56,29 +56,29 @@ variable "flavor" {
} }
variable "floating_ip_network" { variable "floating_ip_network" {
type = string type = string
description = "floating ip network to use with (temporary) ip assignmnet to a vm" description = "floating ip network to use with (temporary) ip assignmnet to a vm"
} }
variable "networks" { variable "networks" {
type = list(string) type = list(string)
description = "List of network UUIDs to assign to the network" description = "List of network UUIDs to assign to the network"
} }
variable "security_groups" { variable "security_groups" {
type = list(string) type = list(string)
default = [] default = []
description = "A list of security groups to add - you should make sure ssh access is open to the machine" description = "A list of security groups to add - you should make sure ssh access is open to the machine"
} }
variable "build_instance_name" { variable "build_instance_name" {
type = string type = string
default = "base" default = "base"
description = "A name of build instance used for image build" description = "A name of build instance used for image build"
} }
variable "ssh_username" { variable "ssh_username" {
type = string type = string
default = "centos" default = "centos"
description = "The default username to use for SSH" description = "The default username to use for SSH"
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment