在Debian服務器上安裝和配置Proxmox虛擬環境6.x/7.x/8.x。
此角色使您可以在Debian Buster(10)和Bullseye(11)和Bookworm(12)上部署和管理單節點PVE安裝和PVE群集(3個以上的節點)。您能夠在此角色的幫助下配置以下內容:
datacenter.cfg
pve-no-subscription
或pve-enterprise
)通過啟用聚類,此角色確實(或允許您執行):
為了獲得支持,或者如果您想為這個角色做出貢獻,但想要指導,請隨時加入此Discord Server:https://discord.gg/cjqr6fg。請注意,這是一個臨時邀請,因此您需要等待@lae分配角色,否則在註銷時,Discord會從服務器中刪除您。
該角色的主要目標是配置和管理一個proxmox ve群集(請參閱示例劇本),但是該角色可用於快速安裝單節點Proxmox服務器。
我假設您已經安裝了Ansible。您需要將外部計算機使用您正在安裝的proxmox上的機器(主要是因為安裝中間的重新啟動,儘管我可能會在此用例中對此有所不同)。
將以下劇本複製到install_proxmox.yml
之類的文件:
- hosts: all
become: True
roles:
- role: geerlingguy.ntp
vars:
ntp_manage_config: true
ntp_servers:
- clock.sjc.he.net,
- clock.fmt.he.net,
- clock.nyc.he.net
- role: lae.proxmox
vars:
- pve_group: all
- pve_reboot_on_kernel_update: true
安裝此角色和配置NTP的角色:
ansible-galaxy install lae.proxmox geerlingguy.ntp
現在您可以執行安裝:
ansible-playbook install_proxmox.yml -i $SSH_HOST_FQDN, -u $SSH_USER
如果您的SSH_USER
有一個sudo密碼,請將-K
標誌傳遞到上述命令。如果您還通過密碼而不是PubKey Auth對主機進行身份驗證,請傳遞-k
標誌(請確保也安裝了sshpass
)。您可以在運行命令之前設置這些變量,也可以替換它們。請注意,逗號很重要,因為預計列表(否則,它將嘗試查找包含主機列表的文件)。
完成後,您應該能夠在https://$SSH_HOST_FQDN:8006
上訪問您的proxmox ve實例。
創建一個新的劇本目錄。我們稱我們的lab-cluster
。我們的劇本最終將看起來像這樣,但是您的劇本不必遵循所有步驟:
lab-cluster/
├── files
│ └── pve01
│ ├── lab-node01.local.key
│ ├── lab-node01.local.pem
│ ├── lab-node02.local.key
│ ├── lab-node02.local.pem
│ ├── lab-node03.local.key
│ └── lab-node03.local.pem
├── group_vars
│ ├── all
│ └── pve01
├── inventory
├── roles
│ └── requirements.yml
├── site.yml
└── templates
└── interfaces-pve01.j2
6 directories, 12 files
您可能會注意到的第一件事是,我們有一堆.key
和.pem
文件。這些是私鑰和SSL證書,該角色將用於在所有節點上配置proxmox的Web界面。但是,如果您想繼續使用proxmox內部設置的CA簽名證書,則不是必需的。您通常可以使用Ansible Vault來加密私鑰,例如:
ansible-vault encrypt files/pve01/*.key
然後,這將要求您在運行劇本時傳遞保險庫密碼。
讓我們首先指定群集主機。我們的inventory
文件可能看起來像這樣:
[pve01]
lab-node01.local
lab-node02.local
lab-node03.local
您可能有多個集群,因此最好為每個集群組成一個組。現在,讓我們在roles/requirements.yml
中指定我們的角色要求。
---
- src: geerlingguy.ntp
- src: lae.proxmox
我們需要NTP角色來配置NTP,因此我們使用Jeff Geerling的角色來做到這一點。如果您已經配置了NTP或配置NTP的不同方法,則不需要它。
現在,讓我們指定一些組變量。首先,讓我們創建group_vars/all
用於設置與NTP相關的變量:
---
ntp_manage_config: true
ntp_servers:
- lab-ntp01.local iburst
- lab-ntp02.local iburst
當然,將這些NTP服務器替換為您喜歡的服務器。
現在,對於劇本的肉, pve01
的組變量。創建文件group_vars/pve01
,添加以下內容,並為您的環境進行相應的修改。
---
pve_group: pve01
pve_watchdog: ipmi
pve_ssl_private_key: "{{ lookup('file', pve_group + '/' + inventory_hostname + '.key') }}"
pve_ssl_certificate: "{{ lookup('file', pve_group + '/' + inventory_hostname + '.pem') }}"
pve_cluster_enabled: yes
pve_groups:
- name: ops
comment: Operations Team
pve_users:
- name: admin1@pam
email: [email protected]
firstname: Admin
lastname: User 1
groups: [ "ops" ]
- name: admin2@pam
email: [email protected]
firstname: Admin
lastname: User 2
groups: [ "ops" ]
pve_acls:
- path: /
roles: [ "Administrator" ]
groups: [ "ops" ]
pve_storages:
- name: localdir
type: dir
content: [ "images", "iso", "backup" ]
path: /plop
maxfiles: 4
pve_ssh_port: 22
interfaces_template: "interfaces-{{ pve_group }}.j2"
pve_group
設置為我們群集的組名, pve01
將用於確保該組中的所有主機都可以相互連接並聚集在一起。請注意,除非pve_cluster_clustername
另有說明,否則PVE群集名稱也將設置為此組名稱。離開此不確定的將默認為proxmox
。
pve_watchdog
在這裡啟用IPMI看門狗的支持,並配置PVE的HA Manager可以使用它。 None
使用或留下此不確定的使用默認的proxmox軟件看門狗。如果設置為其他任何東西,則該值有望為看門狗內核模塊。
pve_ssl_private_key
和pve_ssl_certificate
指向PVECLUSTER的SSL證書。在這裡,文件查找用於讀取劇本中的文件內容,例如files/pve01/lab-node01.key
。如果您願意,您可能只使用主機變量而不是文件。
pve_cluster_enabled
可以執行所有群集管理任務。這包括創建一個群集(如果不存在),或將節點添加到現有群集中。有一些檢查可以確保您不會混合已經在具有不同名稱的現有群集中的節點。
pve_groups
, pve_users
和pve_acls
授權某些本地Unix用戶(必須已經存在)訪問PVE,並將管理員角色作為ops
組的一部分。閱讀用戶和ACL管理部分以獲取更多信息。
pve_storages
允許創建不同類型的存儲並配置它們。後端需要由Proxmox支持。閱讀“存儲管理”部分以獲取更多信息。
pve_metric_servers
允許您為PVE群集配置公制服務器。如果您想使用InfluxDB,Graphite或其他(使用Telegraf),這將很有用。
pve_ssh_port
允許您更改SSH端口。如果您的SSH在默認22以外的端口上偵聽,請設置此變量。如果一個新節點正在加入集群,則PVE群集需要通過SSH進行一次通信。
pve_manage_ssh
(默認為true)允許您禁用該模塊對SSH服務器配置的任何更改。如果您使用另一個角色來管理SSH服務器,這將很有用。請注意,將其設置為false不正式支持,您可以獨自複制通常在ssh_cluster_config.yml
和pve_add_node.yml
中進行的更改。
interfaces_template
設置為將用於在這些Debian機器上配置網絡的模板的路徑。僅當您想從Ansible而不是手動或通過PVE中的每個主機來管理網絡時,這是必要的。在此之前,您可能應該熟悉Ansible,因為您的方法可能涉及為每個主機的IP地址設置主機變量,等等。
讓我們避開該接口模板。否則可以隨意跳過此文件(並在group_vars/pve01
中保留未定義)。這是我使用的:
# {{ ansible_managed }}
auto lo
iface lo inet loopback
allow-hotplug enp2s0f0
iface enp2s0f0 inet manual
auto vmbr0
iface vmbr0 inet static
address {{ lookup('dig', ansible_fqdn) }}
gateway 10.4.0.1
netmask 255.255.255.0
bridge_ports enp2s0f0
bridge_stp off
bridge_fd 0
allow-hotplug enp2s0f1
auto enp2s0f1
iface enp2s0f1 inet static
address {{ lookup('dig', ansible_hostname + "-clusternet.local") }}
netmask 255.255.255.0
您可能不熟悉dig
查找,但基本上,我們正在為第一個接口為每台機器(例如Lab-node01.local)進行錄製(並將其配置為橋樑,我們將用於VM接口),然後是我們可能用於CEPH(“ lab-node01-clusternet.local”)的“聚類”網絡的另一個稍微修改的查找。當然,您的外觀可能完全不同,尤其是當您使用Bonding,三個不同的網絡用於管理/CoroSync,存儲和VM流量等。
最後,讓我們寫我們的劇本。 site.yml
看起來像這樣:
---
- hosts: all
become: True
roles:
- geerlingguy.ntp
# Leave this out if you're not modifying networking through Ansible
- hosts: pve01
become: True
serial: 1
tasks:
- name: Install bridge-utils
apt:
name: bridge-utils
- name: Configure /etc/network/interfaces
template:
src: "{{ interfaces_template }}"
dest: /etc/network/interfaces
register: _configure_interfaces
- block:
- name: Reboot for networking changes
shell: "sleep 5 && shutdown -r now 'Networking changes found, rebooting'"
async: 1
poll: 0
- name: Wait for server to come back online
wait_for_connection:
delay: 15
when: _configure_interfaces is changed
- hosts: pve01
become: True
roles:
- lae.proxmox
基本上,我們在所有主機上運行NTP角色(您可能需要添加一些非Proxmox機器),使用我們的單獨的集群網絡和橋樑佈局在pve01
上配置網絡,重新啟動以使這些更改發生,然後運行此Proxmox角色針對主機設置集群。
在這一點上,我們的劇本已經準備就緒,我們可以運行劇本。
確保安裝角色和依賴項:
ansible-galaxy install -r roles/requirements.yml --force
pip install jmespath dnspython
涉及聚類的某些jmespath
是必需的。僅當您使用dig
查找時,才需要dnspython
,當您跳過配置網絡時,您可能不會。我們在這里傳遞--force
努力到ansible-galaxy
,以便將角色更新到其最新版本(如果已經安裝)。
現在運行劇本:
ansible-playbook -i inventory site.yml -e '{"pve_reboot_on_kernel_update": true}'
-e '{"pve_reboot_on_kernel_update": true}'
應該主要在第一次進行proxmox群集設置時運行,因為它會重新啟動服務器以啟動到PVE內核。隨後的運行應排除在此之後,因為您想在群集運行後順序重新啟動服務器。
要指定特定用戶,請使用-u root
(替換root
),如果您需要提供密碼,請使用-k
用於ssh密碼和/或-K
作為sudo密碼。例如:
ansible-playbook -i inventory site.yml -K -u admin1
這將要求提供一個sudo密碼,然後登錄admin1
用戶(使用public鍵auth -k
for pw)並運行劇本。
就是這樣!現在,您應該擁有一個完全部署的proxmox群集。您可能需要在此之後在其上創建CEPH存儲(有關更多信息,請參見CEPH)和其他任務,但是困難的部分大多是完整的。
這將在組pve01
中將主機配置為一個群集,並在內核已更新時重新啟動機器。 (僅建議在安裝過程中設置此標誌 - 操作期間的重新啟動應在維護期間連續發生。)它還將啟用IPMI看門狗。
- hosts: pve01
become: True
roles:
- role: geerlingguy.ntp
ntp_manage_config: true
ntp_servers:
- clock.sjc.he.net,
- clock.fmt.he.net,
- clock.nyc.he.net
- role: lae.proxmox
pve_group: pve01
pve_cluster_enabled: yes
pve_reboot_on_kernel_update: true
pve_watchdog: ipmi
關於默認值:在運行時選擇了一些默認值,因此與此處列出的示例可能有所不同。
[variable]: [default] #[description/purpose]
pve_group: proxmox # host group that contains the Proxmox hosts to be clustered together
pve_repository_line: "deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription" # apt-repository configuration - change to enterprise if needed (although TODO further configuration may be needed)
pve_remove_subscription_warning: true # patches the subscription warning messages in proxmox if you are using the community edition
pve_extra_packages: [] # Any extra packages you may want to install, e.g. ngrep
pve_run_system_upgrades: false # Let role perform system upgrades
pve_run_proxmox_upgrades: true # Let role perform Proxmox VE upgrades
pve_check_for_kernel_update: true # Runs a script on the host to check kernel versions
pve_reboot_on_kernel_update: false # If set to true, will automatically reboot the machine on kernel updates
pve_reboot_on_kernel_update_delay: 60 # Number of seconds to wait before and after a reboot process to proceed with next task in cluster mode
pve_remove_old_kernels: true # Currently removes kernel from main Debian repository
# pve_default_kernel_version: # version to pin proxmox-default-kernel to (see https://pve.proxmox.com/wiki/Roadmap#Kernel_6.8)
pve_pcie_passthrough_enabled: false # Set this to true to enable PCIe passthrough.
pve_iommu_passthrough_mode: false # Set this to true to allow VMs to bypass the DMA translation. This might increase performance for IOMMU passthrough.
pve_iommu_unsafe_interrupts: false # Set this to true if your system doesn't support interrupt remapping.
pve_mediated_devices_enabled: false # Set this to true if your device supports gtv-g and you wish to enable split functionality.
pve_pcie_ovmf_enabled: false # Set this to true to enable GPU OVMF PCI passthrough.
pve_pci_device_ids: [] # List of pci device ID's (see https://pve.proxmox.com/wiki/Pci_passthrough#GPU_Passthrough).
pve_vfio_blacklist_drivers: [] # List of device drivers to blacklist from the Proxmox host (see https://pve.proxmox.com/wiki/PCI(e)_Passthrough).
pve_pcie_ignore_msrs: false # Set this to true if passing through to Windows machine to prevent VM crashing.
pve_pcie_report_msrs: true # Set this to false to prevent dmesg system from logging msrs crash reports.
pve_watchdog: none # Set this to "ipmi" if you want to configure a hardware watchdog. Proxmox uses a software watchdog (nmi_watchdog) by default.
pve_watchdog_ipmi_action: power_cycle # Can be one of "reset", "power_cycle", and "power_off".
pve_watchdog_ipmi_timeout: 10 # Number of seconds the watchdog should wait
pve_zfs_enabled: no # Specifies whether or not to install and configure ZFS packages
# pve_zfs_options: "" # modprobe parameters to pass to zfs module on boot/modprobe
# pve_zfs_zed_email: "" # Should be set to an email to receive ZFS notifications
pve_zfs_create_volumes: [] # List of ZFS Volumes to create (to use as PVE Storages). See section on Storage Management.
pve_ceph_enabled: false # Specifies wheter or not to install and configure Ceph packages. See below for an example configuration.
pve_ceph_repository_line: "deb http://download.proxmox.com/debian/ceph-pacific bookworm main" # apt-repository configuration. Will be automatically set for 6.x and 7.x (Further information: https://pve.proxmox.com/wiki/Package_Repositories)
pve_ceph_network: "{{ (ansible_default_ipv4.network +'/'+ ansible_default_ipv4.netmask) | ansible.utils.ipaddr('net') }}" # Ceph public network
# pve_ceph_cluster_network: "" # Optional, if the ceph cluster network is different from the public network (see https://pve.proxmox.com/pve-docs/chapter-pveceph.html#pve_ceph_install_wizard)
pve_ceph_nodes: "{{ pve_group }}" # Host group containing all Ceph nodes
pve_ceph_mon_group: "{{ pve_group }}" # Host group containing all Ceph monitor hosts
pve_ceph_mgr_group: "{{ pve_ceph_mon_group }}" # Host group containing all Ceph manager hosts
pve_ceph_mds_group: "{{ pve_group }}" # Host group containing all Ceph metadata server hosts
pve_ceph_osds: [] # List of OSD disks
pve_ceph_pools: [] # List of pools to create
pve_ceph_fs: [] # List of CephFS filesystems to create
pve_ceph_crush_rules: [] # List of CRUSH rules to create
# pve_ssl_private_key: "" # Should be set to the contents of the private key to use for HTTPS
# pve_ssl_certificate: "" # Should be set to the contents of the certificate to use for HTTPS
pve_roles: [] # Added more roles with specific privileges. See section on User Management.
pve_groups: [] # List of group definitions to manage in PVE. See section on User Management.
pve_users: [] # List of user definitions to manage in PVE. See section on User Management.
pve_storages: [] # List of storages to manage in PVE. See section on Storage Management.
pve_metric_servers: [] # List of metric servers to configure in PVE.
pve_datacenter_cfg: {} # Dictionary to configure the PVE datacenter.cfg config file.
pve_domains_cfg: [] # List of realms to use as authentication sources in the PVE domains.cfg config file.
pve_no_log: false # Set this to true in production to prevent leaking of storage credentials in run logs. (may be used in other tasks in the future)
要使用此角色啟用聚類,請適當配置以下變量:
pve_cluster_enabled: no # Set this to yes to configure hosts to be clustered together
pve_cluster_clustername: "{{ pve_group }}" # Should be set to the name of the PVE cluster
pve_manage_hosts_enabled : yes # Set this to no to NOT configure hosts file (case of using vpn and hosts file is already configured)
以下變量用於向CoroSync提供網絡信息。這些被稱為ring0_addr/ring1_addr或link0_addr/link1_addr,具體取決於PVE版本。它們應該是IPv4或IPv6地址。您還可以將這些接口的優先級配置為提示CoroSync,哪些接口應處理群集流量(較低的數字表示優先級更高)。有關更多信息,請參閱PVE文檔中的群集管理器章節。
# pve_cluster_addr0: "{{ defaults to the default interface ipv4 or ipv6 if detected }}"
# pve_cluster_addr1: "another interface's IP address or hostname"
# pve_cluster_addr0_priority: 255
# pve_cluster_addr1_priority: 0
您可以在datacenter.cfg配置文件中設置選項:
pve_datacenter_cfg:
keyboard: en-us
您還可以配置HA Manager組:
pve_cluster_ha_groups: [] # List of HA groups to create in PVE.
此示例為分配給LAB-NODE1主機的資源創建一個組“ LAB_NODE01”:
pve_cluster_ha_groups:
- name: lab_node01
comment: "My HA group"
nodes: "lab-node01"
nofailback: 0
restricted: 0
datacenter.cfg文件中支持的所有配置選項均在proxmox手冊datacenter.cfg部分中記錄。
為了使網絡接口實時重新加載通過PVE Web UI工作,您需要安裝ifupdown2
軟件包。請注意,這將刪除ifupdown
。您可以使用pve_extra_packages
角色變量來指定此內容。
您可以在域中設置領域 /域作為身份驗證源domains.cfg
配置文件。如果此文件不存在,則只有Linux PAM
和Proxmox VE authentication server
領域可用。支持類型是pam
, pve
, ad
和ldap
。可以自動同步基於LDAP的領域(LDAP和Microsoft Active Directory)的用戶和組與sync: true
。一個領域應具有default: 1
屬性,將其標記為默認值:
pve_domains_cfg:
- name: pam
type: pam
attributes:
comment: Linux PAM standard authentication
- name: pve
type: pve
attributes:
comment: Proxmox VE authentication server
- name: ad
type: ad
attributes:
comment: Active Directory authentication
domain: yourdomain.com
server1: dc01.yourdomain.com
default: 1
secure: 1
server2: dc02.yourdomain.com
- name: ldap
type: ldap
sync: true
attributes:
comment: LDAP authentication
base_dn: CN=Users,dc=yourdomain,dc=com
bind_dn: "uid=svc-reader,CN=Users,dc=yourdomain,dc=com"
bind_password: "{{ secret_ldap_svc_reader_password }}"
server1: ldap1.yourdomain.com
user_attr: uid
secure: 1
server2: ldap2.yourdomain.com
此角色不安裝NTP,因此您應該自己配置NTP,例如geerlingguy.ntp
角色,如示例劇本所示。
啟用聚類時,此角色將使用json_query
過濾器,該過濾器要求將jmespath
庫安裝在您的控件主機上。您可以pip install jmespath
或通過發行版的軟件包管理器,例如apt-get install python-jmespath
安裝它。
您可以使用此角色來管理Proxmox VE中的用戶和組(無論是在單個服務器部署和群集部署中)。這是一些例子。
pve_groups:
- name: Admins
comment: Administrators of this PVE cluster
- name: api_users
- name: test_users
pve_users:
- name: root@pam
email: [email protected]
- name: lae@pam
email: [email protected]
firstname: Musee
lastname: Ullah
groups: [ "Admins" ]
- name: pveapi@pve
password: "Proxmox789"
groups:
- api_users
- name: testapi@pve
password: "Test456"
enable: no
groups:
- api_users
- test_users
- name: tempuser@pam
expire: 1514793600
groups: [ "test_users" ]
comment: "Temporary user set to expire on 2018年 1月 1日 月曜日 00:00:00 PST"
email: [email protected]
firstname: Test
lastname: User
請參閱library/proxmox_user.py
鏈接和library/proxmox_group.py
鏈接中的模塊文檔鏈接。
對於管理角色和ACL,採用了一個類似的模塊,但主要區別在於,大多數參數僅接受列表(如更改所示):
pve_roles:
- name: Monitoring
privileges:
- "Sys.Modify"
- "Sys.Audit"
- "Datastore.Audit"
- "VM.Monitor"
- "VM.Audit"
pve_acls:
- path: /
roles: [ "Administrator" ]
groups: [ "Admins" ]
- path: /pools/testpool
roles: [ "PVEAdmin" ]
users:
- pveapi@pve
groups:
- test_users
有關模塊文檔,請參閱library/proxmox_role.py
鏈接和library/proxmox_acl.py
鏈接。
您可以使用此角色來管理Proxmox VE內的存儲(無論是在單個服務器部署和群集部署中)。目前,唯一支持的類型是dir
, rbd
, nfs
, cephfs
, lvm
, lvmthin
, zfspool
, btrfs
, cifs
和pbs
。這是一些例子。
pve_storages:
- name: dir1
type: dir
content: [ "images", "iso", "backup" ]
path: /ploup
disable: no
maxfiles: 4
- name: ceph1
type: rbd
content: [ "images", "rootdir" ]
nodes: [ "lab-node01.local", "lab-node02.local" ]
username: admin
pool: rbd
krbd: yes
monhost:
- 10.0.0.1
- 10.0.0.2
- 10.0.0.3
- name: nfs1
type: nfs
content: [ "images", "iso" ]
server: 192.168.122.2
export: /data
- name: lvm1
type: lvm
content: [ "images", "rootdir" ]
vgname: vg1
- name: lvmthin1
type: lvmthin
content: [ "images", "rootdir" ]
vgname: vg2
thinpool: data
- name: cephfs1
type: cephfs
content: [ "snippets", "vztmpl", "iso" ]
nodes: [ "lab-node01.local", "lab-node02.local" ]
monhost:
- 10.0.0.1
- 10.0.0.2
- 10.0.0.3
- name: pbs1
type: pbs
content: [ "backup" ]
server: 192.168.122.2
username: user@pbs
password: PBSPassword1
datastore: main
namespace: Top/something # Optional
- name: zfs1
type: zfspool
content: [ "images", "rootdir" ]
pool: rpool/data
sparse: true
- name: btrfs1
type: btrfs
content: [ "images", "rootdir" ]
nodes: [ "lab-node01.local", "lab-node02.local" ]
path: /mnt/proxmox_storage
is_mountpoint: true
- name: cifs1
server: cifs-host.domain.tld
type: cifs
content: [ "snippets", "vztmpl", "iso" ]
share: sharename
subdir: /subdir
username: user
password: supersecurepass
domain: addomain.tld
有關更多信息,請參閱https://pve.proxmox.com/pve-docs/api-viewer/index.html。
當前, zfspool
類型僅可用於images
和rootdir
內容。如果要將其他內容類型存儲在ZFS卷上,則需要使用類型dir
,PATH /<POOL>/<VOLUME>
指定它們,並在pve_zfs_create_volumes
中添加一個條目。此示例在ZFS池中添加了iso
存儲:
pve_zfs_create_volumes:
- rpool/iso
pve_storages:
- name: iso
type: dir
path: /rpool/iso
content: [ "iso" ]
有關模塊文檔,請參閱library/proxmox_storage.py
鏈接。
本節可以使用更多的愛。如果您正在積極使用此角色來管理PVE CEPH群集,請隨意更徹底地充實該部分並打開拉動請求!請參閱第68期。
PVE CEPH管理具有此角色是實驗性的。儘管用戶已經成功使用此角色來部署PVE CEPH,但在CI中尚未完全測試(由於缺乏可用的塊設備無法用作Travis CI中的OSD)。請在產品之前先用配置部署測試環境,並在任何遇到任何問題之前報告任何問題。
此角色可以在您的Proxmox主機上配置CEPH存儲系統。以下定義顯示了一些可能的配置。
pve_ceph_enabled: true
pve_ceph_network: '172.10.0.0/24'
pve_ceph_cluster_network: '172.10.1.0/24'
pve_ceph_nodes: "ceph_nodes"
pve_ceph_osds:
# OSD with everything on the same device
- device: /dev/sdc
# OSD with block.db/WAL on another device
- device: /dev/sdd
block.db: /dev/sdb1
# encrypted OSD with everything on the same device
- device: /dev/sdc
encrypted: true
# encrypted OSD with block.db/WAL on another device
- device: /dev/sdd
block.db: /dev/sdb1
encrypted: true
# Crush rules for different storage classes
# By default 'type' is set to host, you can find valid types at
# (https://docs.ceph.com/en/latest/rados/operations/crush-map/)
# listed under 'TYPES AND BUCKETS'
pve_ceph_crush_rules:
- name: replicated_rule
type: osd # This is an example of how you can override a pre-existing rule
- name: ssd
class: ssd
type: osd
min-size: 2
max-size: 8
- name: hdd
class: hdd
type: host
# 2 Ceph pools for VM disks which will also be defined as Proxmox storages
# Using different CRUSH rules
pve_ceph_pools:
- name: ssd
pgs: 128
rule: ssd
application: rbd
storage: true
# This Ceph pool uses custom size/replication values
- name: hdd
pgs: 32
rule: hdd
application: rbd
storage: true
size: 2
min-size: 1
# This Ceph pool uses custom autoscale mode : "off" | "on" | "warn"> (default = "warn")
- name: vm-storage
pgs: 128
rule: replicated_rule
application: rbd
autoscale_mode: "on"
storage: true
pve_ceph_fs:
# A CephFS filesystem not defined as a Proxmox storage
- name: backup
pgs: 64
rule: hdd
storage: false
mountpoint: /srv/proxmox/backup
pve_ceph_network
默認情況下使用ansible.utils.ipaddr
過濾器,該濾波器需要安裝netaddr
庫並由您的Ansible Controller安裝並可用。
pve_ceph_nodes
默認使用pve_group
,此參數允許在哪個節點安裝ceph上指定(例如,如果您不想在所有節點上安裝ceph)。
pve_ceph_osds
默認情況下會創建未加密的CEPH卷。要使用加密量,必須將每個驅動器設置為true
參數encrypted
。
可以將此角色配置為允許PCI設備從Proxmox主機傳遞到VM。默認情況下不啟用此功能,因為並非所有主板和CPU都支持此功能。為了啟用PassThrough,設備CPU必須支持硬件虛擬化(基於Intel的系統的VT-D和基於AMD的系統的AMD-V)。請參閱所有組件的手冊,以確定是否支持此功能。命名慣例會有所不同,但通常稱為IOMMU,VT-D或AMD-V。
通過啟用此功能,可以將專用設備(例如GPU或USB設備)傳遞到VM。除了專用設備外,Intel或AMD集成的GPU等各種集成設備也可以傳遞給VM。
一些設備能夠利用介導的用法。介導的設備可以傳遞到多個VMs以共享資源,同時仍然可以由主機系統使用。並不總是支持設備的分裂,應在啟用以防止錯誤之前進行驗證。請參閱您要通過的設備手冊,以確定設備是否能夠介導的用法(目前僅支持GVT-G; SR-IOV,目前不支持SR-IOV,並且必須在角色完成後手動啟用)。
以下是一個示例配置,可實現PCIE傳遞:
pve_pcie_passthrough_enabled : true
pve_iommu_passthrough_mode : true
pve_iommu_unsafe_interrupts : false
pve_mediated_devices_enabled : false
pve_pcie_ovmf_enabled : false
pve_pci_device_ids :
- id : " 10de:1381 "
- id : " 10de:0fbc "
pve_vfio_blacklist_drivers :
- name : " radeon "
- name : " nouveau "
- name : " nvidia "
pve_pcie_ignore_msrs : false
pve_pcie_report_msrs : true
pve_pcie_passthrough_enabled
需要使用任何PCIE PassThrough功能。如果沒有啟用此功能,所有其他與PCIE相關的字段都將被未使用。
pve_iommu_passthrough_mode
啟用Iommu Passhrough模式可能會提高設備性能。通過啟用此功能,它允許VM繞過通常由Hyper-Visor執行的默認DMA翻譯。相反,VMS將DMA請求直接傳遞給硬件IOMMU。
如果您的系統不支持中斷重新映射,則需要啟用pve_iommu_unsafe_interrupts
才能允許PCI通行。您可以找到檢查設備是否支持使用dmesg | grep 'remapping'
中斷重新映射。 dmesg | grep 'remapping'
。如果您看到以下幾行:
然後支持系統中斷重新映射,您無需啟用不安全的中斷。請注意,通過啟用此值,您的系統可能會變得不穩定。
pve_mediated_devices_enabled
啟用GVT-G支持Intel IGPU等集成設備。並非所有設備都支持GVT-G,因此建議事先向您的特定設備進行檢查以確保允許。
pve_pcie_ovmf_enabled
啟用GPU OVMF PCI PassThrough。使用OVMF時,您應該選擇“ OVMF”作為VM的BIOS選項,而不是Proxmox中的“ Seabios”。如果可能的話,此設置將嘗試從VGA仲裁中選擇退出設備。
pve_pci_device_ids
是設備和供應商ID的列表,希望從主機傳遞到VM。請參閱Proxmox Wiki上的“ GPU通行證”部分,以找到您的特定設備和供應商ID。設置此值時,需要為數組中的每個新元素指定一個“ ID”。
pve_vfio_blacklist_drivers
是一個被排除/黑名單的驅動程序列表。當通過PCI設備以防止主機將設備分配給VM之前,這是必需的。設置此值時,需要為數組中的每個新元素指定一個“名稱”。
pve_pcie_ignore_msrs
防止某些Windows應用程序,例如GeForce Experience,Passmark Performance Test和Sisoftware Sandra崩潰了VM。僅在將PCI設備傳遞給基於Windows的系統時才需要此值。
pve_pcie_report_msrs
可用於啟用或禁用MSRS警告的記錄消息。如果您在“ DMESG”系統日誌中看到很多警告消息,則可以使用此值來使MSRS警告保持沉默。
您可以使用pve_metric_servers
角色變量在Proxmox VE中配置公制服務器。以下是不同類型的度量服務器的示例配置:
pve_metric_servers :
- id : influxdb1
port : 8086
server : influxdb.example.com
type : influxdb
protocol : http
organization : myorg
bucket : mybucket
token : mytoken
timeout : 30
max_body_size : 25000000
verify_certificate : true
- id : graphite1
port : 2003
server : graphite.example.com
type : graphite
protocol : tcp
path : mygraphitepath
mtu : 1500
id
:(必需)公制服務器的唯一標識符。port
:(可選)公制服務器的端口。默認值為8089
。server
:(必需)DNS名稱或公制服務器的IP地址。type
:(可選)公制服務器類型。可能的值: influxdb
, graphite
。默認值為influxdb
。protocol
:(可選)用於發送指標的協議。可能的值: udp
, tcp
, http
, https
。默認值為udp
。disable
:(可選)禁用公制服務器。默認值為false
。organization
:(可選)組織名稱。僅適用於HTTP V2 API的InfluxDB。bucket
:(可選)infuxdb的存儲桶名。僅適用於HTTP V2 API或兼容。token
:(可選)InfluxDB訪問令牌。僅在使用HTTP V2 API時才需要。path
:(可選)石墨根路徑。僅用於石墨。api_path_prefix
:(可選)API路徑前綴插入<host>:<port>/
and /api2/
。如果InfluxDB服務在反向代理後面運行,則有用。僅適用於HTTP V2 API的InfluxDB。timeout
:(可選)以秒為單位。僅適用於HTTP V2 API或Graphite TCP插座的InfluxDB。max_body_size
:(可選)字節中的最大身體大小。僅適用於HTTP V2 API的InfluxDB。默認值為25000000
。mtu
:(可選)MTU用於UDP度量傳輸。verify_certificate
:(可選)驗證SSL證書。僅適用於帶有HTTPS的流入室。 Proxmox 8.2引入Linux 6.8,這可能會在某些部署中引起問題。為了解決此問題,您可以通過添加以下角色變量來固定使用的內核版本:
pve_default_kernel_version : 1.0.1
這將在proxmox-default-kernel
軟件包上創建PIN,這是PVE建議的方法。以後可以通過解開此角色變量來刪除它。
將此部分添加到您的ansible.cfg
中。
[ssh_connection]
ssh_args = -o ServerAliveInterval=20
參考問題
在開發新功能或在此角色中修復某些內容時,您可以使用Vagrant測試更改(目前僅支持Libvirt)。可以在tests/vagrant
中找到劇本(因此請確保根據需要修改組變量)。請確保在提交PR之前,請測試所有受支持版本的Debian版本(在本地更新VagrantFile,以使用debian/bookworm64
, debian/bullseye64
或debian/buster64
)。
您還可以指定APT緩存代理(例如apt-cacher-ng
,並且必須在端口3142上運行)使用APT_CACHE_HOST
環境變量,如果您在環境中本地運行一個,則可以加快程序包下載。流浪者劇本將檢測是否可用的緩存代理,並且僅在可以從網絡訪問的情況下使用它,因此,如果您願意,您只需在開發環境中永久設置此變量即可。
例如,您可以運行以下內容以顯示詳細信息/更易於讀取輸出,使用緩存代理並在遇到錯誤時保持VMS運行(以便您可以對其進行故障排除和/或在修復後運行vagrant provision
):
APT_CACHE_HOST=10.71.71.10 ANSIBLE_STDOUT_CALLBACK=debug vagrant up --no-destroy-on-error
Musee Ullah(@lae,[email protected]) - 主要開發人員
Fabien Brachere(@fbrachere) - 存儲配置支持
Gaudenz Steinlin(@Gaundez) - Ceph支持等
理查德·斯科特(Richard Scott)(@zenntrix) - CEPH支持,PVE 7.x支持等
Thoralf Rickert -Wendt(@Trickert76) - PVE 6.x支持等
Engin Dumlu(@RoadRunner)
喬納斯·梅雷爾(@mejo-)
Ondrej Flidr(@snipercze)
niko2(@niko2)
Christian Aublet(@caublet)
吉爾·皮特里(@gilou)
邁克爾·哈拉斯克(@mholasek)
Alexander Petermann(@lexxxel)-PVE 8.x支持等
Bruno Travouillon(@btravouillon) - UX改進
tobias negd(@wu3rstle)-Ceph支持
pendagtp(@pendagtp)-Ceph支持
約翰·馬里恩(John Marion)(@jmariondev)
foerkede(@foerkede)-ZFS存儲支持
Guiffo Joel(@futuriste) - 池配置支持
Adam Delo(@ol3d) - PCIE PASSTHROUGH支持Antoine Thys(@thystips) - 公制服務器支持
貢獻者的完整列表