-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Debian cloud image for running on Proxmox
- Loading branch information
Showing
10 changed files
with
227 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[proxmox] | ||
192.168.1.20 | ||
|
||
[localhost] | ||
localhost | ||
|
||
[chroot] | ||
/mnt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
- name: Mount/Unmount Cloud Image | ||
connection: local | ||
hosts: localhost | ||
gather_facts: yes | ||
become: True | ||
vars: | ||
cloud_image: "{{ lookup('ansible.builtin.env', 'HOME') }}/Downloads/debian-12-generic-amd64-daily-20231117-1567.qcow2" | ||
mount_point: "/mnt" | ||
mount_device: "/dev/nbd0" | ||
tasks: | ||
- name: Load NBD Module | ||
community.general.modprobe: | ||
name: "nbd" | ||
params: "max_part=2" | ||
state: present | ||
tags: | ||
- mount | ||
|
||
- name: Connect Cloud Image Using NBD | ||
ansible.builtin.shell: | ||
cmd: "qemu-nbd --connect={{ mount_device }} {{ cloud_image }}" | ||
args: | ||
executable: /bin/bash | ||
tags: | ||
- mount | ||
|
||
- name: Mount the NBD Exported Cloud Image | ||
ansible.posix.mount: | ||
src: "{{ mount_device }}p1" | ||
path: "{{ mount_point }}" | ||
fstype: auto | ||
state: ephemeral | ||
tags: | ||
- mount | ||
|
||
- name: Mount /sys and /dev into {{ mount_point }} | ||
ansible.posix.mount: | ||
src: "{{ item }}" | ||
path: "{{ mount_point }}{{ item }}" | ||
fstype: none | ||
opts: bind | ||
state: ephemeral | ||
with_items: | ||
- "/sys" | ||
- "/dev" | ||
tags: | ||
- mount | ||
|
||
- name: Remove Existing File {{ mount_point }}/etc/resolv.conf | ||
ansible.builtin.file: | ||
path: "{{ mount_point }}/etc/resolv.conf" | ||
state: absent | ||
tags: | ||
- mount | ||
- unmount | ||
|
||
- name: Copy /etc/resolv.conf to {{ mount_point }}/etc/resolv.conf | ||
ansible.builtin.copy: | ||
src: "/etc/resolv.conf" | ||
dest: "{{ mount_point }}/etc/resolv.conf" | ||
tags: | ||
- mount | ||
|
||
- name: Restore Symlink {{ mount_point }}/etc/resolv.conf | ||
ansible.builtin.file: | ||
path: "/etc/resolv.conf" | ||
state: absent | ||
delegate_to: chroot | ||
vars: | ||
ansible_connection: community.general.chroot | ||
tags: | ||
- mount | ||
- unmount | ||
|
||
- name: Umount /sys, /dev and {{ mount_point }} | ||
ansible.posix.mount: | ||
path: "{{ item }}" | ||
state: unmounted | ||
with_items: | ||
- "{{ mount_point }}/sys" | ||
- "{{ mount_point }}/dev" | ||
- "{{ mount_point }}" | ||
tags: | ||
- unmount | ||
|
||
- name: Disconnect Cloud Image Using NBD | ||
ansible.builtin.shell: | ||
cmd: "qemu-nbd --disconnect {{ mount_device }}" | ||
args: | ||
executable: /bin/bash | ||
tags: | ||
- unmount | ||
|
||
- name: Unload NBD Module | ||
community.general.modprobe: | ||
name: "nbd" | ||
state: absent | ||
tags: | ||
- unmount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
--- | ||
- name: Create and Start Proxmox VMs | ||
hosts: all | ||
hosts: proxmox | ||
gather_facts: yes | ||
become: True | ||
roles: | ||
- provision_proxmox_vms | ||
tags: create-and-start-vms | ||
|
||
- name: Run Common Roles | ||
hosts: k8s_nodes | ||
gather_facts: yes | ||
become: True | ||
roles: | ||
- linux_common | ||
- motd | ||
tags: common-roles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# defaults file for pve_ci_tweak | ||
pve_ci_image: "" | ||
pve_ci_update_grub_cmdline: True | ||
pve_ci_grub_config_path: "/etc/default/grub" | ||
pve_ci_grub_cmdline: 'GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"' | ||
pve_ci_kernel_modules_override_path: "/etc/modules-load.d/override.conf" | ||
pve_ci_kernel_modules: | | ||
nf_conntrack | ||
br_netfilter | ||
pve_ci_sysctl_override_path: "/etc/sysctl.d/override.conf" | ||
pve_ci_sysctl_parameters: | ||
vm.swappiness=1 | ||
net.ipv4.ip_forward=1 | ||
net.bridge.bridge-nf-call-iptables=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
galaxy_info: | ||
author: Saad Ali | ||
description: Tweak PVE Cloud Image. | ||
license: license (MIT) | ||
platforms: | ||
- name: Debian | ||
versions: | ||
- bookworm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# tasks file for pve_ci_tweak | ||
- name: Update Grub Configuration | ||
ansible.builtin.lineinfile: | ||
path: "{{ pve_ci_grub_config_path }}" | ||
regexp: '^GRUB_CMDLINE_LINUX_DEFAULT=' | ||
line: "{{ pve_ci_grub_cmdline }}" | ||
backrefs: yes | ||
when: pve_ci_update_grub_cmdline | ||
|
||
- name: Add Kernel Modules | ||
ansible.builtin.lineinfile: | ||
path: "{{ pve_ci_kernel_modules_override_path }}" | ||
line: "{{ pve_ci_kernel_modules }}" | ||
create: yes | ||
|
||
- name: Update sysctl Parameters | ||
ansible.builtin.lineinfile: | ||
path: "{{ pve_ci_sysctl_override_path }}" | ||
line: "{{ pve_ci_sysctl_parameters }}" | ||
create: yes | ||
|
||
- name: Update Grub | ||
ansible.builtin.shell: | ||
cmd: "update-grub" | ||
args: | ||
executable: /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Prepare PVE Cloud Image | ||
connection: community.general.chroot | ||
hosts: chroot | ||
gather_facts: yes | ||
become: True | ||
roles: | ||
- linux_common | ||
- motd | ||
- pve_ci_tweak |