Compare commits
1 Commits
fc20a3a6e1
...
6c87255360
Author | SHA1 | Date |
---|---|---|
wpetit | 6c87255360 |
|
@ -16,4 +16,5 @@ locals {
|
|||
ssh_password = "toor"
|
||||
disk_size = 8000
|
||||
memory = 512
|
||||
headless = var.headless
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ echo "${1}" >/etc/hostname
|
|||
|
||||
apt-get update
|
||||
apt-get -y dist-upgrade
|
||||
apt-get install wget curl -y
|
||||
apt-get install wget curl open-vm-tools -y
|
||||
|
||||
systemctl enable --now open-vm-tools.service
|
||||
|
||||
touch /etc/cloud/cloud-init.disabled
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: Ciblage de la machine locale
|
||||
hosts: localhost
|
||||
connection: local
|
||||
tasks:
|
||||
- name: Clonage du projet "EFS/quid-ansible"
|
||||
ansible.builtin.git:
|
||||
repo: "ssh://git@forge.cadoles.com:2222/EFS/quid-ansible.git"
|
||||
dest: "quid-ansible"
|
||||
version: "master"
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- import_playbook: quid-ansible/deploy.yml
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Clone repository if necessary
|
||||
if [ ! -d "${REPO_DEST}" ]; then
|
||||
git clone "${REPO_URL}" "${REPO_DEST}"
|
||||
fi
|
||||
|
||||
cd "${REPO_DEST}"
|
||||
|
||||
# Update local repository
|
||||
git fetch
|
||||
|
||||
# Checkout repository ref
|
||||
git checkout ${REPO_REF}
|
|
@ -4,41 +4,13 @@ build {
|
|||
description = <<EOF
|
||||
This builder builds a QEMU image from a Debian cloud image.
|
||||
EOF
|
||||
|
||||
source "vmware-iso.debian" {
|
||||
source "vmware-vmx.debian" {
|
||||
output_directory = "${var.output_dir}/${var.version}/quid"
|
||||
vm_name = "quid-${local.output_name}-${var.version}"
|
||||
disk_size = 10240
|
||||
iso_url = "${local.source_iso}"
|
||||
iso_checksum = "${var.iso_cd_checksum}"
|
||||
guest_os_type = "ubuntu-64"
|
||||
ssh_password = "quid"
|
||||
http_content = {
|
||||
"/ssh-packer-pub.key" = data.sshkey.install.public_key
|
||||
"/preseed.cfg" = templatefile("${local.locations.provisionning}/${var.name}/http/preseed.cfg.pkrtpl.hcl", { data: data, var: var, local: local })
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<enter><wait10s>",
|
||||
"<enter>"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "shell-local" {
|
||||
script = "${local.locations.provisionning}/quid/update-playbook.sh"
|
||||
env = {
|
||||
"REPO_DEST": "${local.locations.provisionning}/quid/quid-ansible",
|
||||
"REPO_URL": "ssh://git@forge.cadoles.com:2222/EFS/quid-ansible.git",
|
||||
"REPO_REF": "master"
|
||||
}
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
script = "${local.locations.provisionning}/${var.name}/${var.name}-${var.short_version}-install.sh"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
script = "${local.locations.provisionning}/letsencrypt.sh"
|
||||
source_path = "${var.output_dir}/${var.version}/base/${local.output_name}-${var.version}.vmx"
|
||||
boot_command = [ "<enter><enter><wait>" ]
|
||||
ssh_clear_authorized_keys = true
|
||||
disk_additional_size = [ 102400 ]
|
||||
}
|
||||
|
||||
// Store temporarily ansible vault password in local file
|
||||
|
@ -46,8 +18,17 @@ EOF
|
|||
inline = ["echo '${var.quid_ansible_vault_passphrase}' > '${local.locations.provisionning}/quid/.ansible_vault_passphrase'"]
|
||||
}
|
||||
|
||||
// Clone quid-ansible repository
|
||||
provisioner "ansible" {
|
||||
playbook_file = "${local.locations.provisionning}/quid/quid-ansible/deploy.yml"
|
||||
playbook_file = "${local.locations.provisionning}/quid/clone-quid-ansible.yml"
|
||||
// Manjaro/Arch OpenSSH version compatibility mode
|
||||
// See https://github.com/hashicorp/packer/issues/11783
|
||||
extra_arguments = [ "--scp-extra-args", "'-O'", "-v" ]
|
||||
}
|
||||
|
||||
// Run quid-ansible playbook from cloned repository
|
||||
provisioner "ansible" {
|
||||
playbook_file = "${local.locations.provisionning}/quid/run-quid-ansible.yml"
|
||||
groups = ["quid_server"]
|
||||
// Manjaro/Arch OpenSSH version compatibility mode
|
||||
// See https://github.com/hashicorp/packer/issues/11783
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
2. Lancer la construction de l'image de la machine virtuelle
|
||||
|
||||
```
|
||||
BUILDER="vmware-iso" QUID_ANSIBLE_VAULT_PASSPHRASE="<passphrase>" ./build start debian 12
|
||||
QUID_ANSIBLE_VAULT_PASSPHRASE="<passphrase>" PACKER_OPTS="-var headless=false" ./build start debian 12
|
||||
```
|
||||
|
||||
> **Tip** Le paramètre `PACKER_OPTS="-var headless=false"` n'est nécessaire que dans le cas où vous souhaitez l'exécuteur VMWare avec son interface graphique.
|
||||
|
||||
## Générer le fichier OVF à partir de l'OVA
|
||||
|
||||
```
|
||||
|
|
|
@ -4,7 +4,7 @@ source qemu "debian" {
|
|||
accelerator = "kvm"
|
||||
vnc_bind_address = "0.0.0.0"
|
||||
|
||||
headless = false
|
||||
headless = local.headless
|
||||
|
||||
# Serve the `http` directory via HTTP, used for preseeding the Debian installer.
|
||||
#http_directory = "${path.cwd}/recipes/${var.name}/provisionning/${var.name}/http"
|
||||
|
@ -39,7 +39,7 @@ source "vmware-iso" "debian" {
|
|||
memory = "${local.memory}"
|
||||
vnc_bind_address = "0.0.0.0"
|
||||
|
||||
headless = false
|
||||
headless = local.headless
|
||||
|
||||
# Serve the `http` directory via HTTP, used for preseeding the Debian installer.
|
||||
#http_directory = "${path.cwd}/recipes/${var.name}/provisionning/${var.name}/http"
|
||||
|
@ -71,7 +71,7 @@ source "vmware-iso" "debian" {
|
|||
source "vmware-vmx" "debian" {
|
||||
vnc_bind_address = "0.0.0.0"
|
||||
|
||||
headless = false
|
||||
headless = local.headless
|
||||
|
||||
# Serve the `http` directory via HTTP, used for preseeding the Debian installer.
|
||||
#http_directory = "${path.cwd}/recipes/${var.name}/provisionning/${var.name}/http"
|
||||
|
|
|
@ -57,3 +57,8 @@ variable "cloud_init_runcmd" {
|
|||
type = list(string)
|
||||
default = [ "uname" ]
|
||||
}
|
||||
|
||||
variable "headless" {
|
||||
type = bool
|
||||
default = true
|
||||
}
|
Loading…
Reference in New Issue