add aws ami build scripts
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
- name: 'Provision Image'
|
||||||
|
hosts: default
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: echo hello
|
||||||
|
command: echo "Not Valid Ruby Version"
|
||||||
|
|
||||||
|
|
||||||
54
build_ami/datasaker-bastion-packer-ubuntu.pkr.hcl
Normal file
54
build_ami/datasaker-bastion-packer-ubuntu.pkr.hcl
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
packer {
|
||||||
|
required_plugins {
|
||||||
|
amazon = {
|
||||||
|
version = ">= 0.0.2"
|
||||||
|
source = "github.com/hashicorp/amazon"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ami_prefix" {
|
||||||
|
type = string
|
||||||
|
default = "datasaker-bastion-ubuntu2004"
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
source "amazon-ebs" "datasaker-bastion-ubuntu2004" {
|
||||||
|
ami_name = "${var.ami_prefix}-${local.timestamp}"
|
||||||
|
instance_type = "t3.small"
|
||||||
|
region = "ap-northeast-2"
|
||||||
|
source_ami_filter {
|
||||||
|
filters = {
|
||||||
|
image-id = "ami-0ea5eb4b05645aa8a"
|
||||||
|
root-device-type = "ebs"
|
||||||
|
virtualization-type = "hvm"
|
||||||
|
}
|
||||||
|
most_recent = true
|
||||||
|
owners = ["099720109477"]
|
||||||
|
}
|
||||||
|
tags = {
|
||||||
|
source_ami_name = "{{ .SourceAMIName }}"
|
||||||
|
}
|
||||||
|
ssh_username = "ubuntu"
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
name = "datasaker-bastion-packer"
|
||||||
|
sources = [
|
||||||
|
"source.amazon-ebs.datasaker-bastion-ubuntu2004"
|
||||||
|
]
|
||||||
|
|
||||||
|
provisioner "ansible" {
|
||||||
|
playbook_file = "./datasaker-bastion-ansible-install_apt_packages.yaml"
|
||||||
|
extra_arguments = [
|
||||||
|
"--become",
|
||||||
|
]
|
||||||
|
ansible_env_vars = [
|
||||||
|
"ANSIBLE_HOST_KEY_CHECKING=False",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
18
build_ami/datasaker-node-ansible-install_apt_packages.yaml
Normal file
18
build_ami/datasaker-node-ansible-install_apt_packages.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
- name: 'Provision Image'
|
||||||
|
hosts: default
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: echo hello
|
||||||
|
command: echo "Not Valid Ruby Version"
|
||||||
|
|
||||||
|
- name: Update apt repo and cache on all Debian/Ubuntu boxes
|
||||||
|
apt: update_cache=yes cache_valid_time=3600
|
||||||
|
|
||||||
|
- name: Install cifs-utils
|
||||||
|
apt: name=cifs-utils state=latest update_cache=yes
|
||||||
|
|
||||||
|
- name: Install nfs-common
|
||||||
|
apt: name=nfs-common state=latest update_cache=yes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
57
build_ami/datasaker-node-packer-ubuntu.pkr.hcl
Normal file
57
build_ami/datasaker-node-packer-ubuntu.pkr.hcl
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
packer {
|
||||||
|
required_plugins {
|
||||||
|
amazon = {
|
||||||
|
version = ">= 0.0.2"
|
||||||
|
source = "github.com/hashicorp/amazon"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ami_prefix" {
|
||||||
|
type = string
|
||||||
|
default = "datasaker-node-ubuntu2004"
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# source 블록에는 실제 빌드할 이미지에 대한 스펙을 정의
|
||||||
|
source "amazon-ebs" "datasaker-node-ubuntu2004" {
|
||||||
|
ami_name = "${var.ami_prefix}-${local.timestamp}"
|
||||||
|
instance_type = "t3.small"
|
||||||
|
region = "ap-northeast-2"
|
||||||
|
source_ami_filter {
|
||||||
|
filters = {
|
||||||
|
image-id = "ami-0ea5eb4b05645aa8a"
|
||||||
|
root-device-type = "ebs"
|
||||||
|
virtualization-type = "hvm"
|
||||||
|
}
|
||||||
|
most_recent = true
|
||||||
|
owners = ["099720109477"]
|
||||||
|
}
|
||||||
|
tags = {
|
||||||
|
source_ami_name = "{{ .SourceAMIName }}"
|
||||||
|
}
|
||||||
|
ssh_username = "ubuntu"
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
name = "datasaker-packer"
|
||||||
|
sources = [
|
||||||
|
"source.amazon-ebs.datasaker-node-ubuntu2004"
|
||||||
|
]
|
||||||
|
|
||||||
|
provisioner "ansible" {
|
||||||
|
playbook_file = "./datasaker-node-ansible-install_apt_packages.yaml"
|
||||||
|
extra_arguments = [
|
||||||
|
"--become",
|
||||||
|
]
|
||||||
|
ansible_env_vars = [
|
||||||
|
"ANSIBLE_HOST_KEY_CHECKING=False",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user