通过 Ansible 创建 VM 并将应用程序部署到 Azure VM

Create VM and deploy application on to Azure VM via Ansible

我是 Ansible Azure 模块的新手。我需要的是创建 VM's(n) 并在所有虚拟机上部署应用程序的能力。根据我在网上阅读的内容 azure_rm_virtual machine can be used to create VM(Assuming vnet, subnet and other networking jazz is in place). I am trying to figure out how do I deploy(copy bits and run my app installer) my application onto the newly created VM's? Can my app deployment be part of the VM creation process? If so what are the options? I looked into other modules 但找不到任何相关的内容。在天蓝色的文档中也没有找到任何内容。谢谢

使用azure_rm_deployment模块创建虚拟机。

因为您知道自己在部署什么,所以使用 azure_rm_networkinterface_facts 获取 VM 的 IP 地址。

使用 add_host 创建临时清单。这一切都与:

---
- name: Create VM
  hosts: localhost
  gather_facts: true

拥有库存后使用:

- name: Run updates
  hosts: myazureinventory
  gather_facts: true

从这里,您可以安装您的软件。希望对你有帮助。