Skip to content
Snippets Groups Projects
Commit bedd65c6 authored by Ravi Tripathi's avatar Ravi Tripathi
Browse files

Merge branch 'feat-add-ansible-prov-OOD2x' into 'main'

Build packer image for OOD 2.x

See merge request rc/packer-openstack-hpc-image!5
parents a59779c7 4d29ba7e
No related branches found
No related tags found
No related merge requests found
...@@ -12,3 +12,17 @@ security_groups = ["allow ssh"] ...@@ -12,3 +12,17 @@ security_groups = ["allow ssh"]
image_date_suffix = false image_date_suffix = false
# Set to a public key that will be added as a root ssh key # Set to a public key that will be added as a root ssh key
root_ssh_key = "ecdsa-sha2-nistp256 AAAAyourkeyhere comment string here" root_ssh_key = "ecdsa-sha2-nistp256 AAAAyourkeyhere comment string here"
# Create image at the end of build. Set to true during a build test stage
skip_create_image = false
# Project/tenants to share the image with
image_membership = []
# Auto accept image on behalf of members. Need privileges both in build project and members provided
auto_accept_members = false
# Tags for the resulting image.
image_tags = []
# The username to connect to SSH with. Used by Packer build section
ssh_username = "centos"
# Key that will be used for SSH with the machine. Must match key pair name loaded up into the remote.
ssh_keypair_name = ""
# Path to the private key file to use to authenticate with SSH.
ssh_private_key_file = ""
...@@ -3,15 +3,23 @@ locals { ...@@ -3,15 +3,23 @@ locals {
} }
source "openstack" "image" { source "openstack" "image" {
skip_create_image = var.skip_create_image
image_name = local.local_image_name image_name = local.local_image_name
source_image_name = var.source_image source_image_name = var.source_image
image_members = var.image_membership
image_auto_accept_members = var.auto_accept_members
image_tags = var.image_tags
flavor = var.flavor flavor = var.flavor
instance_name = var.build_instance_name
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
ssh_keypair_name = var.ssh_keypair_name
ssh_private_key_file = var.ssh_private_key_file
} }
build { build {
...@@ -24,4 +32,18 @@ build { ...@@ -24,4 +32,18 @@ build {
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'" "--extra-vars", "root_ssh_key='${var.root_ssh_key}'"
] ]
} }
provisioner "ansible" {
use_proxy = false
ssh_authorized_key_file = "/home/ubuntu/.ssh/id_rsa.pub"
ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"]
playbook_file = "../CRI_XCBC/ood-packer.yaml"
roles_path = "./ansible/roles"
inventory_file = "../CRI_XCBC/hosts"
extra_arguments = [
"--extra-vars", "root_ssh_key='${var.root_ssh_key}'",
"--private-key=${var.ssh_private_key_file}",
"--user=centos",
#"-vvvv"
]
}
} }
...@@ -15,6 +15,30 @@ variable "image_date_suffix" { ...@@ -15,6 +15,30 @@ variable "image_date_suffix" {
description = "Append a date to the image name (in YYYYMMDDHHMMSS format)" description = "Append a date to the image name (in YYYYMMDDHHMMSS format)"
} }
variable "image_tags" {
type = list(string)
default = []
description = "List of tags to be associated to the resulting image"
}
variable "image_membership" {
type = list(string)
default = []
description = "Projects/tenants to share the image in openstack with"
}
variable "auto_accept_members" {
type = bool
default = false
description = "A boolean value for auto accepting image in the projects/tenants defined in image_membership."
}
variable "skip_create_image" {
type = bool
default = false
description = "A boolean value for skipping image creation at the end of the build"
}
variable "source_image" { variable "source_image" {
type = string type = string
description = "The name of the source image to use" description = "The name of the source image to use"
...@@ -25,12 +49,6 @@ variable "flavor" { ...@@ -25,12 +49,6 @@ variable "flavor" {
description = "The name of the flavor to use" description = "The name of the flavor to use"
} }
variable "ssh_username" {
type = string
default = "centos"
description = "The default username to use for SSH"
}
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"
...@@ -46,3 +64,25 @@ variable "security_groups" { ...@@ -46,3 +64,25 @@ variable "security_groups" {
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" {
type = string
default = "ood"
description = "A name of build instance used for image build"
}
variable "ssh_username" {
type = string
default = "centos"
description = "The default username to use for SSH"
}
variable "ssh_keypair_name" {
type = string
description = "SSH keypair to use from OS project"
}
variable "ssh_private_key_file" {
type = string
description = "Private key file"
}
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