proxmox:kvm:kvm-automated
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| proxmox:kvm:kvm-automated [2020/05/27 21:50] – [CLI] chuck | proxmox:kvm:kvm-automated [2021/11/10 06:58] (current) – ↷ Links adapted because of a move operation 173.245.52.212 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======Speedy KVM Creation====== | ======Speedy KVM Creation====== | ||
| - | I created a special [[linux: | + | I created a special [[linux: |
| ---- | ---- | ||
| Line 7: | Line 7: | ||
| The preseeded iso starts automatically, | The preseeded iso starts automatically, | ||
| - | * I created the preseed file then added it to the ISO using my [[:linux: | + | * I created the preseed file then added it to the ISO using my [[linux: |
| * https:// | * https:// | ||
| Line 15: | Line 15: | ||
| I created a small playbook to configure the system for me so it's set up the way I like. | I created a small playbook to configure the system for me so it's set up the way I like. | ||
| + | * https:// | ||
| * Run it like so:< | * Run it like so:< | ||
| - | ansible-playbook -v -b --ask-become-pass -i xxx.xxx.xxx.xxx, | + | ansible-playbook -v -b --ask-become-pass -i xxx.xxx.xxx.xxx, |
| </ | </ | ||
| - | * The file: <file ansible kvm_init.yml> | ||
| - | --- | ||
| - | - name: Initialize KVM VM | ||
| - | hosts: all | ||
| - | vars: | ||
| - | admin_user: chuck | ||
| - | admin_group: | ||
| - | tasks: | ||
| - | - name: Create ssh-user group | ||
| - | group: | ||
| - | name: ssh-user | ||
| - | gid: 1010 | ||
| - | state: present | ||
| - | - name: Add {{ admin_user }} to ssh-user group | ||
| - | user: | ||
| - | name: "{{ admin_user }}" | ||
| - | groups: ssh-user | ||
| - | append: yes | ||
| - | |||
| - | - name: Create dotfiles directory | ||
| - | become: yes | ||
| - | become_user: | ||
| - | file: | ||
| - | path: "/ | ||
| - | owner: "{{ admin_user }}" | ||
| - | group: "{{ admin_group }}" | ||
| - | state: directory | ||
| - | mode: ' | ||
| - | | + | ---- |
| - | become: yes | + | |
| - | become_user: | + | |
| - | file: | + | |
| - | path: "/ | + | |
| - | state: absent | + | |
| - | with_items: | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | - name: Clone dotfiles | + | =====Configure pfSense===== |
| - | | + | If it's a VM that I plan on keeping around for a while, I'll give it a static IP address in pfSense before installing Debian. The preseed will use the hostname I assigned it in pfSense as the system hostname when configuring the network via DHCP. |
| - | become_user: | + | |
| - | git: | + | |
| - | repo: "{{ item.repo }}" | + | |
| - | dest: "/ | + | |
| - | loop: | + | |
| - | - { name: 'bash', | + | |
| - | - { name: ' | + | |
| - | - { name: ' | + | |
| - | - { name: ' | + | |
| - | - { name: ' | + | |
| - | - name: Stow dotfiles | + | Otherwise, the system' |
| - | become: yes | + | |
| - | become_user: | + | |
| - | command: stow "{{ item }}" | + | |
| - | args: | + | |
| - | chdir: "/home/{{ admin_user }}/.dotfiles" | + | |
| - | loop: | + | |
| - | - bash | + | |
| - | - git | + | |
| - | - screen | + | |
| - | - vim | + | |
| - | + | ||
| - | - name: Install MOTD | + | |
| - | become: yes | + | |
| - | copy: | + | |
| - | src: "/home/{{ admin_user }}/ | + | |
| - | dest: "/ | + | |
| - | remote_src: yes | + | |
| - | owner: root | + | |
| - | group: root | + | |
| - | mode: 0755 | + | |
| - | loop: | + | |
| - | - 10-uname | + | |
| - | - 20-sysinfo | + | |
| - | - 90-fortune | + | |
| - | + | ||
| - | - name: Set PAM motd | + | |
| - | become: yes | + | |
| - | lineinfile: | + | |
| - | backup: yes | + | |
| - | path: / | + | |
| - | regexp: | + | |
| - | line: '# | + | |
| - | + | ||
| - | - name: Disable password ssh | + | |
| - | become: yes | + | |
| - | lineinfile: | + | |
| - | path: / | + | |
| - | regexp: "# | + | |
| - | line: " | + | |
| - | + | ||
| - | - name: Restrict ssh to ssh-user group | + | |
| - | become: yes | + | |
| - | blockinfile: | + | |
| - | path: / | + | |
| - | block: " | + | |
| - | + | ||
| - | - name: Add {{ admin_user }} to / | + | |
| - | become: yes | + | |
| - | blockinfile: | + | |
| - | path: / | + | |
| - | block: '+:{{ admin_user }}: | + | |
| - | + | ||
| - | - name: Configure PAM | + | |
| - | become: yes | + | |
| - | lineinfile: | + | |
| - | path: / | + | |
| - | regexp: ' | + | |
| - | line: ' | + | |
| - | </ | + | |
| ---- | ---- | ||
| - | |||
| =====Create a VM===== | =====Create a VM===== | ||
| ====GUI==== | ====GUI==== | ||
| Line 148: | Line 42: | ||
| ====CLI==== | ====CLI==== | ||
| - | * ssh into Proxmox | + | * ssh into Proxmox:< |
| - | * The iso's on my system are located at '' | + | ssh user@proxmox |
| + | </ | ||
| + | * The iso's on my system are located at '' | ||
| * List current VMs:< | * List current VMs:< | ||
| sudo qm list</ | sudo qm list</ | ||
| * Pick a free vmid and create a new VM with your preferred settings:< | * Pick a free vmid and create a new VM with your preferred settings:< | ||
| sudo qm create 150 --cdrom sas-storage: | sudo qm create 150 --cdrom sas-storage: | ||
| - | --name preseed --numa 0 --ostype l26 \ | + | |
| - | --cpu cputype=host --cores 2 --sockets 2 \ | + | --cpu cputype=host --cores 2 --sockets 2 \ |
| - | --memory 4096 \ | + | --memory 4096 \ |
| - | --net0 bridge=vmbr90, | + | --net0 bridge=vmbr90, |
| - | --bootdisk scsi0 --scsihw virtio-scsi-pci --scsi0 file=ssd-lvm: | + | --bootdisk scsi0 --scsihw virtio-scsi-pci --scsi0 file=ssd-lvm: |
| - | --serial0 socket --vga qxl --audio0 device=ich9-intel-hda, | + | --serial0 socket --vga qxl --audio0 device=ich9-intel-hda, |
| + | |||
| + | # I'll add macaddr=XX: | ||
| </ | </ | ||
| * Start the vm:< | * Start the vm:< | ||
| Line 165: | Line 63: | ||
| </ | </ | ||
| * Wait for it to complete. | * Wait for it to complete. | ||
| + | * Run the ansible playbook. | ||
| + | * Enjoy! | ||
| + | * See '' | ||
| ---- | ---- | ||
proxmox/kvm/kvm-automated.1590616220.txt.gz · Last modified: by chuck
