ansible - Ansible - 有没有办法使用 Ansible 更改 Windows Server IP 地址?
问题描述
我想使用 Ansible 设置一个新的域控制器。我有一个从模板克隆新服务器的脚本,现在如何使用 Ansible 静态设置 Windows Server 的 IP 地址?
解决方案
花了好几个小时寻找同一个问题的答案:) 希望下面的帮助:
- name: Set up static IP address
win_shell: "Get-NetIpAddress -InterfaceAlias 'Ethernet' | New-NetIpAddress -IpAddress 192.168.1.120 -PrefixLength 24 -DefaultGateway 192.168.1.1"
async: 100 # Using "fire-and-forget" asynchronous execution for this task, otherwise it will always fail and timeout
poll: 0
- name: Change ansible's ip address for each host
set_fact:
ansible_host: "192.168.1.120"
- name: Wait for the hosts network interface to come back up
local_action:
module: wait_for
host: "{{ ansible_host }}"
port: 5985
delay: 10
state: started
register: wait_result
- name: Create a test folder to celebrate success
win_file:
path: C:\itworks
state: directory
推荐阅读
- javascript - 超过 1 个系列的 Highchart 显示未显示
- python - Python3.7:多行字符串之间的正则表达式?
- corda - Corda:在一个流程中创建和使用相同的状态?
- java - 对 assertEquals 的模糊引用
- python - 从 Google Composer (Airflow) 中检索 Kubernetes 的秘密
- android - 没有符合条件的设备进行应用安装。| 安卓 | 奥利奥 8.1.0
- php - 无法使用 Slim 框架将图像保存到数据库和文件夹
- java - 我应该在流中改变对象吗?
- c# - 无法将 lambda 表达式转换为 c# 中的预期委托类型
- flutter - 如何定义我正在绘画的材料的垂直层?