ansible win exe install 32/64 bit



有人能提供建议吗。我正在做的是在远程windows机器上下载phpstorme并安装它,但它安装了32位,我怎么能强迫ansible安装64位?提前谢谢。下面的剧本。

---
- hosts: win
gather_facts: true
#  ansible_connection: winrm
tasks:
name: Download  application
win_get_url:
url: https://download-cf.jetbrains.com/webide/PhpStorm-2018.2.5.exe
dest: 'C:UsersadministratorDownloads'
name: Install application
win_package:
path: 'C:UsersadministratorDownloadsPhpStorm-2018.2.5.exe'
product_id: "PhpStorm"
arguments: /S /install
state: present

Ansible自己不知道在哪里下载32位版本或64位版本。如果只有64位目标计算机,只需指定64位可执行文件的路径即可。

如果同时具有这两种体系结构,则可以编写两个单独的任务,并使用与ansible_architecture变量相关联的when关键字,该值可以是32 bits64 bits,请参阅下文。

此外,您可能不需要有两个单独的下载和安装操作,因为win_package可以在相同的taks中同时执行这两个操作。

---
- hosts: win
gather_facts: true
#  ansible_connection: winrm
tasks:
name: Download and install application, 32 bit case
win_package:
path: 'https://download-cf.jetbrains.com/[path-of-the-32-bits-edition].exe'
product_id: "PhpStorm"
arguments: /S /install
state: present
when: ansible_architecture == "32 bits"
name: Download and install application, 64 bit case
win_package:
path: 'https://download-cf.jetbrains.com/[path-of-the-64-bits-edition].exe'
product_id: "PhpStorm"
arguments: /S /install
state: present
when: ansible_architecture == "64 bits"

为了更简单,您还可以使用Chocolatey,他提供了phpstorm包,请参阅https://chocolatey.org/packages/phpstorm

Ansible能够使用win_chocolatey安装Chocolatey软件包,请参阅https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.

使用Chocolatey软件包的优点是多方面的,例如依赖关系管理、自动更新版本(如果需要,可以保持在指定版本(、。。。

在这里,您的playBook可以简化为:

---
- hosts: win
gather_facts: true
#  ansible_connection: winrm
tasks:
- name: choco install phpstorm
win_chocolatey:
name: phpstorm
state: latest

最新更新