Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve_cloudinit_template
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wen Wei Li
pve_cloudinit_template
Commits
17a82324
Commit
17a82324
authored
Apr 23, 2024
by
Wen Wei Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ubuntu18 cloudinti
parent
f7266399
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
README.md
README.md
+2
-2
create-template.sh
create-template.sh
+14
-7
No files found.
README.md
View file @
17a82324
...
...
@@ -2,6 +2,6 @@
### Usage
*
`./create-template.sh {VM_ID}`
*
`./create-template.sh {
Ubuntu Version(18 or 22)}{
VM_ID}`
*
Note that the VM_ID should not be repeated with other template even in other nodes.
\ No newline at end of file
*
Note that the VM_ID should not be repeated with other template even in other nodes.
create-template.sh
View file @
17a82324
...
...
@@ -2,7 +2,7 @@
# get the cloudinit ubuntu 22.04 img
ubuntu_22
=
"https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img"
ubuntu_18
=
"https://cloud-images.ubuntu.com/minimal/releases/bionic/release
-20230602
/ubuntu-18.04-minimal-cloudimg-amd64.img"
ubuntu_18
=
"https://cloud-images.ubuntu.com/minimal/releases/bionic/release/ubuntu-18.04-minimal-cloudimg-amd64.img"
if
[[
$1
==
'18'
]]
;
then
echo
$ubuntu_18
eval
"wget
$ubuntu_18
"
...
...
@@ -10,20 +10,26 @@ if [[ $1 == '18' ]]; then
elif
[[
$1
==
'22'
]]
;
then
eval
"wget
$ubuntu_22
"
mv
ubuntu-22.04-minimal-cloudimg-amd64.img ubuntu.img
else
echo
"No such version support"
return
1
fi
# Install libguestfs-tools on Proxmox server.
#
apt-get install libguestfs-tools -y
apt-get
install
libguestfs-tools
-y
# Install qemu-guest-agent on Ubuntu image.
#
virt-customize -a ubuntu.img --install qemu-guest-agent
virt-customize
-a
ubuntu.img
--install
qemu-guest-agent
# to let vm will not get same ip address if using dhcp
#
virt-customize -a ubuntu.img --run-command "echo -n > /etc/machine-id"
virt-customize
-a
ubuntu.img
--run-command
"echo -n > /etc/machine-id"
export
STORAGE_POOL
=
local-lvm
export
VM_ID
=
$1
export
VM_NAME
=
ubuntu-22.04-cloudinit
export
VM_ID
=
$2
if
[[
$1
==
'18'
]]
;
then
export
VM_NAME
=
'ubuntu-18.04-cloudinit'
elif
[[
$1
==
'22'
]]
;
then
export
VM_NAME
=
'ubuntu-22.04-cloudinit'
fi
# Create Proxmox VM image from Ubuntu Cloud Image.
qm create
$VM_ID
--name
$VM_NAME
--memory
2048
--cores
2
--net0
virtio,bridge
=
vmbr0
qm importdisk
$VM_ID
ubuntu.img
$STORAGE_POOL
...
...
@@ -34,3 +40,4 @@ qm set $VM_ID --boot c --bootdisk scsi0
qm
set
$VM_ID
--serial0
socket
--vga
serial0
qm
set
$VM_ID
--agent
enabled
=
1
qm template
$VM_ID
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment