You've already forked role_proxmox
feat: Create role
This commit is contained in:
94
handlers/main.yml
Normal file
94
handlers/main.yml
Normal file
@@ -0,0 +1,94 @@
|
||||
---
|
||||
# handlers file for proxmox
|
||||
|
||||
- name: Configure cloud-init
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
agent: "enabled=1,fstrim_cloned_disks=1"
|
||||
cipassword: "{{ proxmox_instance_cloudinit_cipassword }}"
|
||||
ciuser: "{{ proxmox_instance_cloudinit_ciuser }}"
|
||||
ciupgrade: false
|
||||
ide:
|
||||
ide2: "{{ proxmox_instance_disks[0].storage }}:cloudinit"
|
||||
ipconfig: "{{ proxmox_instance_ipconfig }}"
|
||||
name: "{{ inventory_hostname }}"
|
||||
nameservers: "{{ proxmox_instance_cloudinit_nameservers }}"
|
||||
node: "{{ proxmox_instance_node }}"
|
||||
searchdomains: "{{ proxmox_instance_cloudinit_searchdomains }}"
|
||||
sshkeys: "{{ proxmox_instance_cloudinit_sshkeys }}"
|
||||
vmid: "{{ proxmox_instance_vmid }}"
|
||||
update: true
|
||||
update_unsafe: true
|
||||
when: proxmox_instance_cloudinit
|
||||
delegate_to: "{{ proxmox_delegate_to | default(omit) }}"
|
||||
|
||||
- name: Start instance
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
name: "{{ inventory_hostname }}"
|
||||
node: "{{ proxmox_instance_node }}"
|
||||
state: started
|
||||
when:
|
||||
- proxmox_start_instance
|
||||
- not rebooted.changed
|
||||
delegate_to: "{{ proxmox_delegate_to | default(omit) }}"
|
||||
|
||||
- name: Wait SSH port is open
|
||||
ansible.builtin.wait_for:
|
||||
host: "{{ proxmox_instance_ssh_ip }}"
|
||||
port: "{{ proxmox_instance_ssh_port }}"
|
||||
search_regex: OpenSSH
|
||||
delay: 30
|
||||
when: proxmox_start_instance
|
||||
delegate_to: "{{ proxmox_delegate_to | default(omit) }}"
|
||||
|
||||
- name: Wait cloud-init
|
||||
ansible.builtin.command: # noqa: no-changed-when
|
||||
cmd: cloud-init status
|
||||
when: proxmox_instance_cloudinit
|
||||
register: cloudinit_status
|
||||
until: cloudinit_status.stdout.find("done") != -1
|
||||
retries: 100
|
||||
delay: 36
|
||||
ignore_errors: true
|
||||
|
||||
- name: Enable maintenance mode
|
||||
ansible.builtin.command: # noqa: no-changed-when
|
||||
argv:
|
||||
- ha-manager
|
||||
- crm-command
|
||||
- node-maintenance
|
||||
- enable
|
||||
- "{{ inventory_hostname_short }}"
|
||||
become: true
|
||||
listen: Upgrade the node
|
||||
|
||||
- name: Wait instances migration
|
||||
ansible.builtin.command: # noqa: no-changed-when
|
||||
argv:
|
||||
- ha-manager
|
||||
- status
|
||||
become: true
|
||||
register: ha_manager_status
|
||||
retries: 10
|
||||
delay: 60
|
||||
until: not ha_manager_status.stdout_lines | regex_search('migrate', ignorecase=true)
|
||||
listen: Upgrade the node
|
||||
|
||||
- name: Run the full-upgrade
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
update_cache: true
|
||||
become: true
|
||||
listen: Upgrade the node
|
||||
|
||||
- name: Reboot
|
||||
ansible.builtin.reboot:
|
||||
become: true
|
||||
listen: Upgrade the node
|
Reference in New Issue
Block a user