不运行vmware_guest运行时

问题描述 投票:0回答:1

我具有以下任务,用于从模板部署Windows 2016 VM。除了未执行的runonce命令之外,我所有的自定义设置均正确完成。即使在调试模式下运行剧本,也不会出现错误或警告。

- name: "[DEEPLOY-INSTANCE] Create a VM Win From a template"
  vmware_guest:
        hostname: "{{ vmware.host }}"
        username: "{{ vmware.username }}"
        password: "{{ vmware.password }}"
        validate_certs: False
        datacenter: "{{ vm_datacenter }}"
        cluster: "{{ vm_cluster }}"
        name: "{{ vm_name }}"
        template: "{{ vm_template_full }}"
        folder: "{{ vm_folder }}"
        datastore: "{{ vm_datastore }}"
        hardware:
          num_cpus: "{{ vm_cpu }}"
          memory_mb: "{{ vm_ram }}"
        networks: 
        - name: "{{ vm_netname }}"
          start_connected: yes
          ip: "{{ vm_ip }}"
          netmask: "{{ vm_mask }}"
          gateway: "{{ vm_gw }}"
          type: static  
        customization:
          fullname: "Windows Server"
          orgname: "My Company"
          timezone: 110
          dns_servers:
           - 10.100.100.10
           - 10.100.110.10
          domain: "{{ domain }}"
          joindomain: "{{ domain }}"
          password: "{{ template_pass }}"
          domainadmin: "{{ vmware.username }}"
          domainadminpassword: "{{ vmware.password }}"
          runonce:
          - 'powershell.exe -ExecutionPolicy Unrestricted -File C:\Admin\Scripts\RunOnce.bat'
  register: vm_facts
  delegate_to: localhost

我尝试将整个runonce命令放在单引号和双引号之间,但输出是相同的。如果我检查日志C:\ WINDOWS \ TEMP \ vmware-imc \ guestcust.log,甚至都没有提到尝试执行runone,但其中包含有关正在执行某些自定义的信息。

Ansible版本为2.9

编辑

将runonce的索引更改为我现在拥有的索引,尽管无论有没有引号,它都无法正常工作。作为解决方法,我设法使用模块vmware_vm_shell

在单独的任务上启动了.bat文件。
ansible vmware
1个回答
0
投票

您能否像下面那样纠正缩进并尝试一次

runonce:
- powershell.exe -ExecutionPolicy Unrestricted -File C:\Admin\Scripts\RunOnce.bat

请参阅此问题:https://github.com/ansible/ansible/issues/28312

© www.soinside.com 2019 - 2024. All rights reserved.