mariadb-lxc.pkr.hcl (1531B)
1 variable "manifest" { 2 type = string 3 default = "manifest.json" 4 } 5 6 variable "mysql_additional_hosts" { 7 type = string 8 default = "\"127.0.0.1\" \"localhost\" \"localhost\"" 9 } 10 11 variable "mysql_additional_passwords" { 12 type = string 13 default = "\"password1\" \"password2\" \"password3\"" 14 sensitive = true 15 } 16 17 variable "mysql_additional_users" { 18 type = string 19 default = "\"user1\" \"user2\" \"user3\"" 20 } 21 22 variable "mysql_bind" { 23 type = string 24 default = "127.0.0.1" 25 } 26 27 variable "mysql_root_password" { 28 type = string 29 default = "" 30 sensitive = true 31 } 32 33 source "lxc" "mariadb" { 34 config_file = "config/lxc-config" 35 template_name = "download" 36 template_parameters = ["--dist", "Debian_by_maurer", "--release", "Bookworm", "--arch", "armv7l"] 37 } 38 39 build { 40 sources = ["source.lxc.mariadb"] 41 42 provisioner "shell" { 43 script = "scripts/timezone.sh" 44 } 45 46 provisioner "shell" { 47 environment_vars = [ 48 "MYSQL_BIND=${var.mysql_bind}", 49 "MYSQL_ROOT_PASSWORD=${var.mysql_root_password}", 50 "MYSQL_ADDITIONAL_USERS=${var.mysql_additional_users}", 51 "MYSQL_ADDITIONAL_PASSWORDS=${var.mysql_additional_passwords}", 52 "MYSQL_ADDITIONAL_HOSTS=${var.mysql_additional_hosts}" 53 ] 54 script = "scripts/mariadb.sh" 55 } 56 57 #provisioner "shell" { 58 # inline = ["mysql -e \"GRANT ALL PRIVILEGES on db1.* to 'user1'@'localhost';\""] 59 #} 60 61 } 62 63 packer { 64 required_plugins { 65 lxc = { 66 version = ">= 1.0.2" 67 source = "github.com/hashicorp/lxc" 68 } 69 } 70 }