Обновить ansible/expand_ubuntu_disk_workflow.yml
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
current_disk_gb: "{{ (sda_size_bytes.stdout | int) // 1024 // 1024 // 1024 }}"
|
current_disk_gb: "{{ (sda_size_bytes.stdout | int) // 1024 // 1024 // 1024 }}"
|
||||||
target_disk_gb: "{{ ((sda_size_bytes.stdout | int) // 1024 // 1024 // 1024) + (increase_gb | int) }}"
|
target_disk_gb: "{{ ((sda_size_bytes.stdout | int) // 1024 // 1024 // 1024) + (increase_gb | int) }}"
|
||||||
|
|
||||||
- name: Stage 4 - Expand disk in vCenter
|
- name: Stage 4 - Power off VM in vCenter
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
@@ -68,6 +68,24 @@
|
|||||||
- "Current disk: {{ hostvars['ubuntu-resize-target']['current_disk_gb'] }} GB"
|
- "Current disk: {{ hostvars['ubuntu-resize-target']['current_disk_gb'] }} GB"
|
||||||
- "Target disk: {{ hostvars['ubuntu-resize-target']['target_disk_gb'] }} GB"
|
- "Target disk: {{ hostvars['ubuntu-resize-target']['target_disk_gb'] }} GB"
|
||||||
|
|
||||||
|
- name: Power off VM gracefully
|
||||||
|
community.vmware.vmware_guest_powerstate:
|
||||||
|
hostname: "{{ vsphere_server }}"
|
||||||
|
username: "{{ vsphere_user }}"
|
||||||
|
password: "{{ vsphere_password }}"
|
||||||
|
validate_certs: false
|
||||||
|
datacenter: "{{ vsphere_datacenter }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
state: powered-off
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Wait until SSH port is closed
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
host: "{{ vm_ip }}"
|
||||||
|
port: 22
|
||||||
|
state: drained
|
||||||
|
timeout: 180
|
||||||
|
|
||||||
- name: Expand VMware disk
|
- name: Expand VMware disk
|
||||||
community.vmware.vmware_guest_disk:
|
community.vmware.vmware_guest_disk:
|
||||||
hostname: "{{ vsphere_server }}"
|
hostname: "{{ vsphere_server }}"
|
||||||
@@ -83,7 +101,37 @@
|
|||||||
size_gb: "{{ hostvars['ubuntu-resize-target']['target_disk_gb'] }}"
|
size_gb: "{{ hostvars['ubuntu-resize-target']['target_disk_gb'] }}"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Stage 5 - Expand partition, LVM and filesystem inside Ubuntu
|
- name: Power on VM
|
||||||
|
community.vmware.vmware_guest_powerstate:
|
||||||
|
hostname: "{{ vsphere_server }}"
|
||||||
|
username: "{{ vsphere_user }}"
|
||||||
|
password: "{{ vsphere_password }}"
|
||||||
|
validate_certs: false
|
||||||
|
datacenter: "{{ vsphere_datacenter }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
state: powered-on
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Wait for SSH port to return
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
host: "{{ vm_ip }}"
|
||||||
|
port: 22
|
||||||
|
timeout: 300
|
||||||
|
sleep: 5
|
||||||
|
|
||||||
|
- name: Stage 5 - Wait for SSH session after reboot
|
||||||
|
hosts: ubuntu_resize_group
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Wait for SSH connection
|
||||||
|
ansible.builtin.wait_for_connection:
|
||||||
|
timeout: 300
|
||||||
|
|
||||||
|
- name: Stage 6 - Expand partition, LVM and filesystem inside Ubuntu
|
||||||
hosts: ubuntu_resize_group
|
hosts: ubuntu_resize_group
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
become: true
|
become: true
|
||||||
|
|||||||
Reference in New Issue
Block a user