繁体   English   中英

ansible win exe 安装 32/64 位

[英]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:\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 本身不知道从哪里下载 32 位版本或 64 位版本。 如果您只有 64 位目标机器,只需指定 64 位可执行文件的路径。

如果您有两种架构,则可以编写两个单独的任务并使用与ansible_architecture变量关联的when关键字,该值可以是32 bits64 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"

为了更简单,您还可以使用提供 phpstorm 包的 Chocolatey,请参阅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

暂无
暂无

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

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