--- # tasks file for proxmox - name: Install prerequisite ansible.builtin.apt: name: python3-proxmoxer update_cache: true become: true - name: Manage Proxmox VE node bridge interface community.proxmox.proxmox_node_network: api_host: "{{ proxmox_api_host }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" api_user: "{{ proxmox_api_user }}" autostart: "{{ item.autostart | default(true) }}" cidr: "{{ item.cidr | default(omit) }}" cidr6: "{{ item.cidr6 | default(omit) }}" comments: "{{ item.comments | default(omit) }}" gateway: "{{ item.gateway | default(omit) }}" gateway6: "{{ item.gateway6 | default(omit) }}" iface_type: bridge iface: "{{ item.iface }}" mtu: "{{ item.mtu | default(omit) }}" node: "{{ inventory_hostname_short }}" state: "{{ item.states | default('present') }}" validate_certs: "{{ proxmox_api_validate_certs }}" become: true loop: "{{ proxmox_node_interfaces | selectattr('type', 'equalto', 'bridge') }}" loop_control: label: "{{ item.iface }}" - name: Manage Proxmox VE node eth interface community.proxmox.proxmox_node_network: api_host: "{{ proxmox_api_host }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" api_user: "{{ proxmox_api_user }}" autostart: "{{ item.autostart | default(true) }}" cidr: "{{ item.cidr | default(omit) }}" cidr6: "{{ item.cidr6 | default(omit) }}" comments: "{{ item.comments | default(omit) }}" gateway: "{{ item.gateway | default(omit) }}" gateway6: "{{ item.gateway6 | default(omit) }}" iface_type: eth iface: "{{ item.iface }}" mtu: "{{ item.mtu | default(omit) }}" node: "{{ inventory_hostname_short }}" state: "{{ item.states | default('present') }}" validate_certs: "{{ proxmox_api_validate_certs }}" become: true loop: "{{ proxmox_node_interfaces | selectattr('type', 'equalto', 'eth') }}" loop_control: label: "{{ item.iface }}" - name: Proxmox VE cluster management tasks when: proxmox_cluster_name | length > 0 block: - name: List existing Proxmox VE cluster join information community.proxmox.proxmox_cluster_join_info: api_host: "{{ proxmox_api_host }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" api_user: "{{ proxmox_api_user }}" validate_certs: "{{ proxmox_api_validate_certs }}" become: true register: proxmox_cluster_join - name: Define variables to join an existing Proxmox VE cluster ansible.builtin.set_fact: proxmox_cluster_name: "{{ proxmox_cluster_join.cluster_join.totem.cluster_name }}" proxmox_cluster_master_ip: "{{ proxmox_cluster_join.cluster_join.nodelist[0].pve_addr }}" proxmox_cluster_fingerprint: "{{ proxmox_cluster_join.cluster_join.nodelist[0].pve_fp }}" when: proxmox_cluster_join.cluster_join.nodelist | length > 0 - name: Manage Proxmox VE Cluster community.proxmox.proxmox_cluster: api_host: "{{ proxmox_api_host }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" api_user: "{{ proxmox_api_user }}" cluster_name: "{{ proxmox_cluster_name }}" fingerprint: "{{ proxmox_cluster_fingerprint | default(omit) }}" link0: "{{ proxmox_cluster_link0 | default(omit) }}" link1: "{{ proxmox_cluster_link1 | default(omit) }}" master_ip: "{{ proxmox_cluster_master_ip | default(omit) }}" state: "{{ item.states | default('present') }}" validate_certs: "{{ proxmox_api_validate_certs }}" become: true when: >- proxmox_cluster_join.cluster_join.nodelist | length == 0 or proxmox_cluster_join.cluster_join.nodelist | selectattr('name', 'equalto', inventory_hostname_short) | list | length == 0 - name: Manage Proxmox VE storage community.proxmox.proxmox_storage: api_host: "{{ proxmox_api_host }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" api_user: "{{ proxmox_api_user }}" content: "{{ item.content }}" name: "{{ item.name }}" nfs_options: "{{ item.nfs_options | default(omit) }}" nodes: "{{ item.nodes }}" state: "{{ item.states | default('present') }}" type: "{{ item.type }}" validate_certs: "{{ proxmox_api_validate_certs }}" loop: "{{ proxmox_storage }}" loop_control: label: "{{ item.name }}" - name: Download images ansible.builtin.get_url: url: "{{ item.url }}" dest: "{{ item.dest }}" mode: u=rw,g=r,o=r become: true loop: "{{ proxmox_images }}" loop_control: label: "{{ item.dest | ansible.builtin.basename }}"