Compare commits
1 Commits
transcaffe
...
bee1722cea
Author | SHA1 | Date | |
---|---|---|---|
bee1722cea
|
@ -1,20 +0,0 @@
|
||||
# `debian-proxmox` ansible role
|
||||
|
||||
This ansible role can be used to convert a (running and reachable) debian to a proxmox instance.
|
||||
|
||||
It automates the instructions from https://pve.proxmox.com/wiki/Install_Proxmox_VE_on_Debian_11_Bullseye.
|
||||
|
||||
## Usage
|
||||
|
||||
This role will attempt to ensure that the `/etc/hosts` are configured correctly for PVE.
|
||||
The public IP of the server should be given in `debian_proxmox_public_ip` and defaults to
|
||||
`ansible_facts['eno1'].ipv4.address`.
|
||||
|
||||
The hostname and fqdn should be correctly set in `debian_proxmox_hostname` and `debian_proxmox_fqdn`,
|
||||
and default to `ansible_hostname` and `ansible_fqdn` respectively.
|
||||
|
||||
## Packages
|
||||
|
||||
It is recommended to remove the packages for the `os-prober` (which would attempt to add VMs as bootable entries
|
||||
in the bootloader) and the default linux kernel `linux-image-amd64` / `linux-image-5.10*` (and use the proxmox-provided
|
||||
kernel instead). This role will remove those packages without asking, so be aware.
|
@ -1,43 +0,0 @@
|
||||
---
|
||||
|
||||
debian_proxmox_role_required_packages:
|
||||
- python3-apt
|
||||
- gpg
|
||||
|
||||
debian_proxmox_apt_repo_fingerprint: "28139A2F830BD68478A1A01FDD4BA3917E23BF59"
|
||||
debian_proxmox_apt_repo_key_url: "https://enterprise.proxmox.com/debian/proxmox-release-{{ ansible_distribution_release }}.gpg"
|
||||
|
||||
debian_proxmox_apt_repo_url: "http://download.proxmox.com/debian/pve"
|
||||
debian_proxmox_apt_repo: "deb [arch=amd64] {{ debian_proxmox_apt_repo_url }} {{ ansible_distribution_release }} pve-no-subscription"
|
||||
|
||||
debian_proxmox_apt_packages:
|
||||
- "proxmox-ve"
|
||||
- "postfix"
|
||||
- "open-iscsi"
|
||||
|
||||
debian_proxmox_apt_packages_to_remove:
|
||||
- "linux-image-amd64"
|
||||
- "linux-image-{{ (ansible_facts['kernel'] | split('-') | first | split('.'))[:2] | join('.') }}*"
|
||||
- "os-prober"
|
||||
|
||||
debian_proxmox_max_reboot_timeout_seconds: 900
|
||||
|
||||
debian_proxmox_public_ip: "{{ ansible_facts['eno1'].ipv4.address }}"
|
||||
debian_proxmox_loopback_ipv4: "{{ ansible_facts['lo'].ipv4.address }}"
|
||||
|
||||
debian_proxmox_hostname: "{{ ansible_hostname }}"
|
||||
debian_proxmox_fqdn: "{{ ansible_fqdn }}"
|
||||
|
||||
debian_proxmox_hosts_file:
|
||||
- ip: "{{ debian_proxmox_loopback_ipv4 }}"
|
||||
fqdn: localhost.localdomain
|
||||
aliases:
|
||||
- localhost
|
||||
- ip: "{[ debian_proxmox_public_ip }}"
|
||||
fqdn: "{{ debian_proxmox_fqdn }}"
|
||||
aliases:
|
||||
- "{{ debian_proxmox_hostname }}"
|
||||
- pvelocalhost
|
||||
- ip: 127.0.1.1
|
||||
fqdn: "{{ debian_proxmox_hostname }}"
|
||||
state: absent
|
@ -1,67 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Ensure python3-apt and gpg is available
|
||||
apt:
|
||||
package: "{{ debian_proxmox_role_required_packages }}"
|
||||
state: present
|
||||
|
||||
- name: Check if target is debian before attempting to convert to proxmox
|
||||
fail:
|
||||
msg: "Target is {{ ansible_distribution }} which is not Debian"
|
||||
when: ansible_distribution != 'Debian'
|
||||
|
||||
- name: Check if debian version is supported by role
|
||||
fail:
|
||||
msg: "{{ ansible_distribution }} {{ ansible_distribution_version }} is not supported by the role"
|
||||
when: ansible_distribution_version not in debian_proxmox_supported_debian_versions
|
||||
|
||||
- name: Ensure /etc/hosts entries are safe for use with proxmox
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
line: "{{ item.ip }}\t{{ item.fqdn | default('') }}\t{{ item.aliases | default([]) | join('\t') }}"
|
||||
regex: "{{ item.ip }}.+"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
loop: "{{ debian_proxmox_hosts_file }}"
|
||||
|
||||
- name: Ensure Proxmox VE apt repository keys are added
|
||||
apt_key:
|
||||
id: "{{ debian_proxmox_apt_repo_fingerprint }}"
|
||||
url: "{{ debian_proxmox_apt_repo_key_url }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure Proxmox VE apt repository is added
|
||||
apt_repository:
|
||||
filename: pve-install-repo
|
||||
repo: "{{ debian_proxmox_apt_repo }}"
|
||||
state: present
|
||||
register: proxmox_ve_apt_repo
|
||||
|
||||
- name: Ensure APT cache is up to date
|
||||
apt:
|
||||
update_cache: yes
|
||||
when: proxmox_ve_apt_repo.changed
|
||||
|
||||
- name: Ensure system is upgraded
|
||||
apt:
|
||||
upgrade: full
|
||||
|
||||
- name: Ensure Proxmox VE packages are installed
|
||||
apt:
|
||||
package: "{{ debian_proxmox_apt_packages }}"
|
||||
state: present
|
||||
register: proxmox_ve_installed
|
||||
|
||||
- name: Ensure system is rebooted after install of PVE packages
|
||||
reboot:
|
||||
reboot_timeout: "{{ debian_proxmox_max_reboot_timeout_seconds | int }}"
|
||||
when: proxmox_ve_installed.changed
|
||||
|
||||
- name: Ensure packages are removed that will conflict with proxmox operation
|
||||
apt:
|
||||
package: "{{ debian_proxmox_apt_packages_to_remove }}"
|
||||
state: absent
|
||||
register: proxmox_apt_packages_removed
|
||||
|
||||
- name: Ensure grub was updated after the kernel was removed
|
||||
command: update-grub
|
||||
when: proxmox_apt_packages_removed.changed
|
@ -1,4 +0,0 @@
|
||||
---
|
||||
|
||||
debian_proxmox_supported_debian_versions:
|
||||
- 11
|
32
roles/mariadb/defaults/main.yml
Normal file
32
roles/mariadb/defaults/main.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
|
||||
mariadb_version: "10.6.11"
|
||||
mariadb_base_path: /var/lib/mariadb
|
||||
mariadb_data_path: "{{ mariadb_base_path }}/{{ mariadb_version }}"
|
||||
|
||||
mariadb_root_password: ~
|
||||
mariadb_database: ~
|
||||
mariadb_username: ~
|
||||
mariadb_password: ~
|
||||
|
||||
mariadb_container_base_environment:
|
||||
MARIADB_ROOT_PASSWORD: "{{ mariadb_root_password }}"
|
||||
mariadb_container_extra_environment: {}
|
||||
|
||||
mariadb_container_name: mariadb
|
||||
mariadb_container_image_name: docker.io/mariadb
|
||||
mariadb_container_image_tag: ~
|
||||
mariadb_container_image: "{{ mariadb_container_image_name }}:{{ mariadb_container_image_tag | default(mariadb_version, true) }}"
|
||||
mariadb_container_base_volumes:
|
||||
- "{{ mariadb_data_path }}:{{ mariadb_container_data_path }}:z"
|
||||
mariadb_container_extra_volumes: []
|
||||
mariadb_container_base_labels:
|
||||
version: "{{ mariadb_version }}"
|
||||
mariadb_container_extra_labels: {}
|
||||
mariadb_container_restart_policy: "unless-stopped"
|
||||
mariadb_container_environment: >-2
|
||||
{{ mariadb_container_base_environment
|
||||
| combine(mariadb_container_database_environment
|
||||
if (mariadb_database and mariadb_username and mariadb_password)
|
||||
else {}, recursive=True)
|
||||
| combine(mariadb_container_extra_environment) }}
|
20
roles/mariadb/tasks/main.yml
Normal file
20
roles/mariadb/tasks/main.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Ensure mariaDB container image is present on host
|
||||
community.docker.docker_image:
|
||||
name: "{{ mariadb_container_image }}"
|
||||
state: present
|
||||
source: pull
|
||||
|
||||
- name: Ensure mariaDB {{ mariadb_version }} is running as '{{ mariadb_container_name }}'
|
||||
community.docker.docker_container:
|
||||
name: "{{ mariadb_container_name }}"
|
||||
image: "{{ mariadb_container_image }}"
|
||||
env: "{{ mariadb_container_environment }}"
|
||||
ports: "{{ mariadb_container_ports }}"
|
||||
labels: "{{ mariadb_container_labels }}"
|
||||
volumes: "{{ mariadb_container_volumes }}"
|
||||
networks: "{{ mariadb_container_networks | default(omit, true) }}"
|
||||
etc_hosts: "{{ mariadb_container_etc_hosts | default(omit, true) }}"
|
||||
purge_networks: "{{ mariadb_container_purge_networks | default(omit, true) }}"
|
||||
restart_policy: "{{ mariadb_container_restart_policy }}"
|
||||
state: started
|
10
roles/mariadb/vars/main.yml
Normal file
10
roles/mariadb/vars/main.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
mariadb_container_database_environment:
|
||||
MARIADB_DATABASE: "{{ mariadb_database }}"
|
||||
MARIADB_USER: "{{ mariadb_username }}"
|
||||
MARIADB_PASSWORD: "{{ mariadb_password }}"
|
||||
|
||||
mariadb_container_data_path: /var/lib/mysql
|
||||
mariadb_container_volumes: "{{ mariadb_container_base_volumes + mariadb_container_extra_volumes }}"
|
||||
mariadb_container_labels: "{{ mariadb_container_base_labels | combine(mariadb_container_extra_labels, recursive=True) }}"
|
Reference in New Issue
Block a user