简体   繁体   English

ansible win exe 安装 32/64 位

[英]ansible win exe install 32/64 bit

can someone please advise.有人可以请指教。 What im doing is downloading phpstorme in remote windows machine and installing it, but it installed 32 bit, how can i force ansible to install 64bit?我在做什么是在远程 Windows 机器上下载 phpstorme 并安装它,但它安装了 32 位,我如何强制 ansible 安装 64 位? Thank you in advance.先感谢您。 playbook below.下面的剧本。

---
- 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

Ansible does not know by itself where to download a 32 bits version or a 64 bits one. Ansible 本身不知道从哪里下载 32 位版本或 64 位版本。 If you have 64 bits target machine only, just specify the path of the 64 bits executable.如果您只有 64 位目标机器,只需指定 64 位可执行文件的路径。

If you have both architectures, you can write two separate tasks and use the when keyword associated with the ansible_architecture variable, which value can be 32 bits or 64 bits , see below.如果您有两种架构,则可以编写两个单独的任务并使用与ansible_architecture变量关联的when关键字,该值可以是32 bits64 bits ,见下文。

Also you probably do not need to have two separates download and install operations, since win_package is able to do both in the same taks.此外,您可能不需要进行两个单独的下载和安装操作,因为 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"

To make it even simplier, you can also use Chocolatey, who provides a phpstorm package, see https://chocolatey.org/packages/phpstorm为了更简单,您还可以使用提供 phpstorm 包的 Chocolatey,请参阅https://chocolatey.org/packages/phpstorm

Ansible is capable of installing Chocolatey packages, using win_chocolatey , see https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html . Ansible 能够使用win_chocolatey安装 Chocolatey 软件包,请参阅https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html

The advantages of using Chocolatey packages are multiple, for instance dependencies management, automatically update version (or stay at specified version if this is wanted), ...使用 Chocolatey 包的优点是多方面的,例如依赖项管理、自动更新版本(或者如果需要的话保持在指定版本)、...

Here your playBook can be reduced to:在这里,您的 playBook 可以简化为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM