Ansible“msg”:“无法在 TCP/443 上的 IP 连接到 vCenter 或 ESXi API:[SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:618)”

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

我正在针对主机运行剧本并收到此错误:

“msg”:“无法在 TCP/443 上连接到位于 192.11.11.111 的 vCenter 或 ESXi API:[SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:618)”

我们使用的是 vCenter 6.5。我有一个剧本,可以让 Ansible 控制器与 vSphere vCenter 对话。我从 vSphere 主页导出了受信任的根 SSL 证书。复制到我的 Ansible 控制器并安装:

sudo mv 9dab0099.0.crt 9dab0099.r0.crl 11ec582d.0.crt /etc/pki/ca-trust/source/anchors
 
sudo update-ca-trust force -enable
 
sudo update-ca-trust extract
  • 能够远程登录到 443 上的主机
  • 能够连续 ping 主机
  • 尝试将 validate_certs 更改为:否
  • 尝试将 validate_certs 更改为:是
  • 尝试将 validate_certs 更改为: false

我的剧本:

- name: Add an additional cpu to virtual machine server
  hosts: '{{ target }}' 
  
  tasks: 
    - name: Login into vCenter and get cookies
      vmware_guest: 
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        folder: "{{ vm_folder }}"   
        cluster: "{{ vcenter_cluster }}"
        datacenter: "{{ vcenter_datacenter }}"
        name: "{{ vm_name }}"
    - name:
      uri:
        url: https://{{ vcenter_hostname }} #/rest/com/vmware/cis/session
        force_basic_auth: yes
        validate_certs: no
        method: POST
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        folder: "{{ vm_folder }}"   
        cluster: "{{ vcenter_cluster }}"
        datacenter: "{{ vcenter_datacenter }}"
        name: "{{ vm_name }}"
      #register: login
  
    - name: Stop virtual machine
      vmware_guest:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        validate_certs: no
        folder: "{{ vm_folder }}"   
        cluster: "{{ vcenter_cluster }}"
        datacenter: "{{ vcenter_datacenter }}"
        name: "{{ vm_name }}"
        state: "poweredoff"

    - name: reconfigure CPU and RAM of VM
      vmware_guest:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        cluster: "{{ vcenter_cluster }}"
        datacenter: "{{ vcenter_datacenter }}"
        name: "{{ vm_name }}"
        state: "present"
        validate_certs: "false"
        folder: "{{ vm_folder }}"
        hardware:
          memory_gb: "{{ memory }}"
          num_cpus: "{{ cpu }}"
        scsi: "lsilogic"

我的 ESXi 防火墙规则已打开。

我用Python 2.7.5和Python 3.6重现了错误,并安装了最新版本的pyvmomi。

有人能从这里给我指出正确的方向吗?

ssl ansible vmware vcenter
1个回答
4
投票

尝试放置

validate_certs: no

进入任务

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