使用 Ansible 实现自动化运维VMware vSphere(入门)

文章目录
  • 概述:
  • 配置:
  • 总结:
  • 概述:

    使用ansible能实现自动化运维,牛刀小试一下,使用 Ansible 来实现自动化运维VMware vSphere ESXi。

    配置:

    配置inventory主机清单,如下

    [vmware]
    192.xx.xx.14 ansible_user="youruser" ansible_password="yourpassword"
    192.xx.xx.15 ansible_user="youruser" ansible_password="yourpassword"

    配置ansible.cfg

    [default]
    remote_user = root
    inventory = /root/ansible/inventory
    
    [privilege_escalation]
    become_method = sudo
    become_user = root
    become_ask_pass = flase

    生成公钥和私钥

     ssh-keygen -N ''

    将秘钥发给vSphere ESXi主机

    ssh-copy-id root@192.xx.xx.14
    ssh-copy-id root@192.xx.xx.15

    验证:

    国际惯例,先检测主机是否在线。

    ansible -i inventory vmware -m ping

    查看当前VMware ESXi 的版本

    ansible -i inventory vmware -m -shell -a 'vmware -v'

    再或者,看下网卡列表?

    ansible -i inventory vmware -m shell -a 'esxcli network nic list'

    总结:

    通过简单的shell模块可以直接批量执行任务,由此思路是否可以实现对大量的vSphere 主机进行批量升级?自动升级呢?未完待续。

    0

    1. This post has no comment yet

    发表回复

    您的邮箱地址不会被公开。 必填项已用 * 标注

    使用DLVM本地部署DeepSeek(补充)
    使用DLVM本地部署DeepSeek(补充)
    Linux 6 张图
    Error response from daemon: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
    Error response from daemon: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
    Linux 2 张图
    MySQL 30周年庆 OCP 认证免费
    MySQL 30周年庆 OCP 认证免费
    Linux 5 张图
    使用Kubeadm在Ubuntu 20.04中部署Kubernetes
    使用Kubeadm在Ubuntu 20.04中部署Kubernetes
    Linux 24 张图
    在Linux上安装和配置Squid代理服务器
    在Linux上安装和配置Squid代理服务器
    Linux 10 张图
    Wifipumpkin3 安装记录
    Wifipumpkin3 安装记录
    Linux 1 张图
    © 2025 诺诺博客如有侵权请联系删除 | 网站地图 | 百度统计 | 又拍云CDN加速
    为了获得更好的浏览效果 建议您使用IE8.0及以上版本浏览器登陆本站点 · 服务器托管于腾讯云
    📢 小站正在装修中,如页面异常请包涵!