# ansible **Repository Path**: ginvip/ansible ## Basic Information - **Project Name**: ansible - **Description**: 工作中的Ansilbe自动化实践 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-30 - **Last Updated**: 2024-12-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Ansible自动化部署 ## 执行前的准备 Ansible主控端安装好 sshpass,因为要分发密钥 ```shell # ubuntu apt install -y sshpass # centos yum install -y sshpass ``` Ansible主控端生成好密钥文件 ```shell ssh-keygen -P "" -t rsa -f ~/.ssh/id_rsa ``` ## ansible-playbook相关执行命令 ```shell # 真正执行 ansible-playbook -i inventory/hosts site.yml # 查看主机列表 ansible-playbook -i inventory/hosts site.yml --list-hosts # 语法检查 ansible-playbook -i inventory/hosts site.yml --syntax-check # 模拟执行 ansible-playbook -i inventory/hosts site.yml -C ``` # Ansible报错集锦 1. 没有`authorized_key`模块 ```shell [root@master101 ansible]# ansible-playbook -i inventory/hosts site.yml ERROR! couldn't resolve module/action 'authorized_key'. This often indicates a misspelling, missing collection, or incorrect module path. # 解决方案 ansible-galaxy collection install ansible.posix ```