---
title: "ansible 自动化部署之 ansible 配置"
author: "annan211"
date: "2018-06-29T16:38:05Z"
tags: []
categories: ["操作系统"]
slug: "ansible-ansible"
draft: false
lastmod: "2018-06-29T16:38:05Z"
id: 2425900
url: "https://annan211.iteye.com/blog/2425900"
---

第一步 ：管理节点上安装ansible环境 略
 第二步 ：管理节点上配置 hosts文件  /etc/ansible/hosts
          testserver ansible_ssh_host=127.0.0.1 ansible_ssh_user=root
          targetserver  ansible_ssh_host=192.168.137.4  ansible_ssh_user=root
 第三步 ：管理节点上配置 ansible.cfg 
          touch /etc/ansible/ansible.cfg
          
inventory      = /etc/ansible/hosts
library        = /usr/share/ansible/
forks          = 5
sudo_user      = root
remote_port    = 22
roles_path    = /root/ansible_playbook/roles
host_key_checking = False
timeout = 20
log_path = /var/log/ansible.log






deprecation_warnings=False
host_key_checking = False

 第四步 ： 管理节点生成pub-key
          ssh-keygen

 第五步 ：copy 相关Key到目标节点
          #ssh-copy-id root@目标节点IP

 第六步 ：test
        ansible -m ping all

 
![](http://dl2.iteye.com/upload/attachment/0130/1653/8c0a2031-a668-327f-a8cd-010ca7374737.png)