Commit ef1f5a91 authored by Rafael Monnerat's avatar Rafael Monnerat

packer: Allow pass tokens and names via command line to auto-configure the VM

  This will generate an image for a ready to use and configured node on SlapOS Node
parent 53a01dd4
......@@ -5,7 +5,10 @@
"domain": "",
"disk_size": "6",
"name": "image",
"custom_script": "scripts/empty.sh"
"custom_script": "scripts/empty.sh",
"re6st_token": "{{env `RE6STTOKEN`}}",
"computer_token": "{{env `COMPUTERTOKEN`}}"
"computer_name": "{{env `COMPUTERNAME`}}"
},
"builders":
......@@ -55,6 +58,7 @@
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"environment_vars": ["re6st_token={{ user `re6st_token` }}", "computer_name={{user `computer_name`}}", "computer_token={{ user `computer_token` }}"],
"scripts": [
"scripts/update.sh",
"scripts/packages.sh",
......
......@@ -12,4 +12,15 @@ pip2 install --exists-action=i requests
pip2 install --exists-action=i slapcache
wget http://deploy.erp5.net/vifib-base -O /root/run-vifib-base
RE6STTOKEN=$re6st_token
COMPUTERTOKEN=$computer_token
COMPUTERNAME=$computer_name
bash /root/run-vifib-base
re6st-conf --registry http://re6stnet.gnet.erp5.cn/ --token $RE6STTOKEN -r title $RE6STTOKEN -d /etc/re6stnet
slapos node register --token $COMPUTERTOKEN --interface-name lo $COMPUTERNAME
# Re-run after the register to finish up the configuration
bash /root/run-vifib-base
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment