Hey Alvaro,
Thank you for responding here is the builder json contents
{
"builders":
[
{
"type": "qemu",
"qemu_binary": "/usr/libexec/qemu-kvm",
"accelerator": "kvm",
"headless": false,
"qemuargs": [
[ "-m", "6000M" ],
[ "-smp", "cpus=6,maxcpus=6,cores=1" ],
[ "-netdev", "user,hostfwd=tcp::{{ .SSHHostPort }}-:22,id=forward"],
[ "-device", "virtio-net,netdev=forward,id=net0"]
],
"disk_interface": "virtio",
"disk_size": 42000,
"format": "qcow2",
"net_device": "virtio-net",
"iso_url": "/root/Downloads/CentOS-7-x86_64-Minimal-1708.iso",
"iso_checksum": "aae20c8052a55cf179af88d9dd35f1a889cd5773",
"iso_checksum_type": "sha1",
"vm_name": "db-node",
"output_directory": "img-output",
"http_directory": "docroot",
"http_port_min": 10082,
"http_port_max": 10089,
"ssh_host_port_min": 2222,
"ssh_host_port_max": 2229,
"ssh_username": "root",
"ssh_private_key_file": "/root/.ssh/id_rsa-1",
"ssh_port": 22,
"ssh_wait_timeout": "3600s",
"boot_wait": "40s",
"boot_command": [
"<up><wait><tab><wait>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/db-ks.cfg<enter><wait>"
],
"shutdown_command": "shutdown -P now"
}
],
"provisioners": [
{
"type" : "file",
"source" : "ifcfg-eth0",
"destination": "/etc/sysconfig/network-scripts/ifcfg-eth0"
},
{
"type" : "file",
"source" : "/home/packer/privateScripts/importBackup.sh",
"destination": "/importBackup.sh"
},
{
"type" : "file",
"source" : "/home/packer/privateScripts/doSqlBackup.sh",
"destination": "/doSqlBackup.sh"
},
{
"type" : "file",
"source" : "./crontask.txt",
"destination": "/crontask.txt"
},
{
"type": "shell",
"script": "/home/packer/privateScripts/setRoot.sh"
},
{
"type": "shell",
"expect_disconnect": true,
"inline_shebang": "/bin/sh -ex",
"inline": [
"curl -k https://puppetmaster.service.smc:8140/packages/current/install.bash | bash",
"printf
'[Unit]\nAfter=mysqld.service\n\n[Service]\nExecStart=/importBackup.sh\nType=idle\n\n[Install]\nWantedBy=default.target'
> /etc/systemd/system/importBackup.service && chmod 664
/etc/systemd/system/importBackup.service",
"systemctl daemon-reload && systemctl enable importBackup.service",
"echo 'Import will be performed on next system boot ONCE'",
"firewall-cmd --set-default-zone=public",
"firewall-cmd --permanent --zone=public --add-port=5666/tcp",
"firewall-cmd --permanent --zone=public --add-port=5667/tcp",
"firewall-cmd --permanent --zone=public --add-port=3306/tcp",
"firewall-cmd --reload",
"crontab /crontask.txt",
". /importBackup.sh",
"ip link set dev eth0 down && ip link set dev eth0 up",
"echo 'network restart succeeded'"
]
}
],
"post-processors":
[
{
"type": "shell-local",
"inline": [
"mv img-output/* /home/packer/img-container -f && rmdir img-output",
"echo 'successfully moved file\nMaking VM...'",
"virt-install
-n databaseClone --vcpus=1 -r 2048 --os-type=linux
--os-variant=centos7.0 --disk
/home/packer/img-container/db-node,device=disk,bus=virtio -w
bridge=virbr1,model=virtio --vnc --noautoconsole --import &&
echo 'VM created!'",
"echo 'giving system time to safely load up'",
"sleep 1m",
"virsh shutdown databaseClone",
"scp /root/.ssh/id_rsa-1 /root/.ssh/id_rsa-1.pub root@admin:/root/.ssh/",
"ssh
admin \"printf '\n\nHost db2 db2.service.smc 172.31.1.145\nHostname
172.31.1.145\nIdentityFile ~/.ssh/id_rsa-1\nUser root' >>
/root/.ssh/config\""
]
}
]
}
Attached is the output of the build attempt.
The system is mounted to that folder via fstab configuration made in the KickStart file.
If you need anything else let me know.
Tanner Posada
On Wednesday, May 9, 2018 at 9:19:15 AM UTC-7, Alvaro Miranda Aguilera wrote: