Ansible關於windows的管理

來源:互聯網
上載者:User

標籤:ansible;windows

Ansible 是基於python的常用自動化營運工具。之所以選ansible是因為它簡單,不需要用戶端,最關鍵的地方是其他的我沒用過。
Ansible 的管理主機必須要安裝在linux環境下的,這個是官方的要求。系統是centos 7.4 ,python就不說了,系統預設必備的。Ansible 對於linux的管理我就不說了,網上大把的文章,我們來研究一下ansible對Windows方面管理。

  1. 環境搭建
    Ansible 安裝方法:
    yum install ansible
    對,你沒看錯,就這麼簡單,當然有人喜歡自訂進行編譯安裝,我覺得沒必要,centos 升級到7之後,很多東西都規範了,不像5或者6的時候,yum 和rpm安裝的檔案包位置很亂不好找,7之後呢,就在固定的檔案夾下了,可以自行搜尋。
    修改設定檔,編輯/etc/ansible/ansible.cfg,指定hosts位置就行:
    vi /etc/ansible/ansible.cfg
    [hosts]
    hostfile = /etc/ansible/hosts
    gather_subset = all
    #remote_user = root
    #remote_port = 22
    host_key_checking = false
    warn=False

    Windows 串連模組安裝:
    yum install python-winrm
    這就完事了,是不是很簡單啊。
    接下來我們在hosts檔案中添加windows機器
    [web]
    iistest-2..com [email protected] ansiblepassword= ansibleport=5985 ansibleconnection=winrm ansiblewinrmtransport=kerberos ansiblewinrmkinitmode=managed
    Iistest-2..com 這是主機名稱,如果沒有內部dns,這裡可以填寫IP地址
    我這邊所有機器都加域了,所有就用域帳號和密碼進行串連,域帳號使用[email protected],域必須大寫,否則驗證不通過,驗證方式是kerberos,關於認證方式可以查看官方文檔http://docs.ansible.com/ansible/latest/userguide/windowswinrm.html?highlight=kerberos
    ansiblewinrmkinitmode=managed 這裡我選用自動,也可以選擇manual手動模式,就是每隔一段時間都要使用驗證命令進行驗證,kinit [email protected] 然後輸入密碼,使用klist查看到期時間。

  2. 配置windows winrm管理
    查詢winrm狀態
    winrm enumerate winrm/config/Listener

    winrm服務預設都是開著的,方便powershell遠端管理,基本上不需要這麼配置。有時候串連不上可能是防火牆沒有開通相應的策略。
    其他的配置方法可以查看官方文檔:http://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#winrm-setup

    然後測試一下效果

  3. 到這裡基本上就完事了,餘下的就是編寫yml檔案了,這個正在學習中。

Ansible關於windows的管理

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.