有人可以请教。 我在做什么是在远程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:\Users\administrator\Downloads'
name: Install application
win_package:
path: 'C:\Users\administrator\Downloads\PhpStorm-2018.2.5.exe'
product_id: "PhpStorm"
arguments: /S /install
state: present
答案 0 :(得分:0)
Ansible本身不知道从何处下载32位版本或64位版本。如果只有64位目标计算机,则只需指定64位可执行文件的路径即可。
如果您拥有两种架构,则可以编写两个单独的任务,并使用与when
变量关联的ansible_architecture
关键字,其值可以为32 bits
或64 bits
,见下文。
另外,由于win_package可以在同一任务中完成两项任务,因此您可能不需要两个单独的下载和安装操作。
---
- 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