alt_vkr/ansible/roles/deploy_vms/tasks/deploy_servers.yml

61 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
- name: Серверы - Клонирование ВМ из шаблона
community.general.proxmox_kvm:
node: "{{ node }}"
name: "{{ item.value.name }}"
newid: "{{ item.value.vmid }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
api_host: "{{ api_host }}"
clone: "{{ server_template }}"
storage: "{{ pve_storage }}"
format: qcow2
timeout: 500
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Настройка IP адресов
command: "qm set {{ item.value.vmid }} --ipconfig0 gw={{ item.value.gw }},ip={{ item.value.ip }}"
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Настройка DNS
command: "qm set {{ item.value.vmid }} --nameserver {{ item.value.dns }}"
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Создание пользователя root
command: "qm set {{ item.value.vmid }} --ciuser {{ vm_user }}"
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Создание пароля пользователя root
command: "qm set {{ item.value.vmid }} --cipassword {{ vm_password }}"
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Копирование SSH ключей в ВМ
command: "qm set {{ item.value.vmid }} --sshkey {{ key_name }}"
args:
chdir: ~/.ssh
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Обновление параметров ВМ
community.general.proxmox_kvm:
api_host: "{{ api_host }}"
api_user: "{{ api_user }}"
api_password: "{{ api_password }}"
cores: "{{ item.value.cores }}"
sockets: "{{ item.value.sockets }}"
memory: "{{ item.value.memory }}"
update: true
vmid: "{{ item.value.vmid }}"
node: "{{ node }}"
name: "{{ item.value.name }}"
loop: "{{ lookup('dict', server_vms) }}"
- name: Серверы - Запуск ВМ
community.general.proxmox_kvm:
api_host: "{{ api_host }}"
api_password: "{{ api_password }}"
api_user: "{{ api_user }}"
vmid: "{{ item.value.vmid }}"
node: "{{ node }}"
state: started
loop: "{{ lookup('dict', server_vms) }}"