update
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[defaults]
|
||||
host_key_checking = False
|
||||
ansible_ssh_common_args = '-o StrictHostKeyChecking=no'
|
||||
@@ -0,0 +1,4 @@
|
||||
[myservers]
|
||||
1 ansible_host=192.168.1.1 ansible_user=root ansible_port=22 ansible_ssh_pass=password1
|
||||
2 ansible_host=192.168.1.2 ansible_user=root ansible_port=22 ansible_ssh_pass=password2
|
||||
3 ansible_host=192.168.1.3 ansible_user=root ansible_port=22 ansible_ssh_pass=password3
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
# 定义要执行任务的主机组
|
||||
- hosts: myservers
|
||||
become: yes
|
||||
gather_facts: no # 禁用事实收集以避免依赖 Python
|
||||
tasks:
|
||||
- name: 将脚本复制到远程主机
|
||||
copy:
|
||||
# 本地脚本路径
|
||||
src: ./shell.sh
|
||||
# 远程主机上的目标路径
|
||||
dest: /tmp/shell.sh
|
||||
# 设置脚本权限为可执行
|
||||
mode: '0755'
|
||||
|
||||
- name: 在远程主机上执行脚本
|
||||
raw: /tmp/shell.sh # 在远程主机上执行脚本
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
echo "Hello, world!"
|
||||
Reference in New Issue
Block a user