bk node and refactor
This commit is contained in:
@@ -49,8 +49,7 @@
|
||||
register: "is_seediso"
|
||||
|
||||
- name: Create seed.iso
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
ansible.builtin.shell: |
|
||||
cloud-localds -N {{ hostvars['console']['node']['data_path'] }}/images/seeds/{{ target_vm }}/network-config \
|
||||
{{ hostvars['console']['node']['data_path'] }}/images/seeds/{{ target_vm }}/seed.iso \
|
||||
{{ hostvars['console']['node']['data_path'] }}/images/seeds/{{ target_vm }}/user-data \
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
become: true
|
||||
|
||||
- name: Check deployed cloud-init file info
|
||||
ansible.builtin.command:
|
||||
cmd: "qemu-img info {{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2 --output json"
|
||||
ansible.builtin.command: |
|
||||
qemu-img info {{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2 --output json
|
||||
changed_when: false
|
||||
failed_when:
|
||||
- deployed_cloudfile_info.rc != 0
|
||||
@@ -37,29 +37,29 @@
|
||||
register: "deployed_cloudfile_info"
|
||||
|
||||
- name: Resize deployed cloud-init file
|
||||
ansible.builtin.command:
|
||||
cmd: "qemu-img resize {{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2 {{ hostvars[target_vm]['vm']['storage'] }}G"
|
||||
ansible.builtin.command: |
|
||||
qemu-img resize {{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2 {{ hostvars[target_vm]['vm']['storage'] }}G
|
||||
when:
|
||||
- deployed_cloudfile_info.rc == 0
|
||||
- (deployed_cloudfile_info.stdout | from_json)['virtual-size'] < (hostvars[target_vm]['vm']['storage'] | int * 1024 * 1024 * 1024)
|
||||
changed_when: true
|
||||
|
||||
- name: Check app data raw image
|
||||
- name: Check bk/app raw image
|
||||
ansible.builtin.stat:
|
||||
path: "{{ hardware['btrfs']['mount_point'] }}/{{ target_vm }}.raw"
|
||||
path: "{{ hardware['disk'][hostvars[target_vm]['vm']['data_storage']['pool']]['fs']['mount_point'] }}/{{ target_vm }}.raw"
|
||||
get_checksum: false
|
||||
get_mime: false
|
||||
get_attributes: false
|
||||
when: target_vm == "app"
|
||||
when: target_vm in ["bk", "app"]
|
||||
register: "is_app_data"
|
||||
|
||||
- name: Create app data raw image
|
||||
ansible.builtin.command:
|
||||
# 3.5T
|
||||
cmd: "qemu-img create -f raw {{ hardware['btrfs']['mount_point'] }}/{{ target_vm }}.raw {{ hostvars[target_vm]['vm']['data_storage']['size'] }}T"
|
||||
- name: Create bk/app raw image
|
||||
ansible.builtin.command: |
|
||||
qemu-img create -f raw {{ hardware['disk'][hostvars[target_vm]['vm']['data_storage']['pool']]['fs']['mount_point'] }}/{{ target_vm }}.raw \
|
||||
{{ hostvars[target_vm]['vm']['data_storage']['size'] }}T
|
||||
become: true
|
||||
when:
|
||||
- target_vm == "app"
|
||||
- target_vm in ["bk", "app"]
|
||||
- not is_app_data.stat.exists
|
||||
changed_when: true
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
command: define
|
||||
|
||||
- name: Deploy VM systemd file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ hostvars['console']['node']['config_path'] }}/services/systemd/vmm/libvirt/services/{{ target_vm }}.service"
|
||||
ansible.builtin.template:
|
||||
src: "{{ hostvars['console']['node']['config_path'] }}/services/systemd/vmm/libvirt/services/{{ target_vm }}.service.j2"
|
||||
dest: "{{ node['home_path'] }}/.config/systemd/user/{{ target_vm }}.service"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
group: "{{ node['group'] }}"
|
||||
mode: "0400"
|
||||
|
||||
- name: Register VM service
|
||||
|
||||
Reference in New Issue
Block a user