美文网首页
ansible环境搭建

ansible环境搭建

作者: zwb_jianshu | 来源:发表于2019-08-25 11:45 被阅读0次

一、实现从管理机m01到其他机器的密钥认证

[root@m01 ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:rKu2og75VVHnsOPn/Lh9YP/2Yi26PwD9wAzMihol4e8 root@m01
The key's randomart image is:
+---[RSA 2048]----+
|    ..  oo.      |
|   .. .. =+      |
|    .o..o..=     |
|    ...+... =    |
|     oo S .. o   |
| .  .o . +  + .  |
|o   . E   o. + . |
|.....  .   +  B o|
|oo.ooo.   o.=*.*+|
+----[SHA256]-----+
[root@m01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub  -p 22 root@172.16.1.7
[root@m01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@172.16.1.7
[root@m01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@172.16.1.61

二、安装ansible

[root@m01 ~]# yum install ansible -y

三、配置ansible的主机列表

[root@m01 ~]# vim /etc/ansible/hosts
[server]
172.16.1.61
[client]
172.16.1.7

四、验证ansible

ansible是通过ssh端口探测通信
[root@m01 /etc/ansible]# ansible server -m ping
10.0.0.61 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
[root@m01 /etc/ansible]# ansible client -m ping
10.0.0.7 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
[root@m01 /etc/ansible]# ansible server -m command -a "df -h" 
10.0.0.61 | CHANGED | rc=0 >>
文件系统                           容量  已用  可用 已用% 挂载点
/dev/mapper/centos_oldboyedu-root   17G  3.2G   14G   19% /
devtmpfs                           979M     0  979M    0% /dev
tmpfs                              991M  128K  991M    1% /dev/shm
tmpfs                              991M  9.7M  981M    1% /run
tmpfs                              991M     0  991M    0% /sys/fs/cgroup
/dev/sda1                         1014M  194M  821M   20% /boot
tmpfs                              199M     0  199M    0% /run/user/0

相关文章

  • 十六、03-使用Ansible Playbook自动化搭建LNM

    使用Ansible Playbook自动化搭建LNMP环境 1、环境配置 2、准备工作 安装ansible工具 配...

  • 十六、04-使用Ansible Role自动化搭建LNMP环境

    使用Ansible Role自动化搭建LNMP环境 1、环境配置 2、准备工作 安装ansible工具 配置主机名...

  • Ansible系列(2):Ansible环境搭建并执行第一条ad

    这是Ansible系列课程第二节,Ansible环境搭建。介绍Ansible在不同的平台上的安装方式,配置SSH ...

  • Ansible环境搭建

    1.概述 官网提供了不同环境的安装方式,可以根据自己的具体情况,选择不同安装方式。鉴于ansible是通过pyth...

  • ansible环境搭建

    一、实现从管理机m01到其他机器的密钥认证 二、安装ansible 三、配置ansible的主机列表 四、验证an...

  • 快速搭建指南 - Minishift

    ☞ 提示:此安装方式适合本地开发环境的搭建,生产环境请使用基于 Ansible 的高级安装方法。 概述 Minis...

  • 8-21

    学了一天ansible,写了一天ansible,最后发现对整个需要搭建的测试环境还不确定,有几个疑问。 1. 为什...

  • 快速搭建指南 - Vagrant

    ☞ 提示:此安装方式适合本地开发环境的搭建,生产环境请使用基于 Ansible 的高级安装方法。 关于使用 Vag...

  • 快速搭建指南 - oc cluster up

    ☞ 提示:此安装方式适合本地开发环境的搭建,生产环境请使用基于 Ansible 的高级安装方法。 概述 本地开发环...

  • Ansible 开发环境的搭建

    通常我不喜欢写开发环境搭建类文章的,但是见到不少同学在 Ansible 的开发环境花了很多时间。所以,就想写这么一...

网友评论

      本文标题:ansible环境搭建

      本文链接:https://www.haomeiwen.com/subject/iyshectx.html