【Windows】【DevOps】Windows Server 2022 安装ansible,基于powershell实现远程自动化运维部署 入门到放弃!

server/2024/10/18 15:54:02/

目标服务器安装openssh server参考

【Windows】【DevOps】Windows Server 2022 在线/离线 安装openssh实现ssh远程登陆powershell、scp文件拷贝-CSDN博客

注意:Ansible不支持Windows操作系统部署

根据官方说明:

Windows Frequently Asked Questions — Ansible Community Documentation

Can Ansible run on Windows?

No, Ansible can only manage Windows hosts. Ansible cannot run on a Windows host natively, though it can run under the Windows Subsystem for Linux (WSL).

Note

The Windows Subsystem for Linux is not supported by Ansible and should not be used for production systems.

基于Cygwin安装Ansbile

参考以下内容

Install Ansible on Windows Using Cygwin

Cygwin is a POSIX-compatible environment that lets you run tools and code designed for Unix-like operating systems on Microsoft Windows.

To install Ansible on Windows using Cygwin, follow these steps:

1. Download the Cygwin installation file. This file is compatible with both the 32-bit and 64-bit versions of Windows. It automatically installs the right version for your system.

2. Double-click the downloaded file to run it. On the welcome screen, click Next to continue.

Cygwin setup welcome screen.

3. Select Install from Internet as the download source and click Next.

Choose Cygwin download source.

4. In the Root Directory field, specify where you want the application installed, then click Next.

Select the root installation directory for Cygwin.

5. In the Local Package Directory field, select where you want to install your Cygwin packages, then click Next.

Cygwin setup - select the local package directory.

6. Choose the appropriate Internet connection option. If you are not using a proxy, select Direct Connection. Otherwise, select Use System Proxy Settings or enter the proxy settings manually with the Use HTTP/FTP Proxy. Click Next to continue.

Select internet connection type for Cygwin setup.

7. Choose one of the available mirrors to download the installation files, then click Next.

Select download mirror for Cygwin.

8. On the Select Packages screen, type ansible in the search bar and press Enter to perform the search. Expand the Admin and Doc categories and double-click the ansible and ansible-doc files to select them.

Click Next to install the packages.

Select which Ansible packages to install.

9. The next screen lets you review the installation settings. To confirm and begin the installation process, click Next.

Review Cygwin installation.

The install wizard downloads and installs all the selected packages, including Ansible.

10. Once the installation is complete, select whether you want to add a Cygwin desktop and the Start Menu icon. Click Finish to close the wizard.

Finish the installation

验证安装

配置/etc/ansible/hosts

[server]
服务器ip  ansible_ssh_user=服务器用户名 ansible_ssh_pass=服务器用户密码

ansible ping(windows版本openssh 有兼容问题!)

直接拿linux主机测试ansible连接windows server上的openssh(乱码!)

严重怀疑其兼容性!

ansible+winrm

Windows Remote Management — Ansible Community Documentation

先使用linux系统测试验证

yum install ansible python3-pywinrm

各种故障,放弃!

基于WSL安装ansible(失败)

管理员权限启动powershell

安装WSL

wsl --install
PS C:\Windows\system32> wsl -l -o
PS C:\Windows\system32>

wsl指令没有列出可用的镜像!

参考资料

How to Install Ansible on Windows {3 Methods Explained} (phoenixnap.com)

在 Windows Server 上安装 Linux 子系统 | Microsoft Learn

直接安装python3+ansible(失败):

控制节点安装python3

下载页:https://www.python.org/downloads/windows/
文件URL:https://www.python.org/ftp/python/3.13.0/python-3.13.0-amd64.exe

图形界面安装python3

验证安装

打开powershell,验证版本

控制节点安装ansible

提前关闭 病毒和威胁防护的实时保护

pip install -vvv ansible -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --default-timeout=100

安装过程比较缓慢(相对Linux来说,可能是Hyper-V主机内CPU调度问题)

安装完成

故障


http://www.ppmy.cn/server/132796.html

相关文章

Android从上帝视角来看PackageManagerService

戳蓝字“牛晓伟”关注我哦! 用心坚持输出易读、有趣、有深度、高质量、体系化的技术文章,技术文章也可以有温度。 前言 阅读该篇之前,建议先阅读下面的系列文章: Android深入理解包管理–PackageManagerService和它的“小伙伴…

vim 12种模式的切换、常用命令集合

开发工具 每当别人问你: 💦你在什么环境下写代码、调试、编译、链接代码? 🧑🏿Visual Studio 2022。VScode。IntelliJ IDEA。Eclipse… 对于上面这种环境,我们称之为集成开发环境(IDE&#xf…

RHCE【时间服务器】

目录 NTP服务简介: Chrony简介: 一、软件安装 二、配置时间服务器 三、配置时间服务器的服务端和客户端,并使客户端与服务端的时间进行同步 (1)服务端配置: (2)客户端配置: &…

DolphinDB 2024 年度峰会回顾之分论坛:权益类数字基建与技术创新

在这个数字化时代,金融科技正以前所未有的速度发展,而权益类数字基建作为这一进程的核心支撑,正不断推动着金融领域的创新与变革。 DolphinDB 2024 年度峰会的分论坛 A 聚焦《权益类数字基建与技术创新》这一核心议题,邀请到了业…

C#高级编程核心知识点

1、函数参数 (1)按值传递参数 public void swap(int x, int y) (2)按引用传递参数 public void swap(ref int x, ref int y) 2、Null可空类型 (1)1个? ? 单问号用于对 int、double、bool 等无法直…

MySQL行格式

MySQL行格式 ✅ 四种行格式✅ 如何指定行格式?✅ 详细谈谈compact行格式 首先我们知道在MySQL中页是数据读写的最小单元,默认是16KB。页内的记录会组成一个单链表,每条记录就是一行数据,行格式决定了一行数据是如何进行物理存储的…

数据结构6——树与二叉树

在本专栏的前五篇中,我们学习了顺序表、链表、栈和队列,他们本质上都是线性表。有线性表就存在非线性表,现在我们就来学习一下结构更复杂的非线性表——树。 1. 树的概念与结构 1.1 树的概念 树是一种非线性的数据结构,它是由n&…

yocto编辑软件包-devtool的使用方法

之前用了很多次devtool,总是忘记用法,故此记录一下。 假设你有一个软件包名叫foo,并且已经下载编译过,需要修改它的源码并生成patch 生成修改工作区 devtool modify foo modify命令会将foo的源码压缩包解压到build/workspace/so…