ansible 노트 (1) centos 에 ansible 설치

16127 단어
ansible  (1):ansible     
      
ansible   ?

    "      ""       ",                ,    ,      ,     ansible    。

 
ansible    ?

            ,ansible              ,               。

  :   100       nginx  ,         。

  :           100     。

  :              ,          redis  ,                   。

             ansible。

 
    ,     ,       ,            ,       ansible ?  ,             ,          ansible,  ansible         ,  "   ""   "      ?    ,                    ,                   ,    ansible       ,      ,                     ,  ansible         ,                   ,ansible             ,   ,ansible "       ""    ",ansible     ,"    "   "    "  ,    ,        ,     ,    "    "  "    ""   ""   "                 ,         ,                       ,     ,        ,           ,         ,        ,     。

 
               ,  puppet  saltstack,       ,        puppet  100   ,    100      puppet   agent(       ), ansible   ,ansible     ssh      ,          agent,    ,      ssh       ,      ansible       。


      ,      ansible         、     :

ansible         ,                     ,ansible  ssh        ,        ,     、  、  ,   ,                  ansible。

 
    ansible ?                 ,    

 :       ,        ,          ,             ,      

ansible 10.11.0.212 -m ping

      ,  ansible ping 10.11.0.212    ,      。

"ping" ansible      ,         ping     ,ansible  ping  ,          ping    ,      "-m ping"    ping  ,  ,ansible         ,      ,                  ,        ,        ,        ,ansible              。

 
  ,          ansible      ,               ,               ,  

   、ansible         ssh       。

   、     IP          ansible "    " 。

 
    ,ansible          agent,       ssh,  ,        ,  ,          ,         ,    ,  ansible         ssh       ,          IP  、ssh               "  (Inventory)"      ,          ansible "  "    ,  ansible         ,            ansible "  "。


      
           ansible。

       ,           。

      ,IP      
10.11.0.210
10.11.0.212
10.11.0.215

    10.11.0.210(     210)        ,       210   ansible,           ,          centos7.5

   yum      ansible,    ansible  epel ,         epel  centos7     ,yum     


# pwd
/etc/yum.repos.d
 
# cat aliBase.repo
[aliBase]
name=aliBase
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-$releasever
 
# cat aliEpel.repo
[aliEpel]
name=aliEpel
baseurl=https://mirrors.aliyun.com/epel/$releasever\Server/$basearch/
enabled=1
gpgcheck=0

yum      ,  ansible

yum install ansible -y

  yum        ansible 2.5.5


    ,    ,               ,   ansible    ,    ,      ansible     ,              ansible "    " ,            ansible      ,  ,        ansible "  ",    ansible  ,ansible        "  ",      /etc/ansible/hosts,     ,          ,  ,       ,       ,        INI     ,  ,              。

 

          ,      ansible    60  ,  ,           IP     /etc/ansible/hosts   ,    , /etc/ansible/hosts        IP

10.11.0.212

      ,  ,      ,     ansible    10.11.0.212      ?       ,         。

 

         :ansible 10.11.0.212 -m ping

  ansible ping  10.11.0.212,      
[root@node1 ~]# ansible 10.11.0.212 -m ping
The authenticity of host '10.11.0.212 (10.11.0.212)' can't be established.
ECDSA key fingerprint is SHA256:Q2YUBNf0DmqBgD9wso2dXiVhKZmJjwBnW08ul4o05ag.
ECDSA key fingerprint is MD5:e8:26:81:0d:0a:2e:62:33:d9:9f:dc:a1:a3:9c:6e:83.
Are you sure you want to continue connecting (yes/no)? yes
10.11.0.212 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '10.11.0.212' (ECDSA) to the list of known hosts.\r
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r
", "unreachable": true } ,10.11.0.212 , ,ansible ssh 212 , ansible 10.11.0.212 , ansible ssh 。 , , 10.11.0.212 ssh , , , IP ssh , : 10.11.0.212 ansible_port=22 ansible_user=root ansible_ssh_pass=pass ansible_port sshd , , 22 , 。 ansible_user 。 ansible_ssh_pass 。 , ,10.11.0.212 sshd 22 , ansible ssh 212 , 212 root , 212 root pass , 212 ssh , , , [root@node1 ~]# ansible 10.11.0.212 -m ping 10.11.0.212 | SUCCESS => { "changed": false, "ping": "pong" } , ,ansible ping 10.11.0.212, , ansible , 10.11.0.212 。 , ,ansible , , " " 。 , 10.11.0.212 node212, , , : node212 ansible_host=10.11.0.212 ansible_port=22 ansible_user=root ansible_ssh_pass=pass , , IP anible_host , ansible 。 , , 。 [root@node1 ~]# ansible node212 -m ping node212 | SUCCESS => { "changed": false, "ping": "pong" } , , IP , IP 。 : ansible2.0 ,2.0 , ansible_port ansible_ssh_port ansible_user ansible_ssh_user ansible_host ansible_ssh_host ansible 2.5, , ,2.5 。 , ssh , ssh, , ssh , , , , , ssh , , , ansible ssh , ? 。 , , " (ansible )" , . , ansible , 。 , , 。 # ssh-keygen 10.11.0.212 # ssh-copy-id -i /root/.ssh/id_rsa.pub root@10.11.0.212 , , , ansible 60 。 , ssh , ssh , " " , , , , 。 10.11.0.212 ansible_port=22 node212 ansible_host=10.11.0.212 ansible_port=22 , sshd 22 , ansible_port , , sshd 。 ansible , , , ssh-agent , ssh-agent, : ssh-agent , ansible_ssh_private_key_file , 。 , , , 。

좋은 웹페이지 즐겨찾기